Class: Peddler::APIs::Invoices20240619

Inherits:
Peddler::API show all
Defined in:
lib/peddler/apis/invoices_2024_06_19.rb,
lib/peddler/apis/invoices_2024_06_19/error.rb,
lib/peddler/apis/invoices_2024_06_19/export.rb,
lib/peddler/apis/invoices_2024_06_19/invoice.rb,
lib/peddler/apis/invoices_2024_06_19/error_list.rb,
lib/peddler/apis/invoices_2024_06_19/attribute_option.rb,
lib/peddler/apis/invoices_2024_06_19/invoices_document.rb,
lib/peddler/apis/invoices_2024_06_19/invoices_attributes.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoice_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_response.rb,
lib/peddler/apis/invoices_2024_06_19/transaction_identifier.rb,
lib/peddler/apis/invoices_2024_06_19/export_invoices_request.rb,
lib/peddler/apis/invoices_2024_06_19/export_invoices_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_export_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_exports_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_document_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_attributes_response.rb

Overview

The Selling Partner API for Invoices.

Use the Selling Partner API for Invoices to retrieve and manage invoice-related operations, which can help selling partners manage their bookkeeping processes.

Constant Summary collapse

Error =

The error response that is 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
Export =

Detailed information about the export.

Structure.new do
  # @return [String] When the export generation fails, this attribute contains a description of the error.
  attribute?(:error_message, String, from: "errorMessage")

  # @return [String] The export identifier.
  attribute?(:export_id, String, from: "exportId")

  # @return [Time] The date and time when the export generation finished. Vales are in [ISO
  # 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format.
  attribute?(:generate_export_finished_at, Time, from: "generateExportFinishedAt")

  # @return [Time] The date and time when the export generation started. Values are in [ISO
  # 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format.
  attribute?(:generate_export_started_at, Time, from: "generateExportStartedAt")

  # @return [Array<String>] The identifier for the export documents. To get the information required to retrieve
  # the export document's contents, pass each ID in the `getInvoicesDocument` operation.
  #
  # This list is empty until the status is `DONE`.
  attribute?(:invoices_document_ids, [String], from: "invoicesDocumentIds")

  # @return [String]
  attribute?(:status, String)
end
Invoice =

Provides detailed information about an invoice.

Structure.new do
  # @return [Time] The date and time the invoice is issued. Values are in [ISO
  # 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format.
  attribute?(:date, Time)

  # @return [String] If the invoice is in an error state, this attribute displays the error code.
  attribute?(:error_code, String, from: "errorCode")

  # @return [String] The invoice identifier that is used by an external party. This is typically the government
  # agency that authorized the invoice.
  attribute?(:external_invoice_id, String, from: "externalInvoiceId")

  # @return [String] The response message from the government authority when there is an error during invoice
  # issuance.
  attribute?(:gov_response, String, from: "govResponse")

  # @return [String] The invoice identifier.
  attribute?(:id, String)

  # @return [String] The classification of the invoice type. This varies across marketplaces. Use the
  # `getInvoicesAttributes` operation to check `invoiceType` options.
  attribute?(:invoice_type, String, from: "invoiceType")

  # @return [String] Use this identifier in conjunction with `externalInvoiceId` to identify invoices from the
  # same seller.
  attribute?(:series, String)

  # @return [String] The invoice status classification. Use the `getInvoicesAttributes` operation to check invoice
  # status options.
  attribute?(:status, String)

  # @return [Array<TransactionIdentifier>] List with identifiers for the transactions associated to the invoice.
  attribute?(:transaction_ids, [TransactionIdentifier], from: "transactionIds")

  # @return [String] Classification of the transaction that originated this invoice. Use the
  # `getInvoicesAttributes` operation to check `transactionType` options.
  attribute?(:transaction_type, String, from: "transactionType")
end
ErrorList =

A list of error responses that are returned when a request is unsuccessful.

Structure.new do
  # @return [Array<Error>] List of errors.
  attribute(:errors, [Error])
end
AttributeOption =

The definition of the attribute option.

Structure.new do
  # @return [String] The description of the attribute value.
  attribute?(:description, String)

  # @return [String] The possible values for the attribute option.
  attribute?(:value, String)
end
InvoicesDocument =

An object that contains the documentId and an S3 pre-signed URL that you can use to download the specified file.

