Skip to content

Commit

Permalink
Fixed REST applying tags for contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Łukasz Matusik committed Mar 12, 2021
1 parent 6cce573 commit 5448abd
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Infusionsoft/Api/Rest/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,27 @@ public function removeContacts($contactIds)
return $response;
}

public function addContacts($contactIds)
/**
* @param array $contactIds
* @param int $tagId
*
* @return mixed
* @throws InfusionsoftException
*/
public function addContacts($contactIds, $tagId)
{
if ( ! is_array($contactIds)) {
if ( ! is_array($contactIds) ) {
throw new InfusionsoftException('Must be an array of contact ids');
} elseif (count($contactIds) > 100) {
}
if ( count($contactIds) > 100 ) {
throw new InfusionsoftException('A maximum of 100 contact ids can be modified at once');
}

if ( !is_int($tagId) ) {
throw new InfusionsoftException('Tag id must be an integer.');
}
$contacts = new \stdClass();
$contacts->ids = $contactIds;

$response = $this->client->restfulRequest('post', $this->getFullUrl($this->id . '/contacts'), $contacts);

return $response;
return $this->client->restfulRequest('post', $this->getFullUrl($this->id . '/' . $tagId . '/contacts'), $contacts);
}

public function addCategory($name, $description)
Expand Down

0 comments on commit 5448abd

Please sign in to comment.