hubspot-ruby 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.hubapi.com/content/api/v2/topics?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
+ Cache-Control:
18
+ - No-store
19
+ Content-Type:
20
+ - application/json
21
+ Date:
22
+ - Mon, 20 Oct 2014 02:53:54 GMT
23
+ P3p:
24
+ - 'P3P: policyref="http://www.hubspot.com/w3c/p3p.xml", CP="CURa ADMa DEVa TAIa
25
+ PSAa PSDa OUR IND DSP NON COR'
26
+ Server:
27
+ - gunicorn/0.17.2
28
+ Vary:
29
+ - Accept-Encoding
30
+ X-Hs-Mc-Reqs:
31
+ - Z2V0X21hbnk6MiwyO3NldDoyLDI7Z2V0OjIsMw==
32
+ Content-Length:
33
+ - '584'
34
+ Connection:
35
+ - keep-alive
36
+ body:
37
+ encoding: UTF-8
38
+ string: '{"total_count": 3, "objects": [{"created": 1381896200000, "deleted_at":
39
+ 0, "description": "", "id": 349001328, "name": "api-docs", "portal_id": 62515,
40
+ "slug": "api-docs", "updated": 1381896200000}, {"created": 1389388053000,
41
+ "deleted_at": 0, "description": "", "id": 447332568, "name": "Test Topic 20140110160733",
42
+ "portal_id": 62515, "slug": "test-topic-20140110160733", "updated": 1389388053000},
43
+ {"created": 1389387669000, "deleted_at": 0, "description": "", "id": 450113517,
44
+ "name": "Test", "portal_id": 62515, "slug": "test", "updated": 1389387669000}],
45
+ "limit": 20, "offset": 0}'
46
+ http_version:
47
+ recorded_at: Mon, 20 Oct 2014 02:53:54 GMT
48
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,86 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.hubapi.com/content/api/v2/topics?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
+ Cache-Control:
18
+ - No-store
19
+ Content-Type:
20
+ - application/json
21
+ Date:
22
+ - Mon, 20 Oct 2014 02:55:54 GMT
23
+ P3p:
24
+ - 'P3P: policyref="http://www.hubspot.com/w3c/p3p.xml", CP="CURa ADMa DEVa TAIa
25
+ PSAa PSDa OUR IND DSP NON COR'
26
+ Server:
27
+ - gunicorn/0.17.2
28
+ Vary:
29
+ - Accept-Encoding
30
+ X-Hs-Mc-Reqs:
31
+ - Z2V0X21hbnk6MSwyO2dldDoyLDQ=
32
+ Content-Length:
33
+ - '584'
34
+ Connection:
35
+ - keep-alive
36
+ body:
37
+ encoding: UTF-8
38
+ string: '{"total_count": 3, "objects": [{"created": 1381896200000, "deleted_at":
39
+ 0, "description": "", "id": 349001328, "name": "api-docs", "portal_id": 62515,
40
+ "slug": "api-docs", "updated": 1381896200000}, {"created": 1389388053000,
41
+ "deleted_at": 0, "description": "", "id": 447332568, "name": "Test Topic 20140110160733",
42
+ "portal_id": 62515, "slug": "test-topic-20140110160733", "updated": 1389388053000},
43
+ {"created": 1389387669000, "deleted_at": 0, "description": "", "id": 450113517,
44
+ "name": "Test", "portal_id": 62515, "slug": "test", "updated": 1389387669000}],
45
+ "limit": 20, "offset": 0}'
46
+ http_version:
47
+ recorded_at: Mon, 20 Oct 2014 02:55:54 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://api.hubapi.com/content/api/v2/topics/349001328?hapikey=demo
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers: {}
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Access-Control-Allow-Credentials:
61
+ - 'false'
62
+ Cache-Control:
63
+ - No-store
64
+ Content-Type:
65
+ - application/json
66
+ Date:
67
+ - Mon, 20 Oct 2014 03:37:14 GMT
68
+ P3p:
69
+ - 'P3P: policyref="http://www.hubspot.com/w3c/p3p.xml", CP="CURa ADMa DEVa TAIa
70
+ PSAa PSDa OUR IND DSP NON COR'
71
+ Server:
72
+ - gunicorn/0.17.2
73
+ X-Hs-Mc-Reqs:
74
+ - Z2V0X21hbnk6MiwzO3NldDoxLDE7Z2V0OjIsMg==
75
+ Content-Length:
76
+ - '165'
77
+ Connection:
78
+ - keep-alive
79
+ body:
80
+ encoding: UTF-8
81
+ string: '{"created": 1381896200000, "deleted_at": 0, "description": "", "id":
82
+ 349001328, "name": "api-docs", "portal_id": 62515, "slug": "api-docs", "updated":
83
+ 1381896200000}'
84
+ http_version:
85
+ recorded_at: Mon, 20 Oct 2014 03:37:14 GMT
86
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,114 @@
1
+ require 'spec_helper'
2
+ require 'timecop'
3
+
4
+ describe Hubspot do
5
+ let(:example_blog_hash) do
6
+ VCR.use_cassette("blog_list", record: :none) do
7
+ url = Hubspot::Utils.generate_url(Hubspot::Blog::BLOG_LIST_PATH)
8
+ resp = HTTParty.get(url, format: :json)
9
+ resp.parsed_response["objects"].first
10
+ end
11
+ end
12
+ let(:created_range_params) { { created__gt: false, created__range: (Time.now..Time.now + 2.years) } }
13
+
14
+ before do
15
+ Hubspot.configure(hapikey: "demo")
16
+ Timecop.freeze(Time.local(2012, 'Oct', 10))
17
+ end
18
+
19
+ after do
20
+ Timecop.return
21
+ end
22
+
23
+ describe Hubspot::Blog do
24
+
25
+ describe ".list" do
26
+ cassette "blog_list"
27
+ let(:blog_list) { Hubspot::Blog.list }
28
+
29
+ it "should have a list of blogs" do
30
+ blog_list.count.should be(1)
31
+ end
32
+ end
33
+
34
+ describe ".find_by_id" do
35
+ cassette "blog_list"
36
+
37
+ it "should have a list of blogs" do
38
+ blog = Hubspot::Blog.find_by_id(351076997)
39
+ blog["id"].should eq(351076997)
40
+ end
41
+ end
42
+
43
+ describe "#initialize" do
44
+ subject{ Hubspot::Blog.new(example_blog_hash) }
45
+ its(["name"]) { should == "API Demonstration Blog" }
46
+ its(["id"]) { should == 351076997 }
47
+ end
48
+
49
+ describe "#posts" do
50
+ cassette "one_month_blog_posts_filter_state"
51
+ let(:blog) { Hubspot::Blog.new(example_blog_hash) }
52
+
53
+ describe "can be filtered by state" do
54
+
55
+ it "should filter the posts to published by default" do
56
+ blog.posts.length.should be(13)
57
+ end
58
+
59
+ it "should validate the state is a valid one" do
60
+ expect { blog.posts('invalid') }.to raise_error(Hubspot::Blog::InvalidParams)
61
+ end
62
+
63
+ it "should allow draft posts if specified" do
64
+ blog.posts({ state: false }.merge(created_range_params)).length.should be > 0
65
+ end
66
+ end
67
+
68
+ describe "can be ordered" do
69
+ it "created at descending is default" do
70
+ created_timestamps = blog.posts(created_range_params).map { |post| post['created'] }
71
+ expect(created_timestamps.sort.reverse).to eq(created_timestamps)
72
+ end
73
+
74
+ it "by created ascending" do
75
+ created_timestamps = blog.posts({order_by: '+created'}.merge(created_range_params)).map { |post| post['created'] }
76
+ expect(created_timestamps.sort).to eq(created_timestamps)
77
+ end
78
+ end
79
+
80
+ it "can set a page size" do
81
+ blog.posts({limit: 10}.merge(created_range_params)).length.should be(10)
82
+ end
83
+ end
84
+ end
85
+
86
+ describe Hubspot::BlogPost do
87
+ cassette "blog_posts"
88
+
89
+ let(:example_blog_post) do
90
+ VCR.use_cassette("one_month_blog_posts_filter_state", record: :none) do
91
+ blog = Hubspot::Blog.new(example_blog_hash)
92
+ blog.posts(created_range_params).first
93
+ end
94
+ end
95
+
96
+ it "should have a created_at value specific method" do
97
+ expect(example_blog_post.created_at).to eq(Time.at(example_blog_post['created'] / 1000))
98
+ end
99
+
100
+ it "can find by blog_post_id" do
101
+ blog = Hubspot::BlogPost.find_by_blog_post_id(422192866)
102
+ expect(blog['id']).to eq(422192866)
103
+ end
104
+
105
+ context 'containing a topic' do
106
+ # 422192866 contains a topic
107
+ let(:blog_with_topic) { Hubspot::BlogPost.find_by_blog_post_id(422192866) }
108
+
109
+ it "should return topic objects" do
110
+ expect(blog_with_topic.topics.first.is_a?(Hubspot::Topic)).to be(true)
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hubspot::Topic do
4
+ before do
5
+ Hubspot.configure(hapikey: "demo")
6
+ end
7
+
8
+ describe ".list" do
9
+ cassette "topics_list"
10
+ let(:topics) { Hubspot::Topic.list }
11
+
12
+ it "should have a list of topics" do
13
+ topics.count.should be(3)
14
+ end
15
+ end
16
+
17
+ describe ".find_by_topic_id" do
18
+ cassette "topics_list"
19
+
20
+ it "should find a specific topic" do
21
+ topic = Hubspot::Topic.find_by_topic_id(349001328)
22
+ topic['id'].should eq(349001328)
23
+ end
24
+ end
25
+ end
26
+
@@ -76,6 +76,19 @@ describe Hubspot::Utils do
76
76
  context "with query params" do
