Class: Peddler::APIs::SalesV1
- Inherits:
-
Peddler::API
- Object
- Peddler::API
- Peddler::APIs::SalesV1
- Defined in:
- lib/peddler/apis/sales_v1.rb,
lib/peddler/apis/sales_v1/error.rb,
lib/peddler/apis/sales_v1/error_list.rb,
lib/peddler/apis/sales_v1/order_metrics_list.rb,
lib/peddler/apis/sales_v1/order_metrics_interval.rb,
lib/peddler/apis/sales_v1/get_order_metrics_response.rb
Overview
Selling Partner API for Sales
The Selling Partner API for Sales provides APIs related to sales performance.
Defined Under Namespace
Classes: ErrorList, OrderMetricsList
Constant Summary collapse
- Error =
Error response returned when the request is unsuccessful.
Structure.new do # @return [String] An error code that identifies the type of error that occured. attribute(:code, String) # @return [String] A message that describes the error condition in a human-readable form. attribute(:message, String) # @return [String] Additional details that can help the caller understand or fix the issue. attribute?(:details, String) end
- OrderMetricsInterval =
Contains order metrics.
Structure.new do # @return [Money] The average price for an item based on the specified filters. Formula is totalSales/unitCount. attribute(:average_unit_price, Money, from: "averageUnitPrice") # @return [String] The interval of time based on requested granularity (ex. Hour, Day, etc.) If this is the # first or the last interval from the list, it might contain incomplete data if the requested interval doesn't # align with the requested granularity (ex. request interval 2018-09-01T02:00:00Z--2018-09-04T19:00:00Z and # granularity day will result in Sept 1st UTC day and Sept 4th UTC days having partial data). attribute(:interval, String) # @return [Integer] The number of orders based on the specified filters. attribute(:order_count, Integer, from: "orderCount") # @return [Integer] The number of order items based on the specified filters. attribute(:order_item_count, Integer, from: "orderItemCount") # @return [Money] The total ordered product sales for all orders based on the specified filters. attribute(:total_sales, Money, from: "totalSales") # @return [Integer] The number of units in orders based on the specified filters. attribute(:unit_count, Integer, from: "unitCount") end
- GetOrderMetricsResponse =
The response schema for the getOrderMetrics operation.
Structure.new do # @return [Array<Error>] Encountered errors for the getOrderMetrics operation. attribute?(:errors, [Error]) # @return [Array<OrderMetricsInterval>] The payload for the getOrderMetrics operation. attribute?(:payload, [OrderMetricsInterval]) end
Instance Attribute Summary
Attributes inherited from Peddler::API
#access_token, #endpoint, #retries
Instance Method Summary collapse
-
#get_order_metrics(marketplace_ids, interval, granularity, granularity_time_zone: nil, buyer_type: "All", fulfillment_network: nil, first_day_of_week: "Monday", asin: nil, sku: nil, amazon_program: nil, rate_limit: 0.5) ⇒ Peddler::Response
Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type.
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
#get_order_metrics(marketplace_ids, interval, granularity, granularity_time_zone: nil, buyer_type: "All", fulfillment_network: nil, first_day_of_week: "Monday", asin: nil, sku: nil, amazon_program: nil, rate_limit: 0.5) ⇒ Peddler::Response
This operation can make a static sandbox call.
Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type.
order was placed. Only one marketplace can be specified. For example, ATVPDKIKX0DER indicates the US
marketplace.
separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and
must represent absolute time (either Z notation or offset notation). Example:
2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the
-07:00 zone.
when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset
of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone
must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone
that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings,
for US/Pacific zone.
Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal
to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from
now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you
specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of
the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval,
where the day boundary is defined by the granularityTimeZone.
B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers.
(merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the
response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to
include order metrics for only Amazon fulfillment network.
or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday.
error. Do not include this filter if you want the response to include order metrics for all ASINs. Example:
B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.
error. Do not include this filter if you want the response to include order metrics for all SKUs. Example:
TestSKU, if you want the response to include order metrics for only SKU TestSKU.
filter if you want the response to include order metrics for all programs. Example: AmazonHaul
returns
order metrics for the Amazon Haul program only.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/peddler/apis/sales_v1.rb', line 56 def get_order_metrics(marketplace_ids, interval, granularity, granularity_time_zone: nil, buyer_type: "All", fulfillment_network: nil, first_day_of_week: "Monday", asin: nil, sku: nil, amazon_program: nil, rate_limit: 0.5) path = "/sales/v1/orderMetrics" params = { "marketplaceIds" => stringify_array(marketplace_ids), "interval" => interval, "granularityTimeZone" => granularity_time_zone, "granularity" => granularity, "buyerType" => buyer_type, "fulfillmentNetwork" => fulfillment_network, "firstDayOfWeek" => first_day_of_week, "asin" => asin, "sku" => sku, "amazonProgram" => amazon_program, }.compact parser = -> { GetOrderMetricsResponse } meter(rate_limit).get(path, params:, parser:) end |