Module: Hive::REST::Contacts

Includes:
Util
Included in:
API
Defined in:
lib/hive/rest/contacts.rb

Instance Method Summary collapse

Methods included from Util

#perform, #perform_with_cursor, #perform_with_object

Instance Method Details

#add_contact_address(id, address, modified_at) ⇒ Object



77
78
79
# File 'lib/hive/rest/contacts.rb', line 77

def add_contact_address(id, address, modified_at)
  add_contact_field("v1/contacts/#{id}/address", address, modified_at)
end

#add_contact_custom(id, custom, modified_at) ⇒ Object



93
94
95
# File 'lib/hive/rest/contacts.rb', line 93

def add_contact_custom(id, custom, modified_at)
  add_contact_field("v1/contacts/#{id}/custom", custom, modified_at)
end

#add_contact_email(id, email, modified_at) ⇒ Object



81
82
83
# File 'lib/hive/rest/contacts.rb', line 81

def add_contact_email(id, email, modified_at)
  add_contact_field("v1/contacts/#{id}/email", email, modified_at)
end

#add_contact_note(id, note, modified_at) ⇒ Object



89
90
91
# File 'lib/hive/rest/contacts.rb', line 89

def add_contact_note(id, note, modified_at)
  add_contact_field("v1/contacts/#{id}/note", note, modified_at)
end

#add_contact_phone(id, phone, modified_at) ⇒ Object



85
86
87
# File 'lib/hive/rest/contacts.rb', line 85

def add_contact_phone(id, phone, modified_at)
  add_contact_field("v1/contacts/#{id}/phone", phone, modified_at)
end

#add_contact_tags(id, tags, modified_at) ⇒ Object



97
98
99
# File 'lib/hive/rest/contacts.rb', line 97

def add_contact_tags(id, tags, modified_at)
  add_contact_field("v1/contacts/#{id}/tags", tags, modified_at)
end

#contact(contact_id) ⇒ Object



15
16
17
# File 'lib/hive/rest/contacts.rb', line 15

def contact(contact_id)
  perform_with_object(:get, "v1/contacts/#{contact_id}", Hive::Contact)
end

#contacts(query_options = {}) ⇒ Object



11
12
13
# File 'lib/hive/rest/contacts.rb', line 11

def contacts(query_options = {})
  perform_with_cursor(:get, 'v1/contacts', Hive::Contact, params: query_options)
end

#contacts_subscribersObject



33
34
35
# File 'lib/hive/rest/contacts.rb', line 33

def contacts_subscribers
  perform_with_cursor(:get, 'v1/contacts/subscribers', Hive::ContactSubscriber)
end

#contacts_tagsObject



29
30
31
# File 'lib/hive/rest/contacts.rb', line 29

def contacts_tags
  perform_with_object(:get, 'v1/contacts/tags', Array)
end

#new_contact(contact) ⇒ Object



19
20
21
# File 'lib/hive/rest/contacts.rb', line 19

def new_contact(contact)
  perform_with_object(:post, 'v1/contacts', Hashie::Mash, body: contact.to_json)
end

#patch_contact(id, patch_operations, modified_at) ⇒ Object



37
38
39
# File 'lib/hive/rest/contacts.rb', line 37

def patch_contact(id, patch_operations, modified_at)
  perform_with_object(:patch, "v1/contacts/#{id}", Hive::Contact, body: patch_operations.to_json, params: { modifiedAt: modified_at })
end

#update_contact_address(id, address_id, address, modified_at) ⇒ Object



53
54
55
# File 'lib/hive/rest/contacts.rb', line 53

def update_contact_address(id, address_id, address, modified_at)
  edit_contact_field("v1/contacts/#{id}/address/#{address_id}", address, modified_at)
end

#update_contact_company(id, company, modified_at) ⇒ Object



45
46
47
# File 'lib/hive/rest/contacts.rb', line 45

def update_contact_company(id, company, modified_at)
  edit_contact_field("v1/contacts/#{id}/company", company, modified_at)
end

#update_contact_custom(id, custom_id, custom, modified_at) ⇒ Object



73
74
75
# File 'lib/hive/rest/contacts.rb', line 73

def update_contact_custom(id, custom_id, custom, modified_at)
  edit_contact_field("v1/contacts/#{id}/custom/#{custom_id}", custom, modified_at)
end

#update_contact_date(id, date_id, date, modified_at) ⇒ Object



65
66
67
# File 'lib/hive/rest/contacts.rb', line 65

def update_contact_date(id, date_id, date, modified_at)
  edit_contact_field("v1/contacts/#{id}/date/#{date_id}", date, modified_at)
end

#update_contact_email(id, email_id, email, modified_at) ⇒ Object



57
58
59
# File 'lib/hive/rest/contacts.rb', line 57

def update_contact_email(id, email_id, email, modified_at)
  edit_contact_field("v1/contacts/#{id}/email/#{email_id}", email, modified_at)
end

#update_contact_name(id, name, modified_at) ⇒ Object



41
42
43
# File 'lib/hive/rest/contacts.rb', line 41

def update_contact_name(id, name, modified_at)
  edit_contact_field("v1/contacts/#{id}/name", name, modified_at)
end

#update_contact_note(id, note_id, note, modified_at) ⇒ Object



69
70
71
# File 'lib/hive/rest/contacts.rb', line 69

def update_contact_note(id, note_id, note, modified_at)
  edit_contact_field("v1/contacts/#{id}/note/#{note_id}", note, modified_at)
end

#update_contact_phone(id, phone_id, phone, modified_at) ⇒ Object



61
62
63
# File 'lib/hive/rest/contacts.rb', line 61

def update_contact_phone(id, phone_id, phone, modified_at)
  edit_contact_field("v1/contacts/#{id}/phone/#{phone_id}", phone, modified_at)
end

#update_contact_picture(id, picture, modified_at) ⇒ Object



49
50
51
# File 'lib/hive/rest/contacts.rb', line 49

def update_contact_picture(id, picture, modified_at)
  edit_contact_field("v1/contacts/#{id}/picture", picture, modified_at)
end

#upsert_contact(args) ⇒ Object



23
24
25
26
27
# File 'lib/hive/rest/contacts.rb', line 23

def upsert_contact(args)
  fail ArgumentError, 'Phone or Email are required!' unless args.key?(:phone) || args.key?(:email)

  perform_with_object(:put, 'v1/contacts', Hashie::Mash, body: args.to_json)
end