Skip to content

Commit

Permalink
Aggiunti metodi subscribe e removeSubscription
Browse files Browse the repository at this point in the history
  • Loading branch information
HighLiuk committed Nov 29, 2021
1 parent 7d9d1c5 commit 95bb40c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Contacts/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,45 @@ class Contacts extends Resource
// CODICE NOSTRO
// -----------------------------------------------------------

/**
* Iscrive un contatto ad una lista
*
* @param int $contact_id L'id su AC del contatto da iscrivere
* @param int $list_id L'id su AC della lista a cui iscriverlo
* @return string La risposta JSON
*/
public function subscribe(int $contact_id, int $list_id): string
{
$req = $this->client
->getClient()
->post('/api/3/contactLists', [
'json' => [
'contactList' => [
'contact' => $contact_id,
'list' => $list_id,
'status' => 1,
],
],
]);

return $req->getBody()->getContents();
}

/**
* Rimuove l'associazione di un contatto ad una lista
*
* @param int $contact_list_id L'id su AC dell'associazione contatto-lista
* @return bool Se si ottiene 200 OK come status code nella risposta
*/
public function removeSubscription(int $contact_list_id): bool
{
$req = $this->client
->getClient()
->delete('/api/3/contactLists/' . $contact_list_id);

return $req->getStatusCode() === 200;
}

/**
* List all contacts
*
Expand Down

0 comments on commit 95bb40c

Please sign in to comment.