public function Api::getBouncesBySubuser in SendGrid Integration 8
Same name and namespace in other branches
- 8.2 modules/sendgrid_integration_reports/src/Api.php \Drupal\sendgrid_integration_reports\Api::getBouncesBySubuser()
Get bounces by subuser.
File
- modules/
sendgrid_integration_reports/ src/ Api.php, line 396
Class
- Api
- Class SendGridReportsController.
Namespace
Drupal\sendgrid_integration_reportsCode
public function getBouncesBySubuser($startTime = 0, $endTime = 0, $subuser = '') {
$cid = 'sendgrid_reports_bounces';
if ($cache = $this->cacheFactory
->get($this->bin)
->get($cid)) {
return $cache->data;
}
$path = 'suppression/bounces';
$query = [
'start_time' => $startTime ? $startTime : strtotime('-1 month'),
'end_time' => $endTime ? $endTime : time(),
];
$subusers = $subuser ? [
(object) [
'username' => $subuser,
],
] : $this
->getSubusers();
$bounces = [];
foreach ($subusers as $subuser) {
$username = $subuser->username;
$response = $this
->getResponse($path, $query, $username);
if (!empty($response)) {
$bounces[$username] = $response;
}
}
$this
->setCache($cid, $bounces);
return $bounces;
}