Class: Peddler::APIs::DeliveryByAmazon20220701

Inherits:
Peddler::API
  • Object
show all
Defined in:
lib/peddler/apis/delivery_by_amazon_2022_07_01.rb,
lib/peddler/apis/delivery_by_amazon_2022_07_01/error.rb,
lib/peddler/apis/delivery_by_amazon_2022_07_01/error_list.rb,
lib/peddler/apis/delivery_by_amazon_2022_07_01/submit_invoice_request.rb,
lib/peddler/apis/delivery_by_amazon_2022_07_01/submit_invoice_response.rb,
lib/peddler/apis/delivery_by_amazon_2022_07_01/get_invoice_status_response.rb

Overview

Selling Partner API for Delivery Shipment Invoicing

The Selling Partner API for Delivery Shipment Invoicing helps you programmatically retrieve shipment invoice information in the Brazil marketplace for a selling partner’s orders.

Defined Under Namespace

Classes: ErrorList

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
SubmitInvoiceRequest =

The request schema for the submitInvoice operation.

Structure.new do
  # @return [String] MD5 sum for validating the invoice data. For more information about calculating this value,
  #   see [Working with Content-MD5
  #   Checksums](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_MD5.html).
  attribute(:content_md5_value, String, from: "contentMD5Value")

  # @return [String] The binary object representing an invoice's content.
  attribute(:invoice_content, String, from: "invoiceContent")

  # @return [String] The type of an invoice.
  attribute(:invoice_type, String, from: "invoiceType")

  # @return [String] An Amazon marketplace identifier.
  attribute(:marketplace_id, String, from: "marketplaceId")

  # @return [String] The Amazon program that the seller is currently enrolled.
  attribute(:program_type, String, from: "programType")
end
SubmitInvoiceResponse =

The response schema for the submitInvoice operation.

Structure.new do
  # @return [Array<Error>] A list of errors returned by this API.
  attribute?(:errors, [Error])
end
GetInvoiceStatusResponse =

The response schema for the getInvoiceStatus operation.

Structure.new do
  # @return [String] The Amazon-defined order identifier.
  attribute?(:amazon_order_id, String, from: "amazonOrderId")

  # @return [String] The Amazon-defined shipment identifier.
  attribute?(:amazon_shipment_id, String, from: "amazonShipmentId")

  # @return [Array<Error>] A list of errors returned by this API.
  attribute?(:errors, [Error])

  # @return [String] The current processing status of a shipment invoice.
  attribute?(:invoice_status, String, from: "invoiceStatus")
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

#get_invoice_status(marketplace_id, invoice_type, program_type, order_id: nil, shipment_id: nil, rate_limit: 1.133) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns the invoice status for the order or shipment you specify. You must specify either an orderId or shipmentId as query parameter. If both parameters are supplied, orderId takes precedence over shipmentId.

Parameters:

  • order_id (String) (defaults to: nil)

    The order identifier.

  • shipment_id (String) (defaults to: nil)

    The shipment identifier.

  • marketplace_id (String)

    The marketplace identifier.

  • invoice_type (String)

    The invoice's type.

  • program_type (String)

    The Amazon program that seller is currently enrolled.

  • rate_limit (Float) (defaults to: 1.133)

    Requests per second

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/peddler/apis/delivery_by_amazon_2022_07_01.rb', line 44

def get_invoice_status(marketplace_id, invoice_type, program_type, order_id: nil, shipment_id: nil,
  rate_limit: 1.133)
  path = "/delivery/2022-07-01/invoice/status"
  params = {
    "orderId" => order_id,
    "shipmentId" => shipment_id,
    "marketplaceId" => marketplace_id,
    "invoiceType" => invoice_type,
    "programType" => program_type,
  }.compact
  parser = -> { GetInvoiceStatusResponse }
  meter(rate_limit).get(path, params:, parser:)
end

#submit_invoice(body, order_id: nil, shipment_id: nil, rate_limit: 1.133) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Submits a shipment invoice for a given order or shipment. You must specify either an orderId or shipmentId as query parameter. If both parameters are supplied, orderId takes precedence over shipmentId.

Parameters:

  • order_id (String) (defaults to: nil)

    The identifier for the order.

  • shipment_id (String) (defaults to: nil)

    The identifier for the shipment.

  • body (Hash)

    The request body that specifies invoice, program and marketplace values.

  • rate_limit (Float) (defaults to: 1.133)

    Requests per second

Returns:



23
24
25
26
27
28
29
30
31
# File 'lib/peddler/apis/delivery_by_amazon_2022_07_01.rb', line 23

def submit_invoice(body, order_id: nil, shipment_id: nil, rate_limit: 1.133)
  path = "/delivery/2022-07-01/invoice"
  params = {
    "orderId" => order_id,
    "shipmentId" => shipment_id,
  }.compact
  parser = -> { SubmitInvoiceResponse }
  meter(rate_limit).post(path, body:, params:, parser:)
end