Skip to content

Commit

Permalink
Merge pull request #81 from patterninc/finances-V20240619
Browse files Browse the repository at this point in the history
Add support for Finances V20240619 list_transactions
  • Loading branch information
natesalisbury authored Nov 11, 2024
2 parents eb76142 + 9274284 commit 32df762
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.4.7

- Finances V20240619 list_transactions [#81](https://github.com/patterninc/muffin_man/pull/81)

# 2.4.6 [#79](https://github.com/patterninc/muffin_man/pull/79)

- Support for FulfillmentInbound delivery window options and listInboundPlanBoxes [#79](https://github.com/patterninc/muffin_man/pull/79)
Expand Down
1 change: 1 addition & 0 deletions lib/muffin_man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "muffin_man/catalog_items/v20220401"
require "muffin_man/data_kiosk/v20231115"
require "muffin_man/finances/v0"
require "muffin_man/finances/v20240619"
require "muffin_man/product_fees/v0"
require "muffin_man/authorization/v1"
require "muffin_man/tokens/v20210301"
Expand Down
19 changes: 19 additions & 0 deletions lib/muffin_man/finances/v20240619.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module MuffinMan
module Finances
class V20240619 < SpApiClient
def list_transactions(posted_after:, posted_before: nil, marketplace_id: nil, next_token: nil)
@local_var_path = "/finances/2024-06-19/transactions"
@query_params = {
"postedAfter" => posted_after
}
@query_params["PostedBefore"] = posted_before unless posted_before.nil?
@query_params["marketplaceId"] = marketplace_id unless marketplace_id.nil?
@query_params["nextToken"] = next_token unless next_token.nil?
@request_type = "GET"
call_api
end
end
end
end
23 changes: 23 additions & 0 deletions spec/muffin_man/finances/v20240619_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

RSpec.describe MuffinMan::Finances::V20240619 do
subject(:client) { described_class.new(credentials) }

let(:posted_after) { "2024-11-07T00:00:00Z" }

before do
stub_request_access_token
end

describe "list_transactions" do
before do
stub_list_financial_transactions(posted_after: posted_after)
end

it "lists transactions" do
response = client.list_transactions(posted_after: posted_after)
expect(response.success?).to be true
expect(JSON.parse(response.body)["payload"]["transactions"]).to be_an(Array)
end
end
end
232 changes: 232 additions & 0 deletions spec/support/finances/list_transactions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"payload": {
"transactions": [
{
"sellingPartnerMetadata": {
"sellingPartnerId": "A1111111111111",
"marketplaceId": "AT614YYYNOC1S",
"accountType": "Standard Orders"
},
"transactionType": "Shipment",
"transactionId": "lo6cQ55-40s5sU4g_lSwkZV22qz-vCNVtjLLqAQyux4",
"transactionStatus": null,
"relatedIdentifiers": [
{
"relatedIdentifierName": "ORDER_ID",
"relatedIdentifierValue": "999-0852306-5138236"
},
{
"relatedIdentifierName": "SHIPMENT_ID",
"relatedIdentifierValue": "11111111111111"
},
{
"relatedIdentifierName": "FINANCIAL_EVENT_GROUP_ID",
"relatedIdentifierValue": "_fSsCZmGkBME7DCFtbqKLcDX-KB-M-5Pdr1NaefqCkB"
}
],
"totalAmount": {
"currencyAmount": 294.46,
"currencyCode": "SEK"
},
"description": "Order Payment",
"postedDate": "2024-01-18T12:45:47Z",
"marketplaceDetails": {
"marketplaceId": "AT614YYYNOC1S",
"marketplaceName": "Amazon.se"
},
"items": [
{
"description": "SAMSUNG Galaxy Tab S6 Lite WiFi - 64GB, 4GB, Grigio",
"totalAmount": {
"currencyAmount": 294.46,
"currencyCode": "SEK"
},
"relatedIdentifiers": [
{
"itemRelatedIdentifierName": "ORDER_ADJUSTMENT_ITEM_ID",
"itemRelatedIdentifierValue": "6226957701205"
}
],
"breakdowns": [
{
"breakdownType": "Tax",
"breakdownAmount": {
"currencyAmount": 89.8,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "OurPriceTax",
"breakdownAmount": {
"currencyAmount": 80,
"currencyCode": "SEK"
},
"breakdowns": []
},
{
"breakdownType": "ShippingTax",
"breakdownAmount": {
"currencyAmount": 9.8,
"currencyCode": "SEK"
},
"breakdowns": []
}
]
},
{
"breakdownType": "ProductCharges",
"breakdownAmount": {
"currencyAmount": 320,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "OurPricePrincipal",
"breakdownAmount": {
"currencyAmount": 320,
"currencyCode": "SEK"
},
"breakdowns": []
}
]
},
{
"breakdownType": "Shipping",
"breakdownAmount": {
"currencyAmount": 39.2,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "ShippingPrincipal",
"breakdownAmount": {
"currencyAmount": 39.2,
"currencyCode": "SEK"
},
"breakdowns": []
}
]
},
{
"breakdownType": "AmazonFees",
"breakdownAmount": {
"currencyAmount": -154.54,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "FBAPerUnitFulfillmentFee",
"breakdownAmount": {
"currencyAmount": -45.54,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "Base",
"breakdownAmount": {
"currencyAmount": -36.43,
"currencyCode": "SEK"
}
},
{
"breakdownType": "Tax",
"breakdownAmount": {
"currencyAmount": -9.11,
"currencyCode": "SEK"
}
}
]
},
{
"breakdownType": "Commission",
"breakdownAmount": {
"currencyAmount": -60,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "Base",
"breakdownAmount": {
"currencyAmount": -60,
"currencyCode": "SEK"
}
}
]
},
{
"breakdownType": "ShippingChargeback",
"breakdownAmount": {
"currencyAmount": -49,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "Base",
"breakdownAmount": {
"currencyAmount": -39.2,
"currencyCode": "SEK"
}
},
{
"breakdownType": "Tax",
"breakdownAmount": {
"currencyAmount": -9.8,
"currencyCode": "SEK"
}
}
]
}
]
}
],
"contexts": [
{
"asin": "B085V6LQPB",
"quantityShipped": 1,
"sku": "PSMM-TEST-SKU-Aug-29_08_03_14-0898",
"fulfillmentNetwork": "AFN",
"contextType": "ProductContext"
}
]
}
],
"breakdowns": [
{
"breakdownType": "Sales",
"breakdownAmount": {
"currencyAmount": 449,
"currencyCode": "SEK"
},
"breakdowns": [
{
"breakdownType": "Tax",
"breakdownAmount": {
"currencyAmount": 89.8,
"currencyCode": "SEK"
},
"breakdowns": null
},
{
"breakdownType": "ProductCharges",
"breakdownAmount": {
"currencyAmount": 320,
"currencyCode": "SEK"
},
"breakdowns": null
},
{
"breakdownType": "Shipping",
"breakdownAmount": {
"currencyAmount": 39.2,
"currencyCode": "SEK"
},
"breakdowns": null
}
]
}
]
}
]
},
"nextToken": "nextToken"
}
6 changes: 6 additions & 0 deletions spec/support/finances/stub_finances.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

def stub_list_financial_transactions(posted_after:)
stub_request(:get, "https://#{hostname}/finances/2024-06-19/transactions?postedAfter=#{posted_after}")
.to_return(status: 200, body: File.read("./spec/support/finances/list_transactions.json"), headers: {})
end
1 change: 1 addition & 0 deletions spec/support/sp_api_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require './spec/support/outbound_fulfillment/stub_outbound_fulfillment'
require './spec/support/feeds/stub_feeds'
require './spec/support/notifications/stub_notifications'
require './spec/support/finances/stub_finances'

module Support
module SpApiHelpers
Expand Down

0 comments on commit 32df762

Please sign in to comment.