Class: Peddler::API::Invoices20240619

Inherits:
Peddler::API show all
Defined in:
lib/peddler/api/invoices_2024_06_19.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.

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #endpoint

Instance Method Summary collapse

Methods inherited from Peddler::API

#cannot_sandbox!, #endpoint_uri, #http, #initialize, #meter, #must_sandbox!, #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) ⇒ Hash

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:

  • (Hash)

    The API response



53
54
55
56
57
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 53

def create_invoices_export(body, rate_limit: 0.167)
  path = "/tax/invoices/2024-06-19/exports"

  meter(rate_limit).post(path, body:)
end

#get_invoice(marketplace_id, invoice_id, rate_limit: 2.0) ⇒ Hash

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:

  • (Hash)

    The API response



171
172
173
174
175
176
177
178
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 171

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

  meter(rate_limit).get(path, params:)
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) ⇒ Hash

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.

  • rate_limit (Float) (defaults to: 0.1)

    Requests per second

Returns:

  • (Hash)

    The API response



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 138

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" => statuses,
    "externalInvoiceId" => external_invoice_id,
    "sortBy" => sort_by,
  }.compact

  meter(rate_limit).get(path, params:)
end

#get_invoices_attributes(marketplace_id, rate_limit: 1.0) ⇒ Hash

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:

  • (Hash)

    The API response



25
26
27
28
29
30
31
32
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 25

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

  meter(rate_limit).get(path, params:)
end

#get_invoices_document(invoices_document_id, rate_limit: 0.0167) ⇒ Hash

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:

  • (Hash)

    The API response



41
42
43
44
45
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 41

def get_invoices_document(invoices_document_id, rate_limit: 0.0167)
  path = "/tax/invoices/2024-06-19/documents/#{invoices_document_id}"

  meter(rate_limit).get(path)
end

#get_invoices_export(export_id, rate_limit: 2.0) ⇒ Hash

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:

  • (Hash)

    The API response



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

def get_invoices_export(export_id, rate_limit: 2.0)
  path = "/tax/invoices/2024-06-19/exports/#{export_id}"

  meter(rate_limit).get(path)
end

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

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.

  • rate_limit (Float) (defaults to: 0.1)

    Requests per second

Returns:

  • (Hash)

    The API response



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 77

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

  meter(rate_limit).get(path, params:)
end