Skip to content

Commit

Permalink
Round delays
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Sep 12, 2024
1 parent bb1c39a commit 5cb0974
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion bin/templates/api.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Peddler
<% method_args << "params:" if operation["query_params"]&.any? %>
<% if operation["rate_limit"] %>
retriable(delay: <%= 1 / operation["rate_limit"] %>, retry_statuses: [429]).<%= http_method %>(<%= method_args.join(", ") %>)
retriable(delay: <%= (1 / operation["rate_limit"]).round(1) %>, retry_statuses: [429]).<%= http_method %>(<%= method_args.join(", ") %>)
<% else %>
<%= http_method %>(<%= method_args.join(", ") %>)
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion lib/peddler/api/application_management_2023_11_30.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ApplicationManagement20231130 < API
def rotate_application_client_secret
path = "/applications/2023-11-30/clientSecret"

retriable(delay: 59.880239520958085, retry_statuses: [429]).post(path)
retriable(delay: 59.9, retry_statuses: [429]).post(path)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/peddler/api/data_kiosk_2023_11_15.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_queries(processing_statuses: nil, page_size: nil, created_since: nil, cr
"paginationToken" => pagination_token,
}.compact

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path, params:)
retriable(delay: 45.0, retry_statuses: [429]).get(path, params:)
end

# Creates a Data Kiosk query request.
Expand All @@ -50,7 +50,7 @@ def create_query(body)
path = "/dataKiosk/2023-11-15/queries"
body = body

retriable(delay: 59.880239520958085, retry_statuses: [429]).post(path, body:)
retriable(delay: 59.9, retry_statuses: [429]).post(path, body:)
end

# Cancels the query specified by the `queryId` parameter. Only queries with a non-terminal `processingStatus`
Expand All @@ -64,7 +64,7 @@ def create_query(body)
def cancel_query(query_id)
path = "/dataKiosk/2023-11-15/queries/#{query_id}"

retriable(delay: 45.04504504504504, retry_statuses: [429]).delete(path)
retriable(delay: 45.0, retry_statuses: [429]).delete(path)
end

# Returns query details for the query specified by the `queryId` parameter. See the `createQuery` operation for
Expand All @@ -86,7 +86,7 @@ def get_query(query_id)
def get_document(document_id)
path = "/dataKiosk/2023-11-15/documents/#{document_id}"

retriable(delay: 59.880239520958085, retry_statuses: [429]).get(path)
retriable(delay: 59.9, retry_statuses: [429]).get(path)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/peddler/api/feeds_2021_06_30.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_feeds(feed_types: nil, marketplace_ids: nil, page_size: nil, processing_
"nextToken" => next_token,
}.compact

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path, params:)
retriable(delay: 45.0, retry_statuses: [429]).get(path, params:)
end

# Creates a feed. Upload the contents of the feed document before calling this operation.
Expand All @@ -50,7 +50,7 @@ def create_feed(body)
path = "/feeds/2021-06-30/feeds"
body = body

retriable(delay: 120.48192771084337, retry_statuses: [429]).post(path, body:)
retriable(delay: 120.5, retry_statuses: [429]).post(path, body:)
end

# Cancels the feed that you specify. Only feeds with `processingStatus=IN_QUEUE` can be cancelled. Cancelled feeds
Expand Down Expand Up @@ -99,7 +99,7 @@ def create_feed_document(body)
def get_feed_document(feed_document_id)
path = "/feeds/2021-06-30/documents/#{feed_document_id}"

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path)
retriable(delay: 45.0, retry_statuses: [429]).get(path)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/peddler/api/orders_v0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_orders(
"LatestDeliveryDateAfter" => latest_delivery_date_after,
}.compact

retriable(delay: 59.880239520958085, retry_statuses: [429]).get(path, params:)
retriable(delay: 59.9, retry_statuses: [429]).get(path, params:)
end

# Returns the order that you specify.
Expand Down
4 changes: 2 additions & 2 deletions lib/peddler/api/product_pricing_2022_05_01.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_featured_offer_expected_price_batch(get_featured_offer_expected_price_ba
path = "/batches/products/pricing/2022-05-01/offer/featuredOfferExpectedPrice"
body = get_featured_offer_expected_price_batch_request_body

retriable(delay: 30.3030303030303, retry_statuses: [429]).post(path, body:)
retriable(delay: 30.3, retry_statuses: [429]).post(path, body:)
end

# Returns the competitive summary response including featured buying options for the ASIN and `marketplaceId`
Expand All @@ -36,7 +36,7 @@ def get_competitive_summary(requests)
path = "/batches/products/pricing/2022-05-01/items/competitiveSummary"
body = requests

retriable(delay: 30.3030303030303, retry_statuses: [429]).post(path, body:)
retriable(delay: 30.3, retry_statuses: [429]).post(path, body:)
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/peddler/api/reports_2021_06_30.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_reports(report_types: nil, processing_statuses: nil, marketplace_ids: ni
"nextToken" => next_token,
}.compact

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path, params:)
retriable(delay: 45.0, retry_statuses: [429]).get(path, params:)
end

