From d07fb4a2b0ca07a235e9e9a2b4e7fcba160f2227 Mon Sep 17 00:00:00 2001 From: fanirytonio <33858885+fanirytonio@users.noreply.github.com> Date: Mon, 11 May 2020 15:43:33 +0200 Subject: [PATCH] :sparkles: Add paging on getting message --- src/Esendex/MessageBatchesService.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Esendex/MessageBatchesService.php b/src/Esendex/MessageBatchesService.php index 5ebe100..f4302d4 100644 --- a/src/Esendex/MessageBatchesService.php +++ b/src/Esendex/MessageBatchesService.php @@ -64,24 +64,28 @@ public function __construct( } /** - * Get detailed information about messages from it's batchid. + * Get detailed information about messages from it's batch_id. * - * @param $messageId - * @return Model\InboxMessage|Model\SentMessage + * @param string $batch_id + * @param int $startIndex + * @param int $pageSize + * @return array */ - public function messages($messageId) + public function messages($batch_id, $startIndex = 0, $pageSize = 15) { $uri = Http\UriBuilder::serviceUri( self::SERVICE_VERSION, self::SERVICE, - array($messageId,'messages'), + array($batch_id, 'messages'), $this->httpClient->isSecure() ); - $result = $this->httpClient->get( - $uri, - $this->authentication - ); + $query = array(); + $query["startIndex"] = $startIndex; + $query["count"] = $pageSize; + $uri .= "?" . Http\UriBuilder::buildQuery($query); + + $result = $this->httpClient->get($uri, $this->authentication); return $this->parser->parse($result); }