Module: Frontapp::Client::Contacts

Included in:
Frontapp::Client
Defined in:
lib/frontapp/client/contacts.rb

Instance Method Summary collapse

Instance Method Details

#add_contact_handle!(contact_id, params = {}) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact


Allowed attributes: Name Type Description


handle string Handle used to reach the contact. Can be an email address, a twitter, handle, a phone number, …source enum Can be ‘twitter’, ’email’ or ‘phone’.




103
104
105
106
# File 'lib/frontapp/client/contacts.rb', line 103

def add_contact_handle!(contact_id, params = {})
  cleaned = params.permit(:handle, :source)
  create_without_response("contacts/#{contact_id}/handles", cleaned)
end

#add_contact_note!(contact_id, params = {}) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact


Allowed attributes: Name Type Description


author_id string Id of the teammate creating the note body string Content of the note




146
147
148
149
# File 'lib/frontapp/client/contacts.rb', line 146

def add_contact_note!(contact_id, params = {})
  cleaned = params.permit(:author_id, :body)
  create("contacts/#{contact_id}/notes", cleaned)
end

#contacts(params = {}) ⇒ Object



5
6
7
# File 'lib/frontapp/client/contacts.rb', line 5

def contacts(params = {})
  list("contacts", params)
end

#create_contact!(params = {}) ⇒ Object

Allowed attributes: Name Type Description


name string (optional) Contact name description string (optional) Contact description avatar_url string (optional) URL of the contact’s avatar is_spammer boolean (optional) Whether or not the contact is marked as a spammer links array (optional) List of all the links of the contact group_names array (optional) List of all the group names the contact belongs to. It will automatically create missing groups. handles array List




55
56
57
58
59
60
61
62
63
64
# File 'lib/frontapp/client/contacts.rb', line 55

def create_contact!(params = {})
  cleaned = params.permit(:name,
                          :description,
                          :avatar_url,
                          :is_spammer,
                          :links,
                          :group_names,
                          :handles)
  create("contacts", cleaned)
end

#delete_contact!(contact_id) ⇒ Object

Name Type Description


contact_id string Id or alias of the requested contact




70
71
72
# File 'lib/frontapp/client/contacts.rb', line 70

def delete_contact!(contact_id)
  delete("contacts/#{contact_id}")
end

#delete_contact_handle!(contact_id, params = {}) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact


Allowed attributes: Name Type Description


handle string Handle used to reach the contact. Can be an email address, a twitter, handle, a phone number, …source enum Can be ‘twitter’, ’email’ or ‘phone’.




120
121
122
123
# File 'lib/frontapp/client/contacts.rb', line 120

def delete_contact_handle!(contact_id, params = {})
  cleaned = params.permit(:handle, :source)
  delete("contacts/#{contact_id}/handles", cleaned)
end

#get_contact(contact_id) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact




14
15
16
# File 'lib/frontapp/client/contacts.rb', line 14

def get_contact(contact_id)
  get("contacts/#{contact_id}")
end

#get_contact_conversations(contact_id, params = {}) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact


Allowed params: Name Type Description


q object (optional) Search query. q.statuses array (optional) List of the statuses of the conversations you want to list




86
87
88
89
# File 'lib/frontapp/client/contacts.rb', line 86

def get_contact_conversations(contact_id, params = {})
  cleaned = params.permit({ q: [:statuses] })
  list("contacts/#{contact_id}/conversations", cleaned)
end

#get_contact_notes(contact_id) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact




130
131
132
# File 'lib/frontapp/client/contacts.rb', line 130

def get_contact_notes(contact_id)
  list("contacts/#{contact_id}/notes")
end

#update_contact!(contact_id, params = {}) ⇒ Object

Parameters Name Type Description


contact_id string Id or alias of the requested contact


Allowed attributes: Name Type Description


name string (optional) Contact name description string (optional) Contact description avatar_url string (optional) URL of the contact’s avatar is_spammer boolean (optional) Whether or not the contact is marked as a spammer links array (optional) List of all the links of the contact group_names array (optional) List of all the group names the contact belongs to. It will automatically create missing groups.




34
35
36
37
38
39
40
41
42
# File 'lib/frontapp/client/contacts.rb', line 34

def update_contact!(contact_id, params = {})
  cleaned = params.permit(:name,
                          :description,
                          :avatar_url,
                          :is_spammer,
                          :links,
                          :group_names)
  update("contacts/#{contact_id}", cleaned)
end