lib/API/TemplatesApi.php
/**
     * Operation renderTemplateWithHttpInfo
     *
     * Render Template
     *
     * @param  string $template_id (required)
     * @param  string $context This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing. (optional, default to '{ "name" : "George Washington", "state" : "VA" }')
     *
     * @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 renderTemplateWithHttpInfo
Render Template

@param  string $template_id (required)
@param  string $context This is the context your email template will be rendered with. Email templates are rendered with contexts in a similar manner to how Django templates are rendered. This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing.

@throws \Klaviyo\ApiException on non-2xx response
@throws \InvalidArgumentException
@return array of array, HTTP status code, HTTP response headers (array of strings)
Operation renderTemplateWithHttpInfo Render Template @param string $template_id ( required ) @param string $context This is the context your email template will be rendered with . Email templates are rendered with contexts in a similar manner to how Django templates are rendered . This means that nested template variables can be referenced via dot notation and template variables without corresponding context values are treated as falsy and output nothing . @throws \ Klaviyo \ ApiException on non - 2xx response @throws \ InvalidArgumentException @return array of array HTTP status code HTTP response headers ( array of strings )
public function renderTemplateWithHttpInfo($template_id, $context = '{ "name" : "George Washington", "state" : "VA" }')
    {
        $request = $this->renderTemplateRequest($template_id, $context);
        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 renderTemplateWithHttpInfo ( $ template_id , $ context = '{ "name" : "George Washington", "state" : "VA" }' ) { $ request = $ this -> renderTemplateRequest ( $ template_id , $ context ) ; 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 renderTemplateWithHttpInfo
 Render Template
Operation renderTemplateWithHttpInfo Render Template
//stream goes to serializer //stream goes to serializer