createNotificationSubscription method

Future<CreateNotificationSubscriptionResponse> createNotificationSubscription({
  1. required String endpoint,
  2. required String organizationId,
  3. required SubscriptionProtocolType protocol,
  4. required SubscriptionType subscriptionType,
})

Configure Amazon WorkDocs to use Amazon SNS notifications. The endpoint receives a confirmation message, and must confirm the subscription.

For more information, see Subscribe to Notifications in the Amazon WorkDocs Developer Guide.

May throw UnauthorizedResourceAccessException. May throw TooManySubscriptionsException. May throw ServiceUnavailableException.

Parameter endpoint : The endpoint to receive the notifications. If the protocol is HTTPS, the endpoint is a URL that begins with https.

Parameter organizationId : The ID of the organization.

Parameter protocol : The protocol to use. The supported value is https, which delivers JSON-encoded messages using HTTPS POST.

Parameter subscriptionType : The notification type.

Implementation

Future<CreateNotificationSubscriptionResponse>
    createNotificationSubscription({
  required String endpoint,
  required String organizationId,
  required SubscriptionProtocolType protocol,
  required SubscriptionType subscriptionType,
}) async {
  ArgumentError.checkNotNull(endpoint, 'endpoint');
  _s.validateStringLength(
    'endpoint',
    endpoint,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(organizationId, 'organizationId');
  _s.validateStringLength(
    'organizationId',
    organizationId,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(protocol, 'protocol');
  ArgumentError.checkNotNull(subscriptionType, 'subscriptionType');
  final $payload = <String, dynamic>{
    'Endpoint': endpoint,
    'Protocol': protocol.toValue(),
    'SubscriptionType': subscriptionType.toValue(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/api/v1/organizations/${Uri.encodeComponent(organizationId)}/subscriptions',
    exceptionFnMap: _exceptionFns,
  );
  return CreateNotificationSubscriptionResponse.fromJson(response);
}