Class: Postmen::ShipperAccount
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Postmen::ShipperAccount
- Defined in:
- lib/postmen/shipper_account.rb
Overview
Shipper account object (brief information for rate and manifest responses)
Class Method Summary collapse
-
.all(options = {}) ⇒ ShipperAccountCollection
Returns all ShipperAccounts.
-
.create(params) ⇒ ShipperAccount
Creates an instance of ShipperAccount.
-
.find(id) ⇒ ShipperAccount
Fetches single ShipperAccount.
Instance Method Summary collapse
-
#destroy ⇒ Object
Deletes given ShipperAccount.
-
#update(params = {}) ⇒ ShipperAccount, Hash
Update a shipper account information.
-
#update!(params = {}) ⇒ ShipperAccount
Update a shipper account information.
-
#update_credentials(params = {}) ⇒ ShipperAccount, Hash
Update a ShipperAccount credentials.
-
#update_credentials!(params = {}) ⇒ ShipperAccount
Update a ShipperAccount credentials.
Class Method Details
.all(options = {}) ⇒ ShipperAccountCollection
Returns all ShipperAccounts
20 21 22 |
# File 'lib/postmen/shipper_account.rb', line 20 def self.all( = {}) ShipperAccountCollection.all() end |
.create(params) ⇒ ShipperAccount
Creates an instance of ShipperAccount
36 37 38 |
# File 'lib/postmen/shipper_account.rb', line 36 def self.create(params) ShipperAccountCollection.create(params) end |
.find(id) ⇒ ShipperAccount
Fetches single ShipperAccount
28 29 30 |
# File 'lib/postmen/shipper_account.rb', line 28 def self.find(id) ShipperAccountCollection.find(id) end |
Instance Method Details
#destroy ⇒ Object
Deletes given ShipperAccount
43 44 45 |
# File 'lib/postmen/shipper_account.rb', line 43 def destroy Connection.new.delete("/shipper-accounts/#{@id}") end |
#update(params = {}) ⇒ ShipperAccount, Hash
Update a shipper account information
101 102 103 104 105 |
# File 'lib/postmen/shipper_account.rb', line 101 def update(params = {}) update!(params) rescue RequestError => error error. end |
#update!(params = {}) ⇒ ShipperAccount
Update a shipper account information
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/postmen/shipper_account.rb', line 82 def update!(params = {}) response = Connection.new.put( "/shipper-accounts/#{@id}/info", ShipperAccountUpdateQuery.new(params.merge(subject: self)).to_query ) raise RequestError, response unless response.success? ShipperAccount.new(response.data) end |
#update_credentials(params = {}) ⇒ ShipperAccount, Hash
Update a ShipperAccount credentials
68 69 70 71 72 |
# File 'lib/postmen/shipper_account.rb', line 68 def update_credentials(params = {}) update_credentials!(params) rescue RequestError => error error. end |
#update_credentials!(params = {}) ⇒ ShipperAccount
Update a ShipperAccount credentials
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/postmen/shipper_account.rb', line 52 def update_credentials!(params = {}) response = Connection.new.put( "/shipper-accounts/#{@id}/credentials", ShipperAccountUpdateCredentialsQuery.new(params).to_query ) raise RequestError, response unless response.success? ShipperAccount.new(response.data) end |