leanplum_api 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +63 -32
  3. data/lib/leanplum_api/api.rb +107 -156
  4. data/lib/leanplum_api/configuration.rb +9 -1
  5. data/lib/leanplum_api/connection.rb +2 -2
  6. data/lib/leanplum_api/data_export_api.rb +78 -0
  7. data/lib/leanplum_api/faraday_middleware/response_validation.rb +23 -19
  8. data/lib/leanplum_api/version.rb +1 -1
  9. data/spec/api_spec.rb +142 -98
  10. data/spec/configuration_spec.rb +2 -2
  11. data/spec/data_export_api_spec.rb +57 -0
  12. data/spec/fixtures/vcr/delete_user.yml +129 -0
  13. data/spec/fixtures/vcr/export_data.yml +5 -5
  14. data/spec/fixtures/vcr/export_data_dates.yml +6 -6
  15. data/spec/fixtures/vcr/export_user.yml +7 -7
  16. data/spec/fixtures/vcr/export_users.yml +44 -0
  17. data/spec/fixtures/vcr/get_ab_test.yml +5 -5
  18. data/spec/fixtures/vcr/get_ab_tests.yml +5 -5
  19. data/spec/fixtures/vcr/get_export_results.yml +5 -5
  20. data/spec/fixtures/vcr/get_messages.yml +5 -5
  21. data/spec/fixtures/vcr/get_vars.yml +5 -5
  22. data/spec/fixtures/vcr/missing_message.yml +4 -4
  23. data/spec/fixtures/vcr/reset_anomalous_user.yml +6 -6
  24. data/spec/fixtures/vcr/set_device_attributes.yml +46 -0
  25. data/spec/fixtures/vcr/set_user_attributes.yml +7 -7
  26. data/spec/fixtures/vcr/set_user_attributes_with_devices.yml +46 -0
  27. data/spec/fixtures/vcr/set_user_attributes_with_devices_and_events.yml +46 -0
  28. data/spec/fixtures/vcr/set_user_attributes_with_events.yml +46 -0
  29. data/spec/fixtures/vcr/track_events.yml +8 -8
  30. data/spec/fixtures/vcr/track_events_and_attributes.yml +9 -9
  31. data/spec/fixtures/vcr/track_events_anomaly_overrider.yml +20 -19
  32. data/spec/fixtures/vcr/track_offline_events.yml +8 -8
  33. data/spec/http_spec.rb +6 -5
  34. data/spec/spec_helper.rb +11 -8
  35. metadata +40 -3
