promoted-ruby-client 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/dev.md +1 -1
- data/lib/promoted/ruby/client/request_builder.rb +7 -2
- data/lib/promoted/ruby/client/validator.rb +9 -2
- data/lib/promoted/ruby/client/version.rb +1 -1
- data/lib/promoted/ruby/client.rb +9 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cc088a08f160f3a238022f030e042df9a583fdbe22310b007027a9b908b406
|
4
|
+
data.tar.gz: 3b9434274cef7986cceea4876170b9061d873bfa533f0047adff546fd1f20d77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b3a44c22c7bbbb632024b21aa6062253f2cd9e6f3cba73f015eccb1f4fa3a91bfc14cfdabee57a64510ae53a16fe2f01e30f645002b1dc40ea511f8854e54b
|
7
|
+
data.tar.gz: d20bb330c762ea83cf75246a256a20d250d1d3b0e2b1af7fa7ca8d2f5840671505a10584c2d8c3f30fa040daf7d10bbdcd5859454dd822c7898b711e300257eb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,7 @@ Field Name | Type | Optional? | Description
|
|
63
63
|
---------- | ---- | --------- | -----------
|
64
64
|
```:user_id``` | String | Yes | The platform user id, cleared from Promoted logs.
|
65
65
|
```:log_user_id``` | String | Yes | A different user id (presumably a UUID) disconnected from the platform user id, good for working with unauthenticated users or implementing right-to-be-forgotten.
|
66
|
+
```:is_internal_user``` | Boolean | Yes | If this user is a test user or not, defaults to false.
|
66
67
|
|
67
68
|
---
|
68
69
|
### CohortMembership
|
@@ -94,6 +95,8 @@ Field Name | Type | Optional? | Description
|
|
94
95
|
```:insertion_id``` | String | Yes | Generated by the SDK (*do not set*)
|
95
96
|
```:request_id``` | String | Yes | Generated by the SDK when needed (*do not set*)
|
96
97
|
```:content_id``` | String | No | Identifier for the content to be shown, must be set.
|
98
|
+
```:retrieval_rank``` | Number | Yes | Optional original ranking of this content item.
|
99
|
+
```:retrieval_score``` | Number | Yes | Optional original quality score of this content item.
|
97
100
|
```:properties``` | Properties | Yes | Any additional custom properties to associate. For v1 integrations, it is fine not to fill in all the properties.
|
98
101
|
---
|
99
102
|
### Size
|
data/dev.md
CHANGED
@@ -4,5 +4,5 @@
|
|
4
4
|
2. Get credentials for deployment from 1password.
|
5
5
|
3. Modify `promoted-ruby-client.gemspec`'s push block.
|
6
6
|
4. Run `gem build promoted-ruby-client.gemspec` to generate `gem`.
|
7
|
-
5. Run (using new output) `gem push promoted-ruby-client-0.1.
|
7
|
+
5. Run (using new output) `gem push promoted-ruby-client-0.1.22.gem`
|
8
8
|
6. Update README with new version.
|
@@ -178,7 +178,6 @@ module Promoted
|
|
178
178
|
insertion_obj = Hash[insertion_obj]
|
179
179
|
insertion_obj[:user_info] = user_info
|
180
180
|
insertion_obj[:timing] = timing
|
181
|
-
insertion_obj[:insertion_id] = @id_generator.newID
|
182
181
|
insertion_obj[:request_id] = request_id
|
183
182
|
insertion_obj[:position] = offset + index
|
184
183
|
insertion_obj = compact_one_insertion(insertion_obj, @to_compact_metrics_properties_func)
|
@@ -187,6 +186,12 @@ module Promoted
|
|
187
186
|
@insertion
|
188
187
|
end
|
189
188
|
|
189
|
+
def add_missing_insertion_ids! insertions
|
190
|
+
insertions.each do |insertion|
|
191
|
+
insertion[:insertion_id] = @id_generator.newID if not insertion[:insertion_id]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
190
195
|
def client_request_id
|
191
196
|
request[:client_request_id]
|
192
197
|
end
|
@@ -202,10 +207,10 @@ module Promoted
|
|
202
207
|
|
203
208
|
def add_missing_ids_on_insertions! request, insertions
|
204
209
|
insertions.each do |insertion|
|
205
|
-
insertion[:insertion_id] = @id_generator.newID if not insertion[:insertion_id]
|
206
210
|
insertion[:session_id] = request[:session_id] if request[:session_id]
|
207
211
|
insertion[:request_id] = request[:request_id] if request[:request_id]
|
208
212
|
end
|
213
|
+
add_missing_insertion_ids! insertions
|
209
214
|
end
|
210
215
|
|
211
216
|
# A list of the response Insertions. This client expects lists to be truncated
|
@@ -14,6 +14,10 @@ module Promoted
|
|
14
14
|
{
|
15
15
|
:name => :log_user_id,
|
16
16
|
:type => String
|
17
|
+
},
|
18
|
+
{
|
19
|
+
:name => :is_internal_user,
|
20
|
+
:type => [TrueClass, FalseClass]
|
17
21
|
}
|
18
22
|
]
|
19
23
|
)
|
@@ -133,7 +137,6 @@ module Promoted
|
|
133
137
|
req[:full_insertion].each do |insertion_hash|
|
134
138
|
raise ValidationError.new("Insertion.requestId should not be set") if insertion_hash[:request_id]
|
135
139
|
raise ValidationError.new("'Insertion.insertionId should not be set") if insertion_hash[:insertion_id]
|
136
|
-
raise ValidationError.new("Insertion.deliveryScore should not be set") if insertion_hash[:delivery_score]
|
137
140
|
end
|
138
141
|
end
|
139
142
|
|
@@ -147,7 +150,11 @@ module Promoted
|
|
147
150
|
|
148
151
|
# If a field is provided as non-nil, it should be of the correct type.
|
149
152
|
if field[:type] && obj.has_key?(field[:name]) && obj[field[:name]] != nil then
|
150
|
-
|
153
|
+
if field[:type].is_a?(Array) then
|
154
|
+
raise ValidationError.new(field[:name].to_s + " should be one of " + field[:type].to_s) if !field[:type].include?(obj[field[:name]].class)
|
155
|
+
else
|
156
|
+
raise ValidationError.new(field[:name].to_s + " should be a " + field[:type].to_s) if !obj[field[:name]].is_a?(field[:type])
|
157
|
+
end
|
151
158
|
end
|
152
159
|
}
|
153
160
|
end
|
data/lib/promoted/ruby/client.rb
CHANGED
@@ -190,7 +190,7 @@ module Promoted
|
|
190
190
|
request_to_log = nil
|
191
191
|
if !insertions_from_delivery then
|
192
192
|
request_to_log = delivery_request_builder.request
|
193
|
-
response_insertions =
|
193
|
+
response_insertions = build_sdk_response_insertions(delivery_request_builder)
|
194
194
|
end
|
195
195
|
|
196
196
|
log_req = nil
|
@@ -274,6 +274,14 @@ module Promoted
|
|
274
274
|
|
275
275
|
private
|
276
276
|
|
277
|
+
##
|
278
|
+
# Creates response insertions for SDK-side delivery, when we don't get response insertions from Delivery API.
|
279
|
+
def build_sdk_response_insertions delivery_request_builder
|
280
|
+
response_insertions = @pager.apply_paging(delivery_request_builder.full_insertion, Promoted::Ruby::Client::INSERTION_PAGING_TYPE['UNPAGED'], delivery_request_builder.request[:paging])
|
281
|
+
delivery_request_builder.add_missing_insertion_ids! response_insertions
|
282
|
+
return response_insertions
|
283
|
+
end
|
284
|
+
|
277
285
|
def do_warmup
|
278
286
|
if !@delivery_endpoint
|
279
287
|
# Warmup only supported when delivery is enabled.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promoted-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scottmcmaster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.0.3
|
173
173
|
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: A Ruby Client to contact Promoted APIs.
|