leanplum_api 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92bca9f613ba5eb8d2f4eebb6cc88fb29fc2a38b
4
- data.tar.gz: 16979c3cae038e26c6873b6815ae7deefda268e7
3
+ metadata.gz: 43f7d678d33a30f6b8f4a3d50a875f3536328ad1
4
+ data.tar.gz: 7bb19cca732b8023d580d110423fa46f071c64a6
5
5
  SHA512:
6
- metadata.gz: 34f75c8514a7e7b8811a0a80bc35f699834fe3054c5c545d6737e19346d1d02b10c8090c91336f8297ad87eb45ab04d0464f8f9df5fa2d9c967fe89ae8601894
7
- data.tar.gz: 8ded87e06e2ed7b5dee4b24f9888eef4c116cdbc829df41b031706ce2d0cbecdc4de2b9f0550e13148860a2fb3f4821702432732862d79d32222305486eab649
6
+ metadata.gz: eb6851bf1dd347cc0f0e4b91a8d529ac91a38bb61898cc0172491e81d21da464e4c55b3a561750f2078249dcb52bf51ab065eb882c38ac4e729f4565910d74d5
7
+ data.tar.gz: 0bb6461320be68b9cdd09f5a03ff1ca73056cf06db7b7eb99a77d22d7d9fe6bffa0ad8052bfa416cc27e132e61da673f4b9eed6bc50cdf940068b8f2de28b45f
data/README.md CHANGED
@@ -143,7 +143,7 @@ response = data_export_api.wait_for_export_job(job_id)
143
143
  **Note well that Leanplum now officially recommends use of the automated S3 export instead of API based export.** According to a Leanplum engineer these two data export methodologies are completely independent data paths and in our experience we have found API based data export to be missing 10-15% of the data that is eventually returned by the automated export.
144
144
 
145
145
  ### Other Available Methods
146
- These are mostly simple wrappers around Leanplum's API methods. See their documentation for details.
146
+ These are mostly simple wrappers around Leanplum's API methods. See [their documentation](https://www.leanplum.com/docs/api/) for details.
147
147
 
148
148
  * `api.export_user(user_id)`
149
149
  * `api.user_attributes(user_id)` (gives you the attributes section of `exportUser`)
@@ -45,7 +45,9 @@ module LeanplumApi
45
45
 
46
46
  def user_attributes(user_id)
47
47
  # Leanplum returns strings instead of booleans
48
- Hash[export_user(user_id)['userAttributes'].map { |k, v| [k, v.to_s =~ /\Atrue|false\z/i ? eval(v.downcase) : v] }]
48
+ export_user(user_id)['userAttributes']
49
+ .map { |k, v| [k, v.to_s =~ /\A(true|false)\z/i ? eval(v.downcase) : v] }
50
+ .to_h
49
51
  end
50
52
 
51
53
  def user_events(user_id)
@@ -1,3 +1,3 @@
1
1
  module LeanplumApi
2
- VERSION = '4.0.2'
2
+ VERSION = '4.0.3'
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -116,6 +116,10 @@ describe LeanplumApi::API do
116
116
  end
117
117
 
118
118
  context '#user_attributes' do
119
+ let(:true_key) { 'random_true_key' }
120
+ let(:false_key) { 'arbitrary_false_key' }
121
+ let(:test_hash) { { 'userAttributes' => { true_key => 'TrUe', false_key => 'fALSE' } } }
122
+
119
123
  it 'should get user attributes for this user' do
120
124
  VCR.use_cassette('export_user') do
121
125
  api.user_attributes(first_user_id).each do |k, v|
@@ -127,6 +131,28 @@ describe LeanplumApi::API do
127
131
  end
128
132
  end
129
133
  end
134
+
135
+ it 'should convert true / false strings into booleans' do
136
+ allow(api).to receive(:export_user).and_return(test_hash)
137
+ attributes = api.user_attributes(first_user_id)
138
+
139
+ expect(attributes[true_key]).to eq(true)
140
+ expect(attributes[false_key]).to eq(false)
141
+ end
142
+
143
+ context 'boolean looking strings' do
144
+ let(:true_like_value) { 'truegrit' }
145
+ let(:false_like_value) { 'whatever string ending in false' }
146
+ let(:test_hash) { { 'userAttributes' => { true_key => true_like_value, false_key => false_like_value } } }
147
+
148
+ it 'should not convert true / false like strings' do
149
+ allow(api).to receive(:export_user).and_return(test_hash)
150
+ attributes = api.user_attributes(first_user_id)
151
+
152
+ expect(attributes[true_key]).to eq(true_like_value)
153
+ expect(attributes[false_key]).to eq(false_like_value)
154
+ end
155
+ end
130
156
  end
131
157
 
132
158
  context '#reset_anomalous_users' do
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ require 'webmock'
5
5
  require 'vcr'
6
6
  require 'dotenv/load'
7
7
 
8
- DEFAULT_SPEC_KEY = 'JUNKTASTIC_SPASMASTIC'
8
+ DEFAULT_SPEC_KEY = 'JUNKTASTIC_SPASMASTIC'.freeze
9
9
 
10
10
  RSpec.configure do |config|
11
11
  config.before(:all) 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.2
4
+ version: 4.0.3
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-21 00:00:00.000000000 Z
12
+ date: 2017-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport