appboy 0.0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/README.md +111 -21
  5. data/appboy.gemspec +18 -10
  6. data/lib/appboy.rb +5 -3
  7. data/lib/appboy/api.rb +18 -30
  8. data/lib/appboy/deprecated.rb +19 -0
  9. data/lib/appboy/endpoints/email_status.rb +13 -0
  10. data/lib/appboy/endpoints/schedule_messages.rb +15 -0
  11. data/lib/appboy/endpoints/send_messages.rb +15 -0
  12. data/lib/appboy/endpoints/track_users.rb +29 -0
  13. data/lib/appboy/http.rb +24 -0
  14. data/lib/appboy/rest.rb +7 -0
  15. data/lib/appboy/rest/base.rb +15 -0
  16. data/lib/appboy/rest/email_status.rb +21 -0
  17. data/lib/appboy/rest/export_users.rb +27 -0
  18. data/lib/appboy/rest/list_segments.rb +11 -0
  19. data/lib/appboy/rest/schedule_messages.rb +25 -0
  20. data/lib/appboy/rest/send_messages.rb +23 -0
  21. data/lib/appboy/rest/track_users.rb +14 -0
  22. data/lib/appboy/version.rb +1 -1
  23. data/spec/appboy/api_spec.rb +4 -0
  24. data/spec/appboy/endpoints/track_users_spec.rb +72 -0
  25. data/spec/appboy/rest/email_status_spec.rb +19 -0
  26. data/spec/appboy/rest/export_users_spec.rb +20 -0
  27. data/spec/appboy/rest/schedule_messages_spec.rb +34 -0
  28. data/spec/appboy/rest/send_messages_spec.rb +36 -0
  29. data/spec/appboy/rest/track_users_spec.rb +24 -0
  30. data/spec/factories.rb +32 -0
  31. data/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml +54 -0
  32. data/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml +54 -0
  33. data/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml +52 -0
  34. data/spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml +52 -0
  35. data/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml +56 -0
  36. data/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml +54 -0
  37. data/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml +58 -0
  38. data/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml +58 -0
  39. data/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml +53 -0
  40. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml +55 -0
  41. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml +55 -0
  42. data/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml +52 -0
  43. data/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml +54 -0
  44. data/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml +54 -0
  45. data/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml +54 -0
  46. data/spec/fixtures/responses/track_users/with_success/responds_with_created.yml +56 -0
  47. data/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml +56 -0
  48. data/spec/integrations/email_status_spec.rb +36 -0
  49. data/spec/integrations/export_users_spec.rb +27 -0
  50. data/spec/integrations/list_segments_spec.rb +21 -0
  51. data/spec/integrations/schedule_messages_spec.rb +31 -0
  52. data/spec/integrations/send_messages_spec.rb +30 -0
  53. data/spec/integrations/track_users_spec.rb +35 -0
  54. data/spec/spec_helper.rb +10 -1
  55. data/spec/support/factory_girl.rb +10 -0
  56. data/spec/support/integrations.rb +19 -0
  57. data/spec/support/vcr.rb +17 -0
  58. metadata +212 -18
  59. data/spec/api_spec.rb +0 -60
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'list segments' do
4
+ subject(:list_segments) { api.list_segments }
5
+
6
+ context 'with success', :vcr do
7
+ it 'responds with success' do
8
+ expect(list_segments).to be_success
9
+ end
10
+
11
+ it 'responds with a list of segments' do
12
+ expect(segments.count).to be 7
13
+
14
+ expect(segments.first['name']).to eq 'test'
15
+ end
16
+
17
+ def segments
18
+ JSON.parse(list_segments.body)['segments']
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'schedule messages' do
4
+ let(:user_ids) { [1] }
5
+ let(:messages) { build(:messages) }
6
+
7
+ subject(:schedule_messages) do
8
+ api.schedule_messages(send_at: test_time,
9
+ messages: messages, segment_id: segment_id)
10
+ end
11
+
12
+ context 'with success', vcr: true do
13
+ it 'responds with created' do
14
+ expect(schedule_messages.status).to be 201
15
+ end
16
+
17
+ it 'responds with success message' do
18
+ expect(JSON.parse(schedule_messages.body)).to eq(
19
+ 'message' => 'success'
20
+ )
21
+ end
22
+ end
23
+
24
+ context 'unauthorized', vcr: true do
25
+ let(:app_group_id) { 'non-existent' }
26
+
27
+ it 'responds with unauthorize' do
28
+ expect(schedule_messages.status).to be 401
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'send messages' do
4
+ let(:user_ids) { [1] }
5
+ let(:messages) { build(:messages) }
6
+
7
+ subject(:send_messages) do
8
+ api.send_messages(messages: messages, external_user_ids: user_ids)
9
+ end
10
+
11
+ context 'with success', vcr: true do
12
+ it 'responds with created' do
13
+ expect(send_messages.status).to be 201
14
+ end
15
+
16
+ it 'responds with success message' do
17
+ expect(JSON.parse(send_messages.body)).to eq(
18
+ 'message' => 'success'
19
+ )
20
+ end
21
+ end
22
+
23
+ context 'unauthorized', vcr: true do
24
+ let(:app_group_id) { 'non-existent' }
25
+
26
+ it 'responds with unauthorized' do
27
+ expect(send_messages.status).to be 401
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'track users' do
4
+ let(:attributes) { [build(:attribute)] }
5
+ let(:events) { [build(:event, time: test_time)] }
6
+ let(:purchases) { [build(:purchase, time: test_time)] }
7
+
8
+ subject(:track_users) do
9
+ api.track_users(attributes: attributes,
10
+ events: events, purchases: purchases)
11
+ end
12
+
13
+ context 'with success', vcr: true do
14
+ it 'responds with created' do
15
+ expect(track_users.status).to be 201
16
+ end
17
+
18
+ it 'responds with success message' do
19
+ expect(JSON.parse(track_users.body)).to eq(
20
+ 'attributes_processed' => 1,
21
+ 'events_processed' => 1,
22
+ 'purchases_processed' => 1,
23
+ 'message' => 'success'
24
+ )
25
+ end
26
+ end
27
+
28
+ context 'unauthorized', vcr: true do
29
+ let(:app_group_id) { 'non-existent' }
30
+
31
+ it 'responds with unauthorized' do
32
+ expect(track_users.status).to be 401
33
+ end
34
+ end
35
+ end
@@ -1,8 +1,17 @@
1
+ require 'pry'
2
+ require 'dotenv'
1
3
  require 'bundler/setup'
