adzerk_decision_sdk 1.0.0.pre.beta.3 → 1.0.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -10
  3. data/README.md +58 -4
  4. data/adzerk_decision_sdk.gemspec +3 -4
  5. data/docs/ConsentRequest.md +10 -9
  6. data/docs/Content.md +16 -15
  7. data/docs/Decision.md +28 -25
  8. data/docs/DecisionApi.md +30 -13
  9. data/docs/DecisionRequest.md +44 -33
  10. data/docs/DecisionResponse.md +12 -11
  11. data/docs/Event.md +10 -9
  12. data/docs/MatchedPoint.md +20 -0
  13. data/docs/Placement.md +46 -37
  14. data/docs/PricingData.md +16 -15
  15. data/docs/RequestLocation.md +19 -0
  16. data/docs/User.md +8 -7
  17. data/docs/UserdbApi.md +252 -140
  18. data/lib/adzerk_decision_sdk.rb +1 -1
  19. data/lib/adzerk_decision_sdk/api/decision_api.rb +5 -4
  20. data/lib/adzerk_decision_sdk/api/userdb_api.rb +37 -95
  21. data/lib/adzerk_decision_sdk/api_client.rb +50 -48
  22. data/lib/adzerk_decision_sdk/api_error.rb +1 -1
  23. data/lib/adzerk_decision_sdk/client.rb +4 -3
  24. data/lib/adzerk_decision_sdk/configuration.rb +39 -10
  25. data/lib/adzerk_decision_sdk/decision_client.rb +18 -7
  26. data/lib/adzerk_decision_sdk/models/consent_request.rb +19 -7
  27. data/lib/adzerk_decision_sdk/models/content.rb +20 -8
  28. data/lib/adzerk_decision_sdk/models/decision.rb +31 -8
  29. data/lib/adzerk_decision_sdk/models/decision_request.rb +74 -12
  30. data/lib/adzerk_decision_sdk/models/decision_response.rb +19 -7
  31. data/lib/adzerk_decision_sdk/models/event.rb +19 -7
  32. data/lib/adzerk_decision_sdk/models/matched_point.rb +227 -0
  33. data/lib/adzerk_decision_sdk/models/placement.rb +91 -12
  34. data/lib/adzerk_decision_sdk/models/pricing_data.rb +19 -7
  35. data/lib/adzerk_decision_sdk/models/{decision_data.rb → request_location.rb} +16 -52
  36. data/lib/adzerk_decision_sdk/models/user.rb +19 -7
  37. data/lib/adzerk_decision_sdk/pixel_client.rb +8 -2
  38. data/lib/adzerk_decision_sdk/user_db_client.rb +18 -4
  39. data/lib/adzerk_decision_sdk/version.rb +1 -1
  40. data/spec/spec_helper.rb +91 -0
  41. metadata +15 -34
  42. data/docs/DecisionData.md +0 -27
  43. data/pkg/adzerk_decision_sdk-1.0.0.gem +0 -0
  44. data/pkg/adzerk_decision_sdk-1.0.0.pre.beta.1.gem +0 -0
  45. data/pkg/adzerk_decision_sdk-1.0.0.pre.beta.2.gem +0 -0
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.0.1
10
10
 
11
11
  =end
12
12
 
@@ -25,8 +25,9 @@ module AdzerkDecisionSdk
25
25
  configuration = Configuration.new
26
26
  configuration.scheme = protocol
27
27
  configuration.host = host
28
- configuration.api_key['X-Adzerk-ApiKey'] = api_key
28
+ configuration.api_key['ApiKeyAuth'] = api_key
29
29
  configuration.debugging = is_debug
30
+ configuration.server_index = nil
30
31
 
31
32
  unless logger.nil?
32
33
  configuration.logger = logger
@@ -36,8 +37,8 @@ module AdzerkDecisionSdk
36
37
  api_client.default_headers['X-Adzerk-Sdk-Version'] = "adzerk-decision-sdk-ruby:#{version}"
37
38
 
38
39
  @decisions = DecisionClient.new(network_id, site_id, api_client, configuration.logger)
