Skip to content

fix: endpoint used for UPS create/update #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0
7.0.1
19 changes: 6 additions & 13 deletions lib/easypost/services/carrier_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.