getFromSubscription static method

Future<PcoCollection<PcoWebhooksEvent>> getFromSubscription(
  1. String subscriptionId, {
  2. String? id,
  3. PcoWebhooksEventQuery? query,
  4. bool getAll = false,
})

Will get a PcoCollection of PcoWebhooksEvent objects (expecting many) using a path like this: /webhooks/v2/subscriptions/$subscriptionId/events

Getting a PcoCollection is useful even when retrieving a single object because it contains error data and helper functions.

Additional options may be specified by using the query argument, but some query options are also available as boolean flags in this function call too.

Implementation

static Future<PcoCollection<PcoWebhooksEvent>> getFromSubscription(
  String subscriptionId, {
  String? id,
  PcoWebhooksEventQuery? query,
  bool getAll = false,
}) async {
  query ??= PcoWebhooksEventQuery();
  if (getAll) query.getAll = true;

  var url = '/webhooks/v2/subscriptions/$subscriptionId/events';
  if (id != null) url += '/$id';
  return PcoCollection.fromApiCall<PcoWebhooksEvent>(url,
      query: query, apiVersion: kApiVersion);
}