Postmark\PostmarkClient::validateTemplate PHP Метод

validateTemplate() публичный Метод

Confirm that your template content can be parsed/rendered, get a test rendering of your template, and a suggested model to use with your templates.
public validateTemplate ( string $subject = NULL, string $htmlBody = NULL, string $textBody = NULL, object $testRenderModel = NULL, boolean $inlineCssForHtmlTestRender = true ) : Postmark\Models\DynamicResponseModel
$subject string The Subject template you wish to test.
$htmlBody string The HTML template you wish to test
$textBody string The number of templates to "Skip" before returning results.
$testRenderModel object The model to be used when doing test renders of the templates that successfully parse in this request.
$inlineCssForHtmlTestRender boolean If htmlBody is specified, the test render will automatically do CSS Inlining for the HTML content. You may opt-out of this behavior by passing 'false' for this parameter.
Результат Postmark\Models\DynamicResponseModel
    function validateTemplate($subject = NULL, $htmlBody = NULL, $textBody = NULL, $testRenderModel = NULL, $inlineCssForHtmlTestRender = true)
    {
        $query = array();
        $query["subject"] = $subject;
        $query["htmlBody"] = $htmlBody;
        $query["textBody"] = $textBody;
        $query["testRenderModel"] = $testRenderModel;
        $query["inlineCssForHtmlTestRender"] = $inlineCssForHtmlTestRender;
        return new DynamicResponseModel($this->processRestRequest('POST', "/templates/validate", $query));
    }

Usage Example

 function testClientCanValidateTemplate()
 {
     $tk = parent::$testKeys;
     $client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
     $result = $client->validateTemplate("{{subject}}", "Hello <b>{{name}}</b>!", "Hello {{name}}!", NULL, false);
     $this->assertNotEmpty($result);
 }