From 8080ba519006f10f473524f76a583f13cf964b9d Mon Sep 17 00:00:00 2001
From: Hakan Ensari <hakanensari@gmail.com>
Date: Thu, 12 Sep 2024 15:02:40 +0200
Subject: [PATCH] Round delays

---
 bin/templates/api.rb.erb                      |  2 +-
 .../api/application_management_2023_11_30.rb  |  2 +-
 lib/peddler/api/data_kiosk_2023_11_15.rb      |  8 ++---
 lib/peddler/api/feeds_2021_06_30.rb           |  6 ++--
 lib/peddler/api/orders_v0.rb                  |  2 +-
 lib/peddler/api/product_pricing_2022_05_01.rb |  4 +--
 lib/peddler/api/reports_2021_06_30.rb         | 16 ++++-----
 lib/peddler/api/shipment_invoicing_v0.rb      |  6 ++--
 lib/peddler/api/shipping_v2.rb                | 34 +++++++++----------
 9 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/bin/templates/api.rb.erb b/bin/templates/api.rb.erb
index 8e805334..cf12468b 100644
--- a/bin/templates/api.rb.erb
+++ b/bin/templates/api.rb.erb
@@ -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(2) %>, retry_statuses: [429]).<%= http_method %>(<%= method_args.join(", ") %>)
           <% else %>
             <%= http_method %>(<%= method_args.join(", ") %>)
           <% end %>
diff --git a/lib/peddler/api/application_management_2023_11_30.rb b/lib/peddler/api/application_management_2023_11_30.rb
index 1f9ff112..b1f8c670 100644
--- a/lib/peddler/api/application_management_2023_11_30.rb
+++ b/lib/peddler/api/application_management_2023_11_30.rb
@@ -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.88, retry_statuses: [429]).post(path)
       end
     end
   end
diff --git a/lib/peddler/api/data_kiosk_2023_11_15.rb b/lib/peddler/api/data_kiosk_2023_11_15.rb
index 353ed470..76e1b1ee 100644
--- a/lib/peddler/api/data_kiosk_2023_11_15.rb
+++ b/lib/peddler/api/data_kiosk_2023_11_15.rb
@@ -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.05, retry_statuses: [429]).get(path, params:)
       end
 
       # Creates a Data Kiosk query request.
@@ -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.88, retry_statuses: [429]).post(path, body:)
       end
 
       # Cancels the query specified by the `queryId` parameter. Only queries with a non-terminal `processingStatus`
@@ -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.05, retry_statuses: [429]).delete(path)
       end
 
       # Returns query details for the query specified by the `queryId` parameter. See the `createQuery` operation for
@@ -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.88, retry_statuses: [429]).get(path)
       end
     end
   end
diff --git a/lib/peddler/api/feeds_2021_06_30.rb b/lib/peddler/api/feeds_2021_06_30.rb
index 27af2f9a..76622062 100644
--- a/lib/peddler/api/feeds_2021_06_30.rb
+++ b/lib/peddler/api/feeds_2021_06_30.rb
@@ -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.05, retry_statuses: [429]).get(path, params:)
       end
 
       # Creates a feed. Upload the contents of the feed document before calling this operation.
@@ -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.48, retry_statuses: [429]).post(path, body:)
       end
 
       # Cancels the feed that you specify. Only feeds with `processingStatus=IN_QUEUE` can be cancelled. Cancelled feeds
@@ -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.05, retry_statuses: [429]).get(path)
       end
     end
   end
diff --git a/lib/peddler/api/orders_v0.rb b/lib/peddler/api/orders_v0.rb
index 70bcdddf..842898bd 100644
--- a/lib/peddler/api/orders_v0.rb
+++ b/lib/peddler/api/orders_v0.rb
@@ -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.88, retry_statuses: [429]).get(path, params:)
       end
 
       # Returns the order that you specify.
