lib/mail/Mail.php
public function jsonSerialize()
    {
        // Detect if we are using the new dynamic templates
        $template_id = $this->getTemplateId();
        if ($template_id != null) {
            if (substr((string) $template_id->getTemplateId(), 0, 2) == "d-") {
                foreach ($this->personalization as $personalization) {
                    $personalization->setHasDynamicTemplate(true);
                }
            }
        }
        return array_filter(
            [
                'personalizations' => $this->getPersonalizations(),
                'from' => $this->getFrom(),
                'reply_to' => $this->getReplyTo(),
                'subject' => $this->getGlobalSubject(),
                'content' => $this->getContents(),
                'attachments' => $this->getAttachments(),
                'template_id' => $this->getTemplateId(),
                'sections' => $this->getSections(),
                'headers' => $this->getGlobalHeaders(),
                'categories' => $this->getCategories(),
                'custom_args' => $this->getGlobalCustomArgs(),
                'send_at' => $this->getGlobalSendAt(),
                'batch_id' => $this->getBatchId(),
                'asm' => $this->getASM(),
                'ip_pool_name' => $this->getIpPoolName(),
                'substitutions' => $this->getGlobalSubstitutions(),
                'mail_settings' => $this->getMailSettings(),
                'tracking_settings' => $this->getTrackingSettings()
            ],
            function ($value) {
                return $value !== null;
            }
        ) ?: null;
    }
public function jsonSerialize()
    {
        // Detect if we are using the new dynamic templates
        $template_id = $this->getTemplateId();
        if ($template_id != null) {
            if (substr((string) $template_id->getTemplateId(), 0, 2) == "d-") {
                foreach ($this->personalization as $personalization) {
                    $personalization->setHasDynamicTemplate(true);
                }
            }
        }
        return array_filter(
            [
                'personalizations' => $this->getPersonalizations(),
                'from' => $this->getFrom(),
                'reply_to' => $this->getReplyTo(),
                'subject' => $this->getGlobalSubject(),
                'content' => $this->getContents(),
                'attachments' => $this->getAttachments(),
                'template_id' => $this->getTemplateId(),
                'sections' => $this->getSections(),
                'headers' => $this->getGlobalHeaders(),
                'categories' => $this->getCategories(),
                'custom_args' => $this->getGlobalCustomArgs(),
                'send_at' => $this->getGlobalSendAt(),
                'batch_id' => $this->getBatchId(),
                'asm' => $this->getASM(),
                'ip_pool_name' => $this->getIpPoolName(),
                'substitutions' => $this->getGlobalSubstitutions(),
                'mail_settings' => $this->getMailSettings(),
                'tracking_settings' => $this->getTrackingSettings()
            ],
            function ($value) {
                return $value !== null;
            }
        ) ?: null;
    }
public function jsonSerialize ( ) { // Detect if we are using the new dynamic templates $ template_id = $ this -> getTemplateId ( ) ; if ( $ template_id != null ) { if ( substr ( ( string ) $ template_id -> getTemplateId ( ) , 0 , 2 ) == "d-" ) { foreach ( $ this -> personalization as $ personalization ) { $ personalization -> setHasDynamicTemplate ( true ) ; } } } return array_filter ( [ 'personalizations' => $ this -> getPersonalizations ( ) , 'from' => $ this -> getFrom ( ) , 'reply_to' => $ this -> getReplyTo ( ) , 'subject' => $ this -> getGlobalSubject ( ) , 'content' => $ this -> getContents ( ) , 'attachments' => $ this -> getAttachments ( ) , 'template_id' => $ this -> getTemplateId ( ) , 'sections' => $ this -> getSections ( ) , 'headers' => $ this -> getGlobalHeaders ( ) , 'categories' => $ this -> getCategories ( ) , 'custom_args' => $ this -> getGlobalCustomArgs ( ) , 'send_at' => $ this -> getGlobalSendAt ( ) , 'batch_id' => $ this -> getBatchId ( ) , 'asm' => $ this -> getASM ( ) , 'ip_pool_name' => $ this -> getIpPoolName ( ) , 'substitutions' => $ this -> getGlobalSubstitutions ( ) , 'mail_settings' => $ this -> getMailSettings ( ) , 'tracking_settings' => $ this -> getTrackingSettings ( ) ] , function ( $ value ) { return $ value !== null ; } ) ? : null ; }
Return an array representing a request object for the Twilio SendGrid API

@return null|array
Return an array representing a request object for the Twilio SendGrid API