Module: FullContact::Client::Contact

Included in:
FullContact::Client
Defined in:
lib/fullcontact/client/contact.rb

Instance Method Summary collapse

Instance Method Details

#contact_history(list_id, contact_id, options = {}) ⇒ Object

Public: Retrieves a list of eTags representing the history of a contact

list_id - id of the contact list to which this contact belongs contact_id - id of the contact whose history is needed options - Hash containing additional arguments (optional) (default: {})

:actionType("Added"|"Updated"|"Deleted"|"Enriched") - filters list based on the given action type

Example

response = FullContact.history(list_id, contact_id, "Updated")
response.history now contains a list of 'Update' actions, with corresponding eTags for this contact


114
115
116
# File 'lib/fullcontact/client/contact.rb', line 114

def contact_history(list_id, contact_id, options = {})
  get("contactLists/#{list_id}/#{contact_id}/history", options)
end

#delete_contact(list_id, contact_id) ⇒ Object

Public: Delete contact

list_id - id of the contact list from which this contact is to be deleted contact_id - id of the contact which is to be deleted

Example

FullContact.delete_contact(list_id, contact_id)


46
47
48
# File 'lib/fullcontact/client/contact.rb', line 46

def delete_contact(list_id, contact_id)
  delete("contactLists/#{list_id}/#{contact_id}")
end

#get_contact(list_id, contact_id, options = {}) ⇒ Object

Public: Retrieves a contact

list_id - id of the contact list from which this contact is to be retrieved contact_id - id of the contact which is to be retrieved options - Hash containing additonal arguments (optional) (default: {})

:eTag - represents a unique version of the contact. Retrieves latest version if not specified (optional)

Example

contact = FullContact.get_contact(list_id, contact_id)
# contact now contains details about this contact


34
35
36
# File 'lib/fullcontact/client/contact.rb', line 34

def get_contact(list_id, contact_id, options = {})
  get("contactLists/#{list_id}/#{contact_id}", options)
end

#get_enriched_contact(list_id, contact_id) ⇒ Object

Public: Gets fully enriched version of the contact

list_id - id of the contact list to which this contact belongs contact_id - id of the contact whose enriched version is needed

Example

response = FullContact.get_enriched_contact(list_id, contact_id)
response.data now contains the hash denoting the enriched information for this contact


87
88
89
# File 'lib/fullcontact/client/contact.rb', line 87

def get_enriched_contact(list_id, contact_id)
  get("contactLists/#{list_id}/#{contact_id}/enriched")
end

#get_updates(list_id, contact_id) ⇒ Object

Public: Gets latest updates for this contact

list_id - id of the contact list to which this contact belongs contact_id - id of the contact whose updates are needed

Example

response = FullContact.get_updates(list_id, contact_id)
response.updates now contains the hash denoting the updates for this user


74
75
76
# File 'lib/fullcontact/client/contact.rb', line 74

def get_updates(list_id, contact_id)
  get("contactLists/#{list_id}/#{contact_id}/updates")
end

#has_enriched_updates?(list_id, contact_id, options = {}) ⇒ Boolean

Public: Checks if a contact has new enrichment updates available

list_id - id of the contact list to which this contact belongs contact_id - id of the contact which needs to be checked for enrichment updates options - Hash containing additonal arguments (optional) (default: {})

:eTag - represents a unique version of the contact. Retrieves latest version if not specified (optional)

Example

response = FullContact.has_enriched_updates?(list_id, contact_id)
response.hasUpdates is now either true/false

Returns:

  • (Boolean)


61
62
63
# File 'lib/fullcontact/client/contact.rb', line 61

def has_enriched_updates?(list_id, contact_id, options = {})
  get("contactLists/#{list_id}/#{contact_id}/hasUpdates", options)
end

#save_enriched_contact(list_id, contact_id) ⇒ Object

Public: Saves fully enriched version of the contact

list_id - id of the contact list to which this contact belongs contact_id - id of the contact whose enriched version is to be saved

Example

response = FullContact.save_enriched_contact(list_id, contact_id)


99
100
101
# File 'lib/fullcontact/client/contact.rb', line 99

def save_enriched_contact(list_id, contact_id)
  post("contactLists/#{list_id}/#{contact_id}/enriched")
end

#update_contact(list_id, options) ⇒ Object

Public: Creates/Modifies a contact

list_id - id of the contact list to which this contact is to be added options - Hash containing contact data and other options

:contact_data       - Hash representing the contact information in POCO format
:generateIds(0|1)   - Whether or not ids need to be generated by the system (optional) (default: 0)
:queue(true|false)  - Check for updates on creation if true (optional) (default: false)

Example

contact = FullContact.update_contact(list_id, { :contact_data => data , :generateIds => 1 })
# 'contact' contains the newly created contact


16
17
18
19
20
21
# File 'lib/fullcontact/client/contact.rb', line 16

def update_contact(list_id, options)
  options[:content_type] = 'application/json'
  options[:request_body] = options[:contact_data]
  options.delete(:contact_data)
  contacts = post("contactLists/#{list_id}", options)
end