Class: Peddler::APIs::Finances20240619

Inherits:
Peddler::API show all
Defined in:
lib/peddler/apis/finances_2024_06_19.rb,
lib/peddler/apis/finances_2024_06_19/item.rb,
lib/peddler/apis/finances_2024_06_19/error.rb,
lib/peddler/apis/finances_2024_06_19/items.rb,
lib/peddler/apis/finances_2024_06_19/context.rb,
lib/peddler/apis/finances_2024_06_19/contexts.rb,
lib/peddler/apis/finances_2024_06_19/breakdown.rb,
lib/peddler/apis/finances_2024_06_19/breakdowns.rb,
lib/peddler/apis/finances_2024_06_19/error_list.rb,
lib/peddler/apis/finances_2024_06_19/transaction.rb,
lib/peddler/apis/finances_2024_06_19/transactions.rb,
lib/peddler/apis/finances_2024_06_19/product_context.rb,
lib/peddler/apis/finances_2024_06_19/business_context.rb,
lib/peddler/apis/finances_2024_06_19/deferred_context.rb,
lib/peddler/apis/finances_2024_06_19/payments_context.rb,
lib/peddler/apis/finances_2024_06_19/amazon_pay_context.rb,
lib/peddler/apis/finances_2024_06_19/related_identifier.rb,
lib/peddler/apis/finances_2024_06_19/time_range_context.rb,
lib/peddler/apis/finances_2024_06_19/marketplace_details.rb,
lib/peddler/apis/finances_2024_06_19/related_identifiers.rb,
lib/peddler/apis/finances_2024_06_19/transactions_payload.rb,
lib/peddler/apis/finances_2024_06_19/item_related_identifier.rb,
lib/peddler/apis/finances_2024_06_19/item_related_identifiers.rb,
lib/peddler/apis/finances_2024_06_19/selling_partner_metadata.rb,
lib/peddler/apis/finances_2024_06_19/list_transactions_response.rb

Overview

The Selling Partner API for Finances

The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order or date range without having to wait until a statement period closes.

Defined Under Namespace

Classes: Breakdowns, Contexts, ItemRelatedIdentifiers, Items, RelatedIdentifiers, Transactions

Constant Summary collapse

Item =

Additional information about the items in Transaction.

Structure.new do
  # @return [Array<Breakdown>] A list of breakdowns that detail how the total amount is calculated for the
  # transaction.
  attribute?(:breakdowns, [Breakdown])

  # @return [Array<Context>] Additional Information about the item.
  attribute?(:contexts, [Context])

  # @return [String] Description of items in the transaction
  attribute?(:description, String)

  # @return [Array<ItemRelatedIdentifier>] Related business identifiers of the item.
  attribute?(:related_identifiers, [ItemRelatedIdentifier], from: "relatedIdentifiers")

  # @return [Money] The total amount of the item.
  attribute?(:total_amount, Money, from: "totalAmount")
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
Context =

Additional Information about the item.

Structure.new do
  # @return [String]
  attribute(:context_type, String, from: "contextType")

  # @return [String] Amazon Standard Identification Number (ASIN) of the item.
  attribute?(:asin, String)

  # @return [String] Channel details of related transaction.
  attribute?(:channel, String)

  # @return [String] The deferral policy applied to the transaction.
  #
  # **Examples:** `B2B` (invoiced orders), `DD7` (delivery date policy)
  attribute?(:deferral_reason, String, from: "deferralReason")

  # @return [String] End time of the transaction.
  attribute?(:end_time, String, from: "endTime")

  # @return [String] Fulfillment network of the item.
  attribute?(:fulfillment_network, String, from: "fulfillmentNetwork")

  # @return [String] The release date of the transaction.
  attribute?(:maturity_date, String, from: "maturityDate")

  # @return [String] Order type of the transaction.
  attribute?(:order_type, String, from: "orderType")

  # @return [String] Date of payment made.
  attribute?(:payment_date, String, from: "paymentDate")

  # @return [String] Method of payment made.
  attribute?(:payment_method, String, from: "paymentMethod")

  # @return [String] Reference number of payment made.
  attribute?(:payment_reference, String, from: "paymentReference")

  # @return [String] Type of payment made.
  attribute?(:payment_type, String, from: "paymentType")

  # @return [Integer] Quantity of the item shipped.
  attribute?(:quantity_shipped, Integer, from: "quantityShipped")

  # @return [String] Stock keeping unit (SKU) of the item.
  attribute?(:sku, String)

  # @return [String] Start time of the transaction.
  attribute?(:start_time, String, from: "startTime")

  # @return [String] The store name associated with the transaction.
  attribute?(:store_name, String, from: "storeName")
end
Breakdown =

