class EasyPost::Services::CarrierAccount
Constants
- CUSTOM_WORKFLOW_CARRIER_TYPES
- UPS_OAUTH_CARRIER_ACCOUNT_TYPES
Public Instance Methods
Source
# File lib/easypost/services/carrier_account.rb, line 34 def all(params = {}) get_all_helper('carrier_accounts', MODEL_CLASS, params) end
Retrieve all carrier accounts
Source
# File lib/easypost/services/carrier_account.rb, line 9 def create(params = {}) carrier_account_type = params[:type] wrapped_params = { select_top_layer_key(carrier_account_type).to_sym => 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' else 'carrier_accounts' end response = @client.make_request(:post, create_url, wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
Create a carrier account
Source
# File lib/easypost/services/carrier_account.rb, line 53 def delete(id) @client.make_request(:delete, "carrier_accounts/#{id}") # Return true if succeeds, an error will be thrown if it fails true end
Delete a carrier account
Source
# File lib/easypost/services/carrier_account.rb, line 27 def retrieve(id) response = @client.make_request(:get, "carrier_accounts/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
Retrieve a carrier account
Source
# File lib/easypost/services/carrier_account.rb, line 39 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) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
Update a carrier account