Skip to content

Commit

Permalink
Merge pull request #305 from plivo/SMS-5391
Browse files Browse the repository at this point in the history
SMS-5391: Add replaced_sender in MDR Get and List apis
  • Loading branch information
narayana-plivo authored May 3, 2023
2 parents 28bd799 + dff5e08 commit 8ae2746
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [v4.46.0](https://github.com/plivo/plivo-php/tree/v4.46.0) (2023-04-25)
- Add `replacedSender` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message)
- Add `apiId` to the responses for the list all messages API and the get message details API

## [v4.45.0](https://github.com/plivo/plivo-php/tree/v4.45.1) (2023-04-11)
**Feature - Added New Param 'source_ip' in GetCall and ListCalls**
- Add `source_ip` to the response for the [retrieve a call details API](https://www.plivo.com/docs/voice/api/call#retrieve-a-call) and the [retreive all call details API](https://www.plivo.com/docs/voice/api/call#retrieve-all-calls)
Expand Down
7 changes: 6 additions & 1 deletion src/Plivo/Resources/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @property string $totalAmount
* @property string $totalRate
* @property string $units
* @property string $replacedSender
* @property ?string $errorCode
* @property ?string $powerpackID
* @property ?string $requesterIP
Expand Down Expand Up @@ -50,10 +51,14 @@ public function __construct(
'totalAmount' => $response['total_amount'],
'totalRate' => $response['total_rate'],
'units' => $response['units'],
'destination_country_iso2' => $response['destination_country_iso2']
'destination_country_iso2' => $response['destination_country_iso2'],
'replacedSender' => $response['replaced_sender']
];

// handled empty string and null case
if (!empty($response['api_id'])) {
$this->properties['apiId'] = $response['api_id'];
}
if (!empty($response['powerpack_id'])) {
$this->properties['powerpackID'] = $response['powerpack_id'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Resources/Message/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function getList($optionalArgs = [])
$newMessage = new Message($this->client, $message, $this->pathParams['authId'], $this->uri);
array_push($messages, $newMessage);
}
return new MessageList($this->client, $response->getContent()['meta'], $messages);
return new MessageList($this->client, $response->getContent()['meta'], $messages, $response->getContent()["api_id"]);
} else {
throw new PlivoResponseException(
$response->getContent()['error'],
Expand Down
9 changes: 8 additions & 1 deletion src/Plivo/Resources/Message/MessageList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@
class MessageList extends ResourceList
{

/**
* @var
*/
public $apiId;

/**
* MessageList constructor.
* @param MessageClient $plivoClient
* @param $meta
* @param array $resources
* @param string $apiId
*/
function __construct(MessageClient $plivoClient, $meta, array $resources)
function __construct(MessageClient $plivoClient, $meta, array $resources, $apiId=null)
{
parent::__construct($plivoClient, $meta, $resources);
$this->apiId = $apiId;
}
}
3 changes: 2 additions & 1 deletion src/Plivo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Version
/**
* @const int PHP helper library minor version number
*/
const MINOR = 45;
const MINOR = 46;

/**
* @const int PHP helper library patch number
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Mocks/messageGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"powerpack_id": "15c01cc2-4b9f-4d3b-bd15-3c4b38984cc4",
"requester_ip": "192.168.1.1",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
}
60 changes: 40 additions & 20 deletions tests/Mocks/messageListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"units": 1,
"requester_ip": "192.168.1.1",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -39,7 +40,8 @@
"units": 1,
"requester_ip": "192.168.1.2",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -56,7 +58,8 @@
"units": 1,
"requester_ip": "192.168.1.3",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -73,7 +76,8 @@
"units": 1,
"requester_ip": "192.168.1.4",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -90,7 +94,8 @@
"units": 1,
"requester_ip": "192.168.1.5",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -107,7 +112,8 @@
"units": 1,
"requester_ip": "192.168.1.6",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -124,7 +130,8 @@
"units": 1,
"requester_ip": "192.168.1.7",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -141,7 +148,8 @@
"units": 1,
"requester_ip": "192.168.1.8",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -158,7 +166,8 @@
"units": 1,
"requester_ip": "192.168.1.9",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -175,7 +184,8 @@
"units": 1,
"requester_ip": "192.168.1.10",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -192,7 +202,8 @@
"units": 1,
"requester_ip": "192.168.1.11",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -209,7 +220,8 @@
"units": 1,
"requester_ip": "192.168.1.12",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -226,7 +238,8 @@
"units": 1,
"requester_ip": "192.168.1.13",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -243,7 +256,8 @@
"units": 1,
"requester_ip": "192.168.1.14",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -260,7 +274,8 @@
"units": 1,
"requester_ip": "192.168.1.15",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": null,
Expand All @@ -277,7 +292,8 @@
"units": 1,
"requester_ip": "192.168.1.16",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -294,7 +310,8 @@
"units": 1,
"requester_ip": "192.168.1.17",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -311,7 +328,8 @@
"units": 1,
"requester_ip": "192.168.1.18",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -328,7 +346,8 @@
"units": 1,
"requester_ip": "192.168.1.19",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
},
{
"error_code": "000",
Expand All @@ -345,7 +364,8 @@
"units": 1,
"requester_ip": "192.168.1.20",
"is_domestic": false,
"destination_country_iso2": "IN"
"destination_country_iso2": "IN",
"replaced_sender": "INSID"
}
]
}

0 comments on commit 8ae2746

Please sign in to comment.