Class: EasyPost::Services::CarrierAccount
- Defined in:
- lib/easypost/services/carrier_account.rb
Constant Summary collapse
- CUSTOM_WORKFLOW_CARRIER_TYPES =
%w[UpsAccount FedexAccount FedexSmartpostAccount].freeze
- MODEL_CLASS =
EasyPost::Models::CarrierAccount
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Retrieve all carrier accounts.
-
#create(params = {}) ⇒ Object
Create a carrier account.
-
#delete(id) ⇒ Object
Delete a carrier account.
-
#retrieve(id) ⇒ Object
Retrieve a carrier account.
-
#update(id, params = {}) ⇒ Object
Update a carrier account.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#all(params = {}) ⇒ Object
Retrieve all carrier accounts
27 28 29 |
# File 'lib/easypost/services/carrier_account.rb', line 27 def all(params = {}) @client.make_request(:get, 'carrier_accounts', MODEL_CLASS, params) end |
#create(params = {}) ⇒ Object
Create a carrier account
8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 @client.make_request(:post, create_url, MODEL_CLASS, wrapped_params) end |
#delete(id) ⇒ Object
Delete a carrier account
38 39 40 41 42 43 |
# File 'lib/easypost/services/carrier_account.rb', line 38 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) ⇒ Object
Retrieve a carrier account
22 23 24 |
# File 'lib/easypost/services/carrier_account.rb', line 22 def retrieve(id) @client.make_request(:get, "carrier_accounts/#{id}", MODEL_CLASS) end |
#update(id, params = {}) ⇒ Object
Update a carrier account
32 33 34 35 |
# File 'lib/easypost/services/carrier_account.rb', line 32 def update(id, params = {}) wrapped_params = { carrier_account: params } @client.make_request(:put, "carrier_accounts/#{id}", MODEL_CLASS, wrapped_params) end |