-
Notifications
You must be signed in to change notification settings - Fork 96
Added MessageResponse DTO and added the ability to set response objects #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?php | ||
|
||
namespace MessageBird\Objects; | ||
|
||
/** | ||
* Class Message | ||
* | ||
* @property int $protocolId | ||
* @package MessageBird\Objects | ||
*/ | ||
class MessageResponse extends Base | ||
{ | ||
/** | ||
* An unique random ID which is created on the MessageBird | ||
* platform and is returned upon creation of the object. | ||
* | ||
* @var string | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* The URL of the created object. | ||
* | ||
* @var string | ||
*/ | ||
public $href; | ||
|
||
/** | ||
* Tells you if the message is sent or received. | ||
* mt: mobile terminated (sent to mobile) | ||
* mo: mobile originated (received from mobile) | ||
* | ||
* @var string | ||
*/ | ||
public $direction; | ||
|
||
/** | ||
* The type of message. Values can be: sms, binary, premium, or flash | ||
* | ||
* @var string | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* The sender of the message. This can be a telephone number | ||
* (including country code) or an alphanumeric string. In case | ||
* of an alphanumeric string, the maximum length is 11 characters. | ||
* | ||
* @var string | ||
*/ | ||
public $originator; | ||
|
||
/** | ||
* The body of the SMS message. | ||
* | ||
* @var string | ||
*/ | ||
public $body; | ||
|
||
/** | ||
* A client reference. Here you can put your own reference, | ||
* like your internal reference. | ||
* | ||
* @var string | ||
*/ | ||
public $reference; | ||
|
||
/** | ||
* The amount of seconds that the message is valid. | ||
* If a message is not delivered within this time, | ||
* the message will be discarded. | ||
* | ||
* @var int | ||
*/ | ||
public $validity; | ||
|
||
/** | ||
* The SMS route that is used to send the message. This is for | ||
* advanced users. | ||
* | ||
* @var int | ||
*/ | ||
public $gateway; | ||
|
||
/** | ||
* An associative array with extra information. Is only used when a binary or premium | ||
* message is sent. | ||
* | ||
* @var array | ||
*/ | ||
public $typeDetails = []; | ||
|
||
/** | ||
* The datacoding used, can be plain or unicode | ||
* | ||
* @var string | ||
*/ | ||
public $datacoding; | ||
|
||
/** | ||
* Indicates the message type. 1 is a normal message, 0 is a flash message. | ||
* | ||
* @var int | ||
*/ | ||
public $mclass = 1; | ||
|
||
/** | ||
* The scheduled date and time of the message in RFC3339 format (Y-m-d\TH:i:sP) | ||
* | ||
* @var string|null | ||
*/ | ||
public $scheduledDatetime; | ||
|
||
/** | ||
* The date and time of the creation of the message in RFC3339 format (Y-m-d\TH:i:sP) | ||
* @var string | ||
*/ | ||
public $createdDatetime; | ||
|
||
/** | ||
* An array of recipients | ||
* | ||
* @var Recipients | ||
*/ | ||
public $recipients; | ||
|
||
/** | ||
* @param mixed $object | ||
* | ||
* @return $this | ||
*/ | ||
public function loadFromArray($object) | ||
{ | ||
parent::loadFromArray($object); | ||
|
||
$this->recipients = (new Recipients())->loadFromArray($this->recipients); | ||
$this->typeDetails = get_object_vars($this->typeDetails); | ||
|
||
return $this; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace MessageBird\Objects; | ||
|
||
/** | ||
* Class Recipients | ||
* | ||
* @package MessageBird\Objects | ||
*/ | ||
class Recipients extends Base | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
public $totalCount; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $totalSentCount; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $totalDeliveredCount; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $totalDeliveryFailedCount; | ||
|
||
/** | ||
* @var Recipient[] | ||
*/ | ||
public $items; | ||
|
||
/** | ||
* @param $object | ||
* | ||
* @return $this|void | ||
*/ | ||
public function loadFromArray($object) | ||
{ | ||
parent::loadFromArray($object); | ||
|
||
if (!empty($this->items)) { | ||
foreach ($this->items as &$item) { | ||
$recipient = new Recipient(); | ||
$recipient->loadFromArray($item); | ||
|
||
$item = $recipient; | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation returns $typeDetails as a stdClass when its type is set to array