/**
* Message constructor.
* @param $message
*/
public function __construct($message)
{
$this->mid = Helper::array_find($message, 'mid');
$this->seq = Helper::array_find($message, 'seq');
$this->isText = !is_null(Helper::array_find($message, 'text'));
if ($this->isText) {
$this->text = Helper::array_find($message, 'text');
$this->quick_reply = Helper::array_find($message, 'quick_reply.payload', null);
//drill straight to payload
if (!is_null($this->quick_reply)) {
$this->isQuickReply = true;
}
}
$this->isSticker = !is_null(Helper::array_find($message, 'sticker_id'));
if ($this->isSticker) {
$this->sticker_id = Helper::array_find($message, 'sticker_id');
}
$this->hasAttachments = !is_null(Helper::array_find($message, 'attachments'));
if ($this->hasAttachments) {
$this->attachments = collect(Helper::array_find($message, 'attachments'))->map(function ($attachment) {
return new Attachment($attachment);
});
}
//TODO Add checkout update
}