You are here

public function Client::getNotifications in Media: Acquia DAM 8

Returns the list of recent Webdam REST API "Notifications".

Parameters

array $query_options: The associative array of optional query parameters:

  • "limit" - the maximum number of items to return;
  • "offset" - the starting position for the number of items to return;
  • "starttime" - the lowest (inclusive) "date_created_unix" notification property to return;
  • "endtime" - the highest (exclusive) "date_created_unix" notification property to return.

Return value

array The response (associative array) from Notifications API containing the following keys:

  • "last_read" - date/time the Notifications API was last read;
  • "offset" - duplicates the offset parameter;
  • "limit" - duplicates the limit parameter;
  • "total" - the total number of notification items in the API;
  • "notifications" - notification items.

Throws

\GuzzleHttp\Exception\GuzzleException

\cweagans\webdam\Exception\InvalidCredentialsException

File

src/Client.php, line 465

Class

Client
Overridden implementation of the cweagans php-webdam-client.

Namespace

Drupal\media_acquiadam

Code

public function getNotifications(array $query_options = []) : array {
  $this
    ->checkAuth();
  $query_options += [
    'limit' => 100,
    'offset' => 0,
    'starttime' => NULL,
    'endtime' => NULL,
  ];
  $response = $this->client
    ->request('GET', $this->baseUrl . '/notifications', [
    'headers' => $this
      ->getDefaultHeaders(),
    'query' => $query_options,
  ]);
  if ($response
    ->getStatusCode() == 429) {
    Drupal::logger('media_acquiadam')
      ->error('Failed to fetch asset ids: Too Many Requests.');
    return [];
  }
  return json_decode((string) $response
    ->getBody(), TRUE);
}