Skip to content

Pagination in searchContacts is causing an error. #388

@screambeard

Description

@screambeard

When using the IntercomClient->contacts->search and the result has multiple pages, accessing these pages causes the following exception:

Cannot assign null to property Intercom\Types\StartingAfterPaging::$perPage of type int

This is caused because the perPage is not set (or set to null) somewhere while going over the pages.

Code example to replicate the issue. There should be more than 2 contacts to trigger the issue with the example below.

$token = "YOUR TOKEN";
$this->client = new IntercomClient($token);
$query = new SingleFilterSearchRequest(['field' => 'last_seen_at', 'operator' => '<', 'value' => Carbon::now()->getTimestamp()]);
$pagination = new StartingAfterPaging([
  "perPage" => 2,
]);
$searchRequest = new SearchRequest([
  'query' => $query,
  'pagination' => $pagination,
]);
$results = $client->contacts->search($searchRequest);
$all_results = [];
foreach ($results->getPages() as $page) {
  $all_results = array_merge($all_results, $page->getItems());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions