Class: AdvisorsCommandClient::Models::AccountCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/advisors_command_client/models/account_collection.rb

Instance Method Summary collapse

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)
   = AdvisorsCommandClient::Models::Account.new(params)
   = .as_json
   = .merge(default_contact: contact_id)
  resp = @connection.post("accounts.json", { account:  })

  if resp.success?
    .id = resp.body['id']
    
  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(, params)
   = AdvisorsCommandClient::Models::Account.new(params.merge(id: ))
  resp = @connection.put("accounts/#{}.json", { account: .as_json })

  if resp.success?
    return 
  else
    return false
  end
end