# Creates a report.
Expand All @@ -53,7 +53,7 @@ def create_report(body)
path = "/reports/2021-06-30/reports"
body = body

retriable(delay: 59.880239520958085, retry_statuses: [429]).post(path, body:)
retriable(delay: 59.9, retry_statuses: [429]).post(path, body:)
end

# Cancels the report that you specify. Only reports with `processingStatus=IN_QUEUE` can be cancelled. Cancelled
Expand All @@ -65,7 +65,7 @@ def create_report(body)
def cancel_report(report_id)
path = "/reports/2021-06-30/reports/#{report_id}"

retriable(delay: 45.04504504504504, retry_statuses: [429]).delete(path)
retriable(delay: 45.0, retry_statuses: [429]).delete(path)
end

# Returns report details (including the `reportDocumentId`, if available) for the report that you specify.
Expand All @@ -90,7 +90,7 @@ def get_report_schedules(report_types)
"reportTypes" => report_types,
}.compact

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path, params:)
retriable(delay: 45.0, retry_statuses: [429]).get(path, params:)
end

# Creates a report schedule. If a report schedule with the same report type and marketplace IDs already exists, it
Expand All @@ -102,7 +102,7 @@ def create_report_schedule(body)
path = "/reports/2021-06-30/schedules"
body = body

retriable(delay: 45.04504504504504, retry_statuses: [429]).post(path, body:)
retriable(delay: 45.0, retry_statuses: [429]).post(path, body:)
end

# Cancels the report schedule that you specify.
Expand All @@ -113,7 +113,7 @@ def create_report_schedule(body)
def cancel_report_schedule(report_schedule_id)
path = "/reports/2021-06-30/schedules/#{report_schedule_id}"

retriable(delay: 45.04504504504504, retry_statuses: [429]).delete(path)
retriable(delay: 45.0, retry_statuses: [429]).delete(path)
end

# Returns report schedule details for the report schedule that you specify.
Expand All @@ -124,7 +124,7 @@ def cancel_report_schedule(report_schedule_id)
def get_report_schedule(report_schedule_id)
path = "/reports/2021-06-30/schedules/##{report_schedule_id}"

retriable(delay: 45.04504504504504, retry_statuses: [429]).get(path)
retriable(delay: 45.0, retry_statuses: [429]).get(path)
end

# Returns the information required for retrieving a report document's contents.
Expand All @@ -134,7 +134,7 @@ def get_report_schedule(report_schedule_id)
def get_report_document(report_document_id)
path = "/reports/2021-06-30/documents/#{report_document_id}"

retriable(delay: 59.880239520958085, retry_statuses: [429]).get(path)
retriable(delay: 59.9, retry_statuses: [429]).get(path)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/peddler/api/services_v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ServicesV1 < API
def get_service_job_by_service_job_id(service_job_id)
path = "/service/v1/serviceJobs/#{service_job_id}"

retriable(delay: 0.05, retry_statuses: [429]).get(path)
retriable(delay: 0.1, retry_statuses: [429]).get(path)
end

# Cancels the service job indicated by the service job identifier specified.
Expand Down Expand Up @@ -300,7 +300,7 @@ def get_appointment_slots(asin, store_id, marketplace_ids, start_time: nil, end_
"endTime" => end_time,
}.compact

retriable(delay: 0.05, retry_statuses: [429]).get(path, params:)
retriable(delay: 0.1, retry_statuses: [429]).get(path, params:)
end

# Creates an upload destination.
Expand Down
6 changes: 3 additions & 3 deletions lib/peddler/api/shipment_invoicing_v0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ShipmentInvoicingV0 < API
def get_shipment_details(shipment_id)
path = "/fba/outbound/brazil/v0/shipments/#{shipment_id}"

retriable(delay: 0.8826125330979699, retry_statuses: [429]).get(path)
retriable(delay: 0.9, retry_statuses: [429]).get(path)
end

# Submits a shipment invoice document for a given shipment.
Expand All @@ -30,7 +30,7 @@ def submit_invoice(shipment_id, body)
path = "/fba/outbound/brazil/v0/shipments/#{shipment_id}/invoice"
body = body

retriable(delay: 0.8826125330979699, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.9, retry_statuses: [429]).post(path, body:)
end

# Returns the invoice status for the shipment you specify.
Expand All @@ -40,7 +40,7 @@ def submit_invoice(shipment_id, body)
def get_invoice_status(shipment_id)
path = "/fba/outbound/brazil/v0/shipments/#{shipment_id}/invoice/status"

