* Determines an appropriate set of cursor pagination options for the next request to a paginated API method. * @param previousResult - the result of the last request, where the next cursor might be found. * @param pageSize - the maximum number of additional items to fetch in the next request.
( previousResult: WebAPICallResult | undefined, pageSize: number, )
| 806 | * @param pageSize - the maximum number of additional items to fetch in the next request. |
| 807 | */ |
| 808 | function paginationOptionsForNextPage( |
| 809 | previousResult: WebAPICallResult | undefined, pageSize: number, |
| 810 | ): methods.CursorPaginationEnabled | undefined { |
| 811 | if ( |
| 812 | previousResult !== undefined && |
| 813 | previousResult.response_metadata !== undefined && |
| 814 | previousResult.response_metadata.next_cursor !== undefined && |
| 815 | previousResult.response_metadata.next_cursor !== '' |
| 816 | ) { |
| 817 | return { |
| 818 | limit: pageSize, |
| 819 | cursor: previousResult.response_metadata.next_cursor as string, |
| 820 | }; |
| 821 | } |
| 822 | return; |
| 823 | } |
| 824 | |
| 825 | /** |
| 826 | * Extract the amount of time (in seconds) the platform has recommended this client wait before sending another request |