Class: Peddler::APIs::ShippingV1
- Inherits:
-
Peddler::API
- Object
- Peddler::API
- Peddler::APIs::ShippingV1
- Defined in:
- lib/peddler/apis/shipping_v1.rb,
lib/peddler/apis/shipping_v1/rate.rb,
lib/peddler/apis/shipping_v1/error.rb,
lib/peddler/apis/shipping_v1/event.rb,
lib/peddler/apis/shipping_v1/label.rb,
lib/peddler/apis/shipping_v1/party.rb,
lib/peddler/apis/shipping_v1/weight.rb,
lib/peddler/apis/shipping_v1/account.rb,
lib/peddler/apis/shipping_v1/address.rb,
lib/peddler/apis/shipping_v1/location.rb,
lib/peddler/apis/shipping_v1/shipment.rb,
lib/peddler/apis/shipping_v1/container.rb,
lib/peddler/apis/shipping_v1/rate_list.rb,
lib/peddler/apis/shipping_v1/dimensions.rb,
lib/peddler/apis/shipping_v1/error_list.rb,
lib/peddler/apis/shipping_v1/event_list.rb,
lib/peddler/apis/shipping_v1/time_range.rb,
lib/peddler/apis/shipping_v1/label_result.rb,
lib/peddler/apis/shipping_v1/service_rate.rb,
lib/peddler/apis/shipping_v1/accepted_rate.rb,
lib/peddler/apis/shipping_v1/container_item.rb,
lib/peddler/apis/shipping_v1/container_list.rb,
lib/peddler/apis/shipping_v1/get_rates_result.rb,
lib/peddler/apis/shipping_v1/tracking_summary.rb,
lib/peddler/apis/shipping_v1/get_rates_request.rb,
lib/peddler/apis/shipping_v1/label_result_list.rb,
lib/peddler/apis/shipping_v1/service_rate_list.rb,
lib/peddler/apis/shipping_v1/service_type_list.rb,
lib/peddler/apis/shipping_v1/get_rates_response.rb,
lib/peddler/apis/shipping_v1/label_specification.rb,
lib/peddler/apis/shipping_v1/get_account_response.rb,
lib/peddler/apis/shipping_v1/shipping_promise_set.rb,
lib/peddler/apis/shipping_v1/tracking_information.rb,
lib/peddler/apis/shipping_v1/get_shipment_response.rb,
lib/peddler/apis/shipping_v1/create_shipment_result.rb,
lib/peddler/apis/shipping_v1/purchase_labels_result.rb,
lib/peddler/apis/shipping_v1/container_specification.rb,
lib/peddler/apis/shipping_v1/create_shipment_request.rb,
lib/peddler/apis/shipping_v1/purchase_labels_request.rb,
lib/peddler/apis/shipping_v1/cancel_shipment_response.rb,
lib/peddler/apis/shipping_v1/create_shipment_response.rb,
lib/peddler/apis/shipping_v1/purchase_labels_response.rb,
lib/peddler/apis/shipping_v1/purchase_shipment_result.rb,
lib/peddler/apis/shipping_v1/purchase_shipment_request.rb,
lib/peddler/apis/shipping_v1/purchase_shipment_response.rb,
lib/peddler/apis/shipping_v1/container_specification_list.rb,
lib/peddler/apis/shipping_v1/retrieve_shipping_label_result.rb,
lib/peddler/apis/shipping_v1/retrieve_shipping_label_request.rb,
lib/peddler/apis/shipping_v1/retrieve_shipping_label_response.rb,
lib/peddler/apis/shipping_v1/get_tracking_information_response.rb
Overview
Selling Partner API for Shipping
Provides programmatic access to Amazon Shipping APIs.
Note: If you are new to the Amazon Shipping API, refer to the latest version of Amazon Shipping API (v2) on the Amazon Shipping Developer Documentation site.
Defined Under Namespace
Classes: ContainerList, ContainerSpecificationList, ErrorList, EventList, LabelResultList, RateList, ServiceRateList, ServiceTypeList
Constant Summary collapse
- Rate =
The available rate that can be used to send the shipment
Structure.new do # @return [Weight] The weight that was used to calculate the totalCharge. attribute?(:billed_weight, Weight, from: "billedWeight") # @return [Time] The time after which the offering will expire. attribute?(:expiration_time, Time, from: "expirationTime") # @return [ShippingPromiseSet] attribute?(:promise, ShippingPromiseSet) # @return [String] An identifier for the rate. attribute?(:rate_id, String, from: "rateId") # @return [String] attribute?(:service_type, String, from: "serviceType") # @return [Money] The total charge that will be billed for the rate. attribute?(:total_charge, Money, from: "totalCharge") end
- Error =
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
- Event =
An event of a shipment
Structure.new do # @return [String] attribute(:event_code, String, from: "eventCode") # @return [Time] The date and time of an event for a shipment. attribute(:event_time, Time, from: "eventTime") # @return [Location] attribute?(:location, Location) end
- Label =
The label details of the container.
Structure.new do # @return [LabelSpecification] attribute?(:label_specification, LabelSpecification, from: "labelSpecification") # @return [String] attribute?(:label_stream, String, from: "labelStream") end
- Party =
The account related with the shipment.
Structure.new do # @return [String] attribute?(:account_id, String, from: "accountId") end
- Weight =
The weight.
Structure.new do # @return [String] The unit of measurement. attribute(:unit, String) # @return [Float] The measurement value. attribute(:value, Float) end
- Account =
The account related data.
Structure.new do # @return [String] attribute(:account_id, String, from: "accountId") end
- Address =
The address.
Structure.new do # @return [String] First line of that address. attribute(:address_line1, String, from: "addressLine1") # @return [String] attribute(:city, String) # @return [String] attribute(:country_code, String, from: "countryCode") # @return [String] The name of the person, business or institution at that address. attribute(:name, String) # @return [String] attribute(:postal_code, String, from: "postalCode") # @return [String] attribute(:state_or_region, String, from: "stateOrRegion") # @return [String] Additional address information, if required. attribute?(:address_line2, String, from: "addressLine2") # @return [String] Additional address information, if required. attribute?(:address_line3, String, from: "addressLine3") # @return [Array<String>] The email cc addresses of the contact associated with the address. attribute?(:copy_emails, [String], from: "copyEmails") # @return [String] The email address of the contact associated with the address. attribute?(:email, String) # @return [String] The phone number of the person, business or institution located at that address. attribute?(:phone_number, String, from: "phoneNumber") end
- Location =
The location where the person, business or institution is located.
Structure.new do # @return [String] attribute?(:city, String) # @return [String] attribute?(:country_code, String, from: "countryCode") # @return [String] attribute?(:postal_code, String, from: "postalCode") # @return [String] attribute?(:state_or_region, String, from: "stateOrRegion") end
- Shipment =
The shipment related data.
Structure.new do # @return [String] attribute(:client_reference_id, String, from: "clientReferenceId") # @return [Array<Container>] attribute(:containers, [Container]) # @return [Address] attribute(:ship_from, Address, from: "shipFrom") # @return [Address] attribute(:ship_to, Address, from: "shipTo") # @return [String] attribute(:shipment_id, String, from: "shipmentId") # @return [AcceptedRate] attribute?(:accepted_rate, AcceptedRate, from: "acceptedRate") # @return [Party] attribute?(:shipper, Party) end
- Container =
Container in the shipment.
Structure.new do # @return [String] attribute(:container_reference_id, String, from: "containerReferenceId") # @return [Dimensions] The length, width, height, and weight of the container. attribute(:dimensions, Dimensions) # @return [Array<ContainerItem>] A list of the items in the container. attribute(:items, [ContainerItem]) # @return [Money] The total value of all items in the container. attribute(:value, Money) # @return [Weight] The weight of the container. attribute(:weight, Weight) # @return [String] The type of physical container being used. (always 'PACKAGE') attribute?(:container_type, String, from: "containerType") end
- Dimensions =
A set of measurements for a three-dimensional object.
Structure.new do # @return [Float] The height of the container. attribute(:height, Float) # @return [Float] The length of the container. attribute(:length, Float) # @return [String] The unit of these measurements. attribute(:unit, String) # @return [Float] The width of the container. attribute(:width, Float) end
- TimeRange =
The time range.
Structure.new do # @return [Time] The end date and time. This must come after the value of start. This defaults to the next # business day from the start. attribute?(:end, Time) # @return [Time] The start date and time. This defaults to the current date and time. attribute?(:start, Time) end
- LabelResult =
Label details including label stream, format, size.
Structure.new do # @return [String] attribute?(:container_reference_id, String, from: "containerReferenceId") # @return [Label] attribute?(:label, Label) # @return [String] The tracking identifier assigned to the container. attribute?(:tracking_id, String, from: "trackingId") end
- ServiceRate =
The specific rate for a shipping service, or null if no service available.
Structure.new do # @return [Weight] The weight that was used to calculate the totalCharge. attribute(:billable_weight, Weight, from: "billableWeight") # @return [ShippingPromiseSet] attribute(:promise, ShippingPromiseSet) # @return [String] attribute(:service_type, String, from: "serviceType") # @return [Money] The total charge that will be billed for the rate. attribute(:total_charge, Money, from: "totalCharge") end
- AcceptedRate =
The specific rate purchased for the shipment, or null if unpurchased.
Structure.new do # @return [Weight] The weight that was used to calculate the totalCharge. attribute?(:billed_weight, Weight, from: "billedWeight") # @return [ShippingPromiseSet] attribute?(:promise, ShippingPromiseSet) # @return [String] attribute?(:service_type, String, from: "serviceType") # @return [Money] The total charge that will be billed for the rate. attribute?(:total_charge, Money, from: "totalCharge") end
- ContainerItem =
Item in the container.
Structure.new do # @return [Float] The quantity of the items of this type in the container. attribute(:quantity, Float) # @return [String] A descriptive title of the item. attribute(:title, String) # @return [Money] The unit price of an item of this type (the total value of this item type in the container is # unitPrice x quantity). attribute(:unit_price, Money, from: "unitPrice") # @return [Weight] The unit weight of an item of this type (the total weight of this item type in the container # is unitWeight x quantity). attribute(:unit_weight, Weight, from: "unitWeight") end
- GetRatesResult =
The payload schema for the getRates operation.
Structure.new do # @return [Array<ServiceRate>] attribute(:service_rates, [ServiceRate], from: "serviceRates") end
- TrackingSummary =
The tracking summary.
Structure.new do # @return [String] The derived status based on the events in the eventHistory. attribute?(:status, String) end
- GetRatesRequest =
The payload schema for the getRates operation.
Structure.new do # @return [Array<ContainerSpecification>] attribute(:container_specifications, [ContainerSpecification], from: "containerSpecifications") # @return [Array<ServiceType>] attribute(:service_types, Array, from: "serviceTypes") # @return [Address] attribute(:ship_from, Address, from: "shipFrom") # @return [Address] attribute(:ship_to, Address, from: "shipTo") # @return [Time] The start date and time. This defaults to the current date and time. attribute?(:ship_date, Time, from: "shipDate") end
- GetRatesResponse =
The response schema for the getRates operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [GetRatesResult] The payload for getRates operation attribute?(:payload, GetRatesResult) end
- LabelSpecification =
The label specification info.
Structure.new do # @return [String] The format of the label. Enum of PNG only for now. attribute(:label_format, String, from: "labelFormat") # @return [String] The label stock size specification in length and height. Enum of 4x6 only for now. attribute(:label_stock_size, String, from: "labelStockSize") end
- GetAccountResponse =
The response schema for the getAccount operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [Account] The payload for getAccount operation attribute?(:payload, Account) end
- ShippingPromiseSet =
The promised delivery time and pickup time.
Structure.new do # @return [TimeRange] The time window in which the shipment will be delivered. attribute?(:delivery_window, TimeRange, from: "deliveryWindow") # @return [TimeRange] The time window in which Amazon Shipping will pick up the shipment. attribute?(:receive_window, TimeRange, from: "receiveWindow") end
- TrackingInformation =
The payload schema for the getTrackingInformation operation.
Structure.new do # @return [Array<Event>] attribute(:event_history, [Event], from: "eventHistory") # @return [String] attribute(:promised_delivery_date, String, from: "promisedDeliveryDate") # @return [TrackingSummary] attribute(:summary, TrackingSummary) # @return [String] attribute(:tracking_id, String, from: "trackingId") end
- GetShipmentResponse =
The response schema for the getShipment operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [Shipment] The payload for getShipment operation attribute?(:payload, Shipment) end
- CreateShipmentResult =
The payload schema for the createShipment operation.
Structure.new do # @return [Array<Rate>] attribute(:eligible_rates, [Rate], from: "eligibleRates") # @return [String] attribute(:shipment_id, String, from: "shipmentId") end
- PurchaseLabelsResult =
The payload schema for the purchaseLabels operation.
Structure.new do # @return [AcceptedRate] attribute(:accepted_rate, AcceptedRate, from: "acceptedRate") # @return [Array<LabelResult>] attribute(:label_results, [LabelResult], from: "labelResults") # @return [String] attribute(:shipment_id, String, from: "shipmentId") # @return [String] attribute?(:client_reference_id, String, from: "clientReferenceId") end
- ContainerSpecification =
Container specification for checking the service rate.
Structure.new do # @return [Dimensions] The length, width, and height of the container. attribute(:dimensions, Dimensions) # @return [Weight] The weight of the container. attribute(:weight, Weight) end
- CreateShipmentRequest =
The request schema for the createShipment operation.
Structure.new do # @return [String] attribute(:client_reference_id, String, from: "clientReferenceId") # @return [Array<Container>] attribute(:containers, [Container]) # @return [Address] attribute(:ship_from, Address, from: "shipFrom") # @return [Address] attribute(:ship_to, Address, from: "shipTo") end
- PurchaseLabelsRequest =
The request schema for the purchaseLabels operation.
Structure.new do # @return [LabelSpecification] attribute(:label_specification, LabelSpecification, from: "labelSpecification") # @return [String] attribute(:rate_id, String, from: "rateId") end
- CancelShipmentResponse =
The response schema for the cancelShipment operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) end
- CreateShipmentResponse =
The response schema for the createShipment operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [CreateShipmentResult] The payload for createShipment operation attribute?(:payload, CreateShipmentResult) end
- PurchaseLabelsResponse =
The response schema for the purchaseLabels operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [PurchaseLabelsResult] The payload for purchaseLabels operation attribute?(:payload, PurchaseLabelsResult) end
- PurchaseShipmentResult =
The payload schema for the purchaseShipment operation.
Structure.new do # @return [Array<LabelResult>] attribute(:label_results, [LabelResult], from: "labelResults") # @return [ServiceRate] attribute(:service_rate, ServiceRate, from: "serviceRate") # @return [String] attribute(:shipment_id, String, from: "shipmentId") end
- PurchaseShipmentRequest =
The payload schema for the purchaseShipment operation.
Structure.new do # @return [String] attribute(:client_reference_id, String, from: "clientReferenceId") # @return [Array<Container>] attribute(:containers, [Container]) # @return [LabelSpecification] attribute(:label_specification, LabelSpecification, from: "labelSpecification") # @return [String] attribute(:service_type, String, from: "serviceType") # @return [Address] attribute(:ship_from, Address, from: "shipFrom") # @return [Address] attribute(:ship_to, Address, from: "shipTo") # @return [Time] The start date and time. This defaults to the current date and time. attribute?(:ship_date, Time, from: "shipDate") end
- PurchaseShipmentResponse =
The response schema for the purchaseShipment operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [PurchaseShipmentResult] The payload for purchaseShipment operation attribute?(:payload, PurchaseShipmentResult) end
- RetrieveShippingLabelResult =
The payload schema for the retrieveShippingLabel operation.
Structure.new do # @return [LabelSpecification] attribute(:label_specification, LabelSpecification, from: "labelSpecification") # @return [String] attribute(:label_stream, String, from: "labelStream") end
- RetrieveShippingLabelRequest =
The request schema for the retrieveShippingLabel operation.
Structure.new do # @return [LabelSpecification] attribute(:label_specification, LabelSpecification, from: "labelSpecification") end
- RetrieveShippingLabelResponse =
The response schema for the retrieveShippingLabel operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [RetrieveShippingLabelResult] The payload for retrieveShippingLabel operation attribute?(:payload, RetrieveShippingLabelResult) end
- GetTrackingInformationResponse =
The response schema for the getTrackingInformation operation.
Structure.new do # @return [Array<Error>] Encountered errors for the operation. attribute?(:errors, [Error]) # @return [TrackingInformation] The payload for getTrackingInformation operation attribute?(:payload, TrackingInformation) end
Instance Attribute Summary
Attributes inherited from Peddler::API
#access_token, #endpoint, #retries
Instance Method Summary collapse
-
#cancel_shipment(shipment_id, rate_limit: 5.0) ⇒ Peddler::Response
Cancel a shipment by the given shipmentId.
-
#create_shipment(body, rate_limit: 5.0) ⇒ Peddler::Response
Create a new shipment.
-
#get_account(rate_limit: 5.0) ⇒ Peddler::Response
Verify if the current account is valid.
-
#get_rates(body, rate_limit: 5.0) ⇒ Peddler::Response
Get service rates.
-
#get_shipment(shipment_id, rate_limit: 5.0) ⇒ Peddler::Response
Return the entire shipment object for the shipmentId.
-
#get_tracking_information(tracking_id, rate_limit: 1.0) ⇒ Peddler::Response
Return the tracking information of a shipment.
-
#purchase_labels(shipment_id, body, rate_limit: 5.0) ⇒ Peddler::Response
Purchase shipping labels based on a given rate.
-
#purchase_shipment(body, rate_limit: 5.0) ⇒ Peddler::Response
Purchase shipping labels.
-
#retrieve_shipping_label(shipment_id, tracking_id, body, rate_limit: 5.0) ⇒ Peddler::Response
Retrieve shipping label based on the shipment id and tracking id.
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
#cancel_shipment(shipment_id, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Cancel a shipment by the given shipmentId.
47 48 49 50 51 |
# File 'lib/peddler/apis/shipping_v1.rb', line 47 def cancel_shipment(shipment_id, rate_limit: 5.0) path = "/shipping/v1/shipments/#{percent_encode(shipment_id)}/cancel" parser = -> { CancelShipmentResponse } meter(rate_limit).post(path, parser:) end |
#create_shipment(body, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Create a new shipment.
23 24 25 26 27 |
# File 'lib/peddler/apis/shipping_v1.rb', line 23 def create_shipment(body, rate_limit: 5.0) path = "/shipping/v1/shipments" parser = -> { CreateShipmentResponse } meter(rate_limit).post(path, body:, parser:) end |
#get_account(rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Verify if the current account is valid.
109 110 111 112 113 |
# File 'lib/peddler/apis/shipping_v1.rb', line 109 def get_account(rate_limit: 5.0) path = "/shipping/v1/account" parser = -> { GetAccountResponse } meter(rate_limit).get(path, parser:) end |
#get_rates(body, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a dynamic sandbox call.
Get service rates.
98 99 100 101 102 |
# File 'lib/peddler/apis/shipping_v1.rb', line 98 def get_rates(body, rate_limit: 5.0) path = "/shipping/v1/rates" parser = -> { GetRatesResponse } meter(rate_limit).post(path, body:, parser:) end |
#get_shipment(shipment_id, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Return the entire shipment object for the shipmentId.
35 36 37 38 39 |
# File 'lib/peddler/apis/shipping_v1.rb', line 35 def get_shipment(shipment_id, rate_limit: 5.0) path = "/shipping/v1/shipments/#{percent_encode(shipment_id)}" parser = -> { GetShipmentResponse } meter(rate_limit).get(path, parser:) end |
#get_tracking_information(tracking_id, rate_limit: 1.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Return the tracking information of a shipment.
121 122 123 124 125 |
# File 'lib/peddler/apis/shipping_v1.rb', line 121 def get_tracking_information(tracking_id, rate_limit: 1.0) path = "/shipping/v1/tracking/#{percent_encode(tracking_id)}" parser = -> { GetTrackingInformationResponse } meter(rate_limit).get(path, parser:) end |
#purchase_labels(shipment_id, body, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Purchase shipping labels based on a given rate.
60 61 62 63 64 |
# File 'lib/peddler/apis/shipping_v1.rb', line 60 def purchase_labels(shipment_id, body, rate_limit: 5.0) path = "/shipping/v1/shipments/#{percent_encode(shipment_id)}/purchaseLabels" parser = -> { PurchaseLabelsResponse } meter(rate_limit).post(path, body:, parser:) end |
#purchase_shipment(body, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Purchase shipping labels.
86 87 88 89 90 |
# File 'lib/peddler/apis/shipping_v1.rb', line 86 def purchase_shipment(body, rate_limit: 5.0) path = "/shipping/v1/purchaseShipment" parser = -> { PurchaseShipmentResponse } meter(rate_limit).post(path, body:, parser:) end |
#retrieve_shipping_label(shipment_id, tracking_id, body, rate_limit: 5.0) ⇒ Peddler::Response
This operation can make a static sandbox call.
Retrieve shipping label based on the shipment id and tracking id.
74 75 76 77 78 |
# File 'lib/peddler/apis/shipping_v1.rb', line 74 def retrieve_shipping_label(shipment_id, tracking_id, body, rate_limit: 5.0) path = "/shipping/v1/shipments/#{percent_encode(shipment_id)}/containers/#{percent_encode(tracking_id)}/label" parser = -> { RetrieveShippingLabelResponse } meter(rate_limit).post(path, body:, parser:) end |