77
77
  let(:params){{email: "email@address.com", id: 1234}}
78
78
  it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&hapikey=demo" }
79
+
80
+ context "containing a time" do
81
+ let(:start_time) { Time.now }
82
+ let(:params){{email: "email@address.com", id: 1234, start: start_time}}
83
+ it{ should == "https://api.hubapi.com/test/email@address.com/profile?id=1234&start=#{start_time.to_i * 1000}&hapikey=demo" }
84
+ end
85
+
86
+ context "containing a range" do
87
+ let(:start_time) { Time.now }
88
+ let(:end_time) { Time.now + 1.year }
89
+ let(:params){{email: "email@address.com", id: 1234, created__range: start_time..end_time }}
90
+ 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" }
91
+ end
79
92
  end
80
93
 
81
94
  context "with options" do
metadata CHANGED
@@ -1,215 +1,226 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubspot-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrew DiMichele
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: httparty
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.10.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.10.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rr
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: webmock
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: vcr
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rdoc
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: bundler
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: jeweler
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: simplecov
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - ">="
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: awesome_print
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: timecop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: guard-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
188
193
  - !ruby/object:Gem::Version
189
194
  version: '0'
190
195
  description: hubspot-ruby is a wrapper for the HubSpot REST API
191
- email: andrew@omadahealth.com
196
+ email: hello@omadahealth.com
192
197
  executables: []
