hubspot_v3 1.0.0 → 1.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +9 -5
- data/hubspot_v3.gemspec +1 -1
- data/lib/hubspot_v3/version.rb +1 -1
- data/lib/hubspot_v3.rb +29 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa96d005917fcc2fac310755d0986e91214f65d0a255241aee766357200ae628
|
4
|
+
data.tar.gz: 77c75a7d0db6271e1495c0408face4920d34ba19689c2a5cbf478b6d832c8121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5f35449494040503f10355f1dc159996b9b28fa91165a94677f2c2d9b947d4382b18fcc5960fc109df287f68508e0c2ec271236ffadbcbceaa5e9e5c03ae47
|
7
|
+
data.tar.gz: 50645a7ace7c184269dea68367d35851406da22c26f6abb683436f0bc7cab98cf3e15dfd74dec1c6989b8d14932d9c34926013ce42275b4362e3d2a0d5f3eed2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hubspot_v3 (
|
4
|
+
hubspot_v3 (1.0.0)
|
5
5
|
httparty (~> 0.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -11,9 +11,9 @@ GEM
|
|
11
11
|
httparty (0.20.0)
|
12
12
|
mime-types (~> 3.0)
|
13
13
|
multi_xml (>= 0.5.2)
|
14
|
-
mime-types (3.
|
14
|
+
mime-types (3.4.1)
|
15
15
|
mime-types-data (~> 3.2015)
|
16
|
-
mime-types-data (3.
|
16
|
+
mime-types-data (3.2022.0105)
|
17
17
|
multi_xml (0.6.0)
|
18
18
|
rake (13.0.6)
|
19
19
|
rspec (3.10.0)
|
data/README.md
CHANGED
@@ -28,9 +28,11 @@ It's possible to use our gem along with any of these two gems.
|
|
28
28
|
Add this line to your application's Gemfile:
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
gem 'hubspot_v3',
|
31
|
+
gem 'hubspot_v3', '~> 1.0'
|
32
32
|
```
|
33
33
|
|
34
|
+
[![Gem Version](https://badge.fury.io/rb/hubspot_v3.svg)](https://badge.fury.io/rb/hubspot_v3)
|
35
|
+
|
34
36
|
And then execute:
|
35
37
|
|
36
38
|
$ bundle install
|
@@ -321,13 +323,15 @@ require 'hubspot_v3/mock_contract'
|
|
321
323
|
HubspotV3::MockContract.contacts_search_by_emails(["hello@pobble.com", "notfound@pobble.com", "info@pobble.com"])
|
322
324
|
# [
|
323
325
|
# {
|
324
|
-
# "id" => 1589,
|
326
|
+
# "id" => 1589,
|
327
|
+
# "properties" => {
|
325
328
|
# "email"=>"hello@pobble.com",
|
326
329
|
# ...
|
327
330
|
# }
|
328
331
|
# },
|
329
|
-
|
330
|
-
# "id" => 1485,
|
332
|
+
# {
|
333
|
+
# "id" => 1485,
|
334
|
+
# "properties" => {
|
331
335
|
# "email"=>"info@pobble.com",
|
332
336
|
# ...
|
333
337
|
# }
|
@@ -338,7 +342,7 @@ HubspotV3::MockContract.contacts_search_by_emails_mapped(["hello@pobble.com", "n
|
|
338
342
|
# => ["hello@pobble.com", "info@pobble.com"]
|
339
343
|
```
|
340
344
|
|
341
|
-
`id` field of test Contact contracts is calculated as `'info@pobble.com'.bytes.sum == 1485
|
345
|
+
`id` field of test Contact contracts is calculated as `'info@pobble.com'.bytes.sum == 1485` ([source](https://github.com/Pobble/hubspot_v3/blob/master/lib/hubspot_v3/mock_contract.rb#L181)), create contacts will be `'info@pobble.com'.bytes.sum + 1_000_000 == 1001485` ([source](https://github.com/Pobble/hubspot_v3/blob/master/lib/hubspot_v3/mock_contract.rb#L29))
|
342
346
|
|
343
347
|
> More info on how to use [Contract tests](https://blog.eq8.eu/article/explicit-contracts-for-rails-http-api-usecase.html)
|
344
348
|
|
data/hubspot_v3.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "hubspot_v3"
|
7
7
|
spec.version = HubspotV3::VERSION
|
8
8
|
spec.authors = ["Tomas Valent"]
|
9
|
-
spec.email = ["
|
9
|
+
spec.email = ["equivalent@eq8.eu"]
|
10
10
|
|
11
11
|
spec.summary = "Hubspot CRM API (v3) Ruby gem"
|
12
12
|
spec.description = "Ruby wrapper around Hubspot CRM API v3 with simple implementation around batch endpoints and private apps token support"
|
data/lib/hubspot_v3/version.rb
CHANGED
data/lib/hubspot_v3.rb
CHANGED
@@ -15,6 +15,8 @@ module HubspotV3
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
HubspotRequestLimitReached = Class.new(RequestFailedError)
|
19
|
+
|
18
20
|
API_URL='https://api.hubapi.com'
|
19
21
|
CONTACTS_SEARCH='/crm/v3/objects/contacts/search'
|
20
22
|
CONTACTS_CREATE='/crm/v3/objects/contacts/batch/create'
|
@@ -90,15 +92,26 @@ module HubspotV3
|
|
90
92
|
end
|
91
93
|
|
92
94
|
def self.post(path, bodyhash)
|
93
|
-
|
95
|
+
httparty_response = HTTParty.post(url(path), {
|
94
96
|
body: bodyhash.to_json,
|
95
97
|
headers: headers
|
96
98
|
})
|
97
|
-
case
|
99
|
+
case httparty_response.code
|
98
100
|
when 200, 201
|
99
|
-
|
101
|
+
httparty_response.parsed_response['results']
|
102
|
+
when 429
|
103
|
+
# Hubspot error 429 - You have reached your secondly limit.
|
104
|
+
raise _hubspot_request_limit_reached_error(httparty_response)
|
105
|
+
when 500
|
106
|
+
if httparty_response.parsed_response["category"] == "RATE_LIMITS"
|
107
|
+
# e.g.: {"status":"error","message":"You have reached your secondly limit.","category":"RATE_LIMITS"}
|
108
|
+
# Yes, Hubspot will sometimes give 429 or 500 when limit reached
|
109
|
+
raise _hubspot_request_limit_reached_error(httparty_response)
|
110
|
+
else
|
111
|
+
raise _hubspot_request_failed_error(httparty_response)
|
112
|
+
end
|
100
113
|
else
|
101
|
-
raise
|
114
|
+
raise _hubspot_request_failed_error(httparty_response)
|
102
115
|
end
|
103
116
|
end
|
104
117
|
|
@@ -108,4 +121,16 @@ module HubspotV3
|
|
108
121
|
'Authorization': "Bearer #{config.token}"
|
109
122
|
}
|
110
123
|
end
|
124
|
+
|
125
|
+
def self._hubspot_request_limit_reached_error(httparty_response)
|
126
|
+
code = httparty_response.code
|
127
|
+
message = httparty_response.parsed_response['message']
|
128
|
+
HubspotV3::HubspotRequestLimitReached.new("#{code} - #{message}", httparty_response)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self._hubspot_request_failed_error(httparty_response)
|
132
|
+
code = httparty_response.code
|
133
|
+
message = httparty_response.parsed_response['message']
|
134
|
+
HubspotV3::RequestFailedError.new("#{code} - #{message}", httparty_response)
|
135
|
+
end
|
111
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
description: Ruby wrapper around Hubspot CRM API v3 with simple implementation around
|
28
28
|
batch endpoints and private apps token support
|
29
29
|
email:
|
30
|
-
-
|
30
|
+
- equivalent@eq8.eu
|
31
31
|
executables: []
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|