Skip to content

Commit

Permalink
✨ Add paging on getting message
Browse files Browse the repository at this point in the history
  • Loading branch information
fanirytonio authored May 11, 2020
1 parent 1e3db11 commit d07fb4a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Esendex/MessageBatchesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d07fb4a

Please sign in to comment.