Structure.new do
  # @return [String] The identifier of the export document.
  attribute?(:invoices_document_id, String, from: "invoicesDocumentId")

  # @return [String] A pre-signed URL that you can use to download the invoices document in zip format. This URL
  # expires after 30 seconds.
  attribute?(:invoices_document_url, String, from: "invoicesDocumentUrl")
end
InvoicesAttributes =

An object that contains the invoice attributes definition.

Structure.new do
  # @return [Array<AttributeOption>] A list of all the options that are available for the invoice status
  # attribute.
  attribute?(:invoice_status_options, [AttributeOption], from: "invoiceStatusOptions")

  # @return [Array<AttributeOption>] A list of all the options that are available for the invoice type attribute.
  attribute?(:invoice_type_options, [AttributeOption], from: "invoiceTypeOptions")

  # @return [Array<AttributeOption>] A list of all the options that are available for the transaction identifier
  # name attribute.
  attribute?(:transaction_identifier_name_options, [AttributeOption], from: "transactionIdentifierNameOptions")

  # @return [Array<AttributeOption>] A list of all the options that are available for the transaction type
  # attribute.
  attribute?(:transaction_type_options, [AttributeOption], from: "transactionTypeOptions")
end
GetInvoiceResponse =

Success.

Structure.new do
  # @return [Invoice]
  attribute?(:invoice, Invoice)
end
GetInvoicesResponse =

Success.

Structure.new do
  # @return [Array<Invoice>] A list of invoices.
  attribute?(:invoices, [Invoice])

  # @return [String] This token is returned when the number of results exceeds the specified `pageSize` value. To
  # get the next page of results, call the `getInvoices` operation and include this token with the previous call
  # parameters.
  attribute?(:next_token, String, from: "nextToken")
end
TransactionIdentifier =

The identifier for a transaction.

Structure.new do
  # @return [String] The transaction identifier.
  attribute?(:id, String)

  # @return [String] The transaction identifier name. Use the `getInvoicesAttributes` operation to check
  # `transactionIdentifierName` options.
  attribute?(:name, String)
end
ExportInvoicesRequest =

The information required to create the export request.

Structure.new do
  # @return [String] The ID of the marketplace from which you want the invoices.
  attribute(:marketplace_id, String, from: "marketplaceId")

  # @return [Date] The latest invoice creation date for invoices that you want to include in the response. Dates
  # are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. The default is the
  # time of the request.
  attribute?(:date_end, Date, from: "dateEnd")

  # @return [Date] The earliest invoice creation date for invoices that you want to include in the response. Dates
  # are in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. The default is 24
  # hours prior to the time of the request.
  attribute?(:date_start, Date, from: "dateStart")

  # @return [String] The external ID of the invoices you want included in the response.
  attribute?(:external_invoice_id, String, from: "externalInvoiceId")

  # @return [String]
  attribute?(:file_format, String, from: "fileFormat")

  # @return [String] The marketplace-specific classification of the invoice type. Use the `getInvoicesAttributes`
  # operation to check `invoiceType` options.
  attribute?(:invoice_type, String, from: "invoiceType")

  # @return [String] The series number of the invoices you want included in the response.
  attribute?(:series, String)

  # @return [Array<String>] A list of statuses that you can use to filter invoices. Use the
  # `getInvoicesAttributes` operation to check invoice status options.
  #
  # Min count: 1
  attribute?(:statuses, [String])

  # @return [TransactionIdentifier]
  attribute?(:transaction_identifier, TransactionIdentifier, from: "transactionIdentifier")

  # @return [String] The marketplace-specific classification of the transaction type for which the invoice was
  # created. Use the `getInvoicesAttributes` operation to check `transactionType` options
  attribute?(:transaction_type, String, from: "transactionType")
end
ExportInvoicesResponse =

Success.

Structure.new do
  # @return [String] The export identifier.
  attribute?(:export_id, String, from: "exportId")
end
GetInvoicesExportResponse =

Success.

Structure.new do
  # @return [Export]
  attribute?(:export, Export)
end
GetInvoicesExportsResponse =

Success.

Structure.new do
  # @return [Array<Export>] A list of exports.
  attribute?(:exports, [Export])

  # @return [String] This token is returned when the number of results exceeds the specified `pageSize` value. To
  # get the next page of results, call the `getInvoices` operation and include this token with the previous call
  # parameters.
  attribute?(:next_token, String, from: "nextToken")
end
GetInvoicesDocumentResponse =

Success.

Structure.new do
  # @return [InvoicesDocument]
  attribute?(:invoices_document, InvoicesDocument, from: "invoicesDocument")
