helpscout / helpscout-api-php

PHP Wrapper for the Help Scout API
MIT License
98 stars 62 forks source link

Page Parameter for ConversationFilters #248

Closed abhishekrijal closed 4 years ago

abhishekrijal commented 4 years ago

unable to use page parameter in ConversationFilters to list conversation from a specific page.

bkuhl commented 4 years ago

Hey Abhishek,

We'll need some more information in order to be able to assist you. If you could fill out the issue template for this issue that'd be very helpful. That helps us understand how to reproduce the problem, which version of the SDK has the issue, etc.

abhishekrijal commented 4 years ago

Hello, sorry for missing out on the details. Here's the description of my issue.

PHP version: 7.2 SDK version: v2

Current behavior

I am trying to list the conversations from a specific page from a mailbox using ConversationFilters. Currently, when I'm running the request, I can only get 25 results from the first page.

Here's my code:

// GET conversation with the threads
    $conversationRequest = new ConversationRequest();
    $conversationRequest = $conversationRequest->withThreads();

    $filters = (new ConversationFilters())
        ->withMailbox($from_mailboxid)
        ->withSortField('createdAt')
        ->withSortOrder('asc')
        ->withStatus('all');

$from_conversations = $from_client->conversations()->list($filters);

Expected behavior

I am trying to get all of the conversations of the mailbox or use filters to get conversations from specific page.

Thanks.

bkuhl commented 4 years ago

That's no problem, thanks for the additional details. When fetching results from the API, the results are paginated. In this context, $from_conversations would be page 1 of the results. There's several functions to help navigate the pages, see how many pages there are, etc. You can see the Pagination docs for details on how to do this.

abhishekrijal commented 4 years ago

Yes. Thanks for the information on the pagination docs. It solves mu issue perfectly.

Thank you.