39
- @user_db = UserDbClient.new(network_id, api_client)
40
- @pixels = PixelClient.new(api_client)
40
+ @user_db = UserDbClient.new(network_id, api_client, configuration.logger)
41
+ @pixels = PixelClient.new(api_client, configuration.logger)
41
42
  end
42
43
  end
43
44
  end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.0.1
10
10
 
11
11
  =end
12
12
 
@@ -21,6 +21,18 @@ module AdzerkDecisionSdk
21
21
  # Defines url base path
22
22
  attr_accessor :base_path
23
23
 
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
24
36
  # Defines API keys used with API Key authentications.
25
37
  #
26
38
  # @return [Hash] key: parameter name, value: parameter value (API key)
@@ -129,6 +141,10 @@ module AdzerkDecisionSdk
129
141
  @scheme = 'https'
130
142
  @host = 'e-23.adzerk.net'
131
143
  @base_path = ''
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
132
148
  @api_key = {}
133
149
  @api_key_prefix = {}
134
150
  @timeout = 0
@@ -171,17 +187,23 @@ module AdzerkDecisionSdk
171
187
  @base_path = '' if @base_path == '/'
172
188
  end
173
189
 
174
- def base_url
175
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
176
196
  end
177
197
 
178
198
  # Gets API key (with prefix if set).
179
199
  # @param [String] param_name the parameter name of API key auth
180
- def api_key_with_prefix(param_name)
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
181
203
  if @api_key_prefix[param_name]
182
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
204
+ "#{@api_key_prefix[param_name]} #{key}"
183
205
  else
184
- @api_key[param_name]
206
+ key
185
207
  end
186
208
  end
187
209
 
@@ -198,7 +220,7 @@ module AdzerkDecisionSdk
198
220
  type: 'api_key',
199
221
  in: 'header',
200
222
  key: 'X-Adzerk-ApiKey',
201
- value: api_key_with_prefix('X-Adzerk-ApiKey')
223
+ value: api_key_with_prefix('ApiKeyAuth')
202
224
  },
203
225
  }
204
226
  end
@@ -227,12 +249,17 @@ module AdzerkDecisionSdk
227
249
  ]
228
250
  end
229
251
 
252
+ def operation_server_settings
253
+ {
254
+ }
255
+ end
256
+
230
257
  # Returns URL based on server settings
231
258
  #
232
259
  # @param index array index of the server settings
233
260
  # @param variables hash of variable and the corresponding value
234
- def server_url(index, variables = {})
235
- servers = server_settings
261
+ def server_url(index, variables = {}, servers = nil)
262
+ servers = server_settings if servers == nil
236
263
 
237
264
  # check array index out of bound
238
265
  if (index < 0 || index >= servers.size)
@@ -242,10 +269,12 @@ module AdzerkDecisionSdk
242
269
  server = servers[index]
243
270
  url = server[:url]
244
271
 
272
+ return url unless server.key? :variables
273
+
245
274
  # go through variable and assign a value
246
275
  server[:variables].each do |name, variable|
247
276
  if variables.key?(name)
248
- if (server[:variables][name][:enum_values].include? variables[name])
277
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
249
278
  url.gsub! "{" + name.to_s + "}", variables[name]
250
279
  else
251
280
  fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
@@ -2,30 +2,40 @@ require 'adzerk_decision_sdk/api/decision_api'
2
2
 
3
3
  module AdzerkDecisionSdk
4
4
  class DecisionClient
5
+
5
6
  def initialize(network_id, site_id, api_client, logger)
6
7
  @network_id = network_id
7
8
  @site_id = site_id
8
9
  @api = DecisionApi.new(api_client)
9
10
  @logger = logger
11
+ @deprecated_placement_fields = [[:ecpm_partition, 'ecpm_partitions']]
10
12
  end
11
13
 
12
14
  def get(request, opts = {})
13
15
  opts ||= {}
14
16
  header_params = opts[:header_params] || {}
15
- opts[:body] ||= request.respond_to?('to_hash') ? request.to_hash() : request
17
+ opts[:debug_body] ||= request.respond_to?('to_hash') ? request.to_hash() : request
16
18
 
