hubspot-ruby 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hubspot-ruby.gemspec +42 -5
- data/lib/hubspot-ruby.rb +3 -0
- data/lib/hubspot/blog.rb +14 -48
- data/lib/hubspot/connection.rb +95 -0
- data/lib/hubspot/contact.rb +74 -91
- data/lib/hubspot/contact_list.rb +127 -0
- data/lib/hubspot/contact_properties.rb +12 -0
- data/lib/hubspot/deal.rb +29 -25
- data/lib/hubspot/exceptions.rb +2 -0
- data/lib/hubspot/form.rb +88 -4
- data/lib/hubspot/topic.rb +8 -24
- data/lib/hubspot/utils.rb +0 -51
- data/lib/hubspot/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/add_contacts_to_lists.yml +281 -0
- data/spec/fixtures/vcr_cassettes/contact_create.yml +34 -2
- data/spec/fixtures/vcr_cassettes/contact_create_existing_email.yml +34 -2
- data/spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml +35 -3
- data/spec/fixtures/vcr_cassettes/contact_create_with_params.yml +34 -2
- data/spec/fixtures/vcr_cassettes/contact_destroy.yml +36 -4
- data/spec/fixtures/vcr_cassettes/contact_find_by_email_batch_mode.yml +509 -0
- data/spec/fixtures/vcr_cassettes/contact_find_by_id_batch_mode.yml +33 -0
- data/spec/fixtures/vcr_cassettes/contact_find_by_utk_batch_mode.yml +33 -0
- data/spec/fixtures/vcr_cassettes/contact_list_batch_find.yml +65 -0
- data/spec/fixtures/vcr_cassettes/contact_list_destroy.yml +63 -0
- data/spec/fixtures/vcr_cassettes/contact_list_example.yml +33 -0
- data/spec/fixtures/vcr_cassettes/contact_list_find.yml +96 -0
- data/spec/fixtures/vcr_cassettes/contact_list_refresh.yml +33 -0
- data/spec/fixtures/vcr_cassettes/contact_list_update.yml +36 -0
- data/spec/fixtures/vcr_cassettes/contacts_among_list.yml +189 -0
- data/spec/fixtures/vcr_cassettes/create_form.yml +39 -0
- data/spec/fixtures/vcr_cassettes/create_list.yml +36 -0
- data/spec/fixtures/vcr_cassettes/create_list_with_filters.yml +36 -0
- data/spec/fixtures/vcr_cassettes/deal_create.yml +29 -0
- data/spec/fixtures/vcr_cassettes/deal_find.yml +56 -0
- data/spec/fixtures/vcr_cassettes/destroy_deal.yml +110 -0
- data/spec/fixtures/vcr_cassettes/fail_to_create_form.yml +35 -0
- data/spec/fixtures/vcr_cassettes/fail_to_create_list.yml +35 -0
- data/spec/fixtures/vcr_cassettes/field_among_form.yml +34 -0
- data/spec/fixtures/vcr_cassettes/fields_among_form.yml +35 -0
- data/spec/fixtures/vcr_cassettes/find_all_contacts.yml +39 -0
- data/spec/fixtures/vcr_cassettes/find_all_dynamic_lists.yml +104 -0
- data/spec/fixtures/vcr_cassettes/find_all_forms.yml +15378 -0
- data/spec/fixtures/vcr_cassettes/find_all_lists.yml +138 -0
- data/spec/fixtures/vcr_cassettes/find_all_recent_contacts.yml +33 -0
- data/spec/fixtures/vcr_cassettes/find_all_stastic_lists.yml +21876 -0
- data/spec/fixtures/vcr_cassettes/form_destroy.yml +64 -0
- data/spec/fixtures/vcr_cassettes/form_example.yml +39 -0
- data/spec/fixtures/vcr_cassettes/form_find.yml +69 -0
- data/spec/fixtures/vcr_cassettes/form_submit_data.yml +130 -0
- data/spec/fixtures/vcr_cassettes/form_update.yml +77 -0
- data/spec/fixtures/vcr_cassettes/one_month_blog_posts_filter_state.yml +5168 -0
- data/spec/fixtures/vcr_cassettes/remove_contacts_from_lists.yml +315 -0
- data/spec/lib/hubspot/blog_spec.rb +4 -3
- data/spec/lib/hubspot/connection_spec.rb +112 -0
- data/spec/lib/hubspot/contact_list_spec.rb +249 -0
- data/spec/lib/hubspot/contact_properties_spec.rb +8 -0
- data/spec/lib/hubspot/contact_spec.rb +110 -54
- data/spec/lib/hubspot/deal_spec.rb +11 -0
- data/spec/lib/hubspot/form_spec.rb +157 -10
- data/spec/lib/hubspot/utils_spec.rb +0 -67
- data/spec/live/deals_integration_spec.rb +35 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/tests_helper.rb +17 -0
- metadata +70 -33
@@ -0,0 +1,315 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.hubapi.com/contacts/v1/lists/static?count=2&hapikey=demo
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Access-Control-Allow-Credentials:
|
16
|
+
- 'false'
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=UTF-8
|
19
|
+
Date:
|
20
|
+
- Sat, 21 Feb 2015 23:32:57 GMT
|
21
|
+
Vary:
|
22
|
+
- Accept-Encoding
|
23
|
+
- Accept-Encoding
|
24
|
+
Content-Length:
|
25
|
+
- '709'
|
26
|
+
Connection:
|
27
|
+
- keep-alive
|
28
|
+
body:
|
29
|
+
encoding: UTF-8
|
30
|
+
string: '{"lists":[{"metaData":{"processing":"DONE","lastProcessingStateChangeAt":1336673990262,"lastSizeChangeAt":1424559295352,"error":"","size":0},"dynamic":false,"portalId":62515,"createdAt":1336673951299,"updatedAt":1336673951299,"listId":2,"filters":[[{"operator":"IS_NOT_EMPTY","withinTimeMode":"PAST","property":"twitterhandle"}]],"internalListId":2,"name":"HubSpot-HootSuite
|
31
|
+
App"},{"metaData":{"processing":"DONE","lastProcessingStateChangeAt":1344891893390,"lastSizeChangeAt":1424561205790,"error":"","size":2},"dynamic":false,"portalId":62515,"createdAt":1344891893390,"listType":"STATIC","updatedAt":1344891893390,"listId":3,"filters":[],"internalListId":5,"name":"staticTest"}],"offset":2,"has-more":true}'
|
32
|
+
http_version:
|
33
|
+
recorded_at: Sat, 21 Feb 2015 23:32:57 GMT
|
34
|
+
- request:
|
35
|
+
method: get
|
36
|
+
uri: https://api.hubapi.com/contacts/v1/lists/3/contacts/all?count=2&hapikey=demo&property=email
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers: {}
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 200
|
44
|
+
message: OK
|
45
|
+
headers:
|
46
|
+
Access-Control-Allow-Credentials:
|
47
|
+
- 'false'
|
48
|
+
Content-Type:
|
49
|
+
- application/json; charset=UTF-8
|
50
|
+
Date:
|
51
|
+
- Sat, 21 Feb 2015 23:32:58 GMT
|
52
|
+
Vary:
|
53
|
+
- Accept-Encoding
|
54
|
+
- Accept-Encoding
|
55
|
+
Content-Length:
|
56
|
+
- '1887'
|
57
|
+
Connection:
|
58
|
+
- keep-alive
|
59
|
+
body:
|
60
|
+
encoding: UTF-8
|
61
|
+
string: '{"contacts":[{"addedAt":1405720281340,"vid":233443,"canonical-vid":233443,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPb8t4UMyhKYuCYQn5-imBRBo9BDjXQZ8Du3oj2bc29H3WXKC3HCkANkFR7pyr73O37uRg6W2nvihx652BOcXd8SBWt772Z4W_NVPWNbrejPFyiik3humvniib1NqstlYsVqZ4r","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPb8t4UMyhKYuCYQn5-imBRBo9BDjXQZ8Du3oj2bc29H3WXKC3HCkANkFR7pyr73O37uRg6W2nvihx652BOcXd8SBWt772Z4W_NVPWNbrejPFyiik3humvniib1NqstlYsVqZ4r/","properties":{"lastmodifieddate":{"value":"1423206192349"},"email":{"value":"test@123456789test.com"}},"form-submissions":[],"identity-profiles":[{"vid":233443,"saved-at-timestamp":1405720240435,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"test@123456789test.com","timestamp":1405720240352},{"type":"LEAD_GUID","value":"c5d75e47-8abe-4977-a494-d6a5243dd6bc","timestamp":1405720240369}]}],"merge-audits":[]},{"addedAt":1406676072454,"vid":234368,"canonical-vid":234368,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mPsanEOa85h8HlhRpZ-_cfVVkU55CswfPRsIejQiqOZVYiEPg2hPDdKj_s3RM8n5cjxuiPPd5e3jRrdJ8R41C7NCYSXJABeC_LtToznJDSmpDJnFdRIrzZi9Q23j0x7Q2WOMZsz","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPsanEOa85h8HlhRpZ-_cfVVkU55CswfPRsIejQiqOZVYiEPg2hPDdKj_s3RM8n5cjxuiPPd5e3jRrdJ8R41C7NCYSXJABeC_LtToznJDSmpDJnFdRIrzZi9Q23j0x7Q2WOMZsz/","properties":{"lastmodifieddate":{"value":"1423206205727"},"email":{"value":"osmond@azuqua.com"}},"form-submissions":[],"identity-profiles":[{"vid":234368,"saved-at-timestamp":1406666653355,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"osmond@azuqua.com","timestamp":1406666653316},{"type":"LEAD_GUID","value":"68f561be-6908-4e97-880f-b372d3bb11a8","timestamp":1406666653342}]}],"merge-audits":[]}],"has-more":false,"vid-offset":234368}'
|
62
|
+
http_version:
|
63
|
+
recorded_at: Sat, 21 Feb 2015 23:32:58 GMT
|
64
|
+
- request:
|
65
|
+
method: post
|
66
|
+
uri: https://api.hubapi.com/contacts/v1/lists/3/remove?hapikey=demo
|
67
|
+
body:
|
68
|
+
encoding: UTF-8
|
69
|
+
string: '{"vids":[233443,234368]}'
|
70
|
+
headers:
|
71
|
+
Content-Type:
|
72
|
+
- application/json
|
73
|
+
response:
|
74
|
+
status:
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
Access-Control-Allow-Credentials:
|
79
|
+
- 'false'
|
80
|
+
Content-Type:
|
81
|
+
- application/json; charset=UTF-8
|
82
|
+
Date:
|
83
|
+
- Sat, 21 Feb 2015 23:32:59 GMT
|
84
|
+
Vary:
|
85
|
+
- Accept-Encoding
|
86
|
+
- Accept-Encoding
|
87
|
+
Content-Length:
|
88
|
+
- '42'
|
89
|
+
Connection:
|
90
|
+
- keep-alive
|
91
|
+
body:
|
92
|
+
encoding: UTF-8
|
93
|
+
string: '{"updated":[233443,234368],"discarded":[]}'
|
94
|
+
http_version:
|
95
|
+
recorded_at: Sat, 21 Feb 2015 23:32:59 GMT
|
96
|
+
- request:
|
97
|
+
method: get
|
98
|
+
uri: https://api.hubapi.com/contacts/v1/lists/dynamic?count=1&hapikey=demo
|
99
|
+
body:
|
100
|
+
encoding: US-ASCII
|
101
|
+
string: ''
|
102
|
+
headers: {}
|
103
|
+
response:
|
104
|
+
status:
|
105
|
+
code: 200
|
106
|
+
message: OK
|
107
|
+
headers:
|
108
|
+
Access-Control-Allow-Credentials:
|
109
|
+
- 'false'
|
110
|
+
Content-Type:
|
111
|
+
- application/json; charset=UTF-8
|
112
|
+
Date:
|
113
|
+
- Sat, 21 Feb 2015 23:33:00 GMT
|
114
|
+
Vary:
|
115
|
+
- Accept-Encoding
|
116
|
+
- Accept-Encoding
|
117
|
+
Content-Length:
|
118
|
+
- '421'
|
119
|
+
Connection:
|
120
|
+
- keep-alive
|
121
|
+
body:
|
122
|
+
encoding: UTF-8
|
123
|
+
string: '{"lists":[{"dynamic":true,"metaData":{"processing":"DONE","lastProcessingStateChangeAt":1335448864306,"error":"","lastSizeChangeAt":1424402567742,"size":3355},"filters":[[{"operator":"IS_NOT_EMPTY","withinTimeMode":"PAST","property":"twitterhandle"}]],"portalId":62515,"createdAt":1335448813688,"listId":1,"updatedAt":1335448813688,"listType":"DYNAMIC","internalListId":1,"name":"twitterers"}],"offset":1,"has-more":true}'
|
124
|
+
http_version:
|
125
|
+
recorded_at: Sat, 21 Feb 2015 23:33:00 GMT
|
126
|
+
- request:
|
127
|
+
method: get
|
128
|
+
uri: https://api.hubapi.com/contacts/v1/lists/1/contacts/recent?count=1&hapikey=demo&property=email
|
129
|
+
body:
|
130
|
+
encoding: US-ASCII
|
131
|
+
string: ''
|
132
|
+
headers: {}
|
133
|
+
response:
|
134
|
+
status:
|
135
|
+
code: 200
|
136
|
+
message: OK
|
137
|
+
headers:
|
138
|
+
Access-Control-Allow-Credentials:
|
139
|
+
- 'false'
|
140
|
+
Content-Type:
|
141
|
+
- application/json; charset=UTF-8
|
142
|
+
Date:
|
143
|
+
- Sat, 21 Feb 2015 23:33:02 GMT
|
144
|
+
Vary:
|
145
|
+
- Accept-Encoding
|
146
|
+
- Accept-Encoding
|
147
|
+
Content-Length:
|
148
|
+
- '1021'
|
149
|
+
Connection:
|
150
|
+
- keep-alive
|
151
|
+
body:
|
152
|
+
encoding: UTF-8
|
153
|
+
string: '{"contacts":[{"addedAt":1424402567710,"vid":263687,"canonical-vid":263687,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mOLQAb6JByotsEJIGvfPTBqk3_9vvz3ee2-Q9su_4UEimZcZdxTwYjMp0qZuqFqmaOFhHtul-HVvM6-J83RtYrGl0x37FyQZhpiH28TMzUq8MPqWsFNNQp3ZKTnmTeG4oLnHYhU","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOLQAb6JByotsEJIGvfPTBqk3_9vvz3ee2-Q9su_4UEimZcZdxTwYjMp0qZuqFqmaOFhHtul-HVvM6-J83RtYrGl0x37FyQZhpiH28TMzUq8MPqWsFNNQp3ZKTnmTeG4oLnHYhU/","properties":{"lastmodifieddate":{"value":"1424402575285"},"email":{"value":"andrewglover+pivotdesk@gmail.com"}},"form-submissions":[],"identity-profiles":[{"vid":263687,"saved-at-timestamp":1424379142579,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"andrewglover+pivotdesk@gmail.com","timestamp":1424379142521},{"type":"LEAD_GUID","value":"95df8bed-3940-4f27-af69-076db8cd0d72","timestamp":1424379142525}]}],"merge-audits":[]}],"has-more":true,"vid-offset":263687,"time-offset":1424402567710}'
|
154
|
+
http_version:
|
155
|
+
recorded_at: Sat, 21 Feb 2015 23:33:02 GMT
|
156
|
+
- request:
|
157
|
+
method: post
|
158
|
+
uri: https://api.hubapi.com/contacts/v1/lists/1/remove?hapikey=demo
|
159
|
+
body:
|
160
|
+
encoding: UTF-8
|
161
|
+
string: '{"vids":[263687]}'
|
162
|
+
headers:
|
163
|
+
Content-Type:
|
164
|
+
- application/json
|
165
|
+
response:
|
166
|
+
status:
|
167
|
+
code: 400
|
168
|
+
message: Bad Request
|
169
|
+
headers:
|
170
|
+
Access-Control-Allow-Credentials:
|
171
|
+
- 'false'
|
172
|
+
Content-Type:
|
173
|
+
- application/json; charset=UTF-8
|
174
|
+
Date:
|
175
|
+
- Sat, 21 Feb 2015 23:33:29 GMT
|
176
|
+
Vary:
|
177
|
+
- Accept-Encoding
|
178
|
+
- Accept-Encoding
|
179
|
+
Content-Length:
|
180
|
+
- '124'
|
181
|
+
Connection:
|
182
|
+
- keep-alive
|
183
|
+
body:
|
184
|
+
encoding: UTF-8
|
185
|
+
string: '{"status":"error","message":"Can not operate manually on a dynamic
|
186
|
+
list","requestId":"10ad0135-43f1-4c8d-bf84-16d1dbb83ec4"}'
|
187
|
+
http_version:
|
188
|
+
recorded_at: Sat, 21 Feb 2015 23:33:29 GMT
|
189
|
+
- request:
|
190
|
+
method: post
|
191
|
+
uri: https://api.hubapi.com/contacts/v1/lists/3/add?hapikey=demo
|
192
|
+
body:
|
193
|
+
encoding: UTF-8
|
194
|
+
string: '{"vids":[82325]}'
|
195
|
+
headers:
|
196
|
+
Content-Type:
|
197
|
+
- application/json
|
198
|
+
response:
|
199
|
+
status:
|
200
|
+
code: 200
|
201
|
+
message: OK
|
202
|
+
headers:
|
203
|
+
Access-Control-Allow-Credentials:
|
204
|
+
- 'false'
|
205
|
+
Content-Type:
|
206
|
+
- application/json; charset=UTF-8
|
207
|
+
Date:
|
208
|
+
- Sat, 21 Feb 2015 23:43:36 GMT
|
209
|
+
Vary:
|
210
|
+
- Accept-Encoding
|
211
|
+
- Accept-Encoding
|
212
|
+
Content-Length:
|
213
|
+
- '29'
|
214
|
+
Connection:
|
215
|
+
- keep-alive
|
216
|
+
body:
|
217
|
+
encoding: UTF-8
|
218
|
+
string: '{"updated":[],"discarded":[]}'
|
219
|
+
http_version:
|
220
|
+
recorded_at: Sat, 21 Feb 2015 23:43:36 GMT
|
221
|
+
- request:
|
222
|
+
method: get
|
223
|
+
uri: https://api.hubapi.com/contacts/v1/lists/static?count=3&hapikey=demo
|
224
|
+
body:
|
225
|
+
encoding: US-ASCII
|
226
|
+
string: ''
|
227
|
+
headers: {}
|
228
|
+
response:
|
229
|
+
status:
|
230
|
+
code: 200
|
231
|
+
message: OK
|
232
|
+
headers:
|
233
|
+
Access-Control-Allow-Credentials:
|
234
|
+
- 'false'
|
235
|
+
Content-Type:
|
236
|
+
- application/json; charset=UTF-8
|
237
|
+
Date:
|
238
|
+
- Sat, 21 Feb 2015 23:53:00 GMT
|
239
|
+
Vary:
|
240
|
+
- Accept-Encoding
|
241
|
+
- Accept-Encoding
|
242
|
+
Content-Length:
|
243
|
+
- '1013'
|
244
|
+
Connection:
|
245
|
+
- keep-alive
|
246
|
+
body:
|
247
|
+
encoding: UTF-8
|
248
|
+
string: '{"lists":[{"metaData":{"size":0,"error":"","processing":"DONE","lastProcessingStateChangeAt":1336673990262,"lastSizeChangeAt":1424559295352},"name":"HubSpot-HootSuite
|
249
|
+
App","dynamic":false,"filters":[[{"property":"twitterhandle","withinTimeMode":"PAST","operator":"IS_NOT_EMPTY"}]],"portalId":62515,"createdAt":1336673951299,"listId":2,"updatedAt":1336673951299,"internalListId":2},{"metaData":{"size":0,"error":"","processing":"DONE","lastProcessingStateChangeAt":1344891893390,"lastSizeChangeAt":1424561579485},"name":"staticTest","dynamic":false,"filters":[],"portalId":62515,"createdAt":1344891893390,"listId":3,"updatedAt":1344891893390,"listType":"STATIC","internalListId":5},{"metaData":{"size":2,"error":"","processing":"DONE","lastProcessingStateChangeAt":1345057450679,"lastSizeChangeAt":1421930685051},"name":"Workface
|
250
|
+
Leads","dynamic":false,"filters":[],"portalId":62515,"createdAt":1345057450679,"listId":4,"updatedAt":1345057450679,"listType":"STATIC","internalListId":6}],"offset":3,"has-more":true}'
|
251
|
+
http_version:
|
252
|
+
recorded_at: Sat, 21 Feb 2015 23:53:00 GMT
|
253
|
+
- request:
|
254
|
+
method: get
|
255
|
+
uri: https://api.hubapi.com/contacts/v1/lists/4/contacts/all?count=2&hapikey=demo&property=email
|
256
|
+
body:
|
257
|
+
encoding: US-ASCII
|
258
|
+
string: ''
|
259
|
+
headers: {}
|
260
|
+
response:
|
261
|
+
status:
|
262
|
+
code: 200
|
263
|
+
message: OK
|
264
|
+
headers:
|
265
|
+
Access-Control-Allow-Credentials:
|
266
|
+
- 'false'
|
267
|
+
Content-Type:
|
268
|
+
- application/json; charset=UTF-8
|
269
|
+
Date:
|
270
|
+
- Sat, 21 Feb 2015 23:53:00 GMT
|
271
|
+
Vary:
|
272
|
+
- Accept-Encoding
|
273
|
+
- Accept-Encoding
|
274
|
+
Content-Length:
|
275
|
+
- '1887'
|
276
|
+
Connection:
|
277
|
+
- keep-alive
|
278
|
+
body:
|
279
|
+
encoding: UTF-8
|
280
|
+
string: '{"contacts":[{"addedAt":1410377496034,"vid":240665,"canonical-vid":240665,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mO5qqTDBdnw_I_JbldGAIgeB8U3qtUH69ihLg_M8d4xhcp4fC8R_sFqvnYTZN2NEooIsX3i9HKLBy18vtrja6mAlfukTGxvdrUzqpYrVjfBJDGDFaa2sTI4f7xjv-oZMAJVbz4I","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mO5qqTDBdnw_I_JbldGAIgeB8U3qtUH69ihLg_M8d4xhcp4fC8R_sFqvnYTZN2NEooIsX3i9HKLBy18vtrja6mAlfukTGxvdrUzqpYrVjfBJDGDFaa2sTI4f7xjv-oZMAJVbz4I/","properties":{"lastmodifieddate":{"value":"1423206291283"},"email":{"value":"jimmy@jack.com"}},"form-submissions":[],"identity-profiles":[{"vid":240665,"saved-at-timestamp":1410370949852,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"jimmy@jack.com","timestamp":1410370949831},{"type":"LEAD_GUID","value":"17af62d8-4228-4033-976d-ce9bad8b3fb4","timestamp":1410370949840}]}],"merge-audits":[]},{"addedAt":1421930684995,"vid":261954,"canonical-vid":261954,"merged-vids":[],"portal-id":62515,"is-contact":true,"profile-token":"AO_T-mNkRvHRVrSIalWLdVC12ZNilrVAtNlJZj5LHSc40rCrbA5SU5AHrYXFNzW26yrCUh9PsxeMY7pubavabTl2CFEGsWWfnSYlmDjaBFn4awtbT8tovxCcmPOu4zvWLNrgNDbWTgzx","profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNkRvHRVrSIalWLdVC12ZNilrVAtNlJZj5LHSc40rCrbA5SU5AHrYXFNzW26yrCUh9PsxeMY7pubavabTl2CFEGsWWfnSYlmDjaBFn4awtbT8tovxCcmPOu4zvWLNrgNDbWTgzx/","properties":{"lastmodifieddate":{"value":"1423206602823"},"email":{"value":"joelstephen11@stripes.com"}},"form-submissions":[],"identity-profiles":[{"vid":261954,"saved-at-timestamp":1421928766400,"deleted-changed-timestamp":0,"identities":[{"type":"EMAIL","value":"joelstephen11@stripes.com","timestamp":1421928766277},{"type":"LEAD_GUID","value":"3afe6c95-7e83-4a48-a55d-17af2eab05b5","timestamp":1421928766360}]}],"merge-audits":[]}],"has-more":false,"vid-offset":261954}'
|
281
|
+
http_version:
|
282
|
+
recorded_at: Sat, 21 Feb 2015 23:53:00 GMT
|
283
|
+
- request:
|
284
|
+
method: post
|
285
|
+
uri: https://api.hubapi.com/contacts/v1/lists/4/remove?hapikey=demo
|
286
|
+
body:
|
287
|
+
encoding: UTF-8
|
288
|
+
string: '{"vids":[240665,261954]}'
|
289
|
+
headers:
|
290
|
+
Content-Type:
|
291
|
+
- application/json
|
292
|
+
response:
|
293
|
+
status:
|
294
|
+
code: 200
|
295
|
+
message: OK
|
296
|
+
headers:
|
297
|
+
Access-Control-Allow-Credentials:
|
298
|
+
- 'false'
|
299
|
+
Content-Type:
|
300
|
+
- application/json; charset=UTF-8
|
301
|
+
Date:
|
302
|
+
- Sat, 21 Feb 2015 23:53:00 GMT
|
303
|
+
Vary:
|
304
|
+
- Accept-Encoding
|
305
|
+
- Accept-Encoding
|
306
|
+
Content-Length:
|
307
|
+
- '42'
|
308
|
+
Connection:
|
309
|
+
- keep-alive
|
310
|
+
body:
|
311
|
+
encoding: UTF-8
|
312
|
+
string: '{"updated":[261954,240665],"discarded":[]}'
|
313
|
+
http_version:
|
314
|
+
recorded_at: Sat, 21 Feb 2015 23:53:00 GMT
|
315
|
+
recorded_with: VCR 2.4.0
|
@@ -3,7 +3,7 @@ require 'timecop'
|
|
3
3
|
describe Hubspot do
|
4
4
|
let(:example_blog_hash) do
|
5
5
|
VCR.use_cassette("blog_list", record: :none) do
|
6
|
-
url = Hubspot::
|
6
|
+
url = Hubspot::Connection.send(:generate_url, Hubspot::Blog::BLOG_LIST_PATH)
|
7
7
|
resp = HTTParty.get(url, format: :json)
|
8
8
|
resp.parsed_response["objects"].first
|
9
9
|
end
|
@@ -52,11 +52,11 @@ describe Hubspot do
|
|
52
52
|
describe "can be filtered by state" do
|
53
53
|
|
54
54
|
it "should filter the posts to published by default" do
|
55
|
-
blog.posts.length.should be(
|
55
|
+
blog.posts.length.should be(14)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should validate the state is a valid one" do
|
59
|
-
expect { blog.posts('invalid') }.to raise_error(Hubspot::
|
59
|
+
expect { blog.posts('invalid') }.to raise_error(Hubspot::InvalidParams)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should allow draft posts if specified" do
|
@@ -71,6 +71,7 @@ describe Hubspot do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "by created ascending" do
|
74
|
+
pending
|
74
75
|
created_timestamps = blog.posts({order_by: '+created'}.merge(created_range_params)).map { |post| post['created'] }
|
75
76
|
expect(created_timestamps.sort).to eq(created_timestamps)
|
76
77
|
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
describe Hubspot::Connection do
|
2
|
+
before(:each) do
|
3
|
+
@url = 'http://localhost:3000'
|
4
|
+
@http_reponse = mock('http_response')
|
5
|
+
end
|
6
|
+
|
7
|
+
describe '.get_json' do
|
8
|
+
it 'delegates url format to Hubspot::Utils, call HTTParty get and returns response' do
|
9
|
+
@http_reponse.success? { true }
|
10
|
+
@http_reponse.parsed_response { {} }
|
11
|
+
|
12
|
+
mock(Hubspot::Connection).generate_url(@url, {}) { @url }
|
13
|
+
mock(Hubspot::Connection).get(@url, format: :json) { @http_reponse }
|
14
|
+
Hubspot::Connection.get_json(@url, {})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.post_json' do
|
19
|
+
it 'delegates url format to Hubspot::Utils, call HTTParty post and returns response' do
|
20
|
+
@http_reponse.success? { true }
|
21
|
+
@http_reponse.parsed_response { {} }
|
22
|
+
|
23
|
+
mock(Hubspot::Connection).generate_url(@url, {}) { @url }
|
24
|
+
mock(Hubspot::Connection).post(@url, body: "{}", headers: {"Content-Type"=>"application/json"}, format: :json) { @http_reponse }
|
25
|
+
Hubspot::Connection.post_json(@url, params: {}, body: {})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.delete_json' do
|
30
|
+
it 'delegates url format to Hubspot::Utils, call HTTParty delete and returns response' do
|
31
|
+
@http_reponse.success? { true }
|
32
|
+
|
33
|
+
mock(Hubspot::Connection).generate_url(@url, {}) { @url }
|
34
|
+
mock(Hubspot::Connection).delete(@url, format: :json) { @http_reponse }
|
35
|
+
Hubspot::Connection.delete_json(@url, {})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'private methods' do
|
40
|
+
describe ".generate_url" do
|
41
|
+
let(:path){ "/test/:email/profile" }
|
42
|
+
let(:params){{email: "test"}}
|
43
|
+
let(:options){{}}
|
44
|
+
subject{ Hubspot::Connection.send(:generate_url, path, params, options) }
|
45
|
+
before{ Hubspot.configure(hapikey: "demo", portal_id: "62515") }
|
46
|
+
|
47
|
+
it "doesn't modify params" do
|
48
|
+
expect{ subject }.to_not change{params}
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with a portal_id param" do
|
52
|
+
let(:path){ "/test/:portal_id/profile" }
|
53
|
+
let(:params){{}}
|
54
|
+
it{ should == "https://api.hubapi.com/test/62515/profile?hapikey=demo" }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when configure hasn't been called" do
|
58
|
+
before{ Hubspot::Config.reset! }
|
59
|
+
it "raises a config exception" do
|
60
|
+
expect{ subject }.to raise_error Hubspot::ConfigurationError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with interpolations but no params" do
|
65
|
+
let(:params){{}}
|
66
|
+
it "raises an interpolation exception" do
|
67
|
+
expect{ subject }.to raise_error Hubspot::MissingInterpolation
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with an interpolated param" do
|
72
|
+
let(:params){ {email: "email@address.com"} }
|
73
|
+
it{ should == "https://api.hubapi.com/test/email@address.com/profile?hapikey=demo" }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with multiple interpolated params" do
|
77
|
+
let(:path){ "/test/:email/:id/profile" }
|
78
|
+
let(:params){{email: "email@address.com", id: 1234}}
|
79
|
+
it{ should == "https://api.hubapi.com/test/email@address.com/1234/profile?hapikey=demo" }
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with query params" do
|
83
|
+
let(:params){{email: "email@address.com", id: 1234}}
|
84
|
+
it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&hapikey=demo" }
|
85
|
+
|
86
|
+
context "containing a time" do
|
87
|
+
let(:start_time) { Time.now }
|
88
|
+
let(:params){{email: "email@address.com", id: 1234, start: start_time}}
|
89
|
+
it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&start=#{start_time.to_i * 1000}&hapikey=demo" }
|
90
|
+
end
|
91
|
+
|
92
|
+
context "containing a range" do
|
93
|
+
let(:start_time) { Time.now }
|
94
|
+
let(:end_time) { Time.now + 1.year }
|
95
|
+
let(:params){{email: "email@address.com", id: 1234, created__range: start_time..end_time }}
|
96
|
+
it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&created__range=#{start_time.to_i * 1000}&created__range=#{end_time.to_i * 1000}&hapikey=demo" }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with options" do
|
101
|
+
let(:options){ {base_url: "https://cool.com", hapikey: false} }
|
102
|
+
it{ should == "https://cool.com/test/test/profile"}
|
103
|
+
end
|
104
|
+
|
105
|
+
context "passing Array as parameters for batch mode, key is prefixed with batch_" do
|
106
|
+
let(:path) { Hubspot::ContactList::LIST_BATCH_PATH }
|
107
|
+
let(:params) { { batch_list_id: [1,2,3] } }
|
108
|
+
it{ should == "https://api.hubapi.com/contacts/v1/lists/batch?listId=1&listId=2&listId=3&hapikey=demo" }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|