@@ -2,11 +2,11 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://www.leanplum.com/api?action=multi&apiVersion=1.0.6&appId=<LEANPLUM_APP_ID>&clientKey=<LEANPLUM_PRODUCTION_KEY>&devMode=false&time=1505188800
5
+ uri: https://www.leanplum.com/api?action=multi&apiVersion=1.0.6&appId=<LEANPLUM_APP_ID>&clientKey=<LEANPLUM_PRODUCTION_KEY>&devMode=false&time=1505372950
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"data":[{"action":"track","event":"purchase","userId":123456,"time":1505188800,"allowOffline":true,"params":{"some_timestamp":"2015-05-01
9
- 01:02:03"}},{"action":"track","event":"purchase_page_view","userId":54321,"time":1505188200,"allowOffline":true}]}'
8
+ string: '{"data":[{"action":"track","event":"purchase","userId":123456,"time":1505372950,"allowOffline":true,"params":{"some_timestamp":"2015-05-01
9
+ 01:02:03"}},{"action":"track","event":"purchase_page_view","userId":54321,"time":1505372350,"allowOffline":true}]}'
10
10
  headers:
11
11
  User-Agent:
12
12
  - Faraday v0.13.1
@@ -26,22 +26,22 @@ http_interactions:
26
26
  Content-Type:
27
27
  - application/json;charset=utf-8
28
28
  X-Cloud-Trace-Context:
29
- - 9de3f0a7f5bd26fcbf9edada00fd78d6
29
+ - edb9c1a488ab44bc4cc2714a91edfc10
30
30
  Set-Cookie:
31
- - GOOGAPPUID=xCgoIAxB1IOCX4c0F; expires=Sun, 01-Nov-2020 17:04:32 GMT; path=/
31
+ - GOOGAPPUID=xCgoIAxBLIJnX6M0F; expires=Tue, 03-Nov-2020 03:11:21 GMT; path=/
32
32
  Date:
33
- - Tue, 12 Sep 2017 21:04:32 GMT
33
+ - Thu, 14 Sep 2017 07:11:21 GMT
34
34
  Server:
35
35
  - Google Frontend
36
36
  Content-Length:
37
37
  - '82'
38
38
  Expires:
39
- - Tue, 12 Sep 2017 21:04:32 GMT
39
+ - Thu, 14 Sep 2017 07:11:21 GMT
40
40
  Cache-Control:
41
41
  - private
42
42
  body:
43
43
  encoding: UTF-8
44
44
  string: '{"response":[{"success":true,"isOffline":true},{"success":true,"isOffline":true}]}'
45
45
  http_version:
46
- recorded_at: Tue, 12 Sep 2017 04:00:00 GMT
46
+ recorded_at: Thu, 14 Sep 2017 07:09:10 GMT
47
47
  recorded_with: VCR 3.0.3
data/spec/http_spec.rb CHANGED
@@ -1,22 +1,23 @@
1
- require 'spec_helper'
2
-
3
1
  describe LeanplumApi::Connection do
4
2
  let(:http) { described_class.new(LeanplumApi.configuration.production_key) }
3
+
5
4
  def argument_string(dev_mode)
6
5
  "appId=#{LeanplumApi.configuration.app_id}&clientKey=#{LeanplumApi.configuration.production_key}&apiVersion=1.0.6&devMode=#{dev_mode}&action=multi&time=#{Time.now.utc.strftime('%s')}"
7
6
  end
8
7
 
9
8
  context 'regular mode' do
9
+ before do
10
+ LeanplumApi.configure { |c| c.developer_mode = false }
11
+ end
12
+
10
13
  it 'should build the right multi url' do
11
14
  expect(http.send(:authed_multi_param_string)).to eq(argument_string(false))
12
15
  end
13
16
  end
14
17
 
15
18
  context 'devMode' do
16
- around(:all) do |example|
19
+ before do
17
20
  LeanplumApi.configure { |c| c.developer_mode = true }
18
- example.run
19
- LeanplumApi.configure { |c| c.developer_mode = false }
20
21
  end
21
22
 
22
23
  it 'should build the right developer mode url' do
data/spec/spec_helper.rb CHANGED
@@ -3,26 +3,29 @@ require 'rspec'
3
3
  require 'timecop'
4
4
  require 'webmock'
5
5
  require 'vcr'
6
+ require 'dotenv/load'
6
7
 
7
8
  DEFAULT_SPEC_KEY = 'JUNKTASTIC_SPASMASTIC'
8
9
 
9
10
  RSpec.configure do |config|
10
11
  config.before(:all) do
11
- LeanplumApi.configure do |configuration|
12
- configuration.production_key = ENV['LEANPLUM_PRODUCTION_KEY'] || DEFAULT_SPEC_KEY
13
- configuration.app_id = ENV['LEANPLUM_APP_ID'] || DEFAULT_SPEC_KEY
14
- configuration.data_export_key = ENV['LEANPLUM_DATA_EXPORT_KEY'] || DEFAULT_SPEC_KEY
15
- configuration.content_read_only_key = ENV['LEANPLUM_CONTENT_READ_ONLY_KEY'] || DEFAULT_SPEC_KEY
16
- configuration.development_key = ENV['LEANPLUM_DEVELOPMENT_KEY'] || DEFAULT_SPEC_KEY
17
- configuration.logger.level = Logger::FATAL
12
+ LeanplumApi.configure do |config|
13
+ config.production_key = ENV['LEANPLUM_PRODUCTION_KEY'] || DEFAULT_SPEC_KEY
14
+ config.app_id = ENV['LEANPLUM_APP_ID'] || DEFAULT_SPEC_KEY
15
+ config.data_export_key = ENV['LEANPLUM_DATA_EXPORT_KEY'] || DEFAULT_SPEC_KEY
16
+ config.content_read_only_key = ENV['LEANPLUM_CONTENT_READ_ONLY_KEY'] || DEFAULT_SPEC_KEY
17
+ config.development_key = ENV['LEANPLUM_DEVELOPMENT_KEY'] || DEFAULT_SPEC_KEY
18
+
19
+ config.logger.level = config.debug_mode? ? Logger::DEBUG : Logger::FATAL
18
20
  end
19
21
 
20
22
  # Leanplum requires passing the time in some requests so we freeze it.
21
- Timecop.freeze('2017-09-12'.to_time.utc)
23
+ Timecop.freeze('2017-09-14T07:09:10.787Z'.to_time)
22
24
  end
23
25
  end
24
26
 
25
27
  VCR.configure do |c|
28
+ c.allow_http_connections_when_no_cassette = true
26
29
  c.cassette_library_dir = 'spec/fixtures/vcr'
27
30
  c.hook_into :webmock
28
31
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanplum_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lumos Labs, Inc.
8
+ - Countable Corp
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
12
+ date: 2017-09-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -134,9 +135,30 @@ dependencies:
134
135
  - - ">"
135
136
  - !ruby/object:Gem::Version
136
137
  version: '2'
138
+ - !ruby/object:Gem::Dependency
139
+ name: dotenv
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '2.2'
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.2.1
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: '2.2'
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 2.2.1
137
158
  description: Ruby-esque access to Leanplum API
138
159
  email:
139
160
  - analytics-dev@lumoslabs.com
161
+ - eng@countable.us
140
162
  executables: []
141
163
  extensions: []
142
164
  extra_rdoc_files: []
@@ -148,14 +170,18 @@ files:
148
170
  - lib/leanplum_api/api.rb
149
171
  - lib/leanplum_api/configuration.rb
150
172
  - lib/leanplum_api/connection.rb
173
+ - lib/leanplum_api/data_export_api.rb
151
174
  - lib/leanplum_api/faraday_middleware/response_validation.rb
152
175
  - lib/leanplum_api/logger.rb
153
176
  - lib/leanplum_api/version.rb
154
177
  - spec/api_spec.rb
155
178
  - spec/configuration_spec.rb
179
+ - spec/data_export_api_spec.rb
180
+ - spec/fixtures/vcr/delete_user.yml
156
181
  - spec/fixtures/vcr/export_data.yml
157
182
  - spec/fixtures/vcr/export_data_dates.yml
158
183
  - spec/fixtures/vcr/export_user.yml
184
+ - spec/fixtures/vcr/export_users.yml
159
185
  - spec/fixtures/vcr/get_ab_test.yml
160
186
  - spec/fixtures/vcr/get_ab_tests.yml
161
187
  - spec/fixtures/vcr/get_export_results.yml
@@ -163,7 +189,11 @@ files:
163
189
  - spec/fixtures/vcr/get_vars.yml
164
190
  - spec/fixtures/vcr/missing_message.yml
165
191
  - spec/fixtures/vcr/reset_anomalous_user.yml
192
+ - spec/fixtures/vcr/set_device_attributes.yml
166
193
  - spec/fixtures/vcr/set_user_attributes.yml
194
+ - spec/fixtures/vcr/set_user_attributes_with_devices.yml
195
+ - spec/fixtures/vcr/set_user_attributes_with_devices_and_events.yml
196
+ - spec/fixtures/vcr/set_user_attributes_with_events.yml
167
197
  - spec/fixtures/vcr/track_events.yml
168
198
  - spec/fixtures/vcr/track_events_and_attributes.yml
169
199
  - spec/fixtures/vcr/track_events_anomaly_overrider.yml
@@ -182,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
212
  requirements:
183
213
  - - ">="
184
214
  - !ruby/object:Gem::Version
185
- version: 2.1.5
215
+ version: '2.0'
186
216
  required_rubygems_version: !ruby/object:Gem::Requirement
187
217
  requirements:
188
218
  - - ">="
@@ -197,9 +227,12 @@ summary: Gem for the Leanplum API
197
227
  test_files:
198
228
  - spec/api_spec.rb
199
229
  - spec/configuration_spec.rb
230
+ - spec/data_export_api_spec.rb
231
+ - spec/fixtures/vcr/delete_user.yml
200
232
  - spec/fixtures/vcr/export_data.yml
201
233
  - spec/fixtures/vcr/export_data_dates.yml
202
234
  - spec/fixtures/vcr/export_user.yml
235
+ - spec/fixtures/vcr/export_users.yml
203
236
  - spec/fixtures/vcr/get_ab_test.yml
204
237
  - spec/fixtures/vcr/get_ab_tests.yml
205
238
  - spec/fixtures/vcr/get_export_results.yml
@@ -207,7 +240,11 @@ test_files:
207
240
  - spec/fixtures/vcr/get_vars.yml
208
241
  - spec/fixtures/vcr/missing_message.yml
209
242
  - spec/fixtures/vcr/reset_anomalous_user.yml
243
+ - spec/fixtures/vcr/set_device_attributes.yml
210
244
  - spec/fixtures/vcr/set_user_attributes.yml
245
+ - spec/fixtures/vcr/set_user_attributes_with_devices.yml
246
+ - spec/fixtures/vcr/set_user_attributes_with_devices_and_events.yml
247
+ - spec/fixtures/vcr/set_user_attributes_with_events.yml
211
248
  - spec/fixtures/vcr/track_events.yml
212
249
  - spec/fixtures/vcr/track_events_and_attributes.yml
213
250
  - spec/fixtures/vcr/track_events_anomaly_overrider.yml