end
GetInvoicesAttributesResponse =

Success.

Structure.new do
  # @return [InvoicesAttributes]
  attribute?(:invoices_attributes, InvoicesAttributes, from: "invoicesAttributes")
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

#create_invoices_export(body, rate_limit: 0.167) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates an invoice export request.

Parameters:

  • body (Hash)

    Information required to create the export request.

  • rate_limit (Float) (defaults to: 0.167)

    Requests per second

Returns:



48
49
50
51
52
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 48

def create_invoices_export(body, rate_limit: 0.167)
  path = "/tax/invoices/2024-06-19/exports"
  parser = -> { ExportInvoicesResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#get_invoice(marketplace_id, invoice_id, rate_limit: 2.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns invoice data for the specified invoice. This operation returns only a subset of the invoices data; refer to the response definition to get all the possible attributes. To get the full invoice, use the createInvoicesExport operation to start an export request.

Parameters:

  • marketplace_id (String)

    The marketplace from which you want the invoice.

  • invoice_id (String)

    The invoice identifier.

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:



166
167
168
169
170
171
172
173
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 166

def get_invoice(marketplace_id, invoice_id, rate_limit: 2.0)
  path = "/tax/invoices/2024-06-19/invoices/#{percent_encode(invoice_id)}"
  params = {
    "marketplaceId" => marketplace_id,
  }.compact
  parser = -> { GetInvoiceResponse }
  meter(rate_limit).get(path, params:, parser:)
end

#get_invoices(marketplace_id, transaction_identifier_name: nil, page_size: nil, date_end: nil, transaction_type: nil, transaction_identifier_id: nil, date_start: nil, series: nil, next_token: nil, sort_order: nil, invoice_type: nil, statuses: nil, external_invoice_id: nil, sort_by: nil, rate_limit: 0.1) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns invoice details for the invoices that match the filters that you specify.

value for this field, you must also provide a value for the transactionIdentifierId field.Use the getInvoicesAttributes operation to check transactionIdentifierName options. Maximum: 200 Dates are in ISO 8601 date-time format. The default is the current date-time. invoice was created. Use the getInvoicesAttributes operation to check transactionType options. for this field, you must also provide a value for the transactionIdentifierName field. response. Dates are in ISO 8601 date-time format. The default is 24 hours prior to the time of the request. pageSize value. To get the next page of results, call the operation with this token and include the same arguments as the call that produced the token. To get a complete list, call this operation until nextToken is null. Note that this operation can return empty pages. getInvoicesAttributes operation to check invoiceType options. getInvoicesAttributes operation to check invoice status options. Min count: 1 Government Invoice ID.

Parameters:

  • transaction_identifier_name (String) (defaults to: nil)

    The name of the transaction identifier filter. If you provide a

  • page_size (Integer) (defaults to: nil)

    The maximum number of invoices you want to return in a single call. Minimum: 1

  • date_end (String) (defaults to: nil)

    The latest invoice creation date for invoices that you want to include in the response.

  • marketplace_id (String)

    The response includes only the invoices that match the specified marketplace.

  • transaction_type (String) (defaults to: nil)

    The marketplace-specific classification of the transaction type for which the

  • transaction_identifier_id (String) (defaults to: nil)

    The ID of the transaction identifier filter. If you provide a value

  • date_start (String) (defaults to: nil)

    The earliest invoice creation date for invoices that you want to include in the

  • series (String) (defaults to: nil)

    Return invoices with the specified series number.

  • next_token (String) (defaults to: nil)

    The response includes nextToken when the number of results exceeds the specified

  • sort_order (String) (defaults to: nil)

    Sort the invoices in the response in ascending or descending order.

  • invoice_type (String) (defaults to: nil)

    The marketplace-specific classification of the invoice type. Use the

  • statuses (Array<String>) (defaults to: nil)

    A list of statuses that you can use to filter invoices. Use the

  • external_invoice_id (String) (defaults to: nil)

    Return invoices that match this external ID. This is typically the

  • sort_by (String) (defaults to: nil)

    The attribute by which you want to sort the invoices in the response.

  • rate_limit (Float) (defaults to: 0.1)

    Requests per second

Returns:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 133

def get_invoices(marketplace_id, transaction_identifier_name: nil, page_size: nil, date_end: nil,
  transaction_type: nil, transaction_identifier_id: nil, date_start: nil, series: nil, next_token: nil,
  sort_order: nil, invoice_type: nil, statuses: nil, external_invoice_id: nil, sort_by: nil, rate_limit: 0.1)
  path = "/tax/invoices/2024-06-19/invoices"
  params = {
    "transactionIdentifierName" => transaction_identifier_name,
    "pageSize" => page_size,
    "dateEnd" => date_end,
    "marketplaceId" => marketplace_id,
    "transactionType" => transaction_type,
    "transactionIdentifierId" => transaction_identifier_id,
    "dateStart" => date_start,
    "series" => series,
    "nextToken" => next_token,
    "sortOrder" => sort_order,
    "invoiceType" => invoice_type,
    "statuses" => stringify_array(statuses),
    "externalInvoiceId" => external_invoice_id,
    "sortBy" => sort_by,
  }.compact
  parser = -> { GetInvoicesResponse }
  meter(rate_limit).get(path, params:, parser:)
end

#get_invoices_attributes(marketplace_id, rate_limit: 1.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns marketplace-dependent schemas and their respective set of possible values.

Parameters:

  • marketplace_id (String)

    The marketplace identifier.

  • rate_limit (Float) (defaults to: 1.0)

    Requests per second

Returns:



20
21
22
23
24
25
26
27
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 20

def get_invoices_attributes(marketplace_id, rate_limit: 1.0)
  path = "/tax/invoices/2024-06-19/attributes"
  params = {
    "marketplaceId" => marketplace_id,
  }.compact
  parser = -> { GetInvoicesAttributesResponse }
  meter(rate_limit).get(path, params:, parser:)
end

#get_invoices_document(invoices_document_id, rate_limit: 0.0167) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns the invoice document's ID and URL. Use the URL to download the ZIP file, which contains the invoices from the corresponding createInvoicesExport request.

Parameters:

  • invoices_document_id (String)

    The export document identifier.

  • rate_limit (Float) (defaults to: 0.0167)

    Requests per second

Returns:



36
37
38
39
40
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 36

def get_invoices_document(invoices_document_id, rate_limit: 0.0167)
  path = "/tax/invoices/2024-06-19/documents/#{percent_encode(invoices_document_id)}"
  parser = -> { GetInvoicesDocumentResponse }
  meter(rate_limit).get(path, parser:)
end

#get_invoices_export(export_id, rate_limit: 2.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns invoice export details (including the exportDocumentId, if available) for the export that you specify.

Parameters:

  • export_id (String)

    The unique identifier for the export.

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:



93
94
95
96
97
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 93

def get_invoices_export(export_id, rate_limit: 2.0)
  path = "/tax/invoices/2024-06-19/exports/#{percent_encode(export_id)}"
  parser = -> { GetInvoicesExportResponse }
  meter(rate_limit).get(path, parser:)
end

#get_invoices_exports(marketplace_id, date_start: nil, next_token: nil, page_size: nil, date_end: nil, status: nil, rate_limit: 0.1) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns invoice exports details for exports that match the filters that you specify.

the response. Values are in ISO 8601 date-time format. The default is 30 days ago. pageSize value. To get the next page of results, call the operation with this token and include the same arguments as the call that produced the token. To get a complete list, call this operation until nextToken is null. Note that this operation can return empty pages. response. Values are in ISO 8601 date-time format. The default value is the time of the request.

Parameters:

  • marketplace_id (String)

    The returned exports match the specified marketplace.

  • date_start (String) (defaults to: nil)

    The earliest export creation date and time for exports that you want to include in

  • next_token (String) (defaults to: nil)

    The response includes nextToken when the number of results exceeds the specified

  • page_size (Integer) (defaults to: nil)

    The maximum number of invoices to return in a single call. Minimum: 1 Maximum: 100

  • date_end (String) (defaults to: nil)

    The latest export creation date and time for exports that you want to include in the

  • status (String) (defaults to: nil)

    Return exports matching the status specified.

  • rate_limit (Float) (defaults to: 0.1)

    Requests per second

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 72

def get_invoices_exports(marketplace_id, date_start: nil, next_token: nil, page_size: nil, date_end: nil,
  status: nil, rate_limit: 0.1)
  path = "/tax/invoices/2024-06-19/exports"
  params = {
    "marketplaceId" => marketplace_id,
    "dateStart" => date_start,
    "nextToken" => next_token,
    "pageSize" => page_size,
    "dateEnd" => date_end,
    "status" => status,
  }.compact
  parser = -> { GetInvoicesExportsResponse }
  meter(rate_limit).get(path, params:, parser:)
end