17
- @logger.info("Processing request: #{opts[:body]}")
19
+ @logger.info("Processing request: #{opts[:debug_body]}")
18
20
 
19
- opts[:body][:enableBotFiltering] = false if not opts[:body].has_key?(:enableBotFiltering)
21
+ opts[:debug_body][:enableBotFiltering] = false if not opts[:debug_body].has_key?(:enableBotFiltering)
20
22
 
21
- if !opts[:body].has_key?(:placements) or !opts[:body][:placements] or opts[:body][:placements].length() == 0
23
+ if !opts[:debug_body].has_key?(:placements) or !opts[:debug_body][:placements] or opts[:debug_body][:placements].length() == 0
22
24
  fail ArgumentError, "Each request requires at least one placement"
23
25
  end
24
26
 
25
- opts[:body][:placements].each_with_index do |placement, idx|
27
+ opts[:debug_body][:placements].each_with_index do |placement, idx|
26
28
  if !placement.has_key?(:adTypes) or !placement[:adTypes] or placement[:adTypes].length() == 0
27
29
  fail ArgumentError, "Each placement needs at least one ad type"
28
30
  end
31
+
32
+ @deprecated_placement_fields.each do |pair|
33
+ deprecated_field, replacement = pair
34
+ if placement.has_key?(deprecated_field) and !placement[deprecated_field].nil?
35
+ @logger.warn("DEPRECATION WARNING: #{deprecated_field} has been deprecated. Please use #{replacement} instead.")
36
+ end
37
+ end
38
+
29
39
  placement[:networkId] = @network_id if not placement.has_key?(:networkId)
30
40
  placement[:siteId] = @site_id if not placement.has_key?(:siteId)
31
41
  placement[:divName] = "div#{idx}" if not placement.has_key?(:divName)
@@ -46,13 +56,14 @@ module AdzerkDecisionSdk
46
56
 
47
57
  opts[:header_params] = header_params
48
58
 
49
- @logger.info("Processed request: #{opts[:body]}")
59
+ @logger.info("Processed request: #{opts[:debug_body]}")
50
60
  @logger.info("Requesting with headers: #{opts[:header_params]}")
51
61
 
52
62
  response = @api.get_decisions(opts)
63
+ @logger.info("Received response: #{response}")
53
64
 
54
65
  parsed_response = parse_response(response)
55
- @logger.info("Received response: #{parsed_response}")
66
+ @logger.info("Parsed response: #{parsed_response}")
56
67
 
57
68
  return parsed_response
58
69
  end
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.0.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module AdzerkDecisionSdk
16
17
  class ConsentRequest
@@ -26,6 +27,11 @@ module AdzerkDecisionSdk
26
27
  }
27
28
  end
28
29
 
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
29
35
  # Attribute type mapping.
30
36
  def self.openapi_types
31
37
  {
@@ -111,7 +117,9 @@ module AdzerkDecisionSdk
111
117
  def build_from_hash(attributes)
112
118
  return nil unless attributes.is_a?(Hash)
113
119
  self.class.openapi_types.each_pair do |key, type|
114
- if type =~ /\AArray<(.*)>/i
120
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
121
+ self.send("#{key}=", nil)
122
+ elsif type =~ /\AArray<(.*)>/i
115
123
  # check to ensure the input is an array given that the attribute
116
124
  # is documented as an array but the input is not
117
125
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -119,7 +127,7 @@ module AdzerkDecisionSdk
119
127
  end
120
128
  elsif !attributes[self.class.attribute_map[key]].nil?
121
129
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
- end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
123
131
  end
124
132
 
125
133
  self
@@ -131,8 +139,8 @@ module AdzerkDecisionSdk
131
139
  # @return [Object] Deserialized data
132
140
  def _deserialize(type, value)
133
141
  case type.to_sym
134
- when :DateTime
135
- DateTime.parse(value)
142
+ when :Time
143
+ Time.parse(value)
136
144
  when :Date
137
145
  Date.parse(value)
138
146
  when :String
@@ -162,7 +170,9 @@ module AdzerkDecisionSdk
162
170
  end
163
171
  end
164
172
  else # model
165
- AdzerkDecisionSdk.const_get(type).build_from_hash(value)
173
+ # models (e.g. Pet) or oneOf
174
+ klass = AdzerkDecisionSdk.const_get(type)
175
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
166
176
  end
167
177
  end
168
178
 
@@ -188,7 +198,7 @@ module AdzerkDecisionSdk
188
198
  is_nullable = self.class.openapi_nullable.include?(attr)
189
199
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
190
200
  end
191
-
201
+
192
202
  hash[param] = _to_hash(value)
193
203
  end
194
204
  hash
@@ -211,5 +221,7 @@ module AdzerkDecisionSdk
211
221
  value
212
222
  end
213
223
  end
224
+
214
225
  end
226
+
215
227
  end
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.0.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module AdzerkDecisionSdk
16
17
  class Content
@@ -35,13 +36,18 @@ module AdzerkDecisionSdk
35
36
  }
