-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from patterninc/finances-V20240619
Add support for Finances V20240619 list_transactions
- Loading branch information
Showing
7 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters