Skip to content

Commit 34ecc93

Browse files
authored
Merge pull request #31 from foolsoft/email-vars
Change vars by email
2 parents 0193225 + 9ddc901 commit 34ecc93

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/ApiClient.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,30 @@ public function getBookVariables($id)
322322
return $this->handleResult($requestResult);
323323
}
324324

325+
/**
326+
* Change varible by user email
327+
*
328+
* @param int $bookID
329+
* @param string $email User email
330+
* @param array $vars User vars in [key=>value] format
331+
* @return stdClass
332+
*/
333+
public function updateEmailVariables(int $bookID, string $email, array $vars)
334+
{
335+
if (empty($bookID)) {
336+
return $this->handleError('Empty book id');
337+
}
338+
339+
$data = ['email' => $email, 'variables' => []];
340+
foreach ($vars as $name => $val) {
341+
$data['variables'][] = ['name' => $name, 'value' => $val];
342+
}
343+
344+
$requestResult = $this->sendRequest('/addressbooks/' . $bookID . '/emails/variable', 'POST', $data);
345+
346+
return $this->handleResult($requestResult);
347+
}
348+
325349
/**
326350
* List email addresses from book
327351
*

0 commit comments

Comments
 (0)