public function SendinblueApiV2::getTemplates in SendinBlue 7.2
Get templates.
Return value
GetSmtpTemplates An array of campaigns.
Overrides SendInBlueApiInterface::getTemplates
1 call to SendinblueApiV2::getTemplates()
- SendinblueApiV2::getTemplate in includes/
Api/ SendinblueApiV2.php - Get template by id.
File
- includes/
Api/ SendinblueApiV2.php, line 77
Class
- SendinblueApiV2
- Sendinblue REST client.
Code
public function getTemplates() {
$response = $this->sIBHttpClient
->get("campaign/detailsv2", drupal_json_encode([
"type" => 'template',
]));
$templates = [];
if ($response['code'] === 'success' && is_array($response['data'])) {
foreach ($response['data']['campaign_records'] as $template) {
$templates[] = [
'id' => $template['id'],
'name' => $template['campaign_name'],
'subject' => $template['subject'],
'htmlContent' => $template['html_content'],
'sender' => [
'email' => $template['from_email'],
'name' => $template['from_name'],
],
];
}
}
return new GetSmtpTemplates([
'templates' => $templates,
'count' => count($response['data']),
]);
}