/**
  * 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
 }
 /**
  * Entry constructor.
  * @param $entry
  * entry array object
  */
 public function __construct($entry)
 {
     $this->id = Helper::array_find($entry, 'id');
     $this->time = Helper::array_find($entry, 'time');
     $this->_messaging = Helper::array_find($entry, 'messaging');
     $this->buildMessages();
 }
 /**
  * Delivered constructor.
  * @param $account_linking
  */
 public function __construct($account_linking)
 {
     $this->status = Helper::array_find($account_linking, 'status');
     $this->authorization_code = Helper::array_find($account_linking, 'authorization_code');
     $this->linked = $this->status == 'linked';
     $this->unlinked = $this->status == 'unlinked';
 }
 /**
  * Attachment constructor.
  * @param $attachemnt
  */
 public function __construct($attachment)
 {
     $this->type = Helper::array_find($attachment, 'type');
     $this->isImage = $this->type == 'image';
     $this->isAudio = $this->type == 'audio';
     $this->isVideo = $this->type == 'video';
     $this->isFile = $this->type == 'file';
     $this->isLocation = $this->type == 'location';
     $this->isTemplate = $this->type == 'template';
     $this->isFallback = $this->type == 'fallback';
     if ($this->isImage || $this->isAudio || $this->isVideo || $this->isFile) {
         $this->url = Helper::array_find($attachment, 'payload.url');
     }
     if ($this->isLocation) {
         $this->location = Helper::array_find($attachment, 'payload.coordinates');
         $this->title = Helper::array_find($attachment, 'title');
         $this->url = Helper::array_find($attachment, 'url');
     }
     if ($this->isTemplate) {
         $this->template_type = Helper::array_find($attachment, 'payload.template_type');
         //TODO
         //need to access SendAPI object to get options
     }
     if ($this->isFallback) {
         $this->title = Helper::array_find($attachment, 'title');
         $this->url = Helper::array_find($attachment, 'url');
         $this->payload = Helper::array_find($attachment, 'payload');
         //not sure what the output is here?
     }
 }
 /**
  * Read constructor.
  * @param $read
  */
 public function __construct($read, $useCarbonDate = false)
 {
     $this->watermark = Helper::array_find($read, 'watermark');
     if ($useCarbonDate) {
         $this->datetime = \Carbon\Carbon::createFromTimestamp($this->watermark / 1000);
     }
     //if  needed
     $this->seq = Helper::array_find($read, 'seq');
 }
 /**
  * Delivered constructor.
  * @param $authentication
  */
 public function __construct($authentication)
 {
     $this->ref = Helper::array_find($authentication, 'ref');
 }
 private function updateMessage()
 {
     $this->isMessage = !is_null(Helper::array_find($this->_message, 'message'));
     if ($this->isMessage) {
         $this->message = new Message(Helper::array_find($this->_message, 'message'));
     }
 }
 /**
  * Cb constructor.
  * @param $data
  * An array of request information $request->all()
  */
 public function __construct($data)
 {
     $this->object = Helper::array_find($data, 'object');
     $this->_entries = Helper::array_find($data, 'entry');
     $this->buildEntries();
 }
 /**
  * Delivered constructor.
  * @param $payload
  */
 public function __construct($postback)
 {
     $this->payload = Helper::array_find($postback, 'payload');
 }