Skip to content

Add new methods bookCountSubscriptions() and unsubscribeEmails() #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
43 changes: 42 additions & 1 deletion src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -1628,4 +1669,4 @@ public function deleteSmsCampaign($campaignID)

return $this->handleResult($requestResult);
}
}
}
23 changes: 20 additions & 3 deletions src/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*
Expand Down