193
198
  extensions: []
194
199
  extra_rdoc_files:
195
200
  - LICENSE.txt
196
201
  - README.md
197
202
  files:
198
- - .document
199
- - .rspec
203
+ - ".document"
204
+ - ".rspec"
200
205
  - Gemfile
201
206
  - Gemfile.lock
207
+ - Guardfile
202
208
  - LICENSE.txt
203
209
  - README.md
204
210
  - Rakefile
205
211
  - hubspot-ruby.gemspec
206
212
  - lib/hubspot-ruby.rb
213
+ - lib/hubspot/blog.rb
207
214
  - lib/hubspot/config.rb
208
215
  - lib/hubspot/contact.rb
209
216
  - lib/hubspot/exceptions.rb
210
217
  - lib/hubspot/form.rb
218
+ - lib/hubspot/topic.rb
211
219
  - lib/hubspot/utils.rb
212
220
  - lib/hubspot/version.rb
221
+ - spec/fixtures/vcr_cassettes/blog_list.yml
222
+ - spec/fixtures/vcr_cassettes/blog_posts.yml
223
+ - spec/fixtures/vcr_cassettes/blog_posts_list.yml
213
224
  - spec/fixtures/vcr_cassettes/contact_create.yml
214
225
  - spec/fixtures/vcr_cassettes/contact_create_existing_email.yml
215
226
  - spec/fixtures/vcr_cassettes/contact_create_invalid_email.yml
@@ -220,39 +231,42 @@ files:
220
231
  - spec/fixtures/vcr_cassettes/contact_find_by_id.yml
221
232
  - spec/fixtures/vcr_cassettes/contact_find_by_utk.yml
222
233
  - spec/fixtures/vcr_cassettes/contact_update.yml
234
+ - spec/fixtures/vcr_cassettes/form_post.yml
235
+ - spec/fixtures/vcr_cassettes/one_month_blog_posts_filter_state.yml
236
+ - spec/fixtures/vcr_cassettes/one_month_blog_posts_list.yml
237
+ - spec/fixtures/vcr_cassettes/topic_list.yml
238
+ - spec/fixtures/vcr_cassettes/topics_list.yml
223
239
  - spec/lib/hubspot-ruby_spec.rb
240
+ - spec/lib/hubspot/blog_spec.rb
224
241
  - spec/lib/hubspot/config_spec.rb
225
242
  - spec/lib/hubspot/contact_spec.rb
226
243
  - spec/lib/hubspot/form_spec.rb
244
+ - spec/lib/hubspot/topic_spec.rb
227
245
  - spec/lib/hubspot/utils_spec.rb
228
246
  - spec/live/contacts_integration_spec.rb
229
247
  - spec/spec_helper.rb
230
248
  - spec/support/cassette_helper.rb
231
249
  homepage: http://github.com/omadahealth/hubspot-ruby
232
250
  licenses: []
251
+ metadata: {}
233
252
  post_install_message:
234
253
  rdoc_options: []
235
254
  require_paths:
236
255
  - lib
237
256
  required_ruby_version: !ruby/object:Gem::Requirement
238
- none: false
239
257
  requirements:
240
- - - ! '>='
258
+ - - ">="
241
259
  - !ruby/object:Gem::Version
242
260
  version: '0'
243
- segments:
244
- - 0
245
- hash: 1072152427736485155
246
261
  required_rubygems_version: !ruby/object:Gem::Requirement
247
- none: false
248
262
  requirements:
249
- - - ! '>='
263
+ - - ">="
250
264
  - !ruby/object:Gem::Version
251
265
  version: '0'
252
266
  requirements: []
253
267
  rubyforge_project:
254
- rubygems_version: 1.8.25
268
+ rubygems_version: 2.2.2
255
269
  signing_key:
256
- specification_version: 3
270
+ specification_version: 4
257
271
  summary: hubspot-ruby is a wrapper for the HubSpot REST API
258
272
  test_files: []