lib/API/CampaignsApi.php
/**
     * Create request for operation 'createCampaign'
     *
     * @param  string $list_id The list you will send the campaign to. (required)
     * @param  string $template_id The template that will define the content of the page. Note: the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign. (required)
     * @param  string $from_email The email address your email will be sent from and will be used in the &#x60;reply-to&#x60; header. (required)
     * @param  string $from_name The name or label associated with the email address you&#39;re sending from. (required)
     * @param  string $subject The email subject of the campaign (required)
     * @param  string $name If not specified, this will default to the subject of the campaign. (optional, default to 'Campaign Name')
     * @param  bool $use_smart_sending If set, limits the number of emails sent to an individual within a short period. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;true&#x60;. (optional, default to true)
     * @param  bool $add_google_analytics If specified, adds Google Analytics tracking tags to links. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;false&#x60;. (optional, default to false)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
Create request for operation 'createCampaign'
@param  string $list_id The list you will send the campaign to. (required)
@param  string $template_id The template that will define the content of the page. Note: the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign. (required)
@param  string $from_email The email address your email will be sent from and will be used in the `reply-to` header. (required)
@param  string $from_name The name or label associated with the email address you're sending from. (required)
@param  string $subject The email subject of the campaign (required)
@param  string $name If not specified, this will default to the subject of the campaign. (optional, default to 'Campaign Name')
@param  bool $use_smart_sending If set, limits the number of emails sent to an individual within a short period. Valid values are `true` and `false`. If not specified, defaults to `true`. (optional, default to true)
@param  bool $add_google_analytics If specified, adds Google Analytics tracking tags to links. Valid values are `true` and `false`. If not specified, defaults to `false`. (optional, default to false)


Create request for operation ' createCampaign ' @param string $list_id The list you will send the campaign to . ( required ) @param string $template_id The template that will define the content of the page . Note : the Email Template is copied when creating this campaign so future changes to that Email Template will not alter the content of this campaign . ( required ) @param string $from_email The email address your email will be sent from and will be used in the ` reply - to ` header . ( required ) @param string $from_name The name or label associated with the email address you ' re sending from . ( required ) @param string $subject The email subject of the campaign ( required ) @param string $name If not specified this will default to the subject of the campaign . ( optional default to ' Campaign Name ' ) @param bool $use_smart_sending If set limits the number of emails sent to an individual within a short period . Valid values are ` true ` and ` false ` . If not specified defaults to ` true ` . ( optional default to true ) @param bool $add_google_analytics If specified adds Google Analytics tracking tags to links . Valid values are ` true ` and ` false ` . If not specified defaults to ` false ` . ( optional default to false )
public function createCampaignRequest($list_id, $template_id, $from_email, $from_name, $subject, $name = 'Campaign Name', $use_smart_sending = true, $add_google_analytics = false)
    {
        if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $list_id when calling createCampaign'
            );
        }
        if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $template_id when calling createCampaign'
            );
        }
        if ($from_email === null || (is_array($from_email) && count($from_email) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $from_email when calling createCampaign'
            );
        }
        if ($from_name === null || (is_array($from_name) && count($from_name) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $from_name when calling createCampaign'
            );
        }
        if ($subject === null || (is_array($subject) && count($subject) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $subject when calling createCampaign'
            );
        }
        $resourcePath = '/v1/campaigns';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;
        if ($list_id !== null) {
            $formParams['list_id'] = ObjectSerializer::toFormValue($list_id);
        }
        if ($template_id !== null) {
            $formParams['template_id'] = ObjectSerializer::toFormValue($template_id);
        }
        if ($from_email !== null) {
            $formParams['from_email'] = ObjectSerializer::toFormValue($from_email);
        }
        if ($from_name !== null) {
            $formParams['from_name'] = ObjectSerializer::toFormValue($from_name);
        }
        if ($subject !== null) {
            $formParams['subject'] = ObjectSerializer::toFormValue($subject);
        }
        if ($name !== null) {
            $formParams['name'] = ObjectSerializer::toFormValue($name);
        }
        if ($use_smart_sending !== null) {
            $formParams['use_smart_sending'] = ObjectSerializer::toFormValue($use_smart_sending);
        }
        if ($add_google_analytics !== null) {
            $formParams['add_google_analytics'] = ObjectSerializer::toFormValue($add_google_analytics);
        }
        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                ['application/x-www-form-urlencoded']
            );
        }
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                $httpBody = new MultipartStream($multipartContents);
            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                $httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
            }
        }
        $apiKey = $this->config->getApiKeyWithPrefix('api_key');
        if ($apiKey !== null) {
            $queryParams['api_key'] = $apiKey;
        }
        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }
        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );
        $query = \GuzzleHttp\Psr7\Query::build($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }
public function createCampaignRequest ( $ list_id , $ template_id , $ from_email , $ from_name , $ subject , $ name = 'Campaign Name' , $ use_smart_sending = true , $ add_google_analytics = false ) { if ( $ list_id === null || ( is_array ( $ list_id ) && count ( $ list_id ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $list_id when calling createCampaign' ) ; } if ( $ template_id === null || ( is_array ( $ template_id ) && count ( $ template_id ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $template_id when calling createCampaign' ) ; } if ( $ from_email === null || ( is_array ( $ from_email ) && count ( $ from_email ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $from_email when calling createCampaign' ) ; } if ( $ from_name === null || ( is_array ( $ from_name ) && count ( $ from_name ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $from_name when calling createCampaign' ) ; } if ( $ subject === null || ( is_array ( $ subject ) && count ( $ subject ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $subject when calling createCampaign' ) ; } $ resourcePath = '/v1/campaigns' ; $ formParams = [ ] ; $ queryParams = [ ] ; $ headerParams = [ ] ; $ httpBody = '' ; $ multipart = false ; if ( $ list_id !== null ) { $ formParams [ 'list_id' ] = ObjectSerializer :: toFormValue ( $ list_id ) ; } if ( $ template_id !== null ) { $ formParams [ 'template_id' ] = ObjectSerializer :: toFormValue ( $ template_id ) ; } if ( $ from_email !== null ) { $ formParams [ 'from_email' ] = ObjectSerializer :: toFormValue ( $ from_email ) ; } if ( $ from_name !== null ) { $ formParams [ 'from_name' ] = ObjectSerializer :: toFormValue ( $ from_name ) ; } if ( $ subject !== null ) { $ formParams [ 'subject' ] = ObjectSerializer :: toFormValue ( $ subject ) ; } if ( $ name !== null ) { $ formParams [ 'name' ] = ObjectSerializer :: toFormValue ( $ name ) ; } if ( $ use_smart_sending !== null ) { $ formParams [ 'use_smart_sending' ] = ObjectSerializer :: toFormValue ( $ use_smart_sending ) ; } if ( $ add_google_analytics !== null ) { $ formParams [ 'add_google_analytics' ] = ObjectSerializer :: toFormValue ( $ add_google_analytics ) ; } if ( $ multipart ) { $ headers = $ this -> headerSelector -> selectHeadersForMultipart ( [ 'application/json' ] ) ; } else { $ headers = $ this -> headerSelector -> selectHeaders ( [ 'application/json' ] , [ 'application/x-www-form-urlencoded' ] ) ; } if ( count ( $ formParams ) > 0 ) { if ( $ multipart ) { $ multipartContents = [ ] ; foreach ( $ formParams as $ formParamName => $ formParamValue ) { $ formParamValueItems = is_array ( $ formParamValue ) ? $ formParamValue : [ $ formParamValue ] ; foreach ( $ formParamValueItems as $ formParamValueItem ) { $ multipartContents [ ] = [ 'name' => $ formParamName , 'contents' => $ formParamValueItem ] ; } } $ httpBody = new MultipartStream ( $ multipartContents ) ; } elseif ( $ headers [ 'Content-Type' ] === 'application/json' ) { $ httpBody = \ GuzzleHttp \ json_encode ( $ formParams ) ; } else { $ httpBody = \ GuzzleHttp \ Psr7 \ Query :: build ( $ formParams ) ; } } $ apiKey = $ this -> config -> getApiKeyWithPrefix ( 'api_key' ) ; if ( $ apiKey !== null ) { $ queryParams [ 'api_key' ] = $ apiKey ; } $ defaultHeaders = [ ] ; if ( $ this -> config -> getUserAgent ( ) ) { $ defaultHeaders [ 'User-Agent' ] = $ this -> config -> getUserAgent ( ) ; } $ headers = array_merge ( $ defaultHeaders , $ headerParams , $ headers ) ; $ query = \ GuzzleHttp \ Psr7 \ Query :: build ( $ queryParams ) ; return new Request ( 'POST' , $ this -> config -> getHost ( ) . $ resourcePath . ( $ query ? " ? { $ query } " : '' ) , $ headers , $ httpBody ) ; }
Create request for operation 'createCampaign'
 @param  string $list_id The list you will send the campaign to.
Create request for operation ' createCampaign ' @param string $list_id The list you will send the campaign to .
// verify the required parameter 'list_id' is set // verify the required parameter 'template_id' is set // verify the required parameter 'from_email' is set // verify the required parameter 'from_name' is set // verify the required parameter 'subject' is set // form params // form params // form params // form params // form params // form params // form params // form params // for model (json/xml) // for HTTP post (form) // for HTTP post (form) // this endpoint requires API key authentication