Module: Contacts
- Includes:
- Constants
- Included in:
- Hubspot
- Defined in:
- lib/ruby_hubspot/contacts.rb
Overview
Constant Summary
Constants included
from Constants
Constants::ALL_COMPANIES, Constants::ALL_CONTACTS, Constants::ALL_DEALS, Constants::ALL_SUBMITIONS, Constants::API_URL, Constants::AUTHORIZATION_KEY, Constants::CONTENT_TYPE, Constants::CREATE_OR_UPDATE, Constants::DELETE, Constants::EMAIL, Constants::GET, Constants::INDIVIDUAL_COMPANY, Constants::INDIVIDUAL_CONTACT, Constants::INDIVIDUAL_DEAL, Constants::INDIVIDUAL_SUB, Constants::PATCH, Constants::POST, Constants::PROFILE, Constants::PUT, Constants::VID
Instance Method Summary
collapse
Instance Method Details
7
8
9
10
11
|
# File 'lib/ruby_hubspot/contacts.rb', line 7
def all_contacts
validate_access_token
response(GET, ALL_CONTACTS)
end
|
13
14
15
16
17
|
# File 'lib/ruby_hubspot/contacts.rb', line 13
def create_contact(**params)
validate_access_token
response(POST, INDIVIDUAL_CONTACT, params)
end
|
19
20
21
22
23
24
|
# File 'lib/ruby_hubspot/contacts.rb', line 19
def create_or_update_contact(**params)
validate_access_token
email_handler(params[:email])
response(POST, INDIVIDUAL_CONTACT + CREATE_OR_UPDATE + EMAIL + params[:email].to_s, params)
end
|
41
42
43
44
45
|
# File 'lib/ruby_hubspot/contacts.rb', line 41
def delete_contact(**params)
validate_access_token
response(DELETE, INDIVIDUAL_CONTACT + find_idintificator(params))
end
|
#find_idintificator(params) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ruby_hubspot/contacts.rb', line 47
def find_idintificator(params)
identificator_handler(
%i[email id].any? do |key|
if params.key?(key)
identificator_handler(params[key])
return key == :email ? EMAIL + params[key].to_s : VID + params[key].to_s
end
end
)
end
|
26
27
28
29
30
|
# File 'lib/ruby_hubspot/contacts.rb', line 26
def show_contact(**params)
validate_access_token
response(GET, INDIVIDUAL_CONTACT + find_idintificator(params) + PROFILE)
end
|
32
33
34
35
36
37
38
39
|
# File 'lib/ruby_hubspot/contacts.rb', line 32
def update_contact(**params)
validate_access_token
params_to_update = params.dup
params_to_update.delete(:id)
response(POST, INDIVIDUAL_CONTACT + find_idintificator(params) + PROFILE, params_to_update)
end
|