lib/peddler/api/vendor_orders_v1.rb in peddler-3.0.0.beta1 vs lib/peddler/api/vendor_orders_v1.rb in peddler-3.0.0

- old
+ new

@@ -1,10 +1,16 @@ # frozen_string_literal: true require "peddler/api" module Peddler + class << self + def vendor_orders_v1(...) + API::VendorOrdersV1.new(...) + end + end + class API # Selling Partner API for Retail Procurement Orders # # The Selling Partner API for Retail Procurement Orders provides programmatic access to vendor orders data. class VendorOrdersV1 < API @@ -12,41 +18,41 @@ # frame using the `createdAfter`, `createdBefore`, `changedAfter` and `changedBefore` parameters. The date range # to search must not be more than 7 days. You can choose to get only the purchase order numbers by setting # `includeDetails` to false. You can then use the `getPurchaseOrder` operation to receive details for a specific # purchase order. # - # @param [Integer] limit The limit to the number of records returned. Default value is 100 records. - # @param [String] created_after Purchase orders that became available after this time will be included in the + # @note This operation can make a static sandbox call. + # @param limit [Integer] The limit to the number of records returned. Default value is 100 records. + # @param created_after [String] Purchase orders that became available after this time will be included in the # result. Must be in ISO-8601 date/time format. - # @param [String] created_before Purchase orders that became available before this time will be included in the + # @param created_before [String] Purchase orders that became available before this time will be included in the # result. Must be in ISO-8601 date/time format. - # @param [String] sort_order Sort in ascending or descending order by purchase order creation date. - # @param [String] next_token Used for pagination when there is more purchase orders than the specified result size + # @param sort_order [String] Sort in ascending or descending order by purchase order creation date. + # @param next_token [String] Used for pagination when there is more purchase orders than the specified result size # limit. The token value is returned in the previous API call - # @param [String] include_details When true, returns purchase orders with complete details. Otherwise, only + # @param include_details [String] When true, returns purchase orders with complete details. Otherwise, only # purchase order numbers are returned. Default value is true. - # @param [String] changed_after Purchase orders that changed after this timestamp will be included in the result. + # @param changed_after [String] Purchase orders that changed after this timestamp will be included in the result. # Must be in ISO-8601 date/time format. - # @param [String] changed_before Purchase orders that changed before this timestamp will be included in the + # @param changed_before [String] Purchase orders that changed before this timestamp will be included in the # result. Must be in ISO-8601 date/time format. - # @param [String] po_item_state Current state of the purchase order item. If this value is Cancelled, this API + # @param po_item_state [String] Current state of the purchase order item. If this value is Cancelled, this API # will return purchase orders which have one or more items cancelled by Amazon with updated item quantity as # zero. - # @param [String] is_po_changed When true, returns purchase orders which were modified after the order was placed. + # @param is_po_changed [String] When true, returns purchase orders which were modified after the order was placed. # Vendors are required to pull the changed purchase order and fulfill the updated purchase order and not the # original one. Default value is false. - # @param [String] purchase_order_state Filters purchase orders based on the purchase order state. - # @param [String] ordering_vendor_code Filters purchase orders based on the specified ordering vendor code. This + # @param purchase_order_state [String] Filters purchase orders based on the purchase order state. + # @param ordering_vendor_code [String] Filters purchase orders based on the specified ordering vendor code. This # value should be same as 'sellingParty.partyId' in the purchase order. If not included in the filter, all # purchase orders for all of the vendor codes that exist in the vendor group used to authorize the API client # application are returned. + # @param rate_limit [Float] Requests per second # @return [Hash] The API response - def get_purchase_orders( - limit: nil, created_after: nil, created_before: nil, sort_order: nil, next_token: nil, include_details: nil, - changed_after: nil, changed_before: nil, po_item_state: nil, is_po_changed: nil, purchase_order_state: nil, - ordering_vendor_code: nil - ) + def get_purchase_orders(limit: nil, created_after: nil, created_before: nil, sort_order: nil, next_token: nil, + include_details: nil, changed_after: nil, changed_before: nil, po_item_state: nil, is_po_changed: nil, + purchase_order_state: nil, ordering_vendor_code: nil, rate_limit: 10.0) path = "/vendor/orders/v1/purchaseOrders" params = { "limit" => limit, "createdAfter" => created_after, "createdBefore" => created_before, @@ -59,73 +65,78 @@ "isPOChanged" => is_po_changed, "purchaseOrderState" => purchase_order_state, "orderingVendorCode" => ordering_vendor_code, }.compact - rate_limit(10.0).get(path, params:) + meter(rate_limit).get(path, params:) end # Returns a purchase order based on the `purchaseOrderNumber` value that you specify. # - # @param [String] purchase_order_number The purchase order identifier for the order that you want. Formatting + # @note This operation can make a static sandbox call. + # @param purchase_order_number [String] The purchase order identifier for the order that you want. Formatting # Notes: 8-character alpha-numeric code. + # @param rate_limit [Float] Requests per second # @return [Hash] The API response - def get_purchase_order(purchase_order_number) + def get_purchase_order(purchase_order_number, rate_limit: 10.0) path = "/vendor/orders/v1/purchaseOrders/#{purchase_order_number}" - rate_limit(10.0).get(path) + meter(rate_limit).get(path) end # Submits acknowledgements for one or more purchase orders. # - # @param [Hash] body + # @note This operation can make a static sandbox call. + # @param body [Hash] + # @param rate_limit [Float] Requests per second # @return [Hash] The API response - def submit_acknowledgement(body) + def submit_acknowledgement(body, rate_limit: 10.0) path = "/vendor/orders/v1/acknowledgements" - rate_limit(10.0).post(path, body:) + meter(rate_limit).post(path, body:) end # Returns purchase order statuses based on the filters that you specify. Date range to search must not be more # than 7 days. You can return a list of purchase order statuses using the available filters, or a single purchase # order status by providing the purchase order number. # - # @param [Integer] limit The limit to the number of records returned. Default value is 100 records. - # @param [String] sort_order Sort in ascending or descending order by purchase order creation date. - # @param [String] next_token Used for pagination when there are more purchase orders than the specified result + # @note This operation can make a static sandbox call. + # @param limit [Integer] The limit to the number of records returned. Default value is 100 records. + # @param sort_order [String] Sort in ascending or descending order by purchase order creation date. + # @param next_token [String] Used for pagination when there are more purchase orders than the specified result # size limit. - # @param [String] created_after Purchase orders that became available after this timestamp will be included in the + # @param created_after [String] Purchase orders that became available after this timestamp will be included in the # result. Must be in ISO-8601 date/time format. - # @param [String] created_before Purchase orders that became available before this timestamp will be included in + # @param created_before [String] Purchase orders that became available before this timestamp will be included in # the result. Must be in ISO-8601 date/time format. - # @param [String] updated_after Purchase orders for which the last purchase order update happened after this + # @param updated_after [String] Purchase orders for which the last purchase order update happened after this # timestamp will be included in the result. Must be in ISO-8601 date/time format. - # @param [String] updated_before Purchase orders for which the last purchase order update happened before this + # @param updated_before [String] Purchase orders for which the last purchase order update happened before this # timestamp will be included in the result. Must be in ISO-8601 date/time format. - # @param [String] purchase_order_number Provides purchase order status for the specified purchase order number. - # @param [String] purchase_order_status Filters purchase orders based on the specified purchase order status. If + # @param purchase_order_number [String] Provides purchase order status for the specified purchase order number. + # @param purchase_order_status [String] Filters purchase orders based on the specified purchase order status. If # not included in filter, this will return purchase orders for all statuses. - # @param [String] item_confirmation_status Filters purchase orders based on their item confirmation status. If the + # @param item_confirmation_status [String] Filters purchase orders based on their item confirmation status. If the # item confirmation status is not included in the filter, purchase orders for all confirmation statuses are # included. - # @param [String] item_receive_status Filters purchase orders based on the purchase order's item receive status. + # @param item_receive_status [String] Filters purchase orders based on the purchase order's item receive status. # If the item receive status is not included in the filter, purchase orders for all receive statuses are # included. - # @param [String] ordering_vendor_code Filters purchase orders based on the specified ordering vendor code. This + # @param ordering_vendor_code [String] Filters purchase orders based on the specified ordering vendor code. This # value should be same as 'sellingParty.partyId' in the purchase order. If not included in filter, all purchase # orders for all the vendor codes that exist in the vendor group used to authorize API client application are # returned. - # @param [String] ship_to_party_id Filters purchase orders for a specific buyer's Fulfillment Center/warehouse by + # @param ship_to_party_id [String] Filters purchase orders for a specific buyer's Fulfillment Center/warehouse by # providing ship to location id here. This value should be same as 'shipToParty.partyId' in the purchase order. # If not included in filter, this will return purchase orders for all the buyer's warehouses used for vendor # group purchase orders. + # @param rate_limit [Float] Requests per second # @return [Hash] The API response - def get_purchase_orders_status( - limit: nil, sort_order: nil, next_token: nil, created_after: nil, created_before: nil, updated_after: nil, - updated_before: nil, purchase_order_number: nil, purchase_order_status: nil, item_confirmation_status: nil, - item_receive_status: nil, ordering_vendor_code: nil, ship_to_party_id: nil - ) + def get_purchase_orders_status(limit: nil, sort_order: nil, next_token: nil, created_after: nil, + created_before: nil, updated_after: nil, updated_before: nil, purchase_order_number: nil, + purchase_order_status: nil, item_confirmation_status: nil, item_receive_status: nil, ordering_vendor_code: nil, + ship_to_party_id: nil, rate_limit: 10.0) path = "/vendor/orders/v1/purchaseOrdersStatus" params = { "limit" => limit, "sortOrder" => sort_order, "nextToken" => next_token, @@ -139,10 +150,10 @@ "itemReceiveStatus" => item_receive_status, "orderingVendorCode" => ordering_vendor_code, "shipToPartyId" => ship_to_party_id, }.compact - rate_limit(10.0).get(path, params:) + meter(rate_limit).get(path, params:) end end end end