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
30 31 32 |
# File 'lib/easypost/services/carrier_account.rb', line 30 def all(params = {}) get_all_helper('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 20 |
# 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) ⇒ Object
Delete a carrier account
43 44 45 46 47 48 |
# 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) ⇒ Object
Retrieve a carrier account
23 24 25 26 27 |
# 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 = {}) ⇒ Object
Update a carrier account
35 36 37 38 39 40 |
# 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 |