class AdvisorsCommandClient::Models::ContactCollection

Public Class Methods

new(args = {}) click to toggle source
# File lib/advisors_command_client/models/contact_collection.rb, line 4
def initialize(args = {})
  @connection = args[:connection]
end

Public Instance Methods

create(params) click to toggle source
# File lib/advisors_command_client/models/contact_collection.rb, line 34
def create(params)
  contact = AdvisorsCommandClient::Models::Contact.new(params)
  resp = @connection.post("contacts.json", { contact: contact.as_json })

  if resp.success?
    contact.id = resp.body['id']
    return contact
  else
    return false
  end
end
find(contact_id) click to toggle source
# File lib/advisors_command_client/models/contact_collection.rb, line 25
def find(contact_id)
  resp = @connection.get("contacts/#{contact_id}")
  if resp.success?
    return AdvisorsCommandClient::Models::Contact.load(resp.body, @connection)
  else
    return nil
  end
end
update(contact_id, params) click to toggle source
# File lib/advisors_command_client/models/contact_collection.rb, line 46
def update(contact_id, params)
  contact = AdvisorsCommandClient::Models::Contact.new(params.merge(id: contact_id))
  resp = @connection.put("contacts/#{contact_id}.json", { contact: contact.as_json })

  if resp.success?
    return contact
  else
    return false
  end
end