Class: WalmartApIs::SalesApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/walmart_ap_is/apis/sales_api.rb

Overview

SalesApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from WalmartApIs::BaseApi

Instance Method Details

#get_order_metrics(marketplace_ids, interval, granularity, granularity_time_zone: nil, buyer_type: nil, fulfillment_network: nil, first_day_of_week: nil, asin: nil, sku: nil, sp_api_program: nil) ⇒ ApiResponse

TODO: type endpoint description here identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified selecting order metrics. This takes the form of two dates 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. the grouping of order metrics, based on a unit of time. 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. IANA-compatible time zone for determining the day boundary. Required 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. the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers. results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (marketplace 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 the marketplace fulfillment network. the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sund that you specify. Specifying both ASIN and SKU returns an 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. that you specify. Specifying both ASIN and SKU returns an 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. the program that you specify. Do not include this filter if you want the response to inclu

Parameters:

  • marketplace_ids (Array[String])

    Required parameter: A marketplace

  • interval (String)

    Required parameter: A time interval used for

  • granularity (Granularity)

    Required parameter: The granularity of

  • granularity_time_zone (String) (defaults to: nil)

    Optional parameter: An

  • buyer_type (BuyerType) (defaults to: nil)

    Optional parameter: Filters the results by

  • fulfillment_network (String) (defaults to: nil)

    Optional parameter: Filters the

  • first_day_of_week (FirstDayOfWeek) (defaults to: nil)

    Optional parameter: Specifies

  • asin (String) (defaults to: nil)

    Optional parameter: Filters the results by the ASIN

  • sku (String) (defaults to: nil)

    Optional parameter: Filters the results by the SKU

  • sp_api_program (String) (defaults to: nil)

    Optional parameter: Filters the results by

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/walmart_ap_is/apis/sales_api.rb', line 67

def get_order_metrics(marketplace_ids,
                      interval,
                      granularity,
                      granularity_time_zone: nil,
                      buyer_type: nil,
                      fulfillment_network: nil,
                      first_day_of_week: nil,
                      asin: nil,
                      sku: nil,
                      sp_api_program: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/sales/v4/orderMetrics',
                                 Server::DEFAULT1)
               .query_param(new_parameter(marketplace_ids, key: 'marketplaceIds')
                             .is_required(true))
               .query_param(new_parameter(interval, key: 'interval')
                             .is_required(true))
               .query_param(new_parameter(granularity, key: 'granularity')
                             .is_required(true))
               .query_param(new_parameter(granularity_time_zone, key: 'granularityTimeZone'))
               .query_param(new_parameter(buyer_type, key: 'buyerType'))
               .query_param(new_parameter(fulfillment_network, key: 'fulfillmentNetwork'))
               .query_param(new_parameter(first_day_of_week, key: 'firstDayOfWeek'))
               .query_param(new_parameter(asin, key: 'asin'))
               .query_param(new_parameter(sku, key: 'sku'))
               .query_param(new_parameter(sp_api_program, key: 'sp-apiProgram'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('walletAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             ErrorListErrorException)
                .local_error('403',
                             'Forbidden',
                             ErrorListErrorException)
                .local_error('404',
                             'Not Found',
                             ErrorListErrorException)
                .local_error('429',
                             'Rate limit exceeded',
                             ErrorListErrorException)
                .local_error('500',
                             'Internal Server Error',
                             ErrorListErrorException))
    .execute
end