From bdad015b7ac874039729c326973745c444ef788a Mon Sep 17 00:00:00 2001 From: Leonid Sheikman Date: Sat, 27 Nov 2021 13:34:00 +0300 Subject: [PATCH 1/3] initial commit --- .gitignore | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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 From 961c8ad5bfb4e23a619a0aea7bd88f2fd95befad Mon Sep 17 00:00:00 2001 From: Leonid Sheikman Date: Sat, 27 Nov 2021 13:47:38 +0300 Subject: [PATCH 2/3] add method unsubscribeEmails --- src/ApiClient.php | 25 ++++++++++++++++++++++++- src/ApiInterface.php | 8 ++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/ApiClient.php b/src/ApiClient.php index e2d674c..92861f2 100755 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -439,6 +439,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 +1651,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..79509cc 100644 --- a/src/ApiInterface.php +++ b/src/ApiInterface.php @@ -82,6 +82,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 * From 55fa4fb1255eebbcbcaa925e94970eed424cb0be Mon Sep 17 00:00:00 2001 From: Leonid Sheikman Date: Sat, 27 Nov 2021 13:58:29 +0300 Subject: [PATCH 3/3] add method bookCountSubscriptions --- src/ApiClient.php | 18 ++++++++++++++++++ src/ApiInterface.php | 15 ++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/ApiClient.php b/src/ApiClient.php index 92861f2..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 * diff --git a/src/ApiInterface.php b/src/ApiInterface.php index 79509cc..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