Skip to content

Commit

Permalink
getMessages updated
Browse files Browse the repository at this point in the history
  • Loading branch information
angebagui committed Jun 26, 2020
1 parent fd313ce commit b4135b8
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions src/MtnSmsCloud/MTNSMSApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,46 +180,43 @@ public function getCampaign($campaign_id)
}

/**
* Retrieves all messages associated to the provided authentification Bearer token
* Retrieves all messages dispatchedAt_* format { (Datetime) 2020-02-14 14:14:00 => 20200214141400}
*
* @param string $campaign_id
* @param string $status
* @param array $params
* @param string $status,
* @param string $campaign_id,
* @param string $dispatchedAt_before
* @param string $dispatchedAt_after
* @param string $updatedAt_before
* @param string $updatedAt_after
* @param int $page Page number
* @param int $length Number of messages per pages
* @return mixed
*/
public function getMessages($campaign_id, $status, $params = [])
public function getMessages(string $status = null, string $campaign_id, string $dispatchedAt_before, string $dispatchedAt_after, string $updatedAt_before = null, string $updatedAt_after = null, int $page = 1, int $length = 2)
{
if (is_null($campaign_id) || $campaign_id == "") {
return new MtnSmsCloudException("No campaign ID provided.", 400);
}

$default_params = [
'dispatchedAt_before' => null,
'dispatchedAt_after' => null,
'updatedAt_before' => null,
'updatedAt_after' => null,
'page' => 1,
'length' => 2
];

foreach ($default_params as $key => $value) {
if (!is_isset($params[$key])) {
$params[$key] = $value;
}
}

$params['campaingId'] = $campaign_id;
$params['status'] = $status;
$params['sender'] = $this->getSenderID();


$options = [
'headers'=> [
'Authorization: Bearer '.$this->getAuthHeader(),
'Accept: application/json',
'Content-Type: application/json',
'Cache-Control: no-cache'
],
'params' => $params,
'params' => [
'sender' => $this->getSenderID(),
'status' => $status,
'campaingId' => $campaign_id,
'dispatchedAt_before' => $dispatchedAt_before,
'dispatchedAt_after' => $dispatchedAt_after,
'updatedAt_before' => $updatedAt_before,
'updatedAt_after' => $updatedAt_after,
'page' => $page,
'length' => $length,
]
];

// Sending Get Request
Expand Down

0 comments on commit b4135b8

Please sign in to comment.