Class: Peddler::APIs::ShippingV2

Inherits:
Peddler::API show all
Defined in:
lib/peddler/apis/shipping_v2.rb

Overview

Amazon Shipping API

The Amazon Shipping API is designed to support outbound shipping use cases both for orders originating on Amazon-owned marketplaces as well as external channels/marketplaces. With these APIs, you can request shipping rates, create shipments, cancel shipments, and track shipments.

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?, #typed, #typed?, #use, #via

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#cancel_shipment(shipment_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Cancels a purchased shipment. Returns an empty object if the shipment is successfully cancelled.

Parameters:

  • shipment_id (String)

    The shipment identifier originally returned by the purchaseShipment operation.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



145
146
147
148
149
# File 'lib/peddler/apis/shipping_v2.rb', line 145

def cancel_shipment(shipment_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/shipments/#{percent_encode(shipment_id)}/cancel"
  parser = Peddler::Types::ShippingV2::CancelShipmentResponse if typed?
  meter(rate_limit).put(path, parser:)
end

#create_claim(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

This API will be used to create claim for single eligible shipment.

Parameters:

  • body (Hash)

    Request body for the createClaim operation

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



326
327
328
329
330
# File 'lib/peddler/apis/shipping_v2.rb', line 326

def create_claim(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/claims"
  parser = Peddler::Types::ShippingV2::CreateClaimResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#direct_purchase_shipment(body, x_amzn_idempotency_key: nil, locale: nil, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Purchases the shipping service for a shipment using the best fit service offering. Returns purchase related details and documents.

Parameters:

  • body (Hash)

    DirectPurchaseRequest body

  • x_amzn_idempotency_key (String) (defaults to: nil)

    A unique value which the server uses to recognize subsequent retries of the same request.

  • locale (String) (defaults to: nil)

    The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



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

def direct_purchase_shipment(body, x_amzn_idempotency_key: nil, locale: nil, x_amzn_shipping_business_id: nil,
  rate_limit: 80.0)
  path = "/shipping/v2/shipments/directPurchase"
  parser = Peddler::Types::ShippingV2::DirectPurchaseResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#generate_collection_form(body, x_amzn_idempotency_key: nil, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API Call to generate the collection form.

Parameters:

  • body (Hash)

    GenerateCollectionFormRequest body

  • x_amzn_idempotency_key (String) (defaults to: nil)

    A unique value which the server uses to recognize subsequent retries of the same request.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



236
237
238
239
240
241
# File 'lib/peddler/apis/shipping_v2.rb', line 236

def generate_collection_form(body, x_amzn_idempotency_key: nil, x_amzn_shipping_business_id: nil,
  rate_limit: 80.0)
  path = "/shipping/v2/collectionForms"
  parser = Peddler::Types::ShippingV2::GenerateCollectionFormResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#get_access_points(access_point_types, country_code, postal_code, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Returns a list of access points in proximity of input postal code.

Parameters:

  • access_point_types (Array<String>)

    Access point types

  • country_code (String)

    Country code for access point

  • postal_code (String)

    postal code for access point

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



293
294
295
296
297
298
299
300
301
302
303
# File 'lib/peddler/apis/shipping_v2.rb', line 293

def get_access_points(access_point_types, country_code, postal_code, x_amzn_shipping_business_id: nil,
  rate_limit: 80.0)
  path = "/shipping/v2/accessPoints"
  params = {
    "accessPointTypes" => stringify_array(access_point_types),
    "countryCode" => country_code,
    "postalCode" => postal_code,
  }.compact
  parser = Peddler::Types::ShippingV2::GetAccessPointsResponse if typed?
  meter(rate_limit).get(path, params:, parser:)
end

#get_additional_inputs(request_token, rate_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns the JSON schema to use for providing additional inputs when needed to purchase a shipping offering. Call the getAdditionalInputs operation when the response to a previous call to the getRates operation indicates that additional inputs are required for the rate (shipping offering) that you want to purchase.

Parameters:

  • request_token (String)

    The request token returned in the response to the getRates operation.

  • rate_id (String)

    The rate identifier for the shipping offering (rate) returned in the response to the getRates operation.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



163
164
165
166
167
168
169
170
171
# File 'lib/peddler/apis/shipping_v2.rb', line 163

def get_additional_inputs(request_token, rate_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/shipments/additionalInputs/schema"
  params = {
    "requestToken" => request_token,
    "rateId" => rate_id,
  }.compact
  parser = Peddler::Types::ShippingV2::GetAdditionalInputsResponse if typed?
  meter(rate_limit).get(path, params:, parser:)
end

#get_carrier_account_form_inputs(x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API will return a list of input schema required to register a shipper account with the carrier.

Parameters:

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



179
180
181
182
183
# File 'lib/peddler/apis/shipping_v2.rb', line 179

def (x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/carrierAccountFormInputs"
  parser = Peddler::Types::ShippingV2::GetCarrierAccountFormInputsResponse if typed?
  meter(rate_limit).get(path, parser:)
end

#get_carrier_accounts(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API will return Get all carrier accounts for a merchant.

Parameters:

  • body (Hash)

    GetCarrierAccountsRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



192
193
194
195
196
# File 'lib/peddler/apis/shipping_v2.rb', line 192

def get_carrier_accounts(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/carrierAccounts"
  parser = Peddler::Types::ShippingV2::GetCarrierAccountsResponse if typed?
  meter(rate_limit).put(path, body:, parser:)
end

#get_collection_form(collection_form_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API reprint a collection form.

Parameters:

  • collection_form_id (String)

    collection form Id to reprint a collection.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



277
278
279
280
281
# File 'lib/peddler/apis/shipping_v2.rb', line 277

def get_collection_form(collection_form_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/collectionForms/#{percent_encode(collection_form_id)}"
  parser = Peddler::Types::ShippingV2::GetCollectionFormResponse if typed?
  meter(rate_limit).get(path, parser:)
end

#get_collection_form_history(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API Call to get the history of the previously generated collection forms.

Parameters:

  • body (Hash)

    GetCollectionFormHistoryRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



250
251
252
253
254
# File 'lib/peddler/apis/shipping_v2.rb', line 250

def get_collection_form_history(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/collectionForms/history"
  parser = Peddler::Types::ShippingV2::GetCollectionFormHistoryResponse if typed?
  meter(rate_limit).put(path, body:, parser:)
end

#get_rates(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Returns the available shipping service offerings.

Parameters:

  • body (Hash)

    GetRatesRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



29
30
31
32
33
# File 'lib/peddler/apis/shipping_v2.rb', line 29

def get_rates(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/shipments/rates"
  parser = Peddler::Types::ShippingV2::GetRatesResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#get_shipment_documents(shipment_id, package_client_reference_id, format: nil, dpi: nil, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Returns the shipping documents associated with a package in a shipment.

Parameters:

  • shipment_id (String)

    The shipment identifier originally returned by the purchaseShipment operation.

  • package_client_reference_id (String)

    The package client reference identifier originally provided in the request body parameter for the getRates operation.

  • format (String) (defaults to: nil)

    The file format of the document. Must be one of the supported formats returned by the getRates operation.

  • dpi (Number) (defaults to: nil)

    The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/peddler/apis/shipping_v2.rb', line 125

def get_shipment_documents(shipment_id, package_client_reference_id, format: nil, dpi: nil,
  x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/shipments/#{percent_encode(shipment_id)}/documents"
  params = {
    "packageClientReferenceId" => package_client_reference_id,
    "format" => format,
    "dpi" => dpi,
  }.compact
  parser = Peddler::Types::ShippingV2::GetShipmentDocumentsResponse if typed?
  meter(rate_limit).get(path, params:, parser:)
end

#get_tracking(tracking_id, carrier_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Returns tracking information for a purchased shipment.

Parameters:

  • tracking_id (String)

    A carrier-generated tracking identifier originally returned by the purchaseShipment operation.

  • carrier_id (String)

    A carrier identifier originally returned by the getRates operation for the selected rate.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



101
102
103
104
105
106
107
108
109
# File 'lib/peddler/apis/shipping_v2.rb', line 101

def get_tracking(tracking_id, carrier_id, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/tracking"
  params = {
    "trackingId" => tracking_id,
    "carrierId" => carrier_id,
  }.compact
  parser = Peddler::Types::ShippingV2::GetTrackingResponse if typed?
  meter(rate_limit).get(path, params:, parser:)
end

#get_unmanifested_shipments(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

This API Get all unmanifested carriers with shipment locations. Any locations which has unmanifested shipments with an eligible carrier for manifesting shall be returned.

Parameters:

  • body (Hash)

    GetUmanifestedShipmentsRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



264
265
266
267
268
# File 'lib/peddler/apis/shipping_v2.rb', line 264

def get_unmanifested_shipments(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/unmanifestedShipments"
  parser = Peddler::Types::ShippingV2::GetUnmanifestedShipmentsResponse if typed?
  meter(rate_limit).put(path, body:, parser:)
end
Note:

This operation can make a dynamic sandbox call.

This API associates/links the specified carrier account with the merchant.

Parameters:

  • carrier_id (String)

    An identifier for the carrier with which the seller's account is being linked.

  • body (Hash)

    LinkCarrierAccountRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 5.0)

    Requests per second

Returns:



207
208
209
210
211
# File 'lib/peddler/apis/shipping_v2.rb', line 207

def (carrier_id, body, x_amzn_shipping_business_id: nil, rate_limit: 5.0)
  path = "/shipping/v2/carrierAccounts/#{percent_encode(carrier_id)}"
  parser = Peddler::Types::ShippingV2::LinkCarrierAccountResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#one_click_shipment(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Purchases a shipping service identifier and returns purchase-related details and documents.

Parameters:

  • body (Hash)

    OneClickShipmentRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



84
85
86
87
88
# File 'lib/peddler/apis/shipping_v2.rb', line 84

def one_click_shipment(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/oneClickShipment"
  parser = Peddler::Types::ShippingV2::OneClickShipmentResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#purchase_shipment(body, x_amzn_idempotency_key: nil, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

Purchases a shipping service and returns purchase related details and documents.

Note: You must complete the purchase within 10 minutes of rate creation by the shipping service provider. If you make the request after the 10 minutes have expired, you will receive an error response with the error code equal to "TOKEN_EXPIRED". If you receive this error response, you must get the rates for the shipment again.

Parameters:

  • body (Hash)

    PurchaseShipmentRequest body

  • x_amzn_idempotency_key (String) (defaults to: nil)

    A unique value which the server uses to recognize subsequent retries of the same request.

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



70
71
72
73
74
# File 'lib/peddler/apis/shipping_v2.rb', line 70

def purchase_shipment(body, x_amzn_idempotency_key: nil, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/shipments"
  parser = Peddler::Types::ShippingV2::PurchaseShipmentResponse if typed?
  meter(rate_limit).post(path, body:, parser:)
end

#submit_ndr_feedback(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0) ⇒ Peddler::Response

Note:

This operation can make a dynamic sandbox call.

This API submits the NDR (Non-delivery Report) Feedback for any eligible shipment.

Parameters:

  • body (Hash)

    Request body for ndrFeedback operation

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



313
314
315
316
# File 'lib/peddler/apis/shipping_v2.rb', line 313

def submit_ndr_feedback(body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/ndrFeedback"
  meter(rate_limit).post(path, body:)
end

This API Unlink the specified carrier account with the merchant.

Parameters:

  • carrier_id (String)

    carrier Id to unlink with merchant.

  • body (Hash)

    UnlinkCarrierAccountRequest body

  • x_amzn_shipping_business_id (String) (defaults to: nil)

    Amazon shipping business to assume for this request. The default is AmazonShipping_UK.

  • rate_limit (Float) (defaults to: 80.0)

    Requests per second

Returns:



221
222
223
224
225
# File 'lib/peddler/apis/shipping_v2.rb', line 221

def (carrier_id, body, x_amzn_shipping_business_id: nil, rate_limit: 80.0)
  path = "/shipping/v2/carrierAccounts/#{percent_encode(carrier_id)}/unlink"
  parser = Peddler::Types::ShippingV2::UnlinkCarrierAccountResponse if typed?
  meter(rate_limit).put(path, body:, parser:)
end