Class: Contactually::Contacts

Inherits:
Object
  • Object
show all
Defined in:
lib/contactually/contacts.rb

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Contacts

Returns a new instance of Contacts.



3
4
5
# File 'lib/contactually/contacts.rb', line 3

def initialize(master)
  @master = master
end

Instance Method Details

#count(params = { limit: 1 }) ⇒ Object



50
51
52
# File 'lib/contactually/contacts.rb', line 50

def count(params = { limit: 1 })
  @master.call('contacts.json', :get, params)["total_count"]
end

#create(params = {}) ⇒ Object



7
8
9
10
# 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 = {}) ⇒ Object



12
13
14
# File 'lib/contactually/contacts.rb', line 12

def destroy(id, params = {})
  @master.call("contacts/#{id}.json", :delete, {})
end

#destroy_multiple(params = {}) ⇒ Object



16
17
18
# File 'lib/contactually/contacts.rb', line 16

def destroy_multiple(params = {})
  @master.call('contacts.json', :delete, params)
end

#index(params = {}) ⇒ Object



40
41
42
43
# File 'lib/contactually/contacts.rb', line 40

def index(params = {})
  hash = @master.call('contacts.json', :get, params)
  Contactually::Utils.contacts_hash_to_objects(hash)
end

#merge(params = {}) ⇒ Object



25
26
27
28
# 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 = {}) ⇒ Object



45
46
47
48
# File 'lib/contactually/contacts.rb', line 45

def search(params = {})
  hash = @master.call('contacts/search.json', :get, params)
  Contactually::Utils.contacts_hash_to_objects(hash)
end

#show(id, params = {}) ⇒ Object



20
21
22
23
# 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

#tags(id, params = {}) ⇒ Object



30
31
32
33
# File 'lib/contactually/contacts.rb', line 30

def tags(id, params = {})
  params[:tags] = params[:tags].join(', ') if params[:tags].class == Array
  @master.call("contacts/#{id}/tags.json", :post, params)
end

#update(id, params = {}) ⇒ Object



35
36
37
38
# 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