promoted-ruby-client 0.1.21 → 0.1.22

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
  SHA256:
3
- metadata.gz: 526e2104c5f4658b67b971a1a2f19639ea383ddcee8556dd496c906c7aed8d86
4
- data.tar.gz: f3e6afce46a2995b8497f8426d7fcccda89e9a0c533d270a55dd72598c6a0287
3
+ metadata.gz: e4cc088a08f160f3a238022f030e042df9a583fdbe22310b007027a9b908b406
4
+ data.tar.gz: 3b9434274cef7986cceea4876170b9061d873bfa533f0047adff546fd1f20d77
5
5
  SHA512:
6
- metadata.gz: c3b5e39490f8ceac8c261cfd6a7b3c9264980b98306bf7ac520fcc4f4855600329f43fc1eee55a22f4c8968c1d44eaa1ae47fa1ed737d61fbce6b8e5064eabb8
7
- data.tar.gz: 94fe93237603bc0be26b54a5a7ecbd39f45065d2e878610e240079a946ecde5697b39894a6c7b2fd2817b51fdc60462d5edc66c279be3038e79618e14c9e6deb
6
+ metadata.gz: b9b3a44c22c7bbbb632024b21aa6062253f2cd9e6f3cba73f015eccb1f4fa3a91bfc14cfdabee57a64510ae53a16fe2f01e30f645002b1dc40ea511f8854e54b
7
+ data.tar.gz: d20bb330c762ea83cf75246a256a20d250d1d3b0e2b1af7fa7ca8d2f5840671505a10584c2d8c3f30fa040daf7d10bbdcd5859454dd822c7898b711e300257eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- promoted-ruby-client (0.1.21)
4
+ promoted-ruby-client (0.1.22)
5
5
  concurrent-ruby (~> 1)
6
6
  faraday (>= 0.9.0)
7
7
  faraday_middleware (>= 0.9.0)
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.21.gem`
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
- raise ValidationError.new(field[:name].to_s + " should be a " + field[:type].to_s) if !obj[field[:name]].is_a?(field[:type])
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
@@ -1,7 +1,7 @@
1
1
  module Promoted
2
2
  module Ruby
3
3
  module Client
4
- VERSION = "0.1.21"
4
+ VERSION = "0.1.22"
5
5
  end
6
6
  end
7
7
  end
@@ -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 = @pager.apply_paging(delivery_request_builder.full_insertion, Promoted::Ruby::Client::INSERTION_PAGING_TYPE['UNPAGED'], delivery_request_builder.request[:paging])
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.21
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-02 00:00:00.000000000 Z
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.2.24
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.