36
37
  end
37
38
 
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
38
44
  # Attribute type mapping.
39
45
  def self.openapi_types
40
46
  {
41
47
  :'type' => :'String',
42
48
  :'template' => :'String',
43
49
  :'custom_template' => :'String',
44
- :'data' => :'DecisionData',
50
+ :'data' => :'Object',
45
51
  :'body' => :'String'
46
52
  }
47
53
  end
@@ -138,7 +144,9 @@ module AdzerkDecisionSdk
138
144
  def build_from_hash(attributes)
139
145
  return nil unless attributes.is_a?(Hash)
140
146
  self.class.openapi_types.each_pair do |key, type|
141
- if type =~ /\AArray<(.*)>/i
147
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
148
+ self.send("#{key}=", nil)
149
+ elsif type =~ /\AArray<(.*)>/i
142
150
  # check to ensure the input is an array given that the attribute
143
151
  # is documented as an array but the input is not
144
152
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -146,7 +154,7 @@ module AdzerkDecisionSdk
146
154
  end
147
155
  elsif !attributes[self.class.attribute_map[key]].nil?
148
156
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
- end # or else data not found in attributes(hash), not an issue as the data can be optional
157
+ end
150
158
  end
151
159
 
152
160
  self
@@ -158,8 +166,8 @@ module AdzerkDecisionSdk
158
166
  # @return [Object] Deserialized data
159
167
  def _deserialize(type, value)
160
168
  case type.to_sym
161
- when :DateTime
162
- DateTime.parse(value)
169
+ when :Time
170
+ Time.parse(value)
163
171
  when :Date
164
172
  Date.parse(value)
165
173
  when :String
@@ -189,7 +197,9 @@ module AdzerkDecisionSdk
189
197
  end
190
198
  end
191
199
  else # model
192
- AdzerkDecisionSdk.const_get(type).build_from_hash(value)
200
+ # models (e.g. Pet) or oneOf
201
+ klass = AdzerkDecisionSdk.const_get(type)
202
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
193
203
  end
194
204
  end
195
205
 
@@ -215,7 +225,7 @@ module AdzerkDecisionSdk
215
225
  is_nullable = self.class.openapi_nullable.include?(attr)
216
226
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
227
  end
218
-
228
+
219
229
  hash[param] = _to_hash(value)
220
230
  end
221
231
  hash
@@ -238,5 +248,7 @@ module AdzerkDecisionSdk
238
248
  value
239
249
  end
240
250
  end
251
+
241
252
  end
253
+
242
254
  end
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.0.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module AdzerkDecisionSdk
16
17
  class Decision
@@ -32,6 +33,8 @@ module AdzerkDecisionSdk
32
33
 
33
34
  attr_accessor :events
34
35
 
36
+ attr_accessor :matched_points
37
+
35
38
  attr_accessor :pricing
36
39
 
37
40
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -46,10 +49,16 @@ module AdzerkDecisionSdk
46
49
  :'contents' => :'contents',
47
50
  :'impression_url' => :'impressionUrl',