Breakdown provides details regarding the money movement under the financial transaction. Breakdowns get categorized further into breakdown types, breakdown amounts, and further breakdowns into a hierarchical structure.

Structure.new do
  # @return [Money] The amount of the charge.
  attribute?(:breakdown_amount, Money, from: "breakdownAmount")

  # @return [String] The type of charge.
  attribute?(:breakdown_type, String, from: "breakdownType")

  # @return [Array<self>] A list of breakdowns that detail how the total amount is calculated for the transaction.
  attribute?(:breakdowns, [:self])
end
ErrorList =

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

Structure.new do
  # @return [Array<Error>] Error response returned when the request is unsuccessful.
  attribute(:errors, [Error])
end
Transaction =

Contains all information related to the transaction.

Structure.new do
  # @return [Array<Breakdown>] A list of breakdowns that detail how the total amount is calculated for the
  # transaction.
  attribute?(:breakdowns, [Breakdown])

  # @return [Array<Context>] Additional Information about the transaction.
  attribute?(:contexts, [Context])

  # @return [String] Describes the reasons for the transaction.
  #
  # Example: 'Order Payment','Refund Order'
  attribute?(:description, String)

  # @return [Array<Item>] Additional information about the items in Transaction.
  attribute?(:items, [Item])

  # @return [MarketplaceDetails] Information about the marketplace where the transaction occurred.
  attribute?(:marketplace_details, MarketplaceDetails, from: "marketplaceDetails")

  # @return [String] The date and time when the transaction was posted.
  attribute?(:posted_date, String, from: "postedDate")

  # @return [Array<RelatedIdentifier>] Related business identifiers of the transaction.
  attribute?(:related_identifiers, [RelatedIdentifier], from: "relatedIdentifiers")

  # @return [SellingPartnerMetadata] Metadata describing the seller.
  attribute?(:selling_partner_metadata, SellingPartnerMetadata, from: "sellingPartnerMetadata")

  # @return [Money] Total amount of transaction.
  attribute?(:total_amount, Money, from: "totalAmount")

  # @return [String] The unique identifier for the transaction.
  attribute?(:transaction_id, String, from: "transactionId")

  # @return [String] The status of the transaction.
  #
  # **Possible values:**
  #
  # * `DEFERRED`: the transaction is currently deferred.
  # * `RELEASED`: the transaction is currently released.
  # * `DEFERRED_RELEASED`: the transaction was deferred in the past, but is now released. The status of a deferred
  # transaction is updated to `DEFERRED_RELEASED` when the transaction is released.
  attribute?(:transaction_status, String, from: "transactionStatus")

  # @return [String] The type of transaction.
  #
  # Possible values:
  #
  # * Shipment
  attribute?(:transaction_type, String, from: "transactionType")
end
ProductContext =

Additional information related to the product.

Structure.new do
  # @return [String] Amazon Standard Identification Number (ASIN) of the item.
  attribute?(:asin, String)

  # @return [String] Fulfillment network of the item.
  attribute?(:fulfillment_network, String, from: "fulfillmentNetwork")

  # @return [Integer] Quantity of the item shipped.
  attribute?(:quantity_shipped, Integer, from: "quantityShipped")

  # @return [String] Stock keeping unit (SKU) of the item.
  attribute?(:sku, String)
end
BusinessContext =

Information about the line of business associated with a transaction.

Structure.new do
  # @return [String] The store name associated with the transaction.
  attribute?(:store_name, String, from: "storeName")
end
DeferredContext =

Additional information related to Deferred transactions.

Structure.new do
  # @return [String] The deferral policy applied to the transaction.
  #
  # **Examples:** `B2B` (invoiced orders), `DD7` (delivery date policy)
  attribute?(:deferral_reason, String, from: "deferralReason")

  # @return [String] The release date of the transaction.
  attribute?(:maturity_date, String, from: "maturityDate")
end
PaymentsContext =

Additional information related to Payments related transactions.

Structure.new do
  # @return [String] Date of payment made.
  attribute?(:payment_date, String, from: "paymentDate")

  # @return [String] Method of payment made.
  attribute?(:payment_method, String, from: "paymentMethod")

  # @return [String] Reference number of payment made.
  attribute?(:payment_reference, String, from: "paymentReference")

  # @return [String] Type of payment made.
  attribute?(:payment_type, String, from: "paymentType")
end
AmazonPayContext =

Additional information related to Amazon Pay.

Structure.new do
  # @return [String] Channel details of related transaction.
  attribute?(:channel, String)

  # @return [String] Order type of the transaction.
  attribute?(:order_type, String, from: "orderType")

  # @return [String] Store name related to transaction.
  attribute?(:store_name, String, from: "storeName")