4
+
2
5
  Bundler.setup
6
+ Dotenv.load
3
7
 
4
8
  require 'appboy'
9
+ require 'support/vcr'
10
+ require 'support/factory_girl'
11
+ require 'support/integrations'
5
12
 
6
13
  RSpec.configure do |config|
7
- # some (optional) config here
14
+ def test_time
15
+ Time.parse('2015-02-15 00:00:00 -0500')
16
+ end
8
17
  end
@@ -0,0 +1,10 @@
1
+ require 'factory_girl'
2
+ require 'factories'
3
+
4
+ RSpec.configure do |config|
5
+ config.include FactoryGirl::Syntax::Methods
6
+
7
+ config.before(:suite) do
8
+ FactoryGirl.lint
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ require 'active_support/concern'
2
+
3
+ module Integrations
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ let(:app_group_id) { ENV.fetch('APPBOY_GROUP_ID') }
8
+ let(:segment_id) { ENV.fetch('APPBOY_TEST_SEGMENT') }
9
+
10
+ let(:api) { Appboy::API.new(app_group_id) }
11
+
12
+
13
+
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.include self, type: :integrations, file_path: %r(spec/integrations)
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |config|
4
+ config.filter_sensitive_data('<APPBOY_GROUP_ID>') { ENV.fetch('APPBOY_GROUP_ID') }
5
+ config.filter_sensitive_data('<APPBOY_TEST_SEGMENT>') { ENV.fetch('APPBOY_TEST_SEGMENT') }
6
+
7
+ config.cassette_library_dir = 'spec/fixtures/responses'
8
+
9
+ config.default_cassette_options = {
10
+ match_requests_on: [:method, :uri, :body]
11
+ }
12
+
13
+ config.configure_rspec_metadata!
14
+
15
+ config.hook_into :webmock
16
+ end
17
+
metadata CHANGED
@@ -1,79 +1,194 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
8
+ - Hugo Bastien
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-07 00:00:00.000000000 Z
12
+ date: 2015-04-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: httparty
15
+ name: virtus
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - '>='
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
20
  version: '0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - '>='
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: faraday_middleware
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
25
54
  - !ruby/object:Gem::Version
