From e894db52d7903d8f8814160990499b360f32d8ee Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 14:56:48 -0400 Subject: [PATCH 1/7] Adds new recommend_ship_date and estimate_delivery_date functions --- CHANGELOG.md | 1 + lib/easypost/client.rb | 1 + lib/easypost/models.rb | 1 + lib/easypost/models/smartrate.rb | 5 + lib/easypost/services.rb | 1 + lib/easypost/services/shipment.rb | 9 + lib/easypost/services/smartrate.rb | 21 +++ ...ta_for_each_of_the_Rates_of_a_shipment.yml | 59 +++---- ...ieve_recommend_ship_date_of_a_shipment.yml | 152 +++++++++++++++++ ...ta_for_each_of_the_Rates_of_a_shipment.yml | 154 ++++++++++++++++++ ...y_retrieve_the_estimated_delivery_date.yml | 66 ++++++++ ...er_on_retrieve_a_recommended_ship_date.yml | 66 ++++++++ spec/shipment_spec.rb | 12 ++ spec/smartrate_spec.rb | 37 +++++ spec/support/fixture.rb | 6 +- 15 files changed, 562 insertions(+), 29 deletions(-) create mode 100644 lib/easypost/models/smartrate.rb create mode 100644 lib/easypost/services/smartrate.rb create mode 100644 spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_recommend_ship_date_of_a_shipment.yml create mode 100644 spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml create mode 100644 spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml create mode 100644 spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml create mode 100644 spec/smartrate_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9689d346..d21c0b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next Release +- Adds new `shipment.recommend_ship_date`, `smartrate.recommend_ship_date`, and `smartrate.estimate_delivery_date` functions - Routes `UpsAccount`, `UpsMailInnovationsAccount`, and `UpsSurepostAccount` create/update requests to the new `/ups_oauth_registrations` endpoint - Starting `2024-08-05`, UPS accounts will require a new payload to register or update. See [UPS OAuth 2.0 Update](https://support.easypost.com/hc/en-us/articles/26635027512717-UPS-OAuth-2-0-Update?utm_medium=email&_hsenc=p2ANqtz-96MmFtWICOzy9sKRbbcZSiMovZSrY3MSX1_bgY9N3f9yLVfWQdLhjAGq-SmNcOnDIS6GYhZ0OApjDBrGkKyLLMx1z6_TFOVp6-wllhEFQINrkuRuc&_hsmi=313130292&utm_content=313130292&utm_source=hs_email) for more details diff --git a/lib/easypost/client.rb b/lib/easypost/client.rb index 81fc5356..bbb53625 100644 --- a/lib/easypost/client.rb +++ b/lib/easypost/client.rb @@ -56,6 +56,7 @@ def initialize(api_key:, read_timeout: 60, open_timeout: 30, api_base: 'https:// EasyPost::Services::Report, EasyPost::Services::ScanForm, EasyPost::Services::Shipment, + EasyPost::Services::Smartrate, EasyPost::Services::Tracker, EasyPost::Services::User, EasyPost::Services::Webhook, diff --git a/lib/easypost/models.rb b/lib/easypost/models.rb index 2f313b71..69005e44 100644 --- a/lib/easypost/models.rb +++ b/lib/easypost/models.rb @@ -29,6 +29,7 @@ module EasyPost::Models require_relative 'models/report' require_relative 'models/scan_form' require_relative 'models/shipment' +require_relative 'models/smartrate' require_relative 'models/tax_identifier' require_relative 'models/tracker' require_relative 'models/user' diff --git a/lib/easypost/models/smartrate.rb b/lib/easypost/models/smartrate.rb new file mode 100644 index 00000000..df9552b2 --- /dev/null +++ b/lib/easypost/models/smartrate.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +# The Smartrate object contains details about the smartrate requests. +class EasyPost::Models::Smartrate < EasyPost::Models::EasyPostObject +end diff --git a/lib/easypost/services.rb b/lib/easypost/services.rb index 8bb8bb71..c832607c 100644 --- a/lib/easypost/services.rb +++ b/lib/easypost/services.rb @@ -28,6 +28,7 @@ module EasyPost::Services require_relative 'services/report' require_relative 'services/scan_form' require_relative 'services/shipment' +require_relative 'services/smartrate' require_relative 'services/tracker' require_relative 'services/user' require_relative 'services/webhook' diff --git a/lib/easypost/services/shipment.rb b/lib/easypost/services/shipment.rb index fa163061..177eeb0a 100644 --- a/lib/easypost/services/shipment.rb +++ b/lib/easypost/services/shipment.rb @@ -118,4 +118,13 @@ def retrieve_estimated_delivery_date(id, planned_ship_date) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).rates end + + # Retrieve a recommended ship date for an existing Shipment via the Precision Shipping API, based on a specific desired delivery date. + def recommend_ship_date(id, desired_delivery_date) + url = "shipments/#{id}/smartrate/precision_shipping" + params = { desired_delivery_date: desired_delivery_date } + response = @client.make_request(:get, url, params) + + EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).rates + end end diff --git a/lib/easypost/services/smartrate.rb b/lib/easypost/services/smartrate.rb new file mode 100644 index 00000000..7b28bfb9 --- /dev/null +++ b/lib/easypost/services/smartrate.rb @@ -0,0 +1,21 @@ +class EasyPost::Services::Smartrate < EasyPost::Services::Service + MODEL_CLASS = EasyPost::Models::Smartrate + + # Retrieve the estimated delivery date of each carrier-service level combination via the + # Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. + def estimate_delivery_date(params = {}) + url = "/smartrate/deliver_by" + + response = @client.make_request(:post, url, params) + EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) + end + + # Retrieve a recommended ship date for each carrier-service level combination via the + # Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. + def recommend_ship_date(params = {}) + url = "/smartrate/deliver_on" + + response = @client.make_request(:post, url, params) + EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) + end +end diff --git a/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_estimated_delivery_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_estimated_delivery_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml index 9cd18930..cc6fff51 100644 --- a/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_estimated_delivery_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml +++ b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_estimated_delivery_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml @@ -39,7 +39,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - e77cdde865b01e80e78866890017183b + - b8e53c1f6690294ae79b817a0008626f Cache-Control: - private, no-cache, no-store Pragma: @@ -47,48 +47,51 @@ http_interactions: Expires: - '0' Location: - - "/api/v2/shipments/shp_6d61f56c728e4d369e06d364c6429a05" + - "/api/v2/shipments/shp_2595999354554916ab7a96acb14fc48f" Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.429253' + - '0.742424' Transfer-Encoding: - chunked X-Node: - - bigweb35nuq + - bigweb42nuq X-Version-Label: - - easypost-202401222120-581bacedf7-master + - easypost-202407111640-83b200930f-master X-Backend: - easypost X-Proxied: - - extlb2nuq 003ad9bca0 - - intlb2nuq 2d7a0b01d8 + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"created_at":"2024-01-23T20:16:00Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_91ae96a5fc1f4cf4aa4b69067df5686b","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: - field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_e94e4fa45aba4058809c9246a48712b3","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + string: '{"created_at":"2024-07-11T18:49:46Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_e94e4fa45aba4058809c9246a48712b3","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_c02da7bfb4264ea3bcb85c0f760d4a6e","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_b437adf5f4c64f3d8823d5ffa776a158","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: - field required"}],"mode":"test","options":{"label_format":"PNG","invoice_number":"123","currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":"123","status":"unknown","tracking_code":null,"updated_at":"2024-01-23T20:16:00Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":{"id":"cstinfo_a1e8ced13ace47068c77e129aa10397e","object":"CustomsInfo","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve - Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_d85a6cec35404ed2a5bdb85e6ecfa6b6","object":"CustomsItem","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","description":"Sweet - shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]},"from_address":{"id":"adr_399b19deba2c11ee814f3cecef1b359e","object":"Address","created_at":"2024-01-23T20:16:00+00:00","updated_at":"2024-01-23T20:16:00+00:00","name":"Jack + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_91ae96a5fc1f4cf4aa4b69067df5686b","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_b3781a40f76d4b94a70d2258e6d318c2","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"UPS","carrier_account_id":"ca_d05aecc4f5c9412283e2fdc65d117692","type":"rate_error","message":"Invalid + Access License number"},{"carrier":"UPS","carrier_account_id":"ca_533ac39596fc45809cf6685bbe55523a","type":"rate_error","message":"Invalid + Access License number"}],"mode":"test","options":{"label_format":"PNG","invoice_number":"123","currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":"123","status":"unknown","tracking_code":null,"updated_at":"2024-07-11T18:49:47Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":{"id":"cstinfo_bc5c3701a6b0495387ccd19135aa8abf","object":"CustomsInfo","created_at":"2024-07-11T18:49:46Z","updated_at":"2024-07-11T18:49:46Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_5216ee617d494a83a61e6639ea1fcd62","object":"CustomsItem","created_at":"2024-07-11T18:49:46Z","updated_at":"2024-07-11T18:49:46Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]},"from_address":{"id":"adr_581d817f3fb611efaf3d3cecef1b359e","object":"Address","created_at":"2024-07-11T18:49:46+00:00","updated_at":"2024-07-11T18:49:46+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San - Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":null,"order_id":null,"parcel":{"id":"prcl_d9ae63075cc2433bb01eaa32a177e707","object":"Parcel","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","length":10.0,"width":8.0,"height":4.0,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_47d73769b52841ca818262132a434226","object":"Rate","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.88","currency":"USD","retail_rate":"9.80","retail_currency":"USD","list_rate":"8.25","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_efe83f5404e74f10bbc7830ad439d205","object":"Rate","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_942ca0b84f384dc795a48f27c4d5cf77","object":"Rate","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_3f16f9af5aa74362a9b07e4ba99829da","object":"Rate","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_c0174810bf4d40eb9a8b3e0abd8cc470","object":"Rate","created_at":"2024-01-23T20:16:00Z","updated_at":"2024-01-23T20:16:00Z","mode":"test","service":"Express","carrier":"USPS","rate":"33.10","currency":"USD","retail_rate":"37.90","retail_currency":"USD","list_rate":"33.10","list_currency":"USD","billing_type":"easypost","delivery_days":null,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":null,"shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_399722a7ba2c11ee814d3cecef1b359e","object":"Address","created_at":"2024-01-23T20:16:00+00:00","updated_at":"2024-01-23T20:16:00+00:00","name":"Elizabeth + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":null,"order_id":null,"parcel":{"id":"prcl_9ff874dced4b44d99482a99462d2af52","object":"Parcel","created_at":"2024-07-11T18:49:46Z","updated_at":"2024-07-11T18:49:46Z","length":10.0,"width":8.0,"height":4.0,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_91b1cc943f1b41aba5d9873966b8f707","object":"Rate","created_at":"2024-07-11T18:49:47Z","updated_at":"2024-07-11T18:49:47Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.90","currency":"USD","retail_rate":"9.80","retail_currency":"USD","list_rate":"8.25","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_2595999354554916ab7a96acb14fc48f","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_245605e3ca37452f8c878fc07d22055b","object":"Rate","created_at":"2024-07-11T18:49:47Z","updated_at":"2024-07-11T18:49:47Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_2595999354554916ab7a96acb14fc48f","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_299d7a4d4bde417b8dca28647c9b30db","object":"Rate","created_at":"2024-07-11T18:49:47Z","updated_at":"2024-07-11T18:49:47Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_2595999354554916ab7a96acb14fc48f","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_85a56136be5c400898339afc959421c2","object":"Rate","created_at":"2024-07-11T18:49:47Z","updated_at":"2024-07-11T18:49:47Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_2595999354554916ab7a96acb14fc48f","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_091d7a6844034204a1b8d3ed9b143592","object":"Rate","created_at":"2024-07-11T18:49:47Z","updated_at":"2024-07-11T18:49:47Z","mode":"test","service":"Express","carrier":"USPS","rate":"33.10","currency":"USD","retail_rate":"37.90","retail_currency":"USD","list_rate":"33.10","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_2595999354554916ab7a96acb14fc48f","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_581a01da3fb611ef8287ac1f6bc53342","object":"Address","created_at":"2024-07-11T18:49:46+00:00","updated_at":"2024-07-11T18:49:46+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo - Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":4,"return_address":{"id":"adr_399b19deba2c11ee814f3cecef1b359e","object":"Address","created_at":"2024-01-23T20:16:00+00:00","updated_at":"2024-01-23T20:16:00+00:00","name":"Jack + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":4,"return_address":{"id":"adr_581d817f3fb611efaf3d3cecef1b359e","object":"Address","created_at":"2024-07-11T18:49:46+00:00","updated_at":"2024-07-11T18:49:46+00:00","name":"Jack Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San - Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_399722a7ba2c11ee814d3cecef1b359e","object":"Address","created_at":"2024-01-23T20:16:00+00:00","updated_at":"2024-01-23T20:16:00+00:00","name":"Elizabeth + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_581a01da3fb611ef8287ac1f6bc53342","object":"Address","created_at":"2024-07-11T18:49:46+00:00","updated_at":"2024-07-11T18:49:46+00:00","name":"Elizabeth Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo - Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[],"id":"shp_6d61f56c728e4d369e06d364c6429a05","object":"Shipment"}' - recorded_at: Tue, 23 Jan 2024 20:16:00 GMT + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[],"id":"shp_2595999354554916ab7a96acb14fc48f","object":"Shipment"}' + recorded_at: Thu, 11 Jul 2024 18:49:47 GMT - request: method: get - uri: https://api.easypost.com/v2/shipments/shp_6d61f56c728e4d369e06d364c6429a05/smartrate/delivery_date + uri: https://api.easypost.com/v2/shipments/shp_2595999354554916ab7a96acb14fc48f/smartrate/delivery_date body: encoding: UTF-8 - string: '{"planned_ship_date":"2024-01-25"}' + string: '{"planned_ship_date":"2024-07-16"}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -118,7 +121,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - e77cdde365b01e80e788668a001718c0 + - b8e53c1c6690294be79b817f0008635e Cache-Control: - private, no-cache, no-store Pragma: @@ -128,22 +131,22 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.252080' + - '0.147574' Transfer-Encoding: - chunked X-Node: - - bigweb42nuq + - bigweb34nuq X-Version-Label: - - easypost-202401222120-581bacedf7-master + - easypost-202407111640-83b200930f-master X-Backend: - easypost X-Proxied: - - extlb2nuq 003ad9bca0 - - intlb2nuq 2d7a0b01d8 + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"rates":[{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":5,"percentile_85":5,"percentile_90":5,"percentile_95":5,"percentile_97":6,"percentile_99":8},"easypost_estimated_delivery_date":"2024-01-27","planned_ship_date":"2024-01-25"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-01-23T20:16:00Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_47d73769b52841ca818262132a434226","list_currency":"USD","list_rate":8.25,"mode":"test","object":"Rate","rate":6.88,"retail_currency":"USD","retail_rate":9.8,"service":"Priority","shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","updated_at":"2024-01-23T20:16:00Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":5,"percentile_85":5,"percentile_90":5,"percentile_95":5,"percentile_97":6,"percentile_99":8},"easypost_estimated_delivery_date":"2024-01-27","planned_ship_date":"2024-01-25"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-01-23T20:16:00Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_efe83f5404e74f10bbc7830ad439d205","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"GroundAdvantage","shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","updated_at":"2024-01-23T20:16:00Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":5,"percentile_85":5,"percentile_90":5,"percentile_95":5,"percentile_97":6,"percentile_99":8},"easypost_estimated_delivery_date":"2024-01-27","planned_ship_date":"2024-01-25"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-01-23T20:16:00Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_942ca0b84f384dc795a48f27c4d5cf77","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"First","shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","updated_at":"2024-01-23T20:16:00Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":5,"percentile_85":5,"percentile_90":5,"percentile_95":5,"percentile_97":6,"percentile_99":8},"easypost_estimated_delivery_date":"2024-01-27","planned_ship_date":"2024-01-25"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-01-23T20:16:00Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_3f16f9af5aa74362a9b07e4ba99829da","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"ParcelSelect","shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","updated_at":"2024-01-23T20:16:00Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":1,"percentile_75":2,"percentile_85":2,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"easypost_estimated_delivery_date":"2024-01-26","planned_ship_date":"2024-01-25"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-01-23T20:16:00Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":null,"est_delivery_days":null,"id":"rate_c0174810bf4d40eb9a8b3e0abd8cc470","list_currency":"USD","list_rate":33.1,"mode":"test","object":"Rate","rate":33.1,"retail_currency":"USD","retail_rate":37.9,"service":"Express","shipment_id":"shp_6d61f56c728e4d369e06d364c6429a05","updated_at":"2024-01-23T20:16:00Z"}}]}' - recorded_at: Tue, 23 Jan 2024 20:16:01 GMT -recorded_with: VCR 6.2.0 + string: '{"rates":[{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":3,"percentile_95":4,"percentile_97":6,"percentile_99":7},"easypost_estimated_delivery_date":"2024-07-18","planned_ship_date":"2024-07-16"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:49:47Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_91b1cc943f1b41aba5d9873966b8f707","list_currency":"USD","list_rate":8.25,"mode":"test","object":"Rate","rate":6.9,"retail_currency":"USD","retail_rate":9.8,"service":"Priority","shipment_id":"shp_2595999354554916ab7a96acb14fc48f","updated_at":"2024-07-11T18:49:47Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18","planned_ship_date":"2024-07-16"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:49:47Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_245605e3ca37452f8c878fc07d22055b","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"GroundAdvantage","shipment_id":"shp_2595999354554916ab7a96acb14fc48f","updated_at":"2024-07-11T18:49:47Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18","planned_ship_date":"2024-07-16"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:49:47Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_299d7a4d4bde417b8dca28647c9b30db","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"First","shipment_id":"shp_2595999354554916ab7a96acb14fc48f","updated_at":"2024-07-11T18:49:47Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18","planned_ship_date":"2024-07-16"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:49:47Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_85a56136be5c400898339afc959421c2","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"ParcelSelect","shipment_id":"shp_2595999354554916ab7a96acb14fc48f","updated_at":"2024-07-11T18:49:47Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":1,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":6},"easypost_estimated_delivery_date":"2024-07-17","planned_ship_date":"2024-07-16"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:49:47Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_091d7a6844034204a1b8d3ed9b143592","list_currency":"USD","list_rate":33.1,"mode":"test","object":"Rate","rate":33.1,"retail_currency":"USD","retail_rate":37.9,"service":"Express","shipment_id":"shp_2595999354554916ab7a96acb14fc48f","updated_at":"2024-07-11T18:49:47Z"}}]}' + recorded_at: Thu, 11 Jul 2024 18:49:47 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_recommend_ship_date_of_a_shipment.yml b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_recommend_ship_date_of_a_shipment.yml new file mode 100644 index 00000000..617eba82 --- /dev/null +++ b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_recommend_ship_date_of_a_shipment.yml @@ -0,0 +1,152 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.easypost.com/v2/shipments + body: + encoding: UTF-8 + string: '{"shipment":{"from_address":{"name":"Jack Sparrow","street1":"388 Townsend + St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"},"to_address":{"name":"Elizabeth + Swan","street1":"179 N Harbor Dr","city":"Redondo Beach","state":"CA","zip":"90277","country":"US","email":"test@example.com","phone":"5555555555"},"parcel":{"length":10,"width":8,"height":4,"weight":15.4},"customs_info":{"eel_pfc":"NOEEI + 30.37(a)","customs_certify":true,"customs_signer":"Steve Brule","contents_type":"merchandise","contents_explanation":"","restriction_type":"none","non_delivery_option":"return","customs_items":[{"description":"Sweet + shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]},"options":{"label_format":"PNG","invoice_number":"123"},"reference":"123"}}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 201 + message: Created + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - b8e53c1c66902aaee786b3fc0009c2e2 + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Location: + - "/api/v2/shipments/shp_3d7216c496144494acf875f0a9555272" + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.641766' + Transfer-Encoding: + - chunked + X-Node: + - bigweb41nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Proxied: + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"created_at":"2024-07-11T18:55:42Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_c02da7bfb4264ea3bcb85c0f760d4a6e","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_b437adf5f4c64f3d8823d5ffa776a158","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_e94e4fa45aba4058809c9246a48712b3","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_91ae96a5fc1f4cf4aa4b69067df5686b","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_b3781a40f76d4b94a70d2258e6d318c2","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"UPS","carrier_account_id":"ca_533ac39596fc45809cf6685bbe55523a","type":"rate_error","message":"Invalid + Access License number"},{"carrier":"UPS","carrier_account_id":"ca_d05aecc4f5c9412283e2fdc65d117692","type":"rate_error","message":"Invalid + Access License number"}],"mode":"test","options":{"label_format":"PNG","invoice_number":"123","currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":"123","status":"unknown","tracking_code":null,"updated_at":"2024-07-11T18:55:42Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":{"id":"cstinfo_c3ad9eab71bf4cb299261a158e16ebc2","object":"CustomsInfo","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_d7f0b2f28d5c46c18b5dc0c3fbe1eb93","object":"CustomsItem","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]},"from_address":{"id":"adr_2c14b2853fb711ef985c3cecef1b359e","object":"Address","created_at":"2024-07-11T18:55:42+00:00","updated_at":"2024-07-11T18:55:42+00:00","name":"Jack + Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":null,"order_id":null,"parcel":{"id":"prcl_5d8f1e1f4b3b4081a40215015e38a1b5","object":"Parcel","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","length":10.0,"width":8.0,"height":4.0,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_bdfda26163de43878a65e0f456b30ddb","object":"Rate","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.90","currency":"USD","retail_rate":"9.80","retail_currency":"USD","list_rate":"8.25","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_3d7216c496144494acf875f0a9555272","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_475a7a2b833e401abe78bb26e3fda731","object":"Rate","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_3d7216c496144494acf875f0a9555272","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_253b47e9de5f4159ab4d1509adaf83cb","object":"Rate","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_3d7216c496144494acf875f0a9555272","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_565d5a7580f54504af994b65f969ac1b","object":"Rate","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_3d7216c496144494acf875f0a9555272","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_33de2fbd3f5340eebebb47338723a631","object":"Rate","created_at":"2024-07-11T18:55:42Z","updated_at":"2024-07-11T18:55:42Z","mode":"test","service":"Express","carrier":"USPS","rate":"33.10","currency":"USD","retail_rate":"37.90","retail_currency":"USD","list_rate":"33.10","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_3d7216c496144494acf875f0a9555272","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_2c11fef43fb711ef9ee4ac1f6bc539ae","object":"Address","created_at":"2024-07-11T18:55:42+00:00","updated_at":"2024-07-11T18:55:42+00:00","name":"Elizabeth + Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":4,"return_address":{"id":"adr_2c14b2853fb711ef985c3cecef1b359e","object":"Address","created_at":"2024-07-11T18:55:42+00:00","updated_at":"2024-07-11T18:55:42+00:00","name":"Jack + Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_2c11fef43fb711ef9ee4ac1f6bc539ae","object":"Address","created_at":"2024-07-11T18:55:42+00:00","updated_at":"2024-07-11T18:55:42+00:00","name":"Elizabeth + Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[],"id":"shp_3d7216c496144494acf875f0a9555272","object":"Shipment"}' + recorded_at: Thu, 11 Jul 2024 18:55:42 GMT +- request: + method: get + uri: https://api.easypost.com/v2/shipments/shp_3d7216c496144494acf875f0a9555272/smartrate/precision_shipping + body: + encoding: UTF-8 + string: '{"desired_delivery_date":"2024-07-16"}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 200 + message: OK + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - b8e53c2166902aafe786b4010009c40a + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.107390' + Transfer-Encoding: + - chunked + X-Node: + - bigweb53nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Proxied: + - extlb2nuq fa152d4755 + - intlb4nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"rates":[{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.19,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:55:42Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_bdfda26163de43878a65e0f456b30ddb","list_currency":"USD","list_rate":8.25,"mode":"test","object":"Rate","rate":6.9,"retail_currency":"USD","retail_rate":9.8,"service":"Priority","shipment_id":"shp_3d7216c496144494acf875f0a9555272","updated_at":"2024-07-11T18:55:42Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:55:42Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_475a7a2b833e401abe78bb26e3fda731","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"GroundAdvantage","shipment_id":"shp_3d7216c496144494acf875f0a9555272","updated_at":"2024-07-11T18:55:42Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:55:42Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_253b47e9de5f4159ab4d1509adaf83cb","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"First","shipment_id":"shp_3d7216c496144494acf875f0a9555272","updated_at":"2024-07-11T18:55:42Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:55:42Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_565d5a7580f54504af994b65f969ac1b","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"ParcelSelect","shipment_id":"shp_3d7216c496144494acf875f0a9555272","updated_at":"2024-07-11T18:55:42Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":7},"delivery_date_confidence":0.47,"desired_delivery_date":"2024-07-16","estimated_transit_days":1,"ship_on_date":"2024-07-15"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T18:55:42Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_33de2fbd3f5340eebebb47338723a631","list_currency":"USD","list_rate":33.1,"mode":"test","object":"Rate","rate":33.1,"retail_currency":"USD","retail_rate":37.9,"service":"Express","shipment_id":"shp_3d7216c496144494acf875f0a9555272","updated_at":"2024-07-11T18:55:42Z"}}]}' + recorded_at: Thu, 11 Jul 2024 18:55:43 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml new file mode 100644 index 00000000..01ada987 --- /dev/null +++ b/spec/cassettes/shipment/EasyPost_Services_Shipment_retrieve_recommend_ship_date_retrieve_time-in-transit_data_for_each_of_the_Rates_of_a_shipment.yml @@ -0,0 +1,154 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.easypost.com/v2/shipments + body: + encoding: UTF-8 + string: '{"shipment":{"from_address":{"name":"Jack Sparrow","street1":"388 Townsend + St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"},"to_address":{"name":"Elizabeth + Swan","street1":"179 N Harbor Dr","city":"Redondo Beach","state":"CA","zip":"90277","country":"US","email":"test@example.com","phone":"5555555555"},"parcel":{"length":10,"width":8,"height":4,"weight":15.4},"customs_info":{"eel_pfc":"NOEEI + 30.37(a)","customs_certify":true,"customs_signer":"Steve Brule","contents_type":"merchandise","contents_explanation":"","restriction_type":"none","non_delivery_option":"return","customs_items":[{"description":"Sweet + shirts","quantity":2,"weight":11,"value":23.25,"hs_tariff_number":"654321","origin_country":"US"}]},"options":{"label_format":"PNG","invoice_number":"123"},"reference":"123"}}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 201 + message: Created + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - c8b6f52b669018c5e799fa88004fc3e2 + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Location: + - "/api/v2/shipments/shp_065bac3d8c15493eb75320b9b0bf228b" + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.809710' + Transfer-Encoding: + - chunked + X-Node: + - bigweb43nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Canary: + - direct + X-Proxied: + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"created_at":"2024-07-11T17:39:17Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_b437adf5f4c64f3d8823d5ffa776a158","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_b3781a40f76d4b94a70d2258e6d318c2","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_e94e4fa45aba4058809c9246a48712b3","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_c02da7bfb4264ea3bcb85c0f760d4a6e","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"DhlEcs","carrier_account_id":"ca_91ae96a5fc1f4cf4aa4b69067df5686b","type":"rate_error","message":"shipment.customs_info.customs_items.0.code: + field required"},{"carrier":"UPS","carrier_account_id":"ca_533ac39596fc45809cf6685bbe55523a","type":"rate_error","message":"Invalid + Access License number"},{"carrier":"UPS","carrier_account_id":"ca_d05aecc4f5c9412283e2fdc65d117692","type":"rate_error","message":"Invalid + Access License number"}],"mode":"test","options":{"label_format":"PNG","invoice_number":"123","currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":"123","status":"unknown","tracking_code":null,"updated_at":"2024-07-11T17:39:18Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":{"id":"cstinfo_d49245ee6bc847d1803f8c6ccfaf48e6","object":"CustomsInfo","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","contents_explanation":"","contents_type":"merchandise","customs_certify":true,"customs_signer":"Steve + Brule","eel_pfc":"NOEEI 30.37(a)","non_delivery_option":"return","restriction_comments":null,"restriction_type":"none","mode":"test","declaration":null,"customs_items":[{"id":"cstitem_e8a15e830b364bd6b7c1b30894b11fc4","object":"CustomsItem","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","description":"Sweet + shirts","hs_tariff_number":"654321","origin_country":"US","quantity":2,"value":"23.25","weight":11.0,"code":null,"mode":"test","manufacturer":null,"currency":null,"eccn":null,"printed_commodity_identifier":null}]},"from_address":{"id":"adr_7f325c0b3fac11efa4973cecef1b359e","object":"Address","created_at":"2024-07-11T17:39:17+00:00","updated_at":"2024-07-11T17:39:17+00:00","name":"Jack + Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":null,"order_id":null,"parcel":{"id":"prcl_a78b295cffce40dd8efc8f00b6ef0a34","object":"Parcel","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","length":10.0,"width":8.0,"height":4.0,"predefined_package":null,"weight":15.4,"mode":"test"},"postage_label":null,"rates":[{"id":"rate_70c5de1766b5432cbfca5487b821287a","object":"Rate","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","mode":"test","service":"Priority","carrier":"USPS","rate":"6.90","currency":"USD","retail_rate":"9.80","retail_currency":"USD","list_rate":"8.25","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_fe393bafef834f40bf174b54f5d86b1c","object":"Rate","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_88b41ef6bd65468cadc9e46e875d45a3","object":"Rate","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","mode":"test","service":"First","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_ce40c2866fb747c388d5c56bc2d4590f","object":"Rate","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","mode":"test","service":"ParcelSelect","carrier":"USPS","rate":"5.93","currency":"USD","retail_rate":"8.45","retail_currency":"USD","list_rate":"6.40","list_currency":"USD","billing_type":"easypost","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":3,"shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"},{"id":"rate_978819ef5ee64fe1a0a552f90e12ba53","object":"Rate","created_at":"2024-07-11T17:39:17Z","updated_at":"2024-07-11T17:39:17Z","mode":"test","service":"Express","carrier":"USPS","rate":"33.10","currency":"USD","retail_rate":"37.90","retail_currency":"USD","list_rate":"33.10","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_7f2fe56b3fac11efbbeeac1f6bc53342","object":"Address","created_at":"2024-07-11T17:39:17+00:00","updated_at":"2024-07-11T17:39:17+00:00","name":"Elizabeth + Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":4,"return_address":{"id":"adr_7f325c0b3fac11efa4973cecef1b359e","object":"Address","created_at":"2024-07-11T17:39:17+00:00","updated_at":"2024-07-11T17:39:17+00:00","name":"Jack + Sparrow","company":null,"street1":"388 Townsend St","street2":"Apt 20","city":"San + Francisco","state":"CA","zip":"94107","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_7f2fe56b3fac11efbbeeac1f6bc53342","object":"Address","created_at":"2024-07-11T17:39:17+00:00","updated_at":"2024-07-11T17:39:17+00:00","name":"Elizabeth + Swan","company":null,"street1":"179 N Harbor Dr","street2":null,"city":"Redondo + Beach","state":"CA","zip":"90277","country":"US","phone":"","email":"","mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[],"id":"shp_065bac3d8c15493eb75320b9b0bf228b","object":"Shipment"}' + recorded_at: Thu, 11 Jul 2024 17:39:18 GMT +- request: + method: get + uri: https://api.easypost.com/v2/shipments/shp_065bac3d8c15493eb75320b9b0bf228b/smartrate/precision_shipping + body: + encoding: UTF-8 + string: '{"desired_delivery_date":"2024-07-16"}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 200 + message: OK + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - c8b6f531669018c6e799faa5004fc525 + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.240310' + Transfer-Encoding: + - chunked + X-Node: + - bigweb38nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Proxied: + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"rates":[{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.19,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T17:39:17Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_70c5de1766b5432cbfca5487b821287a","list_currency":"USD","list_rate":8.25,"mode":"test","object":"Rate","rate":6.9,"retail_currency":"USD","retail_rate":9.8,"service":"Priority","shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","updated_at":"2024-07-11T17:39:17Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T17:39:17Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_fe393bafef834f40bf174b54f5d86b1c","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"GroundAdvantage","shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","updated_at":"2024-07-11T17:39:17Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T17:39:17Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_88b41ef6bd65468cadc9e46e875d45a3","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"First","shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","updated_at":"2024-07-11T17:39:17Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"desired_delivery_date":"2024-07-16","estimated_transit_days":3,"ship_on_date":"2024-07-13"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T17:39:17Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":3,"est_delivery_days":3,"id":"rate_ce40c2866fb747c388d5c56bc2d4590f","list_currency":"USD","list_rate":6.4,"mode":"test","object":"Rate","rate":5.93,"retail_currency":"USD","retail_rate":8.45,"service":"ParcelSelect","shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","updated_at":"2024-07-11T17:39:17Z"}},{"easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":7},"delivery_date_confidence":0.47,"desired_delivery_date":"2024-07-16","estimated_transit_days":1,"ship_on_date":"2024-07-15"},"rate":{"carrier":"USPS","carrier_account_id":"ca_716f33fd9fd348238b85c2922237f98b","created_at":"2024-07-11T17:39:17Z","currency":"USD","delivery_date":null,"delivery_date_guaranteed":false,"delivery_days":2,"est_delivery_days":2,"id":"rate_978819ef5ee64fe1a0a552f90e12ba53","list_currency":"USD","list_rate":33.1,"mode":"test","object":"Rate","rate":33.1,"retail_currency":"USD","retail_rate":37.9,"service":"Express","shipment_id":"shp_065bac3d8c15493eb75320b9b0bf228b","updated_at":"2024-07-11T17:39:17Z"}}]}' + recorded_at: Thu, 11 Jul 2024 17:39:18 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml b/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml new file mode 100644 index 00000000..6577a0f9 --- /dev/null +++ b/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml @@ -0,0 +1,66 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.easypost.com/v2/smartrate/deliver_by + body: + encoding: UTF-8 + string: '{"from_zip":"94107","to_zip":"90277","planned_ship_date":"2024-07-16","carriers":["USPS"]}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 200 + message: OK + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - b8e53c2366902919e79b13ec00082fef + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.077908' + Transfer-Encoding: + - chunked + X-Node: + - bigweb34nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Proxied: + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"carriers_without_tint_estimates":null,"from_zip":"94107","planned_ship_date":"2024-07-16","results":[{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":1,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":6},"easypost_estimated_delivery_date":"2024-07-17"},"service":"express"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"groundadvantage"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":3,"percentile_75":3,"percentile_85":3,"percentile_90":6,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"librarymail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":3,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"mediamail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":3,"percentile_95":4,"percentile_97":6,"percentile_99":7},"easypost_estimated_delivery_date":"2024-07-18"},"service":"priority"}],"saturday_delivery":null,"to_zip":"90277"}' + recorded_at: Thu, 11 Jul 2024 18:48:57 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml b/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml new file mode 100644 index 00000000..791da4eb --- /dev/null +++ b/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml @@ -0,0 +1,66 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.easypost.com/v2/smartrate/deliver_on + body: + encoding: UTF-8 + string: '{"from_zip":"94107","to_zip":"90277","desired_delivery_date":"2024-07-16","carriers":["USPS"]}' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: "" + Host: + - api.easypost.com + Content-Type: + - application/json + Authorization: "" + response: + status: + code: 200 + message: OK + headers: + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Permitted-Cross-Domain-Policies: + - none + Referrer-Policy: + - strict-origin-when-cross-origin + X-Ep-Request-Uuid: + - b8e53c1d66902a39e779a00d000947e8 + Cache-Control: + - private, no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Type: + - application/json; charset=utf-8 + X-Runtime: + - '0.069828' + Transfer-Encoding: + - chunked + X-Node: + - bigweb42nuq + X-Version-Label: + - easypost-202407111640-83b200930f-master + X-Backend: + - easypost + X-Proxied: + - extlb2nuq fa152d4755 + - intlb3nuq fa152d4755 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + body: + encoding: UTF-8 + string: '{"carriers_without_tint_estimates":null,"desired_delivery_date":"2024-07-16","from_zip":"94107","results":[{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":7},"delivery_date_confidence":0.47,"estimated_transit_days":1,"ship_on_date":"2024-07-15"},"service":"express"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"groundadvantage"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":6,"percentile_99":9},"delivery_date_confidence":0.25,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"librarymail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.24,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"mediamail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.19,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"priority"}],"saturday_delivery":null,"to_zip":"90277"}' + recorded_at: Thu, 11 Jul 2024 18:53:45 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/shipment_spec.rb b/spec/shipment_spec.rb index d617d8ef..301b6869 100644 --- a/spec/shipment_spec.rb +++ b/spec/shipment_spec.rb @@ -391,4 +391,16 @@ expect(estimated_delivery_dates.all?(&:easypost_time_in_transit_data)).not_to be_nil end end + + describe '.retrieve_recommend_ship_date' do + it 'retrieve recommend ship date of a shipment' do + shipment = client.shipment.create(Fixture.full_shipment) + rates = client.shipment.recommend_ship_date( + shipment.id, + Fixture.desired_delivery_date, + ) + + expect(rates.all?(&:easypost_time_in_transit_data)).not_to be_nil + end + end end diff --git a/spec/smartrate_spec.rb b/spec/smartrate_spec.rb new file mode 100644 index 00000000..ab7bb047 --- /dev/null +++ b/spec/smartrate_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe EasyPost::Services::Smartrate do + let(:client) { EasyPost::Client.new(api_key: ENV['EASYPOST_TEST_API_KEY']) } + + describe '.deliver_by' do + it 'retrieve the estimated delivery date' do + params = { + "from_zip": Fixture.ca_address1["zip"], + "to_zip": Fixture.ca_address2["zip"], + "planned_ship_date": Fixture.planned_ship_date, + "carriers": [Fixture.usps], + } + + rates = client.smartrate.estimate_delivery_date(params) + + expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil + end + end + + describe '.deliver_on' do + it 'retrieve a recommended ship date' do + params = { + "from_zip": Fixture.ca_address1["zip"], + "to_zip": Fixture.ca_address2["zip"], + "desired_delivery_date": Fixture.desired_delivery_date, + "carriers": [Fixture.usps], + } + + rates = client.smartrate.recommend_ship_date(params) + + expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil + end + end +end diff --git a/spec/support/fixture.rb b/spec/support/fixture.rb index b5a6d7f2..586f5ac1 100644 --- a/spec/support/fixture.rb +++ b/spec/support/fixture.rb @@ -144,6 +144,10 @@ def self.rma_form_options end def self.planned_ship_date - '2024-01-25' + '2024-07-16' + end + + def self.desired_delivery_date + '2024-07-16' end end From bc377138776a76a3090eea19162d4cc2c312c273 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 15:05:09 -0400 Subject: [PATCH 2/7] fix lint --- lib/easypost/services/smartrate.rb | 4 ++-- spec/smartrate_spec.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/easypost/services/smartrate.rb b/lib/easypost/services/smartrate.rb index 7b28bfb9..67306e15 100644 --- a/lib/easypost/services/smartrate.rb +++ b/lib/easypost/services/smartrate.rb @@ -4,7 +4,7 @@ class EasyPost::Services::Smartrate < EasyPost::Services::Service # Retrieve the estimated delivery date of each carrier-service level combination via the # Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. def estimate_delivery_date(params = {}) - url = "/smartrate/deliver_by" + url = '/smartrate/deliver_by' response = @client.make_request(:post, url, params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) @@ -13,7 +13,7 @@ def estimate_delivery_date(params = {}) # Retrieve a recommended ship date for each carrier-service level combination via the # Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. def recommend_ship_date(params = {}) - url = "/smartrate/deliver_on" + url = '/smartrate/deliver_on' response = @client.make_request(:post, url, params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) diff --git a/spec/smartrate_spec.rb b/spec/smartrate_spec.rb index ab7bb047..866c71aa 100644 --- a/spec/smartrate_spec.rb +++ b/spec/smartrate_spec.rb @@ -8,10 +8,10 @@ describe '.deliver_by' do it 'retrieve the estimated delivery date' do params = { - "from_zip": Fixture.ca_address1["zip"], - "to_zip": Fixture.ca_address2["zip"], - "planned_ship_date": Fixture.planned_ship_date, - "carriers": [Fixture.usps], + from_zip: Fixture.ca_address1['zip'], + to_zip: Fixture.ca_address2['zip'], + planned_ship_date: Fixture.planned_ship_date, + carriers: [Fixture.usps], } rates = client.smartrate.estimate_delivery_date(params) @@ -23,10 +23,10 @@ describe '.deliver_on' do it 'retrieve a recommended ship date' do params = { - "from_zip": Fixture.ca_address1["zip"], - "to_zip": Fixture.ca_address2["zip"], - "desired_delivery_date": Fixture.desired_delivery_date, - "carriers": [Fixture.usps], + from_zip: Fixture.ca_address1['zip'], + to_zip: Fixture.ca_address2['zip'], + desired_delivery_date: Fixture.desired_delivery_date, + carriers: [Fixture.usps], } rates = client.smartrate.recommend_ship_date(params) From ae575c33e692c0daaf3d8a5186e74a13fe1c78d9 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 15:06:34 -0400 Subject: [PATCH 3/7] lint --- spec/smartrate_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/smartrate_spec.rb b/spec/smartrate_spec.rb index 866c71aa..6e390b7c 100644 --- a/spec/smartrate_spec.rb +++ b/spec/smartrate_spec.rb @@ -15,7 +15,7 @@ } rates = client.smartrate.estimate_delivery_date(params) - + expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil end end @@ -30,7 +30,7 @@ } rates = client.smartrate.recommend_ship_date(params) - + expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil end end From 3936adab86fe2ba6cfe2a3dfc22621df03ece964 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 18:02:00 -0400 Subject: [PATCH 4/7] address feedback --- lib/easypost/client.rb | 2 +- lib/easypost/models/smartrate.rb | 4 ++-- lib/easypost/services/smartrate.rb | 8 ++++---- spec/smartrate_spec.rb | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/easypost/client.rb b/lib/easypost/client.rb index bbb53625..3f5eebb6 100644 --- a/lib/easypost/client.rb +++ b/lib/easypost/client.rb @@ -56,7 +56,7 @@ def initialize(api_key:, read_timeout: 60, open_timeout: 30, api_base: 'https:// EasyPost::Services::Report, EasyPost::Services::ScanForm, EasyPost::Services::Shipment, - EasyPost::Services::Smartrate, + EasyPost::Services::SmartRate, EasyPost::Services::Tracker, EasyPost::Services::User, EasyPost::Services::Webhook, diff --git a/lib/easypost/models/smartrate.rb b/lib/easypost/models/smartrate.rb index df9552b2..58986826 100644 --- a/lib/easypost/models/smartrate.rb +++ b/lib/easypost/models/smartrate.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -# The Smartrate object contains details about the smartrate requests. -class EasyPost::Models::Smartrate < EasyPost::Models::EasyPostObject +# The SmartRate object contains details about the SmartRate requests. +class EasyPost::Models::SmartRate < EasyPost::Models::EasyPostObject end diff --git a/lib/easypost/services/smartrate.rb b/lib/easypost/services/smartrate.rb index 67306e15..094b033b 100644 --- a/lib/easypost/services/smartrate.rb +++ b/lib/easypost/services/smartrate.rb @@ -1,10 +1,10 @@ -class EasyPost::Services::Smartrate < EasyPost::Services::Service - MODEL_CLASS = EasyPost::Models::Smartrate +class EasyPost::Services::SmartRate < EasyPost::Services::Service + MODEL_CLASS = EasyPost::Models::SmartRate # Retrieve the estimated delivery date of each carrier-service level combination via the # Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. def estimate_delivery_date(params = {}) - url = '/smartrate/deliver_by' + url = 'smartrate/deliver_by' response = @client.make_request(:post, url, params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) @@ -13,7 +13,7 @@ def estimate_delivery_date(params = {}) # Retrieve a recommended ship date for each carrier-service level combination via the # Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. def recommend_ship_date(params = {}) - url = '/smartrate/deliver_on' + url = 'smartrate/deliver_on' response = @client.make_request(:post, url, params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) diff --git a/spec/smartrate_spec.rb b/spec/smartrate_spec.rb index 6e390b7c..c76b9ad5 100644 --- a/spec/smartrate_spec.rb +++ b/spec/smartrate_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe EasyPost::Services::Smartrate do +describe EasyPost::Services::SmartRate do let(:client) { EasyPost::Client.new(api_key: ENV['EASYPOST_TEST_API_KEY']) } describe '.deliver_by' do @@ -14,7 +14,7 @@ carriers: [Fixture.usps], } - rates = client.smartrate.estimate_delivery_date(params) + rates = client.smart_rate.estimate_delivery_date(params) expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil end @@ -29,7 +29,7 @@ carriers: [Fixture.usps], } - rates = client.smartrate.recommend_ship_date(params) + rates = client.smart_rate.recommend_ship_date(params) expect(rates['results'].all? { |rate| rate['easypost_time_in_transit_data'] }).not_to be_nil end From 64bee4a5fde554ce3fb1bdce924a72181abaa881 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 18:05:23 -0400 Subject: [PATCH 5/7] re-record cassettee after rename --- lib/easypost/models.rb | 2 +- lib/easypost/models/{smartrate.rb => smart_rate.rb} | 0 ...iver_by_retrieve_the_estimated_delivery_date.yml} | 12 ++++++------ ..._deliver_on_retrieve_a_recommended_ship_date.yml} | 12 ++++++------ spec/{smartrate_spec.rb => smart_rate_spec.rb} | 0 5 files changed, 13 insertions(+), 13 deletions(-) rename lib/easypost/models/{smartrate.rb => smart_rate.rb} (100%) rename spec/cassettes/{smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml => smart_rate/EasyPost_Services_SmartRate_deliver_by_retrieve_the_estimated_delivery_date.yml} (93%) rename spec/cassettes/{smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml => smart_rate/EasyPost_Services_SmartRate_deliver_on_retrieve_a_recommended_ship_date.yml} (93%) rename spec/{smartrate_spec.rb => smart_rate_spec.rb} (100%) diff --git a/lib/easypost/models.rb b/lib/easypost/models.rb index 69005e44..94da512a 100644 --- a/lib/easypost/models.rb +++ b/lib/easypost/models.rb @@ -29,7 +29,7 @@ module EasyPost::Models require_relative 'models/report' require_relative 'models/scan_form' require_relative 'models/shipment' -require_relative 'models/smartrate' +require_relative 'models/smart_rate' require_relative 'models/tax_identifier' require_relative 'models/tracker' require_relative 'models/user' diff --git a/lib/easypost/models/smartrate.rb b/lib/easypost/models/smart_rate.rb similarity index 100% rename from lib/easypost/models/smartrate.rb rename to lib/easypost/models/smart_rate.rb diff --git a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml b/spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_by_retrieve_the_estimated_delivery_date.yml similarity index 93% rename from spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml rename to spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_by_retrieve_the_estimated_delivery_date.yml index 6577a0f9..77fd61ee 100644 --- a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_by_retrieve_the_estimated_delivery_date.yml +++ b/spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_by_retrieve_the_estimated_delivery_date.yml @@ -35,7 +35,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - b8e53c2366902919e79b13ec00082fef + - b8e53c1c669056cbe7873cbe0041fafa Cache-Control: - private, no-cache, no-store Pragma: @@ -45,22 +45,22 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.077908' + - '0.049003' Transfer-Encoding: - chunked X-Node: - - bigweb34nuq + - bigweb40nuq X-Version-Label: - - easypost-202407111640-83b200930f-master + - easypost-202407111940-3cb16a3462-master X-Backend: - easypost X-Proxied: - extlb2nuq fa152d4755 - - intlb3nuq fa152d4755 + - intlb4nuq fa152d4755 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 string: '{"carriers_without_tint_estimates":null,"from_zip":"94107","planned_ship_date":"2024-07-16","results":[{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":1,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":6},"easypost_estimated_delivery_date":"2024-07-17"},"service":"express"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"groundadvantage"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":3,"percentile_75":3,"percentile_85":3,"percentile_90":6,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"librarymail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":3,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":6,"percentile_97":6,"percentile_99":9},"easypost_estimated_delivery_date":"2024-07-18"},"service":"mediamail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":3,"percentile_95":4,"percentile_97":6,"percentile_99":7},"easypost_estimated_delivery_date":"2024-07-18"},"service":"priority"}],"saturday_delivery":null,"to_zip":"90277"}' - recorded_at: Thu, 11 Jul 2024 18:48:57 GMT + recorded_at: Thu, 11 Jul 2024 22:03:55 GMT recorded_with: VCR 6.1.0 diff --git a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml b/spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_on_retrieve_a_recommended_ship_date.yml similarity index 93% rename from spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml rename to spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_on_retrieve_a_recommended_ship_date.yml index 791da4eb..f3d16144 100644 --- a/spec/cassettes/smartrate/EasyPost_Services_Smartrate_deliver_on_retrieve_a_recommended_ship_date.yml +++ b/spec/cassettes/smart_rate/EasyPost_Services_SmartRate_deliver_on_retrieve_a_recommended_ship_date.yml @@ -35,7 +35,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - b8e53c1d66902a39e779a00d000947e8 + - b8e53c21669056cce7873cc50041fbdb Cache-Control: - private, no-cache, no-store Pragma: @@ -45,22 +45,22 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.069828' + - '0.054759' Transfer-Encoding: - chunked X-Node: - - bigweb42nuq + - bigweb53nuq X-Version-Label: - - easypost-202407111640-83b200930f-master + - easypost-202407111940-3cb16a3462-master X-Backend: - easypost X-Proxied: - extlb2nuq fa152d4755 - - intlb3nuq fa152d4755 + - intlb4nuq fa152d4755 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 string: '{"carriers_without_tint_estimates":null,"desired_delivery_date":"2024-07-16","from_zip":"94107","results":[{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":2,"percentile_85":2,"percentile_90":3,"percentile_95":3,"percentile_97":4,"percentile_99":7},"delivery_date_confidence":0.47,"estimated_transit_days":1,"ship_on_date":"2024-07-15"},"service":"express"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":9},"delivery_date_confidence":0.21,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"groundadvantage"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":6,"percentile_99":9},"delivery_date_confidence":0.25,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"librarymail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":3,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.24,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"mediamail"},{"carrier":"USPS","easypost_time_in_transit_data":{"days_in_transit":{"percentile_50":2,"percentile_75":3,"percentile_85":4,"percentile_90":4,"percentile_95":5,"percentile_97":5,"percentile_99":7},"delivery_date_confidence":0.19,"estimated_transit_days":3,"ship_on_date":"2024-07-13"},"service":"priority"}],"saturday_delivery":null,"to_zip":"90277"}' - recorded_at: Thu, 11 Jul 2024 18:53:45 GMT + recorded_at: Thu, 11 Jul 2024 22:03:56 GMT recorded_with: VCR 6.1.0 diff --git a/spec/smartrate_spec.rb b/spec/smart_rate_spec.rb similarity index 100% rename from spec/smartrate_spec.rb rename to spec/smart_rate_spec.rb From d0530ea75281c2e9c33c820c09eb3c877b00a2e1 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 18:06:54 -0400 Subject: [PATCH 6/7] another rename --- lib/easypost/services.rb | 2 +- lib/easypost/services/{smartrate.rb => smart_rate.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/easypost/services/{smartrate.rb => smart_rate.rb} (100%) diff --git a/lib/easypost/services.rb b/lib/easypost/services.rb index c832607c..8f3d4546 100644 --- a/lib/easypost/services.rb +++ b/lib/easypost/services.rb @@ -28,7 +28,7 @@ module EasyPost::Services require_relative 'services/report' require_relative 'services/scan_form' require_relative 'services/shipment' -require_relative 'services/smartrate' +require_relative 'services/smart_rate' require_relative 'services/tracker' require_relative 'services/user' require_relative 'services/webhook' diff --git a/lib/easypost/services/smartrate.rb b/lib/easypost/services/smart_rate.rb similarity index 100% rename from lib/easypost/services/smartrate.rb rename to lib/easypost/services/smart_rate.rb From 9110fa4cc831f4d7b73e6b7adff47e4594b990d2 Mon Sep 17 00:00:00 2001 From: jchen293 Date: Thu, 11 Jul 2024 18:46:26 -0400 Subject: [PATCH 7/7] remote smartrate model --- lib/easypost/models.rb | 1 - lib/easypost/models/smart_rate.rb | 5 ----- lib/easypost/services/smart_rate.rb | 6 ++---- 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 lib/easypost/models/smart_rate.rb diff --git a/lib/easypost/models.rb b/lib/easypost/models.rb index 94da512a..2f313b71 100644 --- a/lib/easypost/models.rb +++ b/lib/easypost/models.rb @@ -29,7 +29,6 @@ module EasyPost::Models require_relative 'models/report' require_relative 'models/scan_form' require_relative 'models/shipment' -require_relative 'models/smart_rate' require_relative 'models/tax_identifier' require_relative 'models/tracker' require_relative 'models/user' diff --git a/lib/easypost/models/smart_rate.rb b/lib/easypost/models/smart_rate.rb deleted file mode 100644 index 58986826..00000000 --- a/lib/easypost/models/smart_rate.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -# The SmartRate object contains details about the SmartRate requests. -class EasyPost::Models::SmartRate < EasyPost::Models::EasyPostObject -end diff --git a/lib/easypost/services/smart_rate.rb b/lib/easypost/services/smart_rate.rb index 094b033b..53eb1eb3 100644 --- a/lib/easypost/services/smart_rate.rb +++ b/lib/easypost/services/smart_rate.rb @@ -1,13 +1,11 @@ class EasyPost::Services::SmartRate < EasyPost::Services::Service - MODEL_CLASS = EasyPost::Models::SmartRate - # Retrieve the estimated delivery date of each carrier-service level combination via the # Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. def estimate_delivery_date(params = {}) url = 'smartrate/deliver_by' response = @client.make_request(:post, url, params) - EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) + EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject) end # Retrieve a recommended ship date for each carrier-service level combination via the @@ -16,6 +14,6 @@ def recommend_ship_date(params = {}) url = 'smartrate/deliver_on' response = @client.make_request(:post, url, params) - EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) + EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::EasyPostObject) end end