end
RelatedIdentifier =

Related business identifier of the transaction.

Structure.new do
  # @return [String] Enumerated set of related business identifier names.
  attribute?(:related_identifier_name, String, from: "relatedIdentifierName")

  # @return [String] Corresponding value of RelatedIdentifierName
  attribute?(:related_identifier_value, String, from: "relatedIdentifierValue")
end
TimeRangeContext =

Additional information related to time range for transaction.

Structure.new do
  # @return [String] End time of the transaction.
  attribute?(:end_time, String, from: "endTime")

  # @return [String] Start time of the transaction.
  attribute?(:start_time, String, from: "startTime")
end
MarketplaceDetails =

Information about the marketplace where the transaction occurred.

Structure.new do
  # @return [String] The identifier of the marketplace where the transaction occurred. The marketplace ID is the
  # globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace
  # IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids).
  attribute?(:marketplace_id, String, from: "marketplaceId")

  # @return [String] The name of the marketplace where the transaction occurred.
  #
  # Example: 'Amazon.com','Amazon.in'
  attribute?(:marketplace_name, String, from: "marketplaceName")
end
TransactionsPayload =

The payload for the listTransactions operation.

Structure.new do
  # @return [String] When present and not empty, pass this string token in the next request to return the next
  # response page.
  attribute?(:next_token, String, from: "nextToken")

  # @return [Array<Transaction>]
  attribute?(:transactions, [Transaction])
end
ItemRelatedIdentifier =

Related business identifiers of the item.

Structure.new do
  # @return [String] Enumerated set of related item identifier names for the item.
  attribute?(:item_related_identifier_name, String, from: "itemRelatedIdentifierName")

  # @return [String] Corresponding value of ItemRelatedIdentifierName
  attribute?(:item_related_identifier_value, String, from: "itemRelatedIdentifierValue")
end
SellingPartnerMetadata =

Metadata describing the seller.

Structure.new do
  # @return [String] Account type of transaction.
  attribute?(:account_type, String, from: "accountType")

  # @return [String] The identifier of the marketplace where the transaction occurred. The marketplace ID is the
  # globally unique identifier of a marketplace. To find the ID for your marketplace, refer to [Marketplace
  # IDs](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids).
  attribute?(:marketplace_id, String, from: "marketplaceId")

  # @return [String] Unique seller identifier.
  attribute?(:selling_partner_id, String, from: "sellingPartnerId")
end
ListTransactionsResponse =

The response schema for the listTransactions operation.

Structure.new do
  # @return [TransactionsPayload] The payload for the `listTransactions` operation.
  attribute?(:payload, TransactionsPayload)
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

#list_transactions(posted_after, posted_before: nil, marketplace_id: nil, transaction_status: nil, next_token: nil, rate_limit: 0.5) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns transactions for the given parameters. Financial events might not include orders from the last 48 hours.

be in ISO 8601 date-time format. The date-time must be more than two minutes before the time of the request. time. The date-time must be later than PostedAfter and no later than two minutes before the request was submitted, in ISO 8601 date time format. If PostedAfter and PostedBefore are more than 180 days apart, no transactions are returned. You must specify the PostedAfter parameter if you specify the PostedBefore parameter. Default: Now minus two minutes. The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to Marketplace IDs. transaction is currently deferred. * RELEASED: the transaction is currently released. * DEFERRED_RELEASED: the transaction was deferred in the past, but is now released. The status of a deferred transaction is updated to DEFERRED_RELEASED when the transaction is released.

Parameters:

  • posted_after (String)

    The response includes financial events posted on or after this date. This date must

  • posted_before (String) (defaults to: nil)

    A date used for selecting transactions posted before (but not at) a specified

  • marketplace_id (String) (defaults to: nil)

    The identifier of the marketplace from which you want to retrieve transactions.

  • transaction_status (String) (defaults to: nil)

    The status of the transaction. Possible values: * DEFERRED: the

  • next_token (String) (defaults to: nil)

    A string token returned in the response of your previous request.

  • rate_limit (Float) (defaults to: 0.5)

    Requests per second

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/peddler/apis/finances_2024_06_19.rb', line 36

def list_transactions(posted_after, posted_before: nil, marketplace_id: nil, transaction_status: nil,
  next_token: nil, rate_limit: 0.5)
  path = "/finances/2024-06-19/transactions"
  params = {
    "postedAfter" => posted_after,
    "postedBefore" => posted_before,
    "marketplaceId" => marketplace_id,
    "transactionStatus" => transaction_status,
    "nextToken" => next_token,
  }.compact
  parser = -> { ListTransactionsResponse }
  meter(rate_limit).get(path, params:, parser:)
end