helpscout / helpscout-api-php

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

get mailbox withFolders limits it to 49 folders #308

Closed amybowers closed 7 months ago

amybowers commented 1 year ago

Current behavior MailboxRequest->withFolders() returns up to 50 folders/teams, but if the mailbox has more than that there's no way to page to the next set.

NOTE: $mailbox->getFolders() returns folders AND teams which is a feature imho.

Expected behavior Fetching a mailbox "with folders" should either return all the folders or have a way to page through the folders.

Steps to reproduce

  1. in Helpscout set up a mailbox with more than 50 folders and/or teams.
  2. fetch the mailbox using the PHP wrapper
    $request = (new MailboxRequest())
        ->withFields()
        ->withFolders();
    $mailbox = $client->mailboxes()->get({your mailbox id}, $request);
    $folders = $mailbox->getFolders();

$folders will have 49 results.

There's no way to call $folders->getNextPage() or $mailbox->folders->getNextPage()

  1. Just for fun, you can fetch using the cURL commands... you'll see a "_link" included in the response

]}, "_links":{"next":{"href":"https://api.helpscout.net/v2/mailboxes/{mailbox id}/folders/?page=2"}, "self":{"href":"https://api.helpscout.net/v2/mailboxes/{mailbox id}/folders/"}, "first":{"href":"https://api.helpscout.net/v2/mailboxes/{mailbox id}/folders/?page=1"}, "last":{"href":"https://api.helpscout.net/v2/mailboxes/{mailbox id}/folders/?page=2"}, "page":{"href":"https://api.helpscout.net/v2/mailboxes/{mailbox id}/folders/{?page}","templated":true}}, "page":{"size":50,"totalElements":51,"totalPages":2,"number":1}}curl: (6) Could not resolve host: HTTP ..

miguelrs commented 1 year ago

@amybowers thanks for raising this!

You're right 👍 Currently you can only get the first page of the linked entities, for example you can only get the first page of folders when fetching a mailbox, or only the first page of threads when fetching a conversation.

In the case of threads of a conversation, this can be solved by using the ThreadsEndpoint directly like $client->threads()->list($convoId). However, we don't have a FoldersEndpoint yet, so you can't do the same for mailbox folders through this SDK at the moment.

You can call the endpoint with cURL directly as you know, although I understand that's not ideal.

We will make note of your request and will try to get that added in a future release 👍 Of course, PRs are always welcome!

miguelrs commented 7 months ago

We're closing this issue due to inactivity. We've moved your request to our backlog of tickets, although we can't tell when we will be able to act on it. Please feel free to reopen if needed. Thank you!