Class: Peddler::APIs::NotificationsV1

Inherits:
Peddler::API show all
Defined in:
lib/peddler/apis/notifications_v1.rb,
lib/peddler/apis/notifications_v1/error.rb,
lib/peddler/apis/notifications_v1/error_list.rb,
lib/peddler/apis/notifications_v1/destination.rb,
lib/peddler/apis/notifications_v1/event_filter.rb,
lib/peddler/apis/notifications_v1/sqs_resource.rb,
lib/peddler/apis/notifications_v1/subscription.rb,
lib/peddler/apis/notifications_v1/marketplace_ids.rb,
lib/peddler/apis/notifications_v1/destination_list.rb,
lib/peddler/apis/notifications_v1/aggregation_filter.rb,
lib/peddler/apis/notifications_v1/marketplace_filter.rb,
lib/peddler/apis/notifications_v1/order_change_types.rb,
lib/peddler/apis/notifications_v1/aggregation_settings.rb,
lib/peddler/apis/notifications_v1/destination_resource.rb,
lib/peddler/apis/notifications_v1/processing_directive.rb,
lib/peddler/apis/notifications_v1/event_bridge_resource.rb,
lib/peddler/apis/notifications_v1/get_destination_response.rb,
lib/peddler/apis/notifications_v1/order_change_type_filter.rb,
lib/peddler/apis/notifications_v1/get_destinations_response.rb,
lib/peddler/apis/notifications_v1/get_subscription_response.rb,
lib/peddler/apis/notifications_v1/create_destination_request.rb,
lib/peddler/apis/notifications_v1/create_destination_response.rb,
lib/peddler/apis/notifications_v1/create_subscription_request.rb,
lib/peddler/apis/notifications_v1/delete_destination_response.rb,
lib/peddler/apis/notifications_v1/create_subscription_response.rb,
lib/peddler/apis/notifications_v1/get_subscription_by_id_response.rb,
lib/peddler/apis/notifications_v1/delete_subscription_by_id_response.rb,
lib/peddler/apis/notifications_v1/destination_resource_specification.rb,
lib/peddler/apis/notifications_v1/event_bridge_resource_specification.rb

Overview

Selling Partner API for Notifications

The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more.

For more information, refer to the Notifications Use Case Guide.

Defined Under Namespace

Classes: DestinationList, ErrorList, MarketplaceIds, OrderChangeTypes

Constant Summary collapse

Error =

An error response returned when the request is unsuccessful.

Structure.new do
  # @return [String] An error code that identifies the type of error that occurred.
  attribute(:code, String)

  # @return [String] A message that describes the error condition.
  attribute(:message, String)

  # @return [String] Additional details that can help the caller understand or fix the issue.
  attribute?(:details, String)
end
Destination =

Information about the destination created when you call the createDestination operation.

Structure.new do
  # @return [String] The destination identifier generated when you created the destination.
  attribute(:destination_id, String, from: "destinationId")

  # @return [String] The developer-defined name for this destination.
  attribute(:name, String)

  # @return [DestinationResource] The resource that will receive notifications associated with this destination.
  attribute(:resource, DestinationResource)
end
EventFilter =

A notificationType specific filter. This object contains all of the currently available filters and properties that you can use to define a notificationType specific filter.

