From fef18f5ae4df53c1d2d33a952828da9c409ded9f Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Fri, 23 May 2025 13:24:57 -0600 Subject: [PATCH] fix: endpoint used for UPS create/update --- CHANGELOG.md | 4 + VERSION | 2 +- lib/easypost/services/carrier_account.rb | 19 ++--- ...erAccount_create_creates_a_UPS_account.yml | 36 ++++----- ...rAccount_update_updates_an_ups_account.yml | 78 +++++++++---------- 5 files changed, 67 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f8b35b8..e103ecc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v7.0.1 (2025-05-27) + +- Corrects the endpoint used for creating/updating UPS accounts + ## v7.0.0 (2025-04-28) See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-6x-to-70) for more details. diff --git a/VERSION b/VERSION index 66ce77b7..9fe9ff9d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.0.0 +7.0.1 diff --git a/lib/easypost/services/carrier_account.rb b/lib/easypost/services/carrier_account.rb index 00912555..bb52fc11 100644 --- a/lib/easypost/services/carrier_account.rb +++ b/lib/easypost/services/carrier_account.rb @@ -2,8 +2,10 @@ class EasyPost::Services::CarrierAccount < EasyPost::Services::Service CUSTOM_WORKFLOW_CARRIER_TYPES = %w[FedexAccount FedexSmartpostAccount].freeze - UPS_OAUTH_CARRIER_ACCOUNT_TYPES = %w[UpsAccount UpsMailInnovationsAccount UpsSurepostAccount].freeze - CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = %w[AmazonShippingAccount].freeze + CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = %w[ + AmazonShippingAccount UpsAccount UpsMailInnovationsAccount + UpsSurepostAccount + ].freeze MODEL_CLASS = EasyPost::Models::CarrierAccount # :nodoc: # Create a carrier account @@ -14,8 +16,6 @@ def create(params = {}) # For UPS and FedEx the endpoint is different create_url = if CUSTOM_WORKFLOW_CARRIER_TYPES.include?(carrier_account_type) 'carrier_accounts/register' - elsif UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(carrier_account_type) - 'ups_oauth_registrations' elsif CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type) 'carrier_accounts/register_oauth' else @@ -42,12 +42,7 @@ def all(params = {}) def update(id, params = {}) carrier_account = retrieve(id) wrapped_params = { select_top_layer_key(carrier_account[:type]).to_sym => params } - update_url = if UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(params[:type]) - 'ups_oauth_registrations/' - else - 'carrier_accounts/' - end - response = @client.make_request(:put, "#{update_url}#{id}", wrapped_params) + response = @client.make_request(:put, "carrier_accounts/#{id}", wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end @@ -64,9 +59,7 @@ def delete(id) # Select the top-layer key for the carrier account creation/update request based on the carrier type. def select_top_layer_key(carrier_account_type) - if UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(carrier_account_type) - 'ups_oauth_registrations' - elsif CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type) + if CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type) 'carrier_account_oauth_registrations' else 'carrier_account' diff --git a/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_create_creates_a_UPS_account.yml b/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_create_creates_a_UPS_account.yml index fb8df7c9..e50e73e3 100644 --- a/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_create_creates_a_UPS_account.yml +++ b/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_create_creates_a_UPS_account.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.easypost.com/v2/ups_oauth_registrations + uri: https://api.easypost.com/v2/carrier_accounts/register_oauth body: encoding: UTF-8 - string: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + string: '{"carrier_account_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -35,7 +35,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d574b4b467f94771e2ca041900520f14 + - 6be4a8f36830cb34e7873c1b0041a88c Cache-Control: - private, no-cache, no-store Pragma: @@ -45,27 +45,27 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.088219' + - '0.080785' Transfer-Encoding: - chunked X-Node: - - bigweb56nuq + - bigweb54nuq X-Version-Label: - - easypost-202504102051-85835c857e-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost X-Proxied: - - extlb2nuq 99aac35317 - - intlb3nuq 284c5d344a + - extlb1nuq 99aac35317 + - intlb3nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"ca_67413142c8ba4766aeb04a08ca3b1526","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-04-11T16:46:41Z","updated_at":"2025-04-11T16:46:41Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' - recorded_at: Fri, 11 Apr 2025 16:46:41 GMT + string: '{"id":"ca_328e7775414142a88731306d3735b317","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:23:32Z","updated_at":"2025-05-23T19:23:32Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' + recorded_at: Fri, 23 May 2025 19:23:32 GMT - request: method: delete - uri: https://api.easypost.com/v2/carrier_accounts/ca_67413142c8ba4766aeb04a08ca3b1526 + uri: https://api.easypost.com/v2/carrier_accounts/ca_328e7775414142a88731306d3735b317 body: encoding: US-ASCII string: '' @@ -98,7 +98,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d574b4b567f94771e2ca041c00520f57 + - 6be4a8f66830cb34e7873c1e0041a8ea Cache-Control: - private, no-cache, no-store Pragma: @@ -108,22 +108,22 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.144699' + - '0.080342' Transfer-Encoding: - chunked X-Node: - - bigweb58nuq + - bigweb34nuq X-Version-Label: - - easypost-202504102051-85835c857e-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost X-Proxied: - - extlb2nuq 99aac35317 - - intlb3nuq 284c5d344a + - extlb1nuq 99aac35317 + - intlb3nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 string: "{}" - recorded_at: Fri, 11 Apr 2025 16:46:41 GMT + recorded_at: Fri, 23 May 2025 19:23:32 GMT recorded_with: VCR 6.3.1 diff --git a/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_update_updates_an_ups_account.yml b/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_update_updates_an_ups_account.yml index 2b24d05a..4f50bcde 100644 --- a/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_update_updates_an_ups_account.yml +++ b/spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_update_updates_an_ups_account.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.easypost.com/v2/ups_oauth_registrations + uri: https://api.easypost.com/v2/carrier_accounts/register_oauth body: encoding: UTF-8 - string: '{"ups_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' + string: '{"carrier_account_oauth_registrations":{"type":"UpsAccount","account_number":"123456789"}}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -35,7 +35,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d044fa7666a7da6ae799d94000598cfb + - 6be4a8f46830cb35e7873c200041a96c Cache-Control: - private, no-cache, no-store Pragma: @@ -45,27 +45,27 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.126232' + - '0.077006' Transfer-Encoding: - chunked X-Node: - - bigweb41nuq + - bigweb33nuq X-Version-Label: - - easypost-202407291746-57ea285141-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost X-Proxied: - - extlb1nuq fa152d4755 - - intlb4nuq c0f5e722d1 + - extlb1nuq 99aac35317 + - intlb4nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"ca_0643d45ed239429baf127357177b0e93","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-29T18:07:38Z","updated_at":"2024-07-29T18:07:38Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' - recorded_at: Mon, 29 Jul 2024 18:07:38 GMT + string: '{"id":"ca_8d60e586beaf4f6b9079c4879c5a2b66","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:23:33Z","updated_at":"2025-05-23T19:23:33Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' + recorded_at: Fri, 23 May 2025 19:23:33 GMT - request: method: get - uri: https://api.easypost.com/v2/carrier_accounts/ca_0643d45ed239429baf127357177b0e93 + uri: https://api.easypost.com/v2/carrier_accounts/ca_8d60e586beaf4f6b9079c4879c5a2b66 body: encoding: US-ASCII string: '' @@ -98,7 +98,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d044fa7b66a7da6be799d94100598da9 + - 6be4a8f46830cb35e7873c3a0041a9e0 Cache-Control: - private, no-cache, no-store Pragma: @@ -108,32 +108,30 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.043159' + - '0.029181' Transfer-Encoding: - chunked X-Node: - - bigweb43nuq + - bigweb58nuq X-Version-Label: - - easypost-202407291746-57ea285141-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost - X-Canary: - - direct X-Proxied: - - extlb1nuq fa152d4755 - - intlb4nuq c0f5e722d1 + - extlb1nuq 99aac35317 + - intlb3nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"ca_0643d45ed239429baf127357177b0e93","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-29T18:07:38Z","updated_at":"2024-07-29T18:07:38Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' - recorded_at: Mon, 29 Jul 2024 18:07:39 GMT + string: '{"id":"ca_8d60e586beaf4f6b9079c4879c5a2b66","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:23:33Z","updated_at":"2025-05-23T19:23:33Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' + recorded_at: Fri, 23 May 2025 19:23:33 GMT - request: method: put - uri: https://api.easypost.com/v2/carrier_accounts/ca_0643d45ed239429baf127357177b0e93 + uri: https://api.easypost.com/v2/carrier_accounts/ca_8d60e586beaf4f6b9079c4879c5a2b66 body: encoding: UTF-8 - string: '{"ups_oauth_registrations":{"account_number":"987654321"}}' + string: '{"carrier_account_oauth_registrations":{"account_number":"987654321"}}' headers: Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -163,7 +161,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d044fa7a66a7da6be799d94200598e34 + - 6be4a8f16830cb35e7873c3d0041aa44 Cache-Control: - private, no-cache, no-store Pragma: @@ -173,27 +171,27 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.155147' + - '0.074220' Transfer-Encoding: - chunked X-Node: - - bigweb42nuq + - bigweb59nuq X-Version-Label: - - easypost-202407291746-57ea285141-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost X-Proxied: - - extlb1nuq fa152d4755 - - intlb3nuq c0f5e722d1 + - extlb1nuq 99aac35317 + - intlb4nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 - string: '{"id":"ca_0643d45ed239429baf127357177b0e93","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2024-07-29T18:07:38Z","updated_at":"2024-07-29T18:07:39Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' - recorded_at: Mon, 29 Jul 2024 18:07:39 GMT + string: '{"id":"ca_8d60e586beaf4f6b9079c4879c5a2b66","object":"CarrierAccount","type":"UpsAccount","clone":false,"created_at":"2025-05-23T19:23:33Z","updated_at":"2025-05-23T19:23:33Z","description":null,"reference":null,"billing_type":"carrier","readable":"UPS","logo":null,"fields":[],"credentials":{},"test_credentials":{}}' + recorded_at: Fri, 23 May 2025 19:23:33 GMT - request: method: delete - uri: https://api.easypost.com/v2/carrier_accounts/ca_0643d45ed239429baf127357177b0e93 + uri: https://api.easypost.com/v2/carrier_accounts/ca_8d60e586beaf4f6b9079c4879c5a2b66 body: encoding: US-ASCII string: '' @@ -226,7 +224,7 @@ http_interactions: Referrer-Policy: - strict-origin-when-cross-origin X-Ep-Request-Uuid: - - d044fa7a66a7da6ce799d94300598ecb + - 6be4a8f26830cb35e7873c400041aa9b Cache-Control: - private, no-cache, no-store Pragma: @@ -236,22 +234,22 @@ http_interactions: Content-Type: - application/json; charset=utf-8 X-Runtime: - - '0.075286' + - '0.115773' Transfer-Encoding: - chunked X-Node: - - bigweb42nuq + - bigweb36nuq X-Version-Label: - - easypost-202407291746-57ea285141-master + - easypost-202505231841-d89645a184-master X-Backend: - easypost X-Proxied: - - extlb1nuq fa152d4755 - - intlb3nuq c0f5e722d1 + - extlb1nuq 99aac35317 + - intlb3nuq 668d3fc830 Strict-Transport-Security: - max-age=31536000; includeSubDomains; preload body: encoding: UTF-8 string: "{}" - recorded_at: Mon, 29 Jul 2024 18:07:40 GMT -recorded_with: VCR 6.1.0 + recorded_at: Fri, 23 May 2025 19:23:34 GMT +recorded_with: VCR 6.3.1