public function SendinblueApiV2::getTemplates in SendinBlue 8
Same name and namespace in other branches
- 8.2 src/Tools/Api/SendinblueApiV2.php \Drupal\sendinblue\Tools\Api\SendinblueApiV2::getTemplates()
Get templates.
Return value
\Drupal\sendinblue\Tools\Model\GetSmtpTemplates An array of campaigns.
Overrides SendInBlueApiInterface::getTemplates
1 call to SendinblueApiV2::getTemplates()
- SendinblueApiV2::getTemplate in src/
Tools/ Api/ SendinblueApiV2.php - Get template by id.
File
- src/
Tools/ Api/ SendinblueApiV2.php, line 122
Class
- SendinblueApiV2
- Sendinblue REST client.
Namespace
Drupal\sendinblue\Tools\ApiCode
public function getTemplates() {
$response = $this->sIBHttpClient
->get("campaign/detailsv2", 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,
]);
}