Structure.new do
  # @return [String] An `eventFilterType` value that is supported by the specific `notificationType`. This is used
  # by the subscription service to determine the type of event filter. Refer to [Notification Type
  # Values](https://developer-docs.amazon.com/sp-api/docs/notification-type-values) to determine if an
  # `eventFilterType` is supported.
  attribute(:event_filter_type, String, from: "eventFilterType")

  # @return [AggregationSettings]
  attribute?(:aggregation_settings, AggregationSettings, from: "aggregationSettings")

  # @return [Array<String>]
  attribute?(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [Array<OrderChangeTypeEnum>]
  attribute?(:order_change_types, Array, from: "orderChangeTypes")
end
SqsResource =

The information required to create an Amazon Simple Queue Service (Amazon SQS) queue destination.

Structure.new do
  # @return [String] The Amazon Resource Name (ARN) associated with the SQS queue.
  attribute(:arn, String)
end
Subscription =

Information about the subscription.

Structure.new do
  # @return [String] The identifier for the destination where notifications will be delivered.
  attribute(:destination_id, String, from: "destinationId")

  # @return [String] The version of the payload object to be used in the notification.
  attribute(:payload_version, String, from: "payloadVersion")

  # @return [String] The subscription identifier generated when the subscription is created.
  attribute(:subscription_id, String, from: "subscriptionId")

  # @return [ProcessingDirective]
  attribute?(:processing_directive, ProcessingDirective, from: "processingDirective")
end
AggregationFilter =

A filter used to select the aggregation time period at which to send notifications (for example: limit to one notification every five minutes for high frequency notifications).

Structure.new do
  # @return [AggregationSettings]
  attribute?(:aggregation_settings, AggregationSettings, from: "aggregationSettings")
end
MarketplaceFilter =

An event filter to customize your subscription to send notifications for only the specified marketplaceIds.

Structure.new do
  # @return [Array<String>]
  attribute?(:marketplace_ids, [String], from: "marketplaceIds")
end
AggregationSettings =

A container that holds all of the necessary properties to configure the aggregation of notifications.

Structure.new do
  # @return [String] The supported time period to use to perform marketplace-ASIN level aggregation.
  attribute(:aggregation_time_period, String, from: "aggregationTimePeriod")
end
DestinationResource =

The destination resource types.

Structure.new do
  # @return [EventBridgeResource] An Amazon EventBridge destination.
  attribute?(:event_bridge, EventBridgeResource, from: "eventBridge")

  # @return [SqsResource] An Amazon Simple Queue Service (SQS) queue destination.
  attribute?(:sqs, SqsResource)
end
ProcessingDirective =

Additional information passed to the subscription to control the processing of notifications. For example, you can use an eventFilter to customize your subscription to send notifications for only the specified marketplaceIds, or select the aggregation time period at which to send notifications (for example: limit to one notification every five minutes for high frequency notifications). The specific features available vary depending on the notificationType.

This feature is currently only supported by the ANY_OFFER_CHANGED and ORDER_CHANGE notificationTypes.

Structure.new do
  # @return [EventFilter] A `notificationType` specific filter.
  attribute?(:event_filter, EventFilter, from: "eventFilter")
end
EventBridgeResource =

The Amazon EventBridge destination.

Structure.new do
  # @return [String] The identifier for the AWS account that is responsible for charges related to receiving
  # notifications.
  attribute(:account_id, String, from: "accountId")

  # @return [String] The name of the partner event source associated with the destination.
  attribute(:name, String)

  # @return [String] The AWS region in which you receive the notifications. For AWS regions that are supported in
  # Amazon EventBridge, refer to [Amazon EventBridge endpoints and
  # quotas](https://docs.aws.amazon.com/general/latest/gr/ev.html).
  attribute(:region, String)
end
GetDestinationResponse =

The response schema for the getDestination operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `getDestination` operation.
  attribute?(:errors, [Error])

  # @return [Destination] The payload for the `getDestination` operation.
  attribute?(:payload, Destination)
end
OrderChangeTypeFilter =

An event filter to customize your subscription to send notifications for only the specified orderChangeType.

Structure.new do
  # @return [Array<OrderChangeTypeEnum>]
  attribute?(:order_change_types, Array, from: "orderChangeTypes")
end
GetDestinationsResponse =

The response schema for the getDestinations operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `getDestinations` operation.
  attribute?(:errors, [Error])

  # @return [Array<Destination>] The payload for the `getDestinations` operation.
  attribute?(:payload, [Destination])
end
GetSubscriptionResponse =

The response schema for the getSubscription operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `getSubscription` operation.
  attribute?(:errors, [Error])

  # @return [Subscription] The payload for the `getSubscription` operation.
  attribute?(:payload, Subscription)
end
CreateDestinationRequest =

The request schema for the createDestination operation.

Structure.new do
  # @return [String] A developer-defined name to help identify this destination.
  attribute(:name, String)

  # @return [DestinationResourceSpecification] The information required to create a destination resource.
  # Applications should use one resource type (sqs or eventBridge) per destination.
  attribute(:resource_specification, DestinationResourceSpecification, from: "resourceSpecification")
end
CreateDestinationResponse =

The response schema for the createDestination operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `createDestination` operation.
  attribute?(:errors, [Error])

  # @return [Destination] The payload for the `createDestination` operation.
  attribute?(:payload, Destination)
end
CreateSubscriptionRequest =

The request schema for the createSubscription operation.

Structure.new do
  # @return [String] The identifier for the destination where notifications will be delivered.
  attribute(:destination_id, String, from: "destinationId")

  # @return [String] The version of the payload object to be used in the notification.
  attribute(:payload_version, String, from: "payloadVersion")

  # @return [ProcessingDirective]
  attribute?(:processing_directive, ProcessingDirective, from: "processingDirective")
end
DeleteDestinationResponse =

The response schema for the deleteDestination operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `deleteDestination` operation.
  attribute?(:errors, [Error])
end
CreateSubscriptionResponse =

The response schema for the createSubscription operation.

Structure.new do
  # @return [Array<Error>] One or more unexpected errors occurred during the `createSubscription` operation.
  attribute?(:errors, [Error])

  # @return [Subscription] The payload for the `createSubscription` operation.
  attribute?(:payload, Subscription)
end
GetSubscriptionByIdResponse =

The response schema for the getSubscriptionById operation.

Structure.new do
  # @return [Array<Error>] An unexpected condition occurred during the `getSubscriptionById` operation.
  attribute?(:errors, [Error])

  # @return [Subscription] The payload for the `getSubscriptionById` operation.
  attribute?(:payload, Subscription)
end
DeleteSubscriptionByIdResponse =

The response schema for the deleteSubscriptionById operation.

Structure.new do
  # @return [Array<Error>] An unexpected condition occurred during the `deleteSubscriptionById` operation.
  attribute?(:errors, [Error])
end
DestinationResourceSpecification =

The information required to create a destination resource. Applications should use one resource type (sqs or eventBridge) per destination.

Structure.new do
  # @return [EventBridgeResourceSpecification] The information required to create an Amazon EventBridge
  # destination.
  attribute?(:event_bridge, EventBridgeResourceSpecification, from: "eventBridge")

  # @return [SqsResource] The information required to create an Amazon Simple Queue Service (SQS) queue
  # destination.
  attribute?(:sqs, SqsResource)
end
EventBridgeResourceSpecification =

The information required to create an Amazon EventBridge destination.

Structure.new do
  # @return [String] The identifier for the AWS account that is responsible for charges related to receiving
  # notifications.
  attribute(:account_id, String, from: "accountId")

  # @return [String] The AWS region in which you will be receiving the notifications.
  attribute(:region, String)
end

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #endpoint, #retries

Instance Method Summary collapse

Methods inherited from Peddler::API

#endpoint_uri, #http, #initialize, #meter, #retriable, #sandbox, #sandbox?, #use, #via

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#create_destination(body, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a destination resource to receive notifications. The createDestination operation is grantless. For more information, refer to Grantless operations.

Parameters:

  • body (Hash)
  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



109
110
111
112
113
# File 'lib/peddler/apis/notifications_v1.rb', line 109

def create_destination(body, rate_limit: 1.0)
  path = "/notifications/v1/destinations"
  parser = -> { CreateDestinationResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#create_subscription(body, notification_type, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a subscription for the specified notification type to be delivered to the specified destination. Before you can subscribe, you must first create the destination by calling the createDestination operation. In cases where the specified notification type supports multiple payload versions, you can utilize this API to subscribe to a different payload version if you already have an existing subscription for a different payload version.

to Notification Type Values.

Parameters:

  • body (Hash)
  • notification_type (String)

    The type of notification. For more information about notification types, refer

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



49
50
51
52
53
# File 'lib/peddler/apis/notifications_v1.rb', line 49

def create_subscription(body, notification_type, rate_limit: 1.0)
  path = "/notifications/v1/subscriptions/#{percent_encode(notification_type)}"
  parser = -> { CreateSubscriptionResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#delete_destination(destination_id, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Deletes the destination that you specify. The deleteDestination operation is grantless. For more information, refer to Grantless operations.

Parameters:

  • destination_id (String)

    The identifier for the destination that you want to delete.

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



136
137
138
139
140
# File 'lib/peddler/apis/notifications_v1.rb', line 136

def delete_destination(destination_id, rate_limit: 1.0)
  path = "/notifications/v1/destinations/#{percent_encode(destination_id)}"
  parser = -> { DeleteDestinationResponse }
  meter(rate_limit).delete(path, parser:)
end

#delete_subscription_by_id(subscription_id, notification_type, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Deletes the subscription indicated by the subscription identifier and notification type that you specify. The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The deleteSubscriptionById operation is grantless. For more information, refer to Grantless operations.

to Notification Type Values.

Parameters:

  • subscription_id (String)

    The identifier for the subscription that you want to delete.

  • notification_type (String)

    The type of notification. For more information about notification types, refer

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



83
84
85
86
87
# File 'lib/peddler/apis/notifications_v1.rb', line 83

def delete_subscription_by_id(subscription_id, notification_type, rate_limit: 1.0)
  path = "/notifications/v1/subscriptions/#{percent_encode(notification_type)}/#{percent_encode(subscription_id)}"
  parser = -> { DeleteSubscriptionByIdResponse }
  meter(rate_limit).delete(path, parser:)
end

#get_destination(destination_id, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns information about the destination that you specify. The getDestination operation is grantless. For more information, refer to Grantless operations.

Parameters:

  • destination_id (String)

    The identifier generated when you created the destination.

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



123
124
125
126
127
# File 'lib/peddler/apis/notifications_v1.rb', line 123

def get_destination(destination_id, rate_limit: 1.0)
  path = "/notifications/v1/destinations/#{percent_encode(destination_id)}"
  parser = -> { GetDestinationResponse }
  meter(rate_limit).get(path, parser:)
end

#get_destinations(rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns information about all destinations. The getDestinations operation is grantless. For more information, refer to Grantless operations.

Parameters:

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



95
96
97
98
99
# File 'lib/peddler/apis/notifications_v1.rb', line 95

def get_destinations(rate_limit: 1.0)
  path = "/notifications/v1/destinations"
  parser = -> { GetDestinationsResponse }
  meter(rate_limit).get(path, parser:)
end

#get_subscription(notification_type, payload_version: nil, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns information about subscription of the specified notification type and payload version. payloadVersion is an optional parameter. When payloadVersion is not provided, it will return latest payload version subscription's information. You can use this API to get subscription information when you do not have a subscription identifier.

to Notification Type Values.

Parameters:

  • payload_version (String) (defaults to: nil)

    The version of the payload object to be used in the notification.

  • notification_type (String)

    The type of notification. For more information about notification types, refer

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



29
30
31
32
33
34
35
36
# File 'lib/peddler/apis/notifications_v1.rb', line 29

def get_subscription(notification_type, payload_version: nil, rate_limit: 1.0)
  path = "/notifications/v1/subscriptions/#{percent_encode(notification_type)}"
  params = {
    "payloadVersion" => payload_version,
  }.compact
  parser = -> { GetSubscriptionResponse }
  meter(rate_limit).get(path, params:, parser:)
end

#get_subscription_by_id(subscription_id, notification_type, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns information about a subscription for the specified notification type. The getSubscriptionById operation is grantless. For more information, refer to Grantless operations.

to Notification Type Values.

Parameters:

  • subscription_id (String)

    The identifier for the subscription that you want to get.

  • notification_type (String)

    The type of notification. For more information about notification types, refer

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



65
66
67
68
69
# File 'lib/peddler/apis/notifications_v1.rb', line 65

def get_subscription_by_id(subscription_id, notification_type, rate_limit: 1.0)
  path = "/notifications/v1/subscriptions/#{percent_encode(notification_type)}/#{percent_encode(subscription_id)}"
  parser = -> { GetSubscriptionByIdResponse }
  meter(rate_limit).get(path, parser:)
end