class EasyPost::Services::CarrierAccount
Constants
- CUSTOM_WORKFLOW_CARRIER_TYPES
- MODEL_CLASS
A
CarrierAccount
encapsulates your credentials with the carrier.
Public Instance Methods
all(params = {})
click to toggle source
Retrieve all carrier accounts
# File lib/easypost/services/carrier_account.rb, line 30 def all(params = {}) get_all_helper('carrier_accounts', MODEL_CLASS, params) end
create(params = {})
click to toggle source
Create a carrier account
# File lib/easypost/services/carrier_account.rb, line 8 def create(params = {}) wrapped_params = { carrier_account: params } # For UPS and FedEx the endpoint is different create_url = if CUSTOM_WORKFLOW_CARRIER_TYPES.include?(params[:type]) 'carrier_accounts/register' else 'carrier_accounts' end response = @client.make_request(:post, create_url, wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
delete(id)
click to toggle source
Delete a carrier account
# File lib/easypost/services/carrier_account.rb, line 43 def delete(id) @client.make_request(:delete, "carrier_accounts/#{id}") # Return true if succeeds, an error will be thrown if it fails true end
retrieve(id)
click to toggle source
Retrieve a carrier account
# File lib/easypost/services/carrier_account.rb, line 23 def retrieve(id) response = @client.make_request(:get, "carrier_accounts/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
update(id, params = {})
click to toggle source
Update a carrier account
# File lib/easypost/services/carrier_account.rb, line 35 def update(id, params = {}) wrapped_params = { carrier_account: params } response = @client.make_request(:put, "carrier_accounts/#{id}", wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end