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/invoice_error.rb,
lib/peddler/apis/invoices_2024_06_19/attribute_option.rb,
lib/peddler/apis/invoices_2024_06_19/invoice_document.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/carrier_details_context.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/government_invoice_request.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/govt_invoice_document_response.rb,
lib/peddler/apis/invoices_2024_06_19/get_invoices_attributes_response.rb,
lib/peddler/apis/invoices_2024_06_19/government_invoice_status_response.rb,
sig/peddler/apis/invoices_2024_06_19.rbs

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.

Defined Under Namespace

Classes: AttributeOption, CarrierDetailsContext, Error, ErrorList, Export, ExportInvoicesRequest, ExportInvoicesResponse, GetInvoiceResponse, GetInvoicesAttributesResponse, GetInvoicesDocumentResponse, GetInvoicesExportResponse, GetInvoicesExportsResponse, GetInvoicesResponse, GovernmentInvoiceRequest, GovernmentInvoiceStatusResponse, GovtInvoiceDocumentResponse, Invoice, InvoiceDocument, InvoiceError, InvoicesAttributes, InvoicesDocument, TransactionIdentifier

Constant Summary

Constants inherited from Peddler::API

Peddler::API::TRANSIENT_STATUSES

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #base_url, #endpoint, #retries

Instance Method Summary collapse

Methods inherited from Peddler::API

#cannot_sandbox!, #delete, #endpoint_uri, #get, #host_header, #http, #initialize, #must_sandbox!, #parse_base_url, #patch, #percent_encode, #post, #put, #request, #sandbox, #sandbox?, #stringify_array, #timestamp, #user_agent

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#create_government_invoice(body) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Submit an asynchronous request to create a government invoice.

Parameters:

  • body (Hash)

    Information required to create the government invoice.

  • (Hash[untyped, untyped])

Returns:



99
100
101
102
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 99

def create_government_invoice(body)
  path = "/tax/invoices/2024-06-19/governmentInvoiceRequests"
  post(path, body:)
end

#create_invoices_export(body) ⇒ 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.

  • (Hash[untyped, untyped])

Returns:



45
46
47
48
49
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 45

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

#get_government_invoice_document(marketplace_id, transaction_type, shipment_id, invoice_type, inbound_plan_id: nil, file_format: nil) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Retrieve the URL of an invoice document.

Parameters:

  • marketplace_id (String)

    The marketplace of the invoice.

  • transaction_type (String)

    The marketplace-specific classification of the transaction type that originated the invoice. Check transactionType options using the getInvoicesAttributes operation.

  • shipment_id (String)

    The unique shipment identifier for which to get an invoice.

  • invoice_type (String)

    The marketplace-specific classification of the invoice type. Check invoiceType options using the getInvoicesAttributes operation.

  • inbound_plan_id (String) (defaults to: nil)

    The unique inbound plan identifier in which the shipment is contained and for which the invoice will be created.

  • file_format (String) (defaults to: nil)

    The file format of the invoice. The default is XML.

  • (String)
  • (String)
  • (String)
  • (String)
  • inbound_plan_id: (String, nil) (defaults to: nil)
  • file_format: (String, nil) (defaults to: nil)

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 143

def get_government_invoice_document(marketplace_id, transaction_type, shipment_id, invoice_type,
  inbound_plan_id: nil, file_format: nil)
  path = "/tax/invoices/2024-06-19/governmentInvoiceRequests/#{percent_encode(shipment_id)}"
  params = {
    "marketplaceId" => marketplace_id,
    "transactionType" => transaction_type,
    "invoiceType" => invoice_type,
    "inboundPlanId" => inbound_plan_id,
    "fileFormat" => file_format,
  }.compact
  parser = -> { GovtInvoiceDocumentResponse }
  get(path, params:, parser:)
end

#get_government_invoice_status(marketplace_id, transaction_type, shipment_id, invoice_type, inbound_plan_id: nil) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Retrieve the status of an invoice generation request.

Parameters:

  • marketplace_id (String)

    The marketplace of the invoice request.

  • transaction_type (String)

    The marketplace-specific classification of the transaction type that originated the invoice. Check transactionType options using the getInvoicesAttributes operation.

  • shipment_id (String)

    The unique shipment identifier for which to get an invoice.

  • invoice_type (String)

    The marketplace-specific classification of the invoice type. Check invoiceType options using the getInvoicesAttributes operation.

  • inbound_plan_id (String) (defaults to: nil)

    The unique inbound plan identifier in which the shipment is contained and for which the invoice will be created.

  • (String)
  • (String)
  • (String)
  • (String)
  • inbound_plan_id: (String, nil) (defaults to: nil)

