create method

Future<NotificationSubscription> create(
  1. NotificationSubscription request,
  2. String parent, {
  3. String? $fields,
})

Creates a notification subscription for a business.

For standalone or subaccounts accounts, the business can create a subscription for self. For MCAs, the business can create a subscription for all managed accounts or for a specific subaccount. We will allow the following types of notification subscriptions to exist together (per business as a subscriber per event type): 1. Subscription for all managed accounts + subscription for self. 2. Multiple "partial" subscriptions for managed accounts + subscription for self. we will not allow (per business as a subscriber per event type): 1. Multiple self subscriptions. 2. Multiple "all managed accounts" subscriptions. 3. "All managed accounts" subscription and partial subscriptions at the same time. 4. Multiple partial subscriptions for the same target account.

request - The metadata request object.

Request parameters:

parent - Required. The merchant account that owns the new notification subscription. Format: accounts/{account} Value must have pattern ^accounts/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a NotificationSubscription.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<NotificationSubscription> create(
  NotificationSubscription request,
  core.String parent, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'notifications/v1/' +
      core.Uri.encodeFull('$parent') +
      '/notificationsubscriptions';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return NotificationSubscription.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}