Class: AdvisorsCommandClient::Models::AccountCollection
- Inherits:
-
Object
- Object
- AdvisorsCommandClient::Models::AccountCollection
- Defined in:
- lib/advisors_command_client/models/account_collection.rb
Instance Method Summary collapse
- #create(contact_id, params) ⇒ Object
-
#initialize(args = {}) ⇒ AccountCollection
constructor
A new instance of AccountCollection.
- #update(account_id, params) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ AccountCollection
Returns a new instance of AccountCollection.
4 5 6 |
# File 'lib/advisors_command_client/models/account_collection.rb', line 4 def initialize(args = {}) @connection = args[:connection] end |
Instance Method Details
#create(contact_id, params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/advisors_command_client/models/account_collection.rb', line 8 def create(contact_id, params) account = AdvisorsCommandClient::Models::Account.new(params) account_json = account.as_json account_json = account_json.merge(default_contact: contact_id) resp = @connection.post("accounts.json", { account: account_json }) if resp.success? account.id = resp.body['id'] account else return false end end |
#update(account_id, params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/advisors_command_client/models/account_collection.rb', line 22 def update(account_id, params) account = AdvisorsCommandClient::Models::Account.new(params.merge(id: account_id)) resp = @connection.put("accounts/#{account_id}.json", { account: account.as_json }) if resp.success? return account else return false end end |