leanplum_api 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba21ebe73260c66ae36b3c901abfe6824d238b26
4
- data.tar.gz: '009e58d6f0537a717bd1a66ddf6f39d5601ab328'
3
+ metadata.gz: d5a76aed3d020547e134ee3a112266a894ede780
4
+ data.tar.gz: 79ef59a1a63018388963bd3d71de1af95ac9cd72
5
5
  SHA512:
6
- metadata.gz: 0e56f3fea79360b0820803e7edb1d153f19691d7adf644699feba9c7abe00edd58593852c8e62988dd202f3471ad7818ed8de9c55225adf6fb10b657c4e420c5
7
- data.tar.gz: 9404b64c448032f32cde14db3082cdb4fc5fa4e2b4d7e27de1ede0ea5f4dc653fd4a8bdf8d3c01b9983df5a75687deb62c922c6d4d6fae05b2035f3f518e88ae
6
+ metadata.gz: 7878726aa0f68c2445c941e3e695ee341780836625f9022fe4a4efa80fbb89f6163fc11991f56781e36132b47b9a2e325bb7452a0bfcefd18892b8e1d2a7543e
7
+ data.tar.gz: 8c2cbb38fbc6f12b439f6f01512bdb94a952bb6fc895ed8f57853b5a57a01605ba73b88f4585db0f9991cc6a29f8ea4f3365412e92e692636b30689682ed8977
@@ -16,8 +16,10 @@ module LeanplumApi
16
16
 
17
17
  @app.call(environment).on_complete do |response|
18
18
  fail ResourceNotFoundError, response.inspect if response.status == 404
19
- fail BadResponseError, response.inspect unless response.status == 200 && (responses = response.body['response']).is_a?(Array)
20
- fail BadResponseError, "No :success key in #{responses.inspect}!" unless responses.all? { |r| r.key?(SUCCESS) }
19
+ fail BadResponseError, response.inspect unless response.status == 200
20
+
21
+ responses = response.body['response']
22
+ fail BadResponseError, "No response array: #{response.inspect}" unless responses.is_a?(Array)
21
23
 
22
24
  validate_request_success(responses, requests) if LeanplumApi.configuration.validate_response
23
25
  end
@@ -27,7 +29,7 @@ module LeanplumApi
27
29
 
28
30
  def validate_request_success(success_indicators, requests)
29
31
  if requests && success_indicators.size != requests.size
30
- fail BadResponseError, "Attempted #{requests.size} operations but received confirmation for #{success_indicators.size}!"
32
+ fail BadResponseError, "Attempted #{requests.size} operations; responses for only #{success_indicators.size}!"
31
33
  end
32
34
 
33
35
  failures = success_indicators.map.with_index do |indicator, i|
@@ -37,7 +39,8 @@ module LeanplumApi
37
39
 
38
40
  next nil if indicator[SUCCESS].to_s == 'true'
39
41
 
40
- requests ? { operation: requests[i], error: indicator } : { error: indicator }
42
+ failure = { message: indicator.key?(SUCCESS) ? indicator.to_s : "No :success key found in #{indicator}" }
43
+ requests ? failure.merge(operation: requests[i]) : failure
41
44
  end.compact
42
45
 
43
46
  unless failures.empty?
@@ -1,3 +1,3 @@
1
1
  module LeanplumApi
2
- VERSION = '4.0.0'
2
+ VERSION = '4.0.1'
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -302,17 +302,17 @@ describe LeanplumApi::API do
302
302
  end
303
303
 
304
304
  context 'hash utility methods' do
305
- let(:hash_with_times) { { not_time: 'grippin', time: Time.now.utc, date: Time.now.utc.to_date } }
305
+ let(:hash_with_times) { { not_time: 'grippin', time: last_event_time, date: last_event_time.to_date } }
306
306
 
307
307
  it 'turns datetimes into seconds from the epoch' do
308
308
  expect(api.send(:fix_seconds_since_epoch, hash_with_times)).to eq(
309
- hash_with_times.merge(time: Time.now.utc.strftime('%s').to_i, date: Time.now.utc.to_date.strftime('%s').to_i)
309
+ hash_with_times.merge(time: last_event_time.strftime('%s').to_i, date: last_event_time.to_date.strftime('%s').to_i)
310
310
  )
311
311
  end
312
312
 
313
313
  it 'turns datetimes into iso8601 format' do
314
314
  expect(api.send(:fix_iso8601, hash_with_times)).to eq(
315
- hash_with_times.merge(time: Time.now.utc.iso8601, date: Time.now.utc.to_date.iso8601)
315
+ hash_with_times.merge(time: last_event_time.iso8601, date: last_event_time.to_date.iso8601)
316
316
  )
317
317
  end
318
318
  end
@@ -10,17 +10,17 @@ describe LeanplumApi::DataExportAPI do
10
10
  context 'data export methods' do
11
11
  context 'export_data' do
12
12
  context 'regular export' do
13
- it 'should request a data export job with a starttime' do
14
- VCR.use_cassette('export_data') do
15
- expect { api.export_data(Time.at(1438660800).utc) }.to raise_error LeanplumApi::BadResponseError
16
- end
17
- end
18
-
19
13
  it 'should request a data export job with start and end dates' do
20
14
  VCR.use_cassette('export_data_dates') do
21
15
  expect { api.export_data(Date.new(2017, 8, 5), Date.new(2017, 8, 6)) }.to_not raise_error
22
16
  end
23
17
  end
18
+
19
+ it 'should exception when requesting a data export job with an invalid starttime' do
20
+ VCR.use_cassette('export_data') do
21
+ expect { api.export_data(Time.at(1438660800).utc) }.to raise_error LeanplumApi::BadResponseError
22
+ end
23
+ end
24
24
  end
25
25
 
26
26
  context 's3 export' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanplum_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lumos Labs, Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-14 00:00:00.000000000 Z
12
+ date: 2017-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport