class Contactually::Contacts
Public Class Methods
new(master)
click to toggle source
# File lib/contactually/contacts.rb, line 3 def initialize(master) @master = master end
Public Instance Methods
count(params = { limit: 1 })
click to toggle source
# File lib/contactually/contacts.rb, line 58 def count(params = { limit: 1 }) @master.call('contacts.json', :get, params)["total_count"] end
create(params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 7 def create(params = {}) hash = @master.call('contacts.json', :post, params) Contactually::Utils.build_contact(hash) end
destroy(id, params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 12 def destroy(id, params = {}) @master.call("contacts/#{id}.json", :delete, {}) end
destroy_multiple(params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 16 def destroy_multiple(params = {}) @master.call('contacts.json', :delete, params) end
index(all=false, params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 40 def index(all=false, params = {}) contacts = [] i = 1 while true params = {page: i} if all h = @master.call('contacts.json', :get, params) contacts.concat(Contactually::Utils.contacts_hash_to_objects(h)) i += 1 break if !all || h['meta']['next_page'] == nil || h['meta']['next_page'] == '' end contacts end
merge(params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 25 def merge(params = {}) hash = @master.call('contacts/merge.json', :post, params) Contactually::Utils.build_contact(hash) end
search(params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 53 def search(params = {}) hash = @master.call('contacts/search.json', :get, params) Contactually::Utils.contacts_hash_to_objects(hash) end
show(id, params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 20 def show(id, params = {}) hash = @master.call("contacts/#{id}.json", :get, params) Contactually::Utils.build_contact(hash) end
update(id, params = {})
click to toggle source
# File lib/contactually/contacts.rb, line 35 def update(id, params = {}) hash = @master.call("contacts/#{id}.json", :put, params) Contactually::Utils.build_contact(hash); end