retriable(delay: 0.8826125330979699, retry_statuses: [429]).get(path)
retriable(delay: 0.9, retry_statuses: [429]).get(path)
end
end
end
Expand Down
34 changes: 17 additions & 17 deletions lib/peddler/api/shipping_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_rates(body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/shipments/rates"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).post(path, body:)
end

# Purchases the shipping service for a shipment using the best fit service offering. Returns purchase related
Expand All @@ -39,7 +39,7 @@ def direct_purchase_shipment(body, x_amzn_idempotency_key: nil, locale: nil, x_a
path = "/shipping/v2/shipments/directPurchase"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).post(path, body:)
end

# Purchases a shipping service and returns purchase related details and documents. Note: You must complete the
Expand All @@ -57,7 +57,7 @@ def purchase_shipment(body, x_amzn_idempotency_key: nil, x_amzn_shipping_busines
path = "/shipping/v2/shipments"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).post(path, body:)
end

# Purchases a shipping service identifier and returns purchase-related details and documents.
Expand All @@ -70,7 +70,7 @@ def one_click_shipment(body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/oneClickShipment"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).post(path, body:)
end

# Returns tracking information for a purchased shipment.
Expand All @@ -89,7 +89,7 @@ def get_tracking(tracking_id, carrier_id, x_amzn_shipping_business_id: nil)
"carrierId" => carrier_id,
}.compact

retriable(delay: 0.0125, retry_statuses: [429]).get(path, params:)
retriable(delay: 0.0, retry_statuses: [429]).get(path, params:)
end

# Returns the shipping documents associated with a package in a shipment.
Expand All @@ -113,7 +113,7 @@ def get_shipment_documents(shipment_id, package_client_reference_id, format: nil
"dpi" => dpi,
}.compact

retriable(delay: 0.0125, retry_statuses: [429]).get(path, params:)
retriable(delay: 0.0, retry_statuses: [429]).get(path, params:)
end

# Cancels a purchased shipment. Returns an empty object if the shipment is successfully cancelled.
Expand All @@ -125,7 +125,7 @@ def get_shipment_documents(shipment_id, package_client_reference_id, format: nil
def cancel_shipment(shipment_id, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/shipments/#{shipment_id}/cancel"

retriable(delay: 0.0125, retry_statuses: [429]).put(path)
retriable(delay: 0.0, retry_statuses: [429]).put(path)
end

# Returns the JSON schema to use for providing additional inputs when needed to purchase a shipping offering. Call
Expand All @@ -145,7 +145,7 @@ def get_additional_inputs(request_token, rate_id, x_amzn_shipping_business_id: n
"rateId" => rate_id,
}.compact

retriable(delay: 0.0125, retry_statuses: [429]).get(path, params:)
retriable(delay: 0.0, retry_statuses: [429]).get(path, params:)
end

# This API will return a list of input schema required to register a shipper account with the carrier.
Expand All @@ -156,7 +156,7 @@ def get_additional_inputs(request_token, rate_id, x_amzn_shipping_business_id: n
def get_carrier_account_form_inputs(x_amzn_shipping_business_id: nil)
path = "/shipping/v2/carrierAccountFormInputs"

retriable(delay: 0.0125, retry_statuses: [429]).get(path)
retriable(delay: 0.0, retry_statuses: [429]).get(path)
end

# This API will return Get all carrier accounts for a merchant.
Expand All @@ -169,7 +169,7 @@ def get_carrier_accounts(body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/carrierAccounts"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).put(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).put(path, body:)
end

# This API associates/links the specified carrier account with the merchant.
Expand All @@ -183,7 +183,7 @@ def link_carrier_account(carrier_id, body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/carrierAccounts/#{carrier_id}"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).put(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).put(path, body:)
end

# This API Unlink the specified carrier account with the merchant.
Expand All @@ -197,7 +197,7 @@ def unlink_carrier_account(carrier_id, body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/carrierAccounts/#{carrier_id}/unlink"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).put(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).put(path, body:)
end

# This API Call to generate the collection form.
Expand All @@ -212,7 +212,7 @@ def generate_collection_form(body, x_amzn_idempotency_key: nil, x_amzn_shipping_
path = "/shipping/v2/collectionForms"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).post(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).post(path, body:)
end

# This API Call to get the history of the previously generated collection forms.
Expand All @@ -225,7 +225,7 @@ def get_collection_form_history(body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/collectionForms/history"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).put(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).put(path, body:)
end

# This API Get all unmanifested carriers with shipment locations. Any locations which has unmanifested shipments
Expand All @@ -239,7 +239,7 @@ def get_unmanifested_shipments(body, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/unmanifestedShipments"
body = body

retriable(delay: 0.0125, retry_statuses: [429]).put(path, body:)
retriable(delay: 0.0, retry_statuses: [429]).put(path, body:)
end

# This API reprint a collection form.
Expand All @@ -251,7 +251,7 @@ def get_unmanifested_shipments(body, x_amzn_shipping_business_id: nil)
def get_collection_form(collection_form_id, x_amzn_shipping_business_id: nil)
path = "/shipping/v2/collectionForms/#{collection_form_id}"

retriable(delay: 0.0125, retry_statuses: [429]).get(path)
retriable(delay: 0.0, retry_statuses: [429]).get(path)
end

# Returns a list of access points in proximity of input postal code.
Expand All @@ -270,7 +270,7 @@ def get_access_points(access_point_types, country_code, postal_code, x_amzn_ship
"postalCode" => postal_code,
}.compact

retriable(delay: 0.0125, retry_statuses: [429]).get(path, params:)
retriable(delay: 0.0, retry_statuses: [429]).get(path, params:)
end
end
end
Expand Down

0 comments on commit 5cb0974

Please sign in to comment.