diff --git a/lib/peddler/api/product_pricing_2022_05_01.rb b/lib/peddler/api/product_pricing_2022_05_01.rb
index 9769279e..d6b6df97 100644
--- a/lib/peddler/api/product_pricing_2022_05_01.rb
+++ b/lib/peddler/api/product_pricing_2022_05_01.rb
@@ -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`
@@ -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
diff --git a/lib/peddler/api/reports_2021_06_30.rb b/lib/peddler/api/reports_2021_06_30.rb
index 664c6242..b59ded2b 100644
--- a/lib/peddler/api/reports_2021_06_30.rb
+++ b/lib/peddler/api/reports_2021_06_30.rb
@@ -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.05, retry_statuses: [429]).get(path, params:)
       end
 
       # Creates a report.
@@ -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.88, retry_statuses: [429]).post(path, body:)
       end
 
       # Cancels the report that you specify. Only reports with `processingStatus=IN_QUEUE` can be cancelled. Cancelled
@@ -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.05, retry_statuses: [429]).delete(path)
       end
 
       # Returns report details (including the `reportDocumentId`, if available) for the report that you specify.
@@ -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.05, 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
@@ -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.05, retry_statuses: [429]).post(path, body:)
       end
 
       # Cancels the report schedule that you specify.
@@ -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.05, retry_statuses: [429]).delete(path)
       end
 
       # Returns report schedule details for the report schedule that you specify.
@@ -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.05, retry_statuses: [429]).get(path)
       end
 
       # Returns the information required for retrieving a report document's contents.
@@ -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.88, retry_statuses: [429]).get(path)
       end
     end
   end
diff --git a/lib/peddler/api/shipment_invoicing_v0.rb b/lib/peddler/api/shipment_invoicing_v0.rb
index 5033d8a0..70e1af25 100644
--- a/lib/peddler/api/shipment_invoicing_v0.rb
+++ b/lib/peddler/api/shipment_invoicing_v0.rb
@@ -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.88, retry_statuses: [429]).get(path)
       end
 
       # Submits a shipment invoice document for a given shipment.
@@ -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.88, retry_statuses: [429]).post(path, body:)
       end
 
       # Returns the invoice status for the shipment you specify.
@@ -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.88, retry_statuses: [429]).get(path)
       end
     end
   end
diff --git a/lib/peddler/api/shipping_v2.rb b/lib/peddler/api/shipping_v2.rb
index e3332e8f..2b839117 100644
--- a/lib/peddler/api/shipping_v2.rb
+++ b/lib/peddler/api/shipping_v2.rb
@@ -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.01, retry_statuses: [429]).post(path, body:)
       end
 
       # Purchases the shipping service for a shipment using the best fit service offering. Returns purchase related
@@ -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.01, retry_statuses: [429]).post(path, body:)
       end
 
       # Purchases a shipping service and returns purchase related details and documents. Note: You must complete the
@@ -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.01, retry_statuses: [429]).post(path, body:)
       end
 
       # Purchases a shipping service identifier and returns purchase-related details and documents.
@@ -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.01, retry_statuses: [429]).post(path, body:)
       end
 
       # Returns tracking information for a purchased shipment.
@@ -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.01, retry_statuses: [429]).get(path, params:)
       end
 
       # Returns the shipping documents associated with a package in a shipment.
@@ -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.01, retry_statuses: [429]).get(path, params:)
       end
 
       # Cancels a purchased shipment. Returns an empty object if the shipment is successfully cancelled.
@@ -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.01, retry_statuses: [429]).put(path)
       end
 
       # Returns the JSON schema to use for providing additional inputs when needed to purchase a shipping offering. Call
@@ -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.01, 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.
@@ -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.01, retry_statuses: [429]).get(path)
       end
 
       # This API will return Get all carrier accounts for a merchant.
@@ -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.01, retry_statuses: [429]).put(path, body:)
       end
 
       # This API associates/links the specified carrier account with the merchant.
@@ -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.01, retry_statuses: [429]).put(path, body:)
       end
 
       # This API Unlink the specified carrier account with the merchant.
@@ -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.01, retry_statuses: [429]).put(path, body:)
       end
 
       # This API Call to generate the collection form.
@@ -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.01, retry_statuses: [429]).post(path, body:)
       end
 
       # This API Call to get the history of the previously generated collection forms.
@@ -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.01, retry_statuses: [429]).put(path, body:)
       end
 
       # This API Get all unmanifested carriers with shipment locations. Any locations which has unmanifested shipments
@@ -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.01, retry_statuses: [429]).put(path, body:)
       end
 
       # This API reprint a collection form.
@@ -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.01, retry_statuses: [429]).get(path)
       end
 
       # Returns a list of access points in proximity of input postal code.
@@ -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.01, retry_statuses: [429]).get(path, params:)
       end
     end
   end