diff --git a/.gitignore b/.gitignore index 9f11b75..9daffbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,61 @@ +# VisualStudioCode +.gitignore +.gitattributes +.history/ +.vscode/ +.vscode-test +#!.vscode/settings.json +#!.vscode/tasks.json +#!.vscode/launch.json +#!.vscode/extensions.json +*.code-workspace + +# Windows.gitignore +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.stackdump +[Dd]esktop.ini +$RECYCLE.BIN/ +*.cab +*.msi +*.msix +*.msm +*.msp +*.lnk + +#Sass.gitignore +.sass-cache/ +*.css.map +*.sass.map +*.scss.map + +# My gitignores .idea/ +.phpunit.cache/ +logs/ +/vendor/ +/tests/ +composer.lock +config.php +settings.php +phpunit.xml +.env +.php_cs.dist +.php.* +*.cache +*.log +*.sql +*.sqlite +*.tmp +*.cache +*.jar +*.war +*.nar +*.ear +*.7z +*.zip +*.tar +*.tar.gz +*.rar diff --git a/src/ApiClient.php b/src/ApiClient.php index e2d674c..4fa47ee 100755 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -388,6 +388,24 @@ public function getEmailsFromBook($id, $limit = null, $offset = null) return $this->handleResult($requestResult); } + /** + * Get amount of subscriptions for the book + * + * @param $bookID + * + * @return stdClass + */ + public function bookCountSubscriptions($bookID) + { + if (empty($bookID)) { + return $this->handleError('Empty book id'); + } + + $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails/total'); + + return $this->handleResult($requestResult); + } + /** * Add new emails to address book * @@ -439,6 +457,29 @@ public function removeEmails($bookID, $emails) return $this->handleResult($requestResult); } + /** + * Unsubscribe email addresses from book + * + * @param $bookID + * @param $emails + * + * @return stdClass + */ + public function unsubscribeEmails($bookID, $emails) + { + if (empty($bookID) || empty($emails)) { + return $this->handleError('Empty book id or emails'); + } + + $data = array( + 'emails' => serialize($emails), + ); + + $requestResult = $this->sendRequest('addressbooks/' . $bookID . '/emails/unsubscribe', 'POST', $data); + + return $this->handleResult($requestResult); + } + /** * Get information about email address from book * @@ -1628,4 +1669,4 @@ public function deleteSmsCampaign($campaignID) return $this->handleResult($requestResult); } -} \ No newline at end of file +} diff --git a/src/ApiInterface.php b/src/ApiInterface.php index 19598c7..9c8ef8b 100644 --- a/src/ApiInterface.php +++ b/src/ApiInterface.php @@ -60,11 +60,20 @@ public function getBookInfo($id); public function getBookVariables($id); /** - * Get list pf emails from book + * Get list email addresses from book * - * @param $id + * @param $id Address book id. + * @param $limit + * @param $offset + */ + public function getEmailsFromBook($id, $limit = null, $offset = null); + + /** + * Get amount of subscriptions for the book + * + * @param $bookID */ - public function getEmailsFromBook($id); + public function bookCountSubscriptions($bookID); /** * Add new emails to book @@ -82,6 +91,14 @@ public function addEmails($bookID, $emails); */ public function removeEmails($bookID, $emails); + /** + * Unsubscribe email addresses from book + * + * @param $bookID + * @param $emails + */ + public function unsubscribeEmails($bookID, $emails); + /** * Get information about email from book *