Postmark\PostmarkClient::listTemplates PHP Method

listTemplates() public method

Get all templates associated with the Server.
public listTemplates ( integer $count = 100, integer $offset ) : Postmark\Models\DynamicResponseModel
$count integer The total number of templates to get at once (default is 100)
$offset integer The number of templates to "Skip" before returning results.
return Postmark\Models\DynamicResponseModel
    function listTemplates($count = 100, $offset = 0)
    {
        $query = array();
        $query["count"] = $count;
        $query["offset"] = $offset;
        return new DynamicResponseModel($this->processRestRequest('GET', "/templates", $query));
    }

Usage Example

 function testClientCanListTemplates()
 {
     $tk = parent::$testKeys;
     $client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
     for ($i = 0; $i < 5; $i++) {
         $client->createTemplate('test-php-template-' . $i . '-' . date('c'), "{{subject}}", "Hello <b>{{name}}</b>!", "Hello {{name}}!");
     }
     $result = $client->listTemplates();
     $this->assertNotEmpty($result->Templates);
 }