Skip to content

Commit 1674223

Browse files
authored
Merge pull request #325 from EasyPost/ups_endpoint
fix: endpoint used for UPS create/update
2 parents bb20176 + fef18f5 commit 1674223

File tree

5 files changed

+67
-72
lines changed

5 files changed

+67
-72
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v7.0.1 (2025-05-27)
4+
5+
- Corrects the endpoint used for creating/updating UPS accounts
6+
37
## v7.0.0 (2025-04-28)
48

59
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-6x-to-70) for more details.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.0.0
1+
7.0.1

lib/easypost/services/carrier_account.rb

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
class EasyPost::Services::CarrierAccount < EasyPost::Services::Service
44
CUSTOM_WORKFLOW_CARRIER_TYPES = %w[FedexAccount FedexSmartpostAccount].freeze
5-
UPS_OAUTH_CARRIER_ACCOUNT_TYPES = %w[UpsAccount UpsMailInnovationsAccount UpsSurepostAccount].freeze
6-
CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = %w[AmazonShippingAccount].freeze
5+
CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = %w[
6+
AmazonShippingAccount UpsAccount UpsMailInnovationsAccount
7+
UpsSurepostAccount
8+
].freeze
79
MODEL_CLASS = EasyPost::Models::CarrierAccount # :nodoc:
810

911
# Create a carrier account
@@ -14,8 +16,6 @@ def create(params = {})
1416
# For UPS and FedEx the endpoint is different
1517
create_url = if CUSTOM_WORKFLOW_CARRIER_TYPES.include?(carrier_account_type)
1618
'carrier_accounts/register'
17-
elsif UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(carrier_account_type)
18-
'ups_oauth_registrations'
1919
elsif CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type)
2020
'carrier_accounts/register_oauth'
2121
else
@@ -42,12 +42,7 @@ def all(params = {})
4242
def update(id, params = {})
4343
carrier_account = retrieve(id)
4444
wrapped_params = { select_top_layer_key(carrier_account[:type]).to_sym => params }
45-
update_url = if UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(params[:type])
46-
'ups_oauth_registrations/'
47-
else
48-
'carrier_accounts/'
49-
end
50-
response = @client.make_request(:put, "#{update_url}#{id}", wrapped_params)
45+
response = @client.make_request(:put, "carrier_accounts/#{id}", wrapped_params)
5146

5247
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
5348
end
@@ -64,9 +59,7 @@ def delete(id)
6459

6560
# Select the top-layer key for the carrier account creation/update request based on the carrier type.
6661
def select_top_layer_key(carrier_account_type)
67-
if UPS_OAUTH_CARRIER_ACCOUNT_TYPES.include?(carrier_account_type)
68-
'ups_oauth_registrations'
69-
elsif CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type)
62+
if CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.include?(carrier_account_type)
7063
'carrier_account_oauth_registrations'
7164
else
7265
'carrier_account'

spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_create_creates_a_UPS_account.yml

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/cassettes/carrier_account/EasyPost_Services_CarrierAccount_update_updates_an_ups_account.yml

Lines changed: 38 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)