48
51
  :'events' => :'events',
52
+ :'matched_points' => :'matchedPoints',
49
53
  :'pricing' => :'pricing'
50
54
  }
51
55
  end
52
56
 
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
53
62
  # Attribute type mapping.
54
63
  def self.openapi_types
55
64
  {
@@ -62,6 +71,7 @@ module AdzerkDecisionSdk
62
71
  :'contents' => :'Array<Content>',
63
72
  :'impression_url' => :'String',
64
73
  :'events' => :'Array<Event>',
74
+ :'matched_points' => :'Array<MatchedPoint>',
65
75
  :'pricing' => :'PricingData'
66
76
  }
67
77
  end
@@ -127,6 +137,12 @@ module AdzerkDecisionSdk
127
137
  end
128
138
  end
129
139
 
140
+ if attributes.key?(:'matched_points')
141
+ if (value = attributes[:'matched_points']).is_a?(Array)
142
+ self.matched_points = value
143
+ end
144
+ end
145
+
130
146
  if attributes.key?(:'pricing')
131
147
  self.pricing = attributes[:'pricing']
132
148
  end
@@ -159,6 +175,7 @@ module AdzerkDecisionSdk
159
175
  contents == o.contents &&
160
176
  impression_url == o.impression_url &&
161
177
  events == o.events &&
178
+ matched_points == o.matched_points &&
162
179
  pricing == o.pricing
163
180
  end
164
181
 
@@ -171,7 +188,7 @@ module AdzerkDecisionSdk
171
188
  # Calculates hash code according to all attributes.
172
189
  # @return [Integer] Hash code
173
190
  def hash
174
- [ad_id, creative_id, flight_id, campaign_id, priority_id, click_url, contents, impression_url, events, pricing].hash
191
+ [ad_id, creative_id, flight_id, campaign_id, priority_id, click_url, contents, impression_url, events, matched_points, pricing].hash
175
192
  end
176
193
 
177
194
  # Builds the object from hash
@@ -187,7 +204,9 @@ module AdzerkDecisionSdk
187
204
  def build_from_hash(attributes)
188
205
  return nil unless attributes.is_a?(Hash)
189
206
  self.class.openapi_types.each_pair do |key, type|
190
- if type =~ /\AArray<(.*)>/i
207
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
208
+ self.send("#{key}=", nil)
209
+ elsif type =~ /\AArray<(.*)>/i
191
210
  # check to ensure the input is an array given that the attribute
192
211
  # is documented as an array but the input is not
193
212
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -195,7 +214,7 @@ module AdzerkDecisionSdk
195
214
  end
196
215
  elsif !attributes[self.class.attribute_map[key]].nil?
197
216
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
198
- end # or else data not found in attributes(hash), not an issue as the data can be optional
217
+ end
199
218
  end
200
219
 
201
220
  self
@@ -207,8 +226,8 @@ module AdzerkDecisionSdk
207
226
  # @return [Object] Deserialized data
208
227
  def _deserialize(type, value)
209
228
  case type.to_sym
210
- when :DateTime
211
- DateTime.parse(value)
229
+ when :Time
230
+ Time.parse(value)
212
231
  when :Date
213
232
  Date.parse(value)
214
233
  when :String
@@ -238,7 +257,9 @@ module AdzerkDecisionSdk
238
257
  end
239
258
  end
240
259
  else # model
241
- AdzerkDecisionSdk.const_get(type).build_from_hash(value)
260
+ # models (e.g. Pet) or oneOf
261
+ klass = AdzerkDecisionSdk.const_get(type)
262
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
242
263
  end
243
264
  end
244
265
 
@@ -264,7 +285,7 @@ module AdzerkDecisionSdk
264
285
  is_nullable = self.class.openapi_nullable.include?(attr)
265
286
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
266
287
  end
267
-
288
+
268
289
  hash[param] = _to_hash(value)
269
290
  end
270
291
  hash
@@ -287,5 +308,7 @@ module AdzerkDecisionSdk
287
308
  value
288
309
  end
289
310
  end
311
+
290
312
  end
313
+
291
314
  end