Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.6.0 [#108](https://github.com/patterninc/muffin_man/pull/108)

- Orders v2026-01-01

# 2.5.1 [#107](https://github.com/patterninc/muffin_man/pull/107)

- Added ORDER_CHANGE to PROCESSING_DIRECTIVE_SUPPORTED_NOTIFICATIONS in Notifications API v1
Expand Down
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,6 @@

MuffinMan is a ruby interface to the Amazon Selling Partner API. For more information on registering to use the Selling Partner API, see [Amazon's documentation](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md)

As of now, this gem only supports portions of the following APIs with more to come:

- `Customer Feedback Insights API v2024-06-01 (BETA)`
- `Amazon Warehousing and Distribution API v2024-05-09`
- `Catalog Items API v2022-04-01`
- `Data Kiosk API v2023-11-15`
- `FBA Inventory API v1`
- `Feeds API v2021-06-30`
- `Finances API v0`
- `Fulfillment Inbound API v2024-03-20`
- `Fulfillment Outbound API v2020-07-01`
- `Listings API v2021-08-01`
- `Listings API v2020-09-01`
- `Listings Restrictions API v2021-08-01`
- `Merchant Fulfillment API v0`
- `Notifications API v1`
- `Orders API v0`
- `Product Fees API v0`
- `Product Pricing API v0`
- `Reports API v2021-06-30`
- `Solicitations API v1`
- `Sellers API v1`
- `Tokens API v2021-03-01`
- `Vendor Direct Fulfillment Transactions API v1`
- `Vendor Direct Fulfillment Orders API v2021-12-28`
- `Vendor Direct Fulfillment Payments API v1`
- `Vendor Direct Fulfillment Shipping API v2021-12-28`
- `Vendor Direct Fulfillment Transactions API v2021-12-28`
- `Vendor Invoices API v1`
- `Vendor Orders API v1`
- `Vendor Shipments API v1`
- `Vendor Transaction Status API v1`
- `Uploads API v2020-11-01`
- `A+ API v2020-11-01`
- `Application Management API v2023-11-30`
- `Finances API v2024-06-19`

## Installation

Add this line to your application's Gemfile:
Expand Down
1 change: 1 addition & 0 deletions lib/muffin_man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "muffin_man/lwa/auth_helper"
require "muffin_man/solicitations/v1"
require "muffin_man/orders/v0"
require "muffin_man/orders/v20260101"
require "muffin_man/reports/v20210630"
require "muffin_man/catalog_items/v20201201"
require "muffin_man/catalog_items/v20220401"
Expand Down
35 changes: 35 additions & 0 deletions lib/muffin_man/orders/v20260101.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

module MuffinMan
module Orders
class V20260101 < SpApiClient
SEARCH_ORDERS_QUERY_PARAMS = %w[
createdAfter
createdBefore
lastUpdatedAfter
lastUpdatedBefore
fulfillmentStatuses
marketplaceIds
fulfilledBy
maxResultsPerPage
paginationToken
includedData
].freeze

def search_orders(query_params: {})
@local_var_path = "/orders/2026-01-01/orders"
@query_params = query_params.slice(*SEARCH_ORDERS_QUERY_PARAMS)
Comment on lines +16 to +21
@request_type = "GET"
call_api
end

def get_order(order_id, included_data: [])
@local_var_path = "/orders/2026-01-01/orders/#{order_id}"
@query_params = {}
@query_params["includedData"] = included_data.join(",") if included_data.any?
@request_type = "GET"
call_api
Comment on lines +26 to +31
end
end
end
end
2 changes: 1 addition & 1 deletion lib/muffin_man/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module MuffinMan
VERSION = "2.5.1"
VERSION = "2.6.0"
end
38 changes: 38 additions & 0 deletions spec/muffin_man/orders/v20260101_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

RSpec.describe MuffinMan::Orders::V20260101 do
subject(:orders_client) { described_class.new(credentials) }

before { stub_request_access_token }

describe "#search_orders" do
it "returns orders" do
query_params = { "lastUpdatedBefore" => "2024-12-25T15:00:00Z" }

stub_request(:get, "https://#{hostname}/orders/2026-01-01/orders")
.with(query: query_params)
.to_return(status: 200, body: File.read("./spec/support/orders/v20260101_search_orders.json"))

Comment on lines +9 to +15
response = orders_client.search_orders(query_params: query_params)

expect(response).to be_success
expect(JSON.parse(response.body)["orders"]).to be_an(Array)
end
end

describe "#get_order" do
it "returns the order" do
order_id = "202-1234567-8901234"
included_data = ["BUYER", "RECIPIENT"]

stub_request(:get, "https://#{hostname}/orders/2026-01-01/orders/#{order_id}")
.with(query: { "includedData" => included_data.join(",") })
.to_return(status: 200, body: File.read("./spec/support/orders/v20260101_get_order.json"))

response = orders_client.get_order(order_id, included_data: included_data)

expect(response).to be_success
expect(JSON.parse(response.body).dig("order", "orderId")).to eq(order_id)
end
Comment on lines +8 to +36
Comment on lines +23 to +36
end
end
207 changes: 207 additions & 0 deletions spec/support/orders/v20260101_get_order.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
{
"order": {
"orderId": "202-1234567-8901234",
"orderAliases": [
{
"aliasId": "UK-MERCHANT-ORDER-2024-001",
"aliasType": "SELLER_ORDER_ID"
}
],
"createdTime": "2024-12-25T09:15:00Z",
"lastUpdatedTime": "2024-12-25T16:30:00Z",
"programs": [
"PRIME"
],
"salesChannel": {
"channelName": "AMAZON",
"marketplaceId": "A1F83G8C2ARO7P",
"marketplaceName": "Amazon.co.uk"
},
"buyer": {
"buyerName": "James Wilson",
"buyerEmail": "buyer-email@marketplace.amazon.co.uk"
},
"recipient": {
"deliveryAddress": {
"name": "James Wilson",
"companyName": "Wilson Electronics Ltd",
"addressLine1": "123 High Street",
"addressLine2": "Unit 4B",
"addressLine3": "",
"city": "Manchester",
"districtOrCounty": "Greater Manchester",
"stateOrRegion": "England",
"municipality": "",
"postalCode": "M1 2AB",
"countryCode": "GB",
"phone": "+44 161 123 4567",
"addressType": "COMMERCIAL"
}
},
"proceeds": {
"grandTotal": {
"amount": "103.97",
"currencyCode": "GBP"
}
},
"fulfillment": {
"fulfillmentStatus": "SHIPPED",
"fulfilledBy": "MERCHANT",
"fulfillmentServiceLevel": "STANDARD",
"shipByWindow": {
"earliestDateTime": "2024-12-25T00:00:00Z",
"latestDateTime": "2024-12-26T23:59:59Z"
},
"deliverByWindow": {
"earliestDateTime": "2024-12-27T00:00:00Z",
"latestDateTime": "2024-12-30T23:59:59Z"
}
},
"orderItems": [
{
"orderItemId": "20212345678901",
"quantityOrdered": 3,
"programs": [
"TRANSPARENCY"
],
"product": {
"asin": "B08DFPV54V",
"title": "Echo Dot (4th Gen) | Smart speaker with Alexa | Charcoal",
"sellerSku": "ECHO-DOT-4-UK-CHARCOAL-3PACK",
"condition": {
"conditionType": "NEW",
"conditionSubtype": "NEW",
"conditionNote": "Brand new, sealed in original packaging"
},
"price": {
"unitPrice": {
"amount": "29.99",
"currencyCode": "GBP"
},
"priceDesignation": "BUSINESS_PRICE"
},
"serialNumbers": [
"ED4UK-2024-ABC123456789",
"ED4UK-2024-DEF987654321",
"ED4UK-2024-GHI456789123"
],
"customization": {
"customizedUrl": ""
}
},
"proceeds": {
"proceedsTotal": {
"amount": "103.97",
"currencyCode": "GBP"
},
"breakdowns": [
{
"type": "ITEM",
"subtotal": {
"amount": "89.97",
"currencyCode": "GBP"
}
},
{
"type": "SHIPPING",
"subtotal": {
"amount": "10.00",
"currencyCode": "GBP"
}
},
{
"type": "TAX",
"subtotal": {
"amount": "4.00",
"currencyCode": "GBP"
},
"detailedBreakdowns": [
{
"subtype": "ITEM",
"value": {
"amount": "3.00",
"currencyCode": "GBP"
}
},
{
"subtype": "SHIPPING",
"value": {
"amount": "1.00",
"currencyCode": "GBP"
}
}
]
}
]
},
"promotion": {
"breakdowns": [
{
"promotionId": "UK-BOXING-DAY-2024"
}
]
},
"fulfillment": {
"quantityFulfilled": 3,
"quantityUnfulfilled": 0,
"packing": {
"giftOption": {
"giftMessage": "Happy Christmas! Hope you enjoy your new smart speakers.",
"giftWrapLevel": "PREMIUM"
}
},
"shipping": {
"scheduledDeliveryWindow": {
"earliestDateTime": "2024-12-27T09:00:00Z",
"latestDateTime": "2024-12-27T17:00:00Z"
},
"shippingConstraints": {
"signatureConfirmation": "MANDATORY",
"recipientIdentityVerification": "MANDATORY"
},
"internationalShipping": {
"iossNumber": "IM1234567890"
}
}
}
}
],
"packages": [
{
"packageReferenceId": "UK-PKG-2024-001",
"createdTime": "2024-12-25T16:45:00Z",
"packageStatus": {
"status": "IN_TRANSIT",
"detailedStatus": "OUT_FOR_DELIVERY"
},
"carrier": "Royal Mail",
"shipTime": "2024-12-26T14:00:00Z",
"shippingService": "Royal Mail Tracked 48",
"trackingNumber": "RR123456789GB",
"shipFromAddress": {
"name": "TechGear UK Warehouse",
"addressLine1": "Industrial Estate Unit 15",
"addressLine2": "Riverside Business Park",
"addressLine3": "",
"city": "Birmingham",
"districtOrCounty": "West Midlands",
"stateOrRegion": "England",
"municipality": "",
"postalCode": "B12 0XY",
"countryCode": "GB"
},
"packageItems": [
{
"orderItemId": "20212345678901",
"quantity": 3,
"transparencyCodes": [
"T12345ABCDE67890UK",
"T12346ABCDF67891UK",
"T12347ABCDG67892UK"
]
}
]
}
]
}
}
Loading
Loading