26
55
  version: '0'
27
56
  - !ruby/object:Gem::Dependency
28
57
  name: bundler
29
58
  requirement: !ruby/object:Gem::Requirement
30
59
  requirements:
31
- - - ~>
60
+ - - "~>"
32
61
  - !ruby/object:Gem::Version
33
62
  version: '1.3'
34
63
  type: :development
35
64
  prerelease: false
36
65
  version_requirements: !ruby/object:Gem::Requirement
37
66
  requirements:
38
- - - ~>
67
+ - - "~>"
39
68
  - !ruby/object:Gem::Version
40
69
  version: '1.3'
41
70
  - !ruby/object:Gem::Dependency
42
71
  name: rake
43
72
  requirement: !ruby/object:Gem::Requirement
44
73
  requirements:
45
- - - '>='
74
+ - - ">="
46
75
  - !ruby/object:Gem::Version
47
76
  version: '0'
48
77
  type: :development
49
78
  prerelease: false
50
79
  version_requirements: !ruby/object:Gem::Requirement
51
80
  requirements:
52
- - - '>='
81
+ - - ">="
53
82
  - !ruby/object:Gem::Version
54
83
  version: '0'
55
84
  - !ruby/object:Gem::Dependency
56
85
  name: rspec
57
86
  requirement: !ruby/object:Gem::Requirement
58
87
  requirements:
59
- - - '>='
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: dotenv
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: vcr
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: pry
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: activesupport
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: factory_girl
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
60
173
  - !ruby/object:Gem::Version
61
174
  version: '0'
62
175
  type: :development
63
176
  prerelease: false
64
177
  version_requirements: !ruby/object:Gem::Requirement
65
178
  requirements:
66
- - - '>='
179
+ - - ">="
67
180
  - !ruby/object:Gem::Version
68
181
  version: '0'
69
182
  description: Appboy wrapper
70
183
  email:
71
184
  - josh@godynamo.com
185
+ - hugo@godynamo.com
72
186
  executables: []
73
187
  extensions: []
74
188
  extra_rdoc_files: []
75
189
  files:
76
- - .gitignore
190
+ - ".gitignore"
191
+ - ".rspec"
77
192
  - Gemfile
78
193
  - LICENSE.txt
79
194
  - README.md
@@ -81,9 +196,56 @@ files:
81
196
  - appboy.gemspec
82
197
  - lib/appboy.rb
83
198
  - lib/appboy/api.rb
199
+ - lib/appboy/deprecated.rb
200
+ - lib/appboy/endpoints/email_status.rb
201
+ - lib/appboy/endpoints/schedule_messages.rb
202
+ - lib/appboy/endpoints/send_messages.rb
203
+ - lib/appboy/endpoints/track_users.rb
204
+ - lib/appboy/http.rb
205
+ - lib/appboy/rest.rb
206
+ - lib/appboy/rest/base.rb
207
+ - lib/appboy/rest/email_status.rb
208
+ - lib/appboy/rest/export_users.rb
209
+ - lib/appboy/rest/list_segments.rb
210
+ - lib/appboy/rest/schedule_messages.rb
211
+ - lib/appboy/rest/send_messages.rb
212
+ - lib/appboy/rest/track_users.rb
84
213
  - lib/appboy/version.rb