Returns:



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 116

def get_government_invoice_status(marketplace_id, transaction_type, shipment_id, invoice_type,
  inbound_plan_id: nil)
  path = "/tax/invoices/2024-06-19/governmentInvoiceRequests"
  params = {
    "marketplaceId" => marketplace_id,
    "transactionType" => transaction_type,
    "shipmentId" => shipment_id,
    "invoiceType" => invoice_type,
    "inboundPlanId" => inbound_plan_id,
  }.compact
  parser = -> { GovernmentInvoiceStatusResponse }
  get(path, params:, parser:)
end

#get_invoice(marketplace_id, invoice_id) ⇒ 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.

  • (String)
  • (String)

Returns:



222
223
224
225
226
227
228
229
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 222

def get_invoice(marketplace_id, invoice_id)
  path = "/tax/invoices/2024-06-19/invoices/#{percent_encode(invoice_id)}"
  params = {
    "marketplaceId" => marketplace_id,
  }.compact
  parser = -> { GetInvoiceResponse }
  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) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

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

Parameters:

  • transaction_identifier_name (String) (defaults to: nil)

    The name of the transaction identifier filter. If you provide a value for this field, you must also provide a value for the transactionIdentifierId field.Use the getInvoicesAttributes operation to check transactionIdentifierName options.

  • page_size (Integer) (defaults to: nil)

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

  • date_end (String) (defaults to: nil)

    The latest invoice creation date for invoices that you want to include in the response. Dates are in ISO 8601 date-time format. The default is the current date-time.

  • 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 invoice was created. Use the getInvoicesAttributes operation to check transactionType options.

  • transaction_identifier_id (String) (defaults to: nil)

    The ID of the transaction identifier filter. If you provide a value for this field, you must also provide a value for the transactionIdentifierName field.

  • date_start (String) (defaults to: nil)

    The earliest invoice creation date for invoices that you want to include in the response. Dates are in ISO 8601 date-time format. The default is 24 hours prior to the time of the request.

  • 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 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.

  • 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 getInvoicesAttributes operation to check invoiceType options.

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

    A list of statuses that you can use to filter invoices. Use the getInvoicesAttributes operation to check invoice status options. Min count: 1

  • external_invoice_id (String) (defaults to: nil)

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

  • sort_by (String) (defaults to: nil)

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

  • (String)
  • transaction_identifier_name: (String, nil) (defaults to: nil)
  • page_size: (Integer, nil) (defaults to: nil)
  • date_end: (String, nil) (defaults to: nil)
  • transaction_type: (String, nil) (defaults to: nil)
  • transaction_identifier_id: (String, nil) (defaults to: nil)
  • date_start: (String, nil) (defaults to: nil)
  • series: (String, nil) (defaults to: nil)
  • next_token: (String, nil) (defaults to: nil)
  • sort_order: (String, nil) (defaults to: nil)
  • invoice_type: (String, nil) (defaults to: nil)
  • statuses: (Array[String], nil) (defaults to: nil)
  • external_invoice_id: (String, nil) (defaults to: nil)
  • sort_by: (String, nil) (defaults to: nil)

Returns:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 190

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)
  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 }
  get(path, params:, parser:)
end

#get_invoices_attributes(marketplace_id) ⇒ 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.

  • (String)

Returns:



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

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

#get_invoices_document(invoices_document_id) ⇒ 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.

  • (String)

Returns:



34
35
36
37
38
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 34

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

#get_invoices_export(export_id) ⇒ 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.

  • (String)

Returns:



88
89
90
91
92
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 88

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

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

Note:

This operation can make a static sandbox call.

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

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 the response. Values are in ISO 8601 date-time format. The default is 30 days ago.

  • next_token (String) (defaults to: nil)

    The response includes nextToken when the number of results exceeds the specified 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.

  • 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 response. Values are in ISO 8601 date-time format. The default value is the time of the request.

  • status (String) (defaults to: nil)

    Return exports matching the status specified.

  • (String)
  • date_start: (String, nil) (defaults to: nil)
  • next_token: (String, nil) (defaults to: nil)
  • page_size: (Integer, nil) (defaults to: nil)
  • date_end: (String, nil) (defaults to: nil)
  • status: (String, nil) (defaults to: nil)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/peddler/apis/invoices_2024_06_19.rb', line 68

def get_invoices_exports(marketplace_id, date_start: nil, next_token: nil, page_size: nil, date_end: nil,
  status: nil)
  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 }
  get(path, params:, parser:)
end