easy_hubspot 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/CHANGELOG.md +13 -3
- data/README.md +75 -14
- data/lib/easy_hubspot/client.rb +8 -3
- data/lib/easy_hubspot/contact.rb +8 -5
- data/lib/easy_hubspot/exceptions.rb +6 -0
- data/lib/easy_hubspot/version.rb +1 -1
- data/lib/easy_hubspot.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10948cb420b0963c35938bdfbc87c017236894bcdb5072ee32e0be6c7e67b313
|
4
|
+
data.tar.gz: 3a4c3668452becd0bada81aa3c9e270606e3d5c7e4347fd9e614d36da27e8234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28470604e252338702a3fd8f8d64bf3c15bdd438032dd1b894a8dc88469aaac423e8fc26c8c7ab75605f934e4a57a7c03ea39ac9852da98d3db6d7a12136d020
|
7
|
+
data.tar.gz: fe41f9081b7534da09bf8e425e9c9fa7f60beb0c870f3aec52ad649d5f4bf8ceb2361b7644c03fb79efb964b87d4d8afa0ee527cdd7cfc0fcd42e19fac52b19f
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
## [
|
1
|
+
## [Official Release]
|
2
|
+
- [0.1.7] - 2023-02-10
|
3
|
+
- [0.1.8] - 2023-02-10
|
4
|
+
- [0.1.9] - 2023-02-14 https://github.com/oroth8/easy_hubspot/pull/6
|
2
5
|
|
3
|
-
## [
|
6
|
+
## [Unreleased]
|
4
7
|
|
5
|
-
|
8
|
+
## [Initial releases]
|
9
|
+
- [0.1.0] - 2023-02-08
|
10
|
+
- [0.1.1] - 2023-02-09
|
11
|
+
- [0.1.2] - 2023-02-09
|
12
|
+
- [0.1.3] - 2023-02-09
|
13
|
+
- [0.1.4] - 2023-02-09
|
14
|
+
- [0.1.5] - 2023-02-09
|
15
|
+
- [0.1.6] - 2023-02-09
|
data/README.md
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
# EasyHubspot
|
2
|
-