85
- - spec/api_spec.rb
214
+ - spec/appboy/api_spec.rb
215
+ - spec/appboy/endpoints/track_users_spec.rb
216
+ - spec/appboy/rest/email_status_spec.rb
217
+ - spec/appboy/rest/export_users_spec.rb
218
+ - spec/appboy/rest/schedule_messages_spec.rb
219
+ - spec/appboy/rest/send_messages_spec.rb
220
+ - spec/appboy/rest/track_users_spec.rb
221
+ - spec/factories.rb
222
+ - spec/fixtures/responses/email_status/existing_email/responds_with_created.yml
223
+ - spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml
224
+ - spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml
225
+ - spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml
226
+ - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
227
+ - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
228
+ - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
229
+ - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
230
+ - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
231
+ - spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml
232
+ - spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml
233
+ - spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml
234
+ - spec/fixtures/responses/send_messages/with_success/responds_with_created.yml
235
+ - spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml
236
+ - spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml
237
+ - spec/fixtures/responses/track_users/with_success/responds_with_created.yml
238
+ - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
239
+ - spec/integrations/email_status_spec.rb
240
+ - spec/integrations/export_users_spec.rb
241
+ - spec/integrations/list_segments_spec.rb
242
+ - spec/integrations/schedule_messages_spec.rb
243
+ - spec/integrations/send_messages_spec.rb
244
+ - spec/integrations/track_users_spec.rb
86
245
  - spec/spec_helper.rb
246
+ - spec/support/factory_girl.rb
247
+ - spec/support/integrations.rb
248
+ - spec/support/vcr.rb
87
249
  homepage: http://appboy.com
88
250
  licenses:
89
251
  - MIT
@@ -94,22 +256,54 @@ require_paths:
94
256
  - lib
95
257
  required_ruby_version: !ruby/object:Gem::Requirement
96
258
  requirements:
97
- - - '>='
259
+ - - ">="
98
260
  - !ruby/object:Gem::Version
99
261
  version: '0'
100
262
  required_rubygems_version: !ruby/object:Gem::Requirement
101
263
  requirements:
102
- - - '>='
264
+ - - ">="
103
265
  - !ruby/object:Gem::Version
104
266
  version: '0'
105
267
  requirements: []
106
268
  rubyforge_project:
107
- rubygems_version: 2.0.3
269
+ rubygems_version: 2.2.2
108
270
  signing_key:
109
271
  specification_version: 4
110
272
  summary: A wrapper for the Appboy REST API, track users/events/purchases, send & schedule
111
273
  messages
112
274
  test_files:
113
- - spec/api_spec.rb
275
+ - spec/appboy/api_spec.rb
276
+ - spec/appboy/endpoints/track_users_spec.rb
277
+ - spec/appboy/rest/email_status_spec.rb
278
+ - spec/appboy/rest/export_users_spec.rb
279
+ - spec/appboy/rest/schedule_messages_spec.rb
280
+ - spec/appboy/rest/send_messages_spec.rb
281
+ - spec/appboy/rest/track_users_spec.rb
282
+ - spec/factories.rb
283
+ - spec/fixtures/responses/email_status/existing_email/responds_with_created.yml
284
+ - spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml
285
+ - spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml
286
+ - spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml
287
+ - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
288
+ - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
289
+ - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
290
+ - spec/fixtures/responses/list_segments/with_success/responds_with_success.yml
291
+ - spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml
292
+ - spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml
293
+ - spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml
294
+ - spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml
295
+ - spec/fixtures/responses/send_messages/with_success/responds_with_created.yml
296
+ - spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml
297
+ - spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml
298
+ - spec/fixtures/responses/track_users/with_success/responds_with_created.yml
299
+ - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
300
+ - spec/integrations/email_status_spec.rb
301
+ - spec/integrations/export_users_spec.rb
302
+ - spec/integrations/list_segments_spec.rb
303
+ - spec/integrations/schedule_messages_spec.rb
304
+ - spec/integrations/send_messages_spec.rb
305
+ - spec/integrations/track_users_spec.rb
114
306
  - spec/spec_helper.rb
115
- has_rdoc:
307
+ - spec/support/factory_girl.rb
308
+ - spec/support/integrations.rb
309
+ - spec/support/vcr.rb