public function toArray()
    {
        if ($this->hasAttachment) {
            return $this->attachmentMessageToArray();
        }

        if ($this->hasText) {
            //check if has buttons
            if (count($this->buttons) > 0) {
                return $this->buttonMessageToArray();
            }

            return $this->textMessageToArray();
        }

        if (count($this->cards) > 0) {
            return $this->genericMessageToArray();
        }

        throw CouldNotCreateMessage::dataNotProvided();
    }
public function toArray()
    {
        if ($this->hasAttachment) {
            return $this->attachmentMessageToArray();
        }

        if ($this->hasText) {
            //check if has buttons
            if (count($this->buttons) > 0) {
                return $this->buttonMessageToArray();
            }

            return $this->textMessageToArray();
        }

        if (count($this->cards) > 0) {
            return $this->genericMessageToArray();
        }

        throw CouldNotCreateMessage::dataNotProvided();
    }
public function toArray ( ) { if ( $ this -> hasAttachment ) { return $ this -> attachmentMessageToArray ( ) ; } if ( $ this -> hasText ) { //check if has buttons if ( count ( $ this -> buttons ) > 0 ) { return $ this -> buttonMessageToArray ( ) ; } return $ this -> textMessageToArray ( ) ; } if ( count ( $ this -> cards ) > 0 ) { return $ this -> genericMessageToArray ( ) ; } throw CouldNotCreateMessage :: dataNotProvided ( ) ; }
Returns message payload for JSON conversion.

@throws CouldNotCreateMessage
@return array
Returns message payload for JSON conversion .