Skip to content

Commit

Permalink
update correct api response for getContactIdsInList
Browse files Browse the repository at this point in the history
- AUT-2568

Co-authored-by: Laszlo Halasz <laszlo.halasz@emarsys.com>
Co-authored-by: fqqdk <csaba.simon@emarsys.com>
  • Loading branch information
3 people committed Feb 9, 2024
1 parent 795b972 commit cff189d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Suite/Api/ContactList.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getContactsOfList(int $customerId, int $contactListId, int $limi
{
try {
$response = $this->apiClient->get($this->endPoints->contactsOfList($customerId, $contactListId, $limit, $offset));
return !empty($response['data']) ? $response['data'] : [];
return $response['data'] ?? [];
} catch (Error $error) {
throw new RequestFailed('Could not fetch contact ids: ' . $error->getMessage(), $error->getCode(), $error);
}
Expand All @@ -122,7 +122,8 @@ public function getContactsOfList(int $customerId, int $contactListId, int $limi
public function getContactIdsInList(int $customerId, int $contactListId)
{
try {
return $this->apiClient->get($this->endPoints->contactIdsInList($customerId, $contactListId));
$response = $this->apiClient->get($this->endPoints->contactIdsInList($customerId, $contactListId));
return $response['data'] ?? [];
} catch (Error $error) {
throw new RequestFailed('Could not fetch contact ids: ' . $error->getMessage(), $error->getCode(), $error);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Suite/Api/ContactListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function getContactIdsInList_Perfect_Perfect()
$response = ['value' => [1, 2, 3], 'next' => null];
$this->apiClient->expects($this->once())->method('get')->with(
$this->endPoints->contactIdsInList($this->customerId, $this->contactListId)
)->willReturn($response);
)->willReturn($this->apiSuccess($response));

$result = $this->listService->getContactIdsInList($this->customerId, $this->contactListId);
$this->assertEquals($response, $result);
Expand Down

0 comments on commit cff189d

Please sign in to comment.