leanplum_api 4.0.2 → 4.0.3
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 +4 -4
- data/README.md +1 -1
- data/lib/leanplum_api/api.rb +3 -1
- data/lib/leanplum_api/version.rb +1 -1
- data/spec/api_spec.rb +26 -0
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f7d678d33a30f6b8f4a3d50a875f3536328ad1
|
4
|
+
data.tar.gz: 7bb19cca732b8023d580d110423fa46f071c64a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`)
|
data/lib/leanplum_api/api.rb
CHANGED
@@ -45,7 +45,9 @@ module LeanplumApi
|
|
45
45
|
|
46
46
|
def user_attributes(user_id)
|
47
47
|
# Leanplum returns strings instead of booleans
|
48
|
-
|
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)
|
data/lib/leanplum_api/version.rb
CHANGED
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
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.
|
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-
|
12
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|