|
3
|
+
Latest: 
|
3
4
|
[](https://github.com/oroth8/easy_hubspot/actions/workflows/ci.yml)
|
4
5
|
[](https://codeclimate.com/github/oroth8/easy_hubspot)
|
5
6
|
|
6
|
-
|
7
|
+
This is a lightweight wrapper for the Hubspot API. It is designed to be easy to use and to provide a simple setup for the most common use cases.
|
8
|
+
|
9
|
+
This gem utilizes the `v3` hubspot-api
|
10
|
+
|
11
|
+
### Dependencies
|
12
|
+
- [gem "httparty", "~> 0.21.0"](https://github.com/jnunemaker/httparty)
|
13
|
+
|
14
|
+
### Compatibility
|
15
|
+
- `ruby >= 2.6.10`
|
16
|
+
- `rails >= 6.0`
|
7
17
|
|
8
|
-
This is a lightweight wrapper for the Hubspot API. It is designed to be easy to use and to provide a simple interface for the most common use cases.
|
9
18
|
## Installation
|
10
19
|
|
11
20
|
Add this line to your application's Gemfile:
|
@@ -33,25 +42,77 @@ rails g easy_hubspot:install
|
|
33
42
|
|
34
43
|
### Contacts
|
35
44
|
|
45
|
+
Please refrence the [hubspot docs](https://developers.hubspot.com/docs/api/crm/contacts)
|
46
|
+
|
36
47
|
```ruby
|
37
|
-
# Create a contact
|
38
|
-
|
48
|
+
# Create a contact
|
49
|
+
# required: body
|
50
|
+
# returns: parsed hubspot contact
|
51
|
+
EasyHubspot::Contact.create_contact(properties: { email: '', firstname: '', lastname: '' , etc: ''})
|
39
52
|
|
40
|
-
# Update a contact
|
41
|
-
|
53
|
+
# Update a contact
|
54
|
+
# required: contact_id, body
|
55
|
+
# - contact_id: can be a hubspot contact_id or email
|
56
|
+
# returns: parsed hubspot contact
|
57
|
+
EasyHubspot::Contact.update_contact(123, properties: { email: '', firstname: '', lastname: '' , etc: ''})
|
42
58
|
|
43
59
|
# Get a contact
|
44
|
-
|
60
|
+
# required: contact_id
|
61
|
+
# - contact_id: can be a hubspot contact_id or email
|
62
|
+
# returns: parsed hubspot contact
|
63
|
+
EasyHubspot::Contact.get_contact(123)
|
45
64
|
# or
|
46
|
-
EasyHubspot::Contact.get_contact('test@gmail.com')
|
65
|
+
EasyHubspot::Contact.get_contact('test@gmail.com')
|
47
66
|
|
48
|
-
# Get all contacts
|
49
|
-
|
67
|
+
# Get all contacts
|
68
|
+
# returns: parsed hubspot contacts
|
69
|
+
EasyHubspot::Contact.get_contacts
|
50
70
|
|
51
|
-
# Delete a contact
|
52
|
-
|
71
|
+
# Delete a contact
|
72
|
+
# required: contact_id
|
73
|
+
# - contact_id: can be a hubspot contact_id or email
|
74
|
+
# returns: {status: 'success'}
|
75
|
+
EasyHubspot::Contact.delete_contact(123)
|
53
76
|
# or
|
54
|
-
EasyHubspot::Contact.delete_contact('test@gmail.com')
|
77
|
+
EasyHubspot::Contact.delete_contact('test@gmail.com')
|
78
|
+
|
79
|
+
# Update or Create a contact
|
80
|
+
# required: email, body
|
81
|
+
# returns: parsed hubspot contact
|
82
|
+
EasyHubspot::Contact.update_or_create_contact(properties: { email: '', firstname: '', lastname: '' , etc: ''})
|
83
|
+
|
84
|
+
|
85
|
+
# Parse hubspot contact example
|
86
|
+
{:id=>"701",
|
87
|
+
:properties=>
|
88
|
+
{:createdate=>"2023-02-08T20:10:36.858Z",
|
89
|
+
:email=>"amber_becker@quigley.io",
|
90
|
+
:firstname=>"Amber",
|
91
|
+
:hs_content_membership_status=>"inactive",
|
92
|
+
:hs_is_contact=>"true",
|
93
|
+
:hs_is_unworked=>"true",
|
94
|
+
:hs_object_id=>"701",
|
95
|
+
:hs_pipeline=>"contacts-lifecycle-pipeline",
|
96
|
+
:lastmodifieddate=>"2023-02-14T18:24:07.654Z",
|
97
|
+
:lastname=>"Quigley",
|
98
|
+
:lifecyclestage=>"lead"},
|
99
|
+
:createdAt=>"2023-02-08T20:10:36.858Z",
|
100
|
+
:updatedAt=>"2023-02-14T18:24:07.654Z",
|
101
|
+
:archived=>false}
|
102
|
+
```
|
103
|
+
|
104
|
+
## Error Handling
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
def call
|
108
|
+
begin
|
109
|
+
EasyHubspot::Contact.create_contact(body)
|
110
|
+
rescue EasyHubspot::HubspotApiError => e
|
111
|
+
# handle error code
|
112
|
+
# e.message = 'Contact already exists. Existing ID: 801'
|
113
|
+
Rails.logger.info(e.message)
|
114
|
+
end
|
115
|
+
end
|
55
116
|
```
|
56
117
|
|
57
118
|
## Development
|
data/lib/easy_hubspot/client.rb
CHANGED
@@ -25,15 +25,20 @@ module EasyHubspot
|
|
25
25
|
def do_delete(path = nil, headers = {})
|
26
26
|
response = HTTParty.delete("#{EasyHubspot.configuration.base_url}#{path}", headers: headers,
|
27
27
|
format: :plain)
|
28
|
-
parse_response(response)
|
28
|
+
parse_response(response).nil? ? { status: 'success' } : parse_response(response)
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def parse_response(res)
|
34
|
-
return if res.
|
34
|
+
return { status: 'error', message: '404 Not Found' } if res.code == 404
|
35
|
+
|
36
|
+
return if res.body.nil? || res.body.empty?
|
37
|
+
|
38
|
+
parsed_res = JSON.parse res, symbolize_names: true
|
39
|
+
raise EasyHubspot::HubspotApiError, parsed_res[:message] if parsed_res[:status] == 'error'
|
35
40
|
|
36
|
-
|
41
|
+
parsed_res
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
data/lib/easy_hubspot/contact.rb
CHANGED
@@ -26,11 +26,14 @@ module EasyHubspot
|
|
26
26
|
Client.do_delete(determine_endpoint(contact_id), headers)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def update_or_create_contact(email, body)
|
30
|
+
res = get_contact(email)
|
31
|
+
if res && res[:id]
|
32
|
+
update_contact(email, body)
|
33
|
+
else
|
34
|
+
create_contact(body)
|
35
|
+
end
|
36
|
+
end
|
34
37
|
|
35
38
|
private
|
36
39
|
|
data/lib/easy_hubspot/version.rb
CHANGED
data/lib/easy_hubspot.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_hubspot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Roth
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/easy_hubspot/base.rb
|
185
185
|
- lib/easy_hubspot/client.rb
|
186
186
|
- lib/easy_hubspot/contact.rb
|
187
|
+
- lib/easy_hubspot/exceptions.rb
|
187
188
|
- lib/easy_hubspot/generators/install_generator.rb
|
188
189
|
- lib/easy_hubspot/generators/templates/easy_hubspot.rb
|
189
190
|
- lib/easy_hubspot/version.rb
|