Module: OntraportApi::APIs::Contacts
- Included in:
- Client
- Defined in:
- lib/ontraport_api/apis/contacts.rb
Constant Summary collapse
- CONTACTS_OBJECT_ID =
0- CONTACTS_API_METHODS_AND_PATHS =
{ 'get_contact' => [:get, '/object'], 'new_contact' => [:post, '/objects'], 'update_contact' => [:put, '/objects'], 'add_sequences_to_contact' => [:put, '/objects'], 'get_contacts' => [:get, '/objects'], 'contact_fields' => [:get, '/objects/meta'], 'add_tags_to_contact' => [:put, '/objects/tag'], 'add_tags_to_contacts' => [:put, '/objects/tag'], 'remove_tags_from_contacts' => [:delete, '/objects/tag'] }
Instance Method Summary collapse
- #add_sequences_to_contact(id, sequence_ids) ⇒ Object
- #add_tags_to_contact(id, tag_ids) ⇒ Object
- #add_tags_to_contacts(tag_ids, conditions = {}) ⇒ Object
- #contact_fields(format = {}) ⇒ Object
- #get_contact(id) ⇒ Object
- #get_contacts(conditions = {}) ⇒ Object
- #new_contact(payload = {}) ⇒ Object
- #query_contacts(payload) ⇒ Object
- #remove_tags_from_contacts(tag_ids, conditions = {}) ⇒ Object
- #update_contact(id, payload = {}) ⇒ Object
Instance Method Details
#add_sequences_to_contact(id, sequence_ids) ⇒ Object
29 30 31 32 |
# File 'lib/ontraport_api/apis/contacts.rb', line 29 def add_sequences_to_contact(id, sequence_ids) sequence_ids = sequence_ids.is_a?(Array) ? sequence_ids.join('*/*') : sequence_ids query_contacts({ id: id, updateSequence: "*/*#{sequence_ids}*/*" }) end |
#add_tags_to_contact(id, tag_ids) ⇒ Object
34 35 36 |
# File 'lib/ontraport_api/apis/contacts.rb', line 34 def (id, tag_ids) (tag_ids, "id = #{id}") end |
#add_tags_to_contacts(tag_ids, conditions = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ontraport_api/apis/contacts.rb', line 44 def (tag_ids, conditions = {}) conditions = { condition: conditions } if conditions.is_a? String default_conditions = { performAll: true } conditions = default_conditions.merge(conditions) tag_ids = tag_ids.is_a?(Array) ? tag_ids.join(',') : tag_ids query_contacts(conditions.merge({ add_list: tag_ids })) end |
#contact_fields(format = {}) ⇒ Object
38 39 40 41 42 |
# File 'lib/ontraport_api/apis/contacts.rb', line 38 def contact_fields(format = {}) default_format = { format: 'byId' } format = default_format.merge(format) query_contacts(format) end |
#get_contact(id) ⇒ Object
17 18 19 |
# File 'lib/ontraport_api/apis/contacts.rb', line 17 def get_contact(id) query_contacts({id: id}) end |
#get_contacts(conditions = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ontraport_api/apis/contacts.rb', line 66 def get_contacts(conditions = {}) conditions = { condition: conditions } if conditions.is_a? String default_conditions = { performAll: true, sortDir: 'asc', searchNotes: 'true' } payload = default_conditions.merge(conditions) query_contacts(payload) end |
#new_contact(payload = {}) ⇒ Object
21 22 23 |
# File 'lib/ontraport_api/apis/contacts.rb', line 21 def new_contact(payload = {}) query_contacts(payload) end |
#query_contacts(payload) ⇒ Object
77 78 79 80 |
# File 'lib/ontraport_api/apis/contacts.rb', line 77 def query_contacts(payload) method, path = CONTACTS_API_METHODS_AND_PATHS[caller[0][/`.*'/][1..-2]] query(method, path, payload.merge({ objectID: CONTACTS_OBJECT_ID })) end |
#remove_tags_from_contacts(tag_ids, conditions = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ontraport_api/apis/contacts.rb', line 55 def (tag_ids, conditions = {}) conditions = { condition: conditions } if conditions.is_a? String default_conditions = { performAll: true } conditions = default_conditions.merge(conditions) tag_ids = tag_ids.is_a?(Array) ? tag_ids.join(',') : tag_ids query_contacts(conditions.merge({ remove_list: tag_ids })) end |
#update_contact(id, payload = {}) ⇒ Object
25 26 27 |
# File 'lib/ontraport_api/apis/contacts.rb', line 25 def update_contact(id, payload = {}) query_contacts(payload.merge(id: id)) end |