diff --git a/src/Suite/Api/ContactList.php b/src/Suite/Api/ContactList.php index 10e7ca7..ba5a5a0 100644 --- a/src/Suite/Api/ContactList.php +++ b/src/Suite/Api/ContactList.php @@ -119,7 +119,7 @@ public function getContactsOfList(int $customerId, int $contactListId, int $limi } } - public function getContactIdsInList(int $customerId, int $contactListId, int $top = null, string $skiptoken = null): array + public function getContactIdsInList(int $customerId, int $contactListId, int $top = null, int $skiptoken = null): array { try { $response = $this->apiClient->get($this->endPoints->contactIdsInList($customerId, $contactListId, $top, $skiptoken)); @@ -135,7 +135,7 @@ public function getListChunkIterator(int $customerId, int $contactListId, int $c try { do { ['value' => $value, 'next' => $next] = $this->apiClient->get($nextUrlFull)['data']; - $nextUrlFull = $this->endPoints->contactIdsInListNextChunk($customerId, $next); + $nextUrlFull = $this->endPoints->contactIdsInListNextChunk($customerId, $contactListId, $next); yield $value; } while ($next !== null); } catch (Error $error) { diff --git a/src/Suite/Api/ContactListEndPoints.php b/src/Suite/Api/ContactListEndPoints.php index bade84a..924b871 100644 --- a/src/Suite/Api/ContactListEndPoints.php +++ b/src/Suite/Api/ContactListEndPoints.php @@ -55,19 +55,18 @@ public function contactIdsInList(int $customerId, int $contactListId, int $top = ); } - public function contactIdsInListNextChunk(int $customerId, string $next = null): ?string + public function contactIdsInListNextChunk(int $customerId, int $contactListId, string $next = null): ?string { - - return $next ? $this->getBaseUrlWithoutInternalPostfix() . "{$next}" : null; + if (null === $next) { + return null; + } + $rawQuery = parse_url($next, PHP_URL_QUERY); + parse_str($rawQuery, $query); + return $this->contactIdsInList($customerId, $contactListId, $query['$top'] ?? null, $query['$skiptoken'] ?? null); } public function deleteContactsFromList(int $customerId, int $contactListId): string { return $this->baseUrl($customerId) . "/{$contactListId}/delete"; } - - public function getBaseUrlWithoutInternalPostfix(): string - { - return preg_replace('/\/internal$/', '', $this->apiBaseUrl); - } }