Class: UspsApi::ListenerUrlSpecificationApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/usps_api/apis/listener_url_specification_api.rb

Overview

ListenerUrlSpecificationApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from UspsApi::BaseApi

Instance Method Details

#post_notification(scope, body, x_hmac: nil) ⇒ ApiResponse

Notification event API callers implement to receive adjustment event data. This is the url in which data will be pushed to. Each subscriptions notification response contains a field named ‘payload` which is a JavaScript object that has been converted into a JSON formatted string. The text should be converted into a JavaScript object via JSON.parse(). The JavaScript object notation (JSON) schemas are provided in the API specification. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-adjustments” for subscriptions-adjustments-related operations. parameter: TODO: type description here the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 30

def post_notification(scope,
                      body,
                      x_hmac: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end

#post_notification1(scope, body, x_hmac: nil, hmac_header: nil) ⇒ ApiResponse

Notification event API callers implement to receive dispute event data. This is the url in which data will be pushed to. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-disputes” for subscriptions-disputes-related operations. TODO: type description here the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header. with the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header.

Parameters:

  • scope (Scope29)

    Required parameter: The scope of the request, which

  • body (SubscriptionsDisputesSubscriptionEvent)

    Required parameter:

  • x_hmac (String) (defaults to: nil)

    Optional parameter: If a secret was provided with

  • hmac_header (String) (defaults to: nil)

    Optional parameter: If a secret was provided

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 94

def post_notification1(scope,
                       body,
                       x_hmac: nil,
                       hmac_header: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .header_param(new_parameter(hmac_header, key: 'hmac-header'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end

#post_notification11(scope, body, x_hmac: nil, hmac_header: nil) ⇒ ApiResponse

Notification event API callers implement to receive tracking event data. This is the url in which data will be pushed to. Each subscriptions notification response contains a field named ‘payload’ which is a JavaScript object that has been converted into a JSON formatted string. The text should be converted into a JavaScript object via JSON.parse(). The JavaScript object schemas are provided in the API specification and can be downloaded for convenience. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-tracking” for subscriptions-tracking-related operations. TODO: type description here the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header. with the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header.

Parameters:

  • scope (Scope32)

    Required parameter: The scope of the request, which

  • body (SubscriptionsTrackingSubscriptionEvent)

    Required parameter:

  • x_hmac (String) (defaults to: nil)

    Optional parameter: If a secret was provided with

  • hmac_header (String) (defaults to: nil)

    Optional parameter: If a secret was provided

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 291

def post_notification11(scope,
                        body,
                        x_hmac: nil,
                        hmac_header: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .header_param(new_parameter(hmac_header, key: 'hmac-header'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request.',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized.',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden.',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable.',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end

#post_notification12(scope, body, x_hmac: nil, hmac_header: nil) ⇒ ApiResponse

Notification event API callers implement to receive Unpaid Packages event data. This is the URL in which data will be pushed to. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-unpaid-packages” for subscriptions-unpaid-packages-related operations. parameter: TODO: type description here the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header. with the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header.

Parameters:

  • scope (Scope33)

    Required parameter: The scope of the request, which

  • body (SubscriptionsUnpaidPackagesSubscriptionEvent)

    Required

  • x_hmac (String) (defaults to: nil)

    Optional parameter: If a secret was provided with

  • hmac_header (String) (defaults to: nil)

    Optional parameter: If a secret was provided

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 356

def post_notification12(scope,
                        body,
                        x_hmac: nil,
                        hmac_header: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .header_param(new_parameter(hmac_header, key: 'hmac-header'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end

#post_notification13(scope, body, x_hmac: nil) ⇒ ApiResponse

Notification event API callers implement to receive package transaction details event data. This is the url in which data will be pushed to. Each subscriptions notification response contains a field named ‘payload` which is a JavaScript object that has been converted into a JSON formatted string. The text should be converted into a JavaScript object via JSON.parse(). The JavaScript object notation (JSON) schemas are provided in the API specification. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-package-transaction-details” for subscriptions-package-transaction-details-related operations. Required parameter: TODO: type description here the subscription, this field will contain an HMAC hash encoded in Base64. To compute the same hash for comparison, concatenate the value of the timestamp field and the value of the payload field, hash the concatenated string using the shared secret and the SHA256 hash function, and encode the output in Base64. The result should match the value of the X-HMAC Http header.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 222

def post_notification13(scope,
                        body,
                        x_hmac: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end

#post_notifications_ncoa(scope, body, x_hmac: nil, hmac_header: nil) ⇒ ApiResponse

Notification event API callers implement to receive change of address data. This is the url in which data will be pushed to. Each subscriptions notification response contains a field named ‘payload` which is a JavaScript object that has been converted into a JSON formatted string. The text should be converted into a JavaScript object via JSON.parse(). The JavaScript object notation (JSON) schemas are provided in the API specification. The Change of Address Subscription Event example should be parsed with the Addres Detail schema example should be parsed with the Address Detail schema. determines the level of access and permissions for the API. The value of this parameter should be set to “subscriptions-ncoa” for subscriptions-ncoa-related operations. type description here the subscription, this field contains an HMAC hash encoded in Base64. X-HMAC.

Parameters:

  • scope (Scope30)

    Required parameter: The scope of the request, which

  • body (ChangeOfAddressSubscriptionEvent)

    Required parameter: TODO:

  • x_hmac (String) (defaults to: nil)

    Optional parameter: If a secret was provided with

  • hmac_header (String) (defaults to: nil)

    Optional parameter: Deprecated alias for

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/usps_api/apis/listener_url_specification_api.rb', line 157

def post_notifications_ncoa(scope,
                            body,
                            x_hmac: nil,
                            hmac_header: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/{scope}/v3/notifications',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(x_hmac, key: 'X-HMAC'))
               .header_param(new_parameter(hmac_header, key: 'hmac-header'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request.',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized.',
                             AddressesErrorException)
                .local_error('403',
                             'Forbidden.',
                             AddressesErrorException)
                .local_error('429',
                             'Too Many Requests. Too many requests have been received from'\
                              ' client in a short amout of time.',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable.',
                             AddressesErrorException)
                .local_error('default',
                             'Other unanticipated errors that may occur.',
                             APIException))
    .execute
end