You are here

public function Api::getSubusers in SendGrid Integration 8

Same name and namespace in other branches
  1. 8.2 modules/sendgrid_integration_reports/src/Api.php \Drupal\sendgrid_integration_reports\Api::getSubusers()

Get list of subusers.

1 call to Api::getSubusers()
Api::getBouncesBySubuser in modules/sendgrid_integration_reports/src/Api.php
Get bounces by subuser.

File

modules/sendgrid_integration_reports/src/Api.php, line 373

Class

Api
Class SendGridReportsController.

Namespace

Drupal\sendgrid_integration_reports

Code

public function getSubusers() {
  $cid = 'sendgrid_reports_subusers';
  if ($cache = $this->cacheFactory
    ->get($this->bin)
    ->get($cid)) {
    return $cache->data;
  }
  $path = 'subusers';
  $query = [
    'limit' => 500,
    'offset' => 0,
  ];
  $subusers = [];
  do {
    $response = $this
      ->getResponse($path, $query);
    $query['offset'] += 500;
    $subusers = array_merge($subusers, $response);
  } while (!empty($response));
  $this
    ->setCache($cid, $subusers);
  return $subusers;
}