Class: NotSoEasyHubspot::Contact

Inherits:
Base
  • Object
show all
Defined in:
lib/not_so_easy_hubspot/contact.rb

Overview

class NotSoEasyHubspot::Contact

Constant Summary collapse

CONTACT_ENDPOINT =
'crm/v3/objects/contacts'

Class Method Summary collapse

Methods inherited from Base

email?, headers

Class Method Details

.create_contact(body) ⇒ Object



17
18
19
# File 'lib/not_so_easy_hubspot/contact.rb', line 17

def create_contact(body)
  Client.do_post(CONTACT_ENDPOINT, body, headers)
end

.delete_contact(contact_id) ⇒ Object



25
26
27
# File 'lib/not_so_easy_hubspot/contact.rb', line 25

def delete_contact(contact_id)
  Client.do_delete(determine_endpoint(contact_id), headers)
end

.get_contact(contact_id) ⇒ Object



9
10
11
# File 'lib/not_so_easy_hubspot/contact.rb', line 9

def get_contact(contact_id)
  Client.do_get(determine_endpoint(contact_id), headers)
end

.get_contactsObject



13
14
15
# File 'lib/not_so_easy_hubspot/contact.rb', line 13

def get_contacts
  Client.do_get(CONTACT_ENDPOINT, headers)
end

.update_contact(contact_id, body) ⇒ Object



21
22
23
# File 'lib/not_so_easy_hubspot/contact.rb', line 21

def update_contact(contact_id, body)
  Client.do_patch(determine_endpoint(contact_id), body, headers)
end

.update_or_create_contact(email, body) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/not_so_easy_hubspot/contact.rb', line 29

def update_or_create_contact(email, body)
  res = get_contact(email)
  if res && res[:id]
    update_contact(email, body)
  else
    create_contact(body)
  end
end