lib/API/CampaignsApi.php
/**
     * Operation createCampaignWithHttpInfo
     *
     * Create New Campaign
     *
     * @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 \Klaviyo\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of array<string,object>, HTTP status code, HTTP response headers (array of strings)
     */
Operation createCampaignWithHttpInfo
Create New Campaign

@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)

@throws \Klaviyo\ApiException on non-2xx response
@throws \InvalidArgumentException
@return array of array, HTTP status code, HTTP response headers (array of strings)
Operation createCampaignWithHttpInfo Create New Campaign @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 ) @throws \ Klaviyo \ ApiException on non - 2xx response @throws \ InvalidArgumentException @return array of array HTTP status code HTTP response headers ( array of strings )
public function createCampaignWithHttpInfo($list_id, $template_id, $from_email, $from_name, $subject, $name = 'Campaign Name', $use_smart_sending = true, $add_google_analytics = false)
    {
        $request = $this->createCampaignRequest($list_id, $template_id, $from_email, $from_name, $subject, $name, $use_smart_sending, $add_google_analytics);
        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }
            $statusCode = $response->getStatusCode();
            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            switch($statusCode) {
                case 200:
                    if ('array<string,object>' === '\SplFileObject') {
                        $content = $response->getBody(); 
                    } else {
                        $content = (string) $response->getBody();
                    }
                    $parsed_content = json_decode($content, TRUE);
                    if (json_last_error() != JSON_ERROR_NONE) {
                        $parsed_content = $content;
                    }
                    return [
                        $parsed_content,
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
            }
            $returnType = 'array<string,object>';
            if ($returnType === '\SplFileObject') {
                $content = $response->getBody(); 
            } else {
                $content = (string) $response->getBody();
            }
            $parsed_content = json_decode($content, TRUE);
            if (json_last_error() != JSON_ERROR_NONE) {
                $parsed_content = $content;
            }
            return [
                $parsed_content,
                $response->getStatusCode(),
                $response->getHeaders()
            ];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        'array<string,object>',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }
public function createCampaignWithHttpInfo ( $ list_id , $ template_id , $ from_email , $ from_name , $ subject , $ name = 'Campaign Name' , $ use_smart_sending = true , $ add_google_analytics = false ) { $ request = $ this -> createCampaignRequest ( $ list_id , $ template_id , $ from_email , $ from_name , $ subject , $ name , $ use_smart_sending , $ add_google_analytics ) ; try { $ options = $ this -> createHttpClientOption ( ) ; try { $ response = $ this -> client -> send ( $ request , $ options ) ; } catch ( RequestException $ e ) { throw new ApiException ( " [ { $ e -> getCode ( ) } ]  { $ e -> getMessage ( ) } " , ( int ) $ e -> getCode ( ) , $ e -> getResponse ( ) ? $ e -> getResponse ( ) -> getHeaders ( ) : null , $ e -> getResponse ( ) ? ( string ) $ e -> getResponse ( ) -> getBody ( ) : null ) ; } catch ( ConnectException $ e ) { throw new ApiException ( " [ { $ e -> getCode ( ) } ]  { $ e -> getMessage ( ) } " , ( int ) $ e -> getCode ( ) , null , null ) ; } $ statusCode = $ response -> getStatusCode ( ) ; if ( $ statusCode < 200 || $ statusCode > 299 ) { throw new ApiException ( sprintf ( '[%d] Error connecting to the API (%s)' , $ statusCode , ( string ) $ request -> getUri ( ) ) , $ statusCode , $ response -> getHeaders ( ) , ( string ) $ response -> getBody ( ) ) ; } switch ( $ statusCode ) { case 200 : if ( 'array<string,object>' === '\SplFileObject' ) { $ content = $ response -> getBody ( ) ; } else { $ content = ( string ) $ response -> getBody ( ) ; } $ parsed_content = json_decode ( $ content , TRUE ) ; if ( json_last_error ( ) != JSON_ERROR_NONE ) { $ parsed_content = $ content ; } return [ $ parsed_content , $ response -> getStatusCode ( ) , $ response -> getHeaders ( ) ] ; } $ returnType = 'array<string,object>' ; if ( $ returnType === '\SplFileObject' ) { $ content = $ response -> getBody ( ) ; } else { $ content = ( string ) $ response -> getBody ( ) ; } $ parsed_content = json_decode ( $ content , TRUE ) ; if ( json_last_error ( ) != JSON_ERROR_NONE ) { $ parsed_content = $ content ; } return [ $ parsed_content , $ response -> getStatusCode ( ) , $ response -> getHeaders ( ) ] ; } catch ( ApiException $ e ) { switch ( $ e -> getCode ( ) ) { case 200 : $ data = ObjectSerializer :: deserialize ( $ e -> getResponseBody ( ) , 'array<string,object>' , $ e -> getResponseHeaders ( ) ) ; $ e -> setResponseObject ( $ data ) ; break ; } throw $ e ; } }
Operation createCampaignWithHttpInfo
 Create New Campaign
Operation createCampaignWithHttpInfo Create New Campaign
//stream goes to serializer //stream goes to serializer