Class: MuffinMan::Notifications::V1
Constant Summary
collapse
- NOTIFICATION_PATH =
"/notifications/v1"
- NOTIFICATION_SCOPE =
"sellingpartnerapi::notifications"
- PROCESSING_DIRECTIVE_SUPPORTED_NOTIFICATIONS =
["ANY_OFFER_CHANGED"].freeze
Constants inherited
from SpApiClient
SpApiClient::ACCESS_TOKEN_URL, SpApiClient::AWS_REGION_MAP, SpApiClient::SERVICE_NAME, SpApiClient::UNPROCESSABLE_ENTITY_STATUS_CODE
Instance Attribute Summary
Attributes inherited from SpApiClient
#access_token_cache_key, #aws_access_key_id, #aws_secret_access_key, #client_id, #client_secret, #config, #credentials, #local_var_path, #pii_data_elements, #query_params, #refresh_token, #region, #request_body, #request_type, #sandbox, #scope, #sts_iam_role_arn
Instance Method Summary
collapse
Methods inherited from SpApiClient
#initialize
Instance Method Details
#create_destination(arn, name, params = {}) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/muffin_man/notifications/v1.rb', line 12
def create_destination(arn, name, params = {})
@local_var_path = "#{NOTIFICATION_PATH}/destinations"
params = params.transform_keys(&:to_s)
@scope = NOTIFICATION_SCOPE
destination_params = { "resourceSpecification" => { "sqs" => { "arn" => arn } }, "name" => name }
unless params["region"].nil? || params["account_id"].nil?
destination_params["resourceSpecification"].merge!("eventBridge" => { "region" => params["region"],
"accountId" => params["account_id"] })
end
@request_body = destination_params
@request_type = "POST"
call_api
end
|
#create_subscription(notification_type, params = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/muffin_man/notifications/v1.rb', line 41
def create_subscription(notification_type, params = {})
@local_var_path = "#{NOTIFICATION_PATH}/subscriptions/#{notification_type}"
params = params.transform_keys(&:to_s)
subscription_params = { "destinationId" => params["destination_id"] }
if include_processing_directive?(notification_type, params)
subscription_params.merge!(
"processingDirective" => params["processing_directive"]
)
end
subscription_params.merge!("payloadVersion" => params["payload_version"]) unless params["payload_version"].nil?
@request_body = subscription_params
@request_type = "POST"
call_api
end
|
#delete_destination(destination_id) ⇒ Object
79
80
81
82
83
84
|
# File 'lib/muffin_man/notifications/v1.rb', line 79
def delete_destination(destination_id)
@local_var_path = "#{NOTIFICATION_PATH}/destinations/#{destination_id}"
@scope = NOTIFICATION_SCOPE
@request_type = "DELETE"
call_api
end
|
#delete_subscription_by_id(notification_type, subscription_id) ⇒ Object
72
73
74
75
76
77
|
# File 'lib/muffin_man/notifications/v1.rb', line 72
def delete_subscription_by_id(notification_type, subscription_id)
@local_var_path = "#{NOTIFICATION_PATH}/subscriptions/#{notification_type}/#{subscription_id}"
@scope = NOTIFICATION_SCOPE
@request_type = "DELETE"
call_api
end
|
#get_destination(destination_id) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/muffin_man/notifications/v1.rb', line 34
def get_destination(destination_id)
@local_var_path = "#{NOTIFICATION_PATH}/destinations/#{destination_id}"
@scope = NOTIFICATION_SCOPE
@request_type = "GET"
call_api
end
|
#get_destinations(params = {}) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/muffin_man/notifications/v1.rb', line 26
def get_destinations(params = {})
@local_var_path = "#{NOTIFICATION_PATH}/destinations"
@scope = NOTIFICATION_SCOPE
@query_params = sp_api_params(params)
@request_type = "GET"
call_api
end
|
#get_subscription(notification_type, params = {}) ⇒ Object
58
59
60
61
62
63
|
# File 'lib/muffin_man/notifications/v1.rb', line 58
def get_subscription(notification_type, params = {})
@local_var_path = "#{NOTIFICATION_PATH}/subscriptions/#{notification_type}"
@query_params = sp_api_params(params)
@request_type = "GET"
call_api
end
|
#get_subscription_by_id(notification_type, subscription_id) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/muffin_man/notifications/v1.rb', line 65
def get_subscription_by_id(notification_type, subscription_id)
@local_var_path = "#{NOTIFICATION_PATH}/subscriptions/#{notification_type}/#{subscription_id}"
@scope = NOTIFICATION_SCOPE
@request_type = "GET"
call_api
end
|