22
33class 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'
0 commit comments