adzerk_decision_sdk 1.0.0.pre.beta.6 → 1.0.0.pre.beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -7
  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 +30 -27
  8. data/docs/DecisionApi.md +30 -13
  9. data/docs/DecisionRequest.md +44 -41
  10. data/docs/DecisionResponse.md +12 -11
  11. data/docs/Event.md +10 -9
  12. data/docs/MatchedPoint.md +10 -9
  13. data/docs/Placement.md +50 -45
  14. data/docs/PricingData.md +16 -15
  15. data/docs/User.md +8 -7
  16. data/docs/UserdbApi.md +259 -98
  17. data/lib/adzerk_decision_sdk/api/decision_api.rb +5 -4
  18. data/lib/adzerk_decision_sdk/api/userdb_api.rb +37 -28
  19. data/lib/adzerk_decision_sdk/api_client.rb +50 -48
  20. data/lib/adzerk_decision_sdk/api_error.rb +1 -1
  21. data/lib/adzerk_decision_sdk/client.rb +2 -1
  22. data/lib/adzerk_decision_sdk/configuration.rb +39 -10
  23. data/lib/adzerk_decision_sdk/decision_client.rb +6 -6
  24. data/lib/adzerk_decision_sdk/models/consent_request.rb +19 -7
  25. data/lib/adzerk_decision_sdk/models/content.rb +19 -7
  26. data/lib/adzerk_decision_sdk/models/decision.rb +29 -8
  27. data/lib/adzerk_decision_sdk/models/decision_request.rb +32 -10
  28. data/lib/adzerk_decision_sdk/models/decision_response.rb +19 -7
  29. data/lib/adzerk_decision_sdk/models/event.rb +19 -7
  30. data/lib/adzerk_decision_sdk/models/matched_point.rb +19 -7
  31. data/lib/adzerk_decision_sdk/models/placement.rb +44 -12
  32. data/lib/adzerk_decision_sdk/models/pricing_data.rb +19 -7
  33. data/lib/adzerk_decision_sdk/models/user.rb +19 -7
  34. data/lib/adzerk_decision_sdk/user_db_client.rb +2 -2
  35. data/lib/adzerk_decision_sdk/version.rb +1 -1
  36. data/openapitools.json +7 -0
  37. data/spec/spec_helper.rb +91 -0
  38. metadata +12 -30
  39. data/pkg/adzerk_decision_sdk-1.0.0.pre.beta.3.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.1.0
10
10
 
11
11
  =end
12
12
 
@@ -66,15 +66,16 @@ module AdzerkDecisionSdk
66
66
  form_params = opts[:form_params] || {}
67
67
 
68
68
  # http body (model)
69
- post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body'])
69
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])
70
70
 
71
71
  # return_type
72
- return_type = opts[:return_type] || 'File'
72
+ return_type = opts[:debug_return_type] || 'File'
73
73
 
74
74
  # auth_names
75
- auth_names = opts[:auth_names] || ['ApiKeyAuth']
75
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
76
76
 
77
77
  new_options = opts.merge(
78
+ :operation => :"UserdbApi.add_custom_properties",
78
79
  :header_params => header_params,
79
80
  :query_params => query_params,
80
81
  :form_params => form_params,
@@ -140,15 +141,16 @@ module AdzerkDecisionSdk
140
141
  form_params = opts[:form_params] || {}
141
142
 
142
143
  # http body (model)
143
- post_body = opts[:body]
144
+ post_body = opts[:debug_body]
144
145
 
145
146
  # return_type
146
- return_type = opts[:return_type] || 'File'
147
+ return_type = opts[:debug_return_type] || 'File'
147
148
 
148
149
  # auth_names
149
- auth_names = opts[:auth_names] || []
150
+ auth_names = opts[:debug_auth_names] || []
150
151
 
151
152
  new_options = opts.merge(
153
+ :operation => :"UserdbApi.add_interests",
152
154
  :header_params => header_params,
153
155
  :query_params => query_params,
154
156
  :form_params => form_params,
@@ -219,15 +221,16 @@ module AdzerkDecisionSdk
219
221
  form_params = opts[:form_params] || {}
220
222
 
221
223
  # http body (model)
222
- post_body = opts[:body]
224
+ post_body = opts[:debug_body]
223
225
 
224
226
  # return_type
225
- return_type = opts[:return_type] || 'File'
227
+ return_type = opts[:debug_return_type] || 'File'
226
228
 
227
229
  # auth_names
228
- auth_names = opts[:auth_names] || []
230
+ auth_names = opts[:debug_auth_names] || []
229
231
 
230
232
  new_options = opts.merge(
233
+ :operation => :"UserdbApi.add_retargeting_segment",
231
234
  :header_params => header_params,
232
235
  :query_params => query_params,
233
236
  :form_params => form_params,
@@ -284,15 +287,16 @@ module AdzerkDecisionSdk
284
287
  form_params = opts[:form_params] || {}
285
288
 
286
289
  # http body (model)
287
- post_body = opts[:body]
290
+ post_body = opts[:debug_body]
288
291
 
289
292
  # return_type
290
- return_type = opts[:return_type]
293
+ return_type = opts[:debug_return_type]
291
294
 
292
295
  # auth_names
293
- auth_names = opts[:auth_names] || ['ApiKeyAuth']
296
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
294
297
 
295
298
  new_options = opts.merge(
299
+ :operation => :"UserdbApi.forget",
296
300
  :header_params => header_params,
297
301
  :query_params => query_params,
298
302
  :form_params => form_params,
@@ -348,15 +352,16 @@ module AdzerkDecisionSdk
348
352
  form_params = opts[:form_params] || {}
349
353
 
350
354
  # http body (model)
351
- post_body = opts[:body] || @api_client.object_to_http_body(opts[:'consent_request'])
355
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'consent_request'])
352
356
 
353
357
  # return_type
354
- return_type = opts[:return_type] || 'File'
358
+ return_type = opts[:debug_return_type] || 'File'
355
359
 
356
360
  # auth_names
357
- auth_names = opts[:auth_names] || ['ApiKeyAuth']
361
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
358
362
 
359
363
  new_options = opts.merge(
364
+ :operation => :"UserdbApi.gdpr_consent",
360
365
  :header_params => header_params,
361
366
  :query_params => query_params,
362
367
  :form_params => form_params,
@@ -422,15 +427,16 @@ module AdzerkDecisionSdk
422
427
  form_params = opts[:form_params] || {}
423
428
 
424
429
  # http body (model)
425
- post_body = opts[:body]
430
+ post_body = opts[:debug_body]
426
431
 
427
432
  # return_type
428
- return_type = opts[:return_type] || 'File'
433
+ return_type = opts[:debug_return_type] || 'File'
429
434
 
430
435
  # auth_names
431
- auth_names = opts[:auth_names] || []
436
+ auth_names = opts[:debug_auth_names] || []
432
437
 
433
438
  new_options = opts.merge(
439
+ :operation => :"UserdbApi.ip_override",
434
440
  :header_params => header_params,
435
441
  :query_params => query_params,
436
442
  :form_params => form_params,
@@ -503,15 +509,16 @@ module AdzerkDecisionSdk
503
509
  form_params = opts[:form_params] || {}
504
510
 
505
511
  # http body (model)
506
- post_body = opts[:body]
512
+ post_body = opts[:debug_body]
507
513
 
508
514
  # return_type
509
- return_type = opts[:return_type] || 'File'
515
+ return_type = opts[:debug_return_type] || 'File'
510
516
 
511
517
  # auth_names
512
- auth_names = opts[:auth_names] || []
518
+ auth_names = opts[:debug_auth_names] || []
513
519
 
514
520
  new_options = opts.merge(
521
+ :operation => :"UserdbApi.match_user",
515
522
  :header_params => header_params,
516
523
  :query_params => query_params,
517
524
  :form_params => form_params,
@@ -570,15 +577,16 @@ module AdzerkDecisionSdk
570
577
  form_params = opts[:form_params] || {}
571
578
 
572
579
  # http body (model)
573
- post_body = opts[:body]
580
+ post_body = opts[:debug_body]
574
581
 
575
582
  # return_type
576
- return_type = opts[:return_type] || 'File'
583
+ return_type = opts[:debug_return_type] || 'File'
577
584
 
578
585
  # auth_names
579
- auth_names = opts[:auth_names] || []
586
+ auth_names = opts[:debug_auth_names] || []
580
587
 
581
588
  new_options = opts.merge(
589
+ :operation => :"UserdbApi.opt_out",
582
590
  :header_params => header_params,
583
591
  :query_params => query_params,
584
592
  :form_params => form_params,
@@ -637,15 +645,16 @@ module AdzerkDecisionSdk
637
645
  form_params = opts[:form_params] || {}
638
646
 
639
647
  # http body (model)
640
- post_body = opts[:body]
648
+ post_body = opts[:debug_body]
641
649
 
642
650
  # return_type
643
- return_type = opts[:return_type] || 'Object'
651
+ return_type = opts[:debug_return_type] || 'Object'
644
652
 
645
653
  # auth_names
646
- auth_names = opts[:auth_names] || []
654
+ auth_names = opts[:debug_auth_names] || []
647
655
 
648
656
  new_options = opts.merge(
657
+ :operation => :"UserdbApi.read",
649
658
  :header_params => header_params,
650
659
  :query_params => query_params,
651
660
  :form_params => form_params,
@@ -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.1.0
10
10
 
11
11
  =end
12
12
 
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
+ require 'time'
17
18
  require 'typhoeus'
18
19
 
19
20
  module AdzerkDecisionSdk
@@ -86,7 +87,7 @@ module AdzerkDecisionSdk
86
87
  # @option opts [Object] :body HTTP body (JSON/XML)
87
88
  # @return [Typhoeus::Request] A Typhoeus Request
88
89
  def build_request(http_method, path, opts = {})
89
- url = build_request_url(path)
90
+ url = build_request_url(path, opts)
90
91
  http_method = http_method.to_sym.downcase
91
92
 
92
93
  header_params = @default_headers.merge(opts[:header_params] || {})
@@ -155,6 +156,44 @@ module AdzerkDecisionSdk
155
156
  data
156
157
  end
157
158
 
159
+ # Save response body into a file in (the defined) temporary folder, using the filename
160
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
161
+ # The response body is written to the file in chunks in order to handle files which
162
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
163
+ # process can use.
164
+ #
165
+ # @see Configuration#temp_folder_path
166
+ def download_file(request)
167
+ tempfile = nil
168
+ encoding = nil
169
+ request.on_headers do |response|
170
+ content_disposition = response.headers['Content-Disposition']
171
+ if content_disposition && content_disposition =~ /filename=/i
172
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
173
+ prefix = sanitize_filename(filename)
174
+ else
175
+ prefix = 'download-'
176
+ end
177
+ prefix = prefix + '-' unless prefix.end_with?('-')
178
+ encoding = response.body.encoding
179
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
180
+ @tempfile = tempfile
181
+ end
182
+ request.on_body do |chunk|
183
+ chunk.force_encoding(encoding)
184
+ tempfile.write(chunk)
185
+ end
186
+ request.on_complete do |response|
187
+ if tempfile
188
+ tempfile.close
189
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
190
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
191
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
192
+ "explicitly with `tempfile.delete`"
193
+ end
194
+ end
195
+ end
196
+
158
197
  # Check if the given MIME is a JSON MIME.
159
198
  # JSON MIME examples:
160
199
  # application/json
@@ -191,7 +230,7 @@ module AdzerkDecisionSdk
191
230
  begin
192
231
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
193
232
  rescue JSON::ParserError => e
194
- if %w(String Date DateTime).include?(return_type)
233
+ if %w(String Date Time).include?(return_type)
195
234
  data = body
196
235
  else
197
236
  raise e
@@ -216,9 +255,9 @@ module AdzerkDecisionSdk
216
255
  data.to_f
217
256
  when 'Boolean'
218
257
  data == true
219
- when 'DateTime'
258
+ when 'Time'
220
259
  # parse date time (expecting ISO 8601 format)
221
- DateTime.parse data
260
+ Time.parse data
222
261
  when 'Date'
223
262
  # parse date time (expecting ISO 8601 format)
224
263
  Date.parse data
@@ -236,46 +275,9 @@ module AdzerkDecisionSdk
236
275
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
237
276
  end
238
277
  else
239
- # models, e.g. Pet
240
- AdzerkDecisionSdk.const_get(return_type).build_from_hash(data)
241
- end
242
- end
243
-
244
- # Save response body into a file in (the defined) temporary folder, using the filename
245
- # from the "Content-Disposition" header if provided, otherwise a random filename.
246
- # The response body is written to the file in chunks in order to handle files which
247
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
248
- # process can use.
249
- #
250
- # @see Configuration#temp_folder_path
251
- def download_file(request)
252
- tempfile = nil
253
- encoding = nil
254
- request.on_headers do |response|
255
- content_disposition = response.headers['Content-Disposition']
256
- if content_disposition && content_disposition =~ /filename=/i
257
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
258
- prefix = sanitize_filename(filename)
259
- else
260
- prefix = 'download-'
261
- end
262
- prefix = prefix + '-' unless prefix.end_with?('-')
263
- encoding = response.body.encoding
264
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
265
- @tempfile = tempfile
266
- end
267
- request.on_body do |chunk|
268
- chunk.force_encoding(encoding)
269
- tempfile.write(chunk)
270
- end
271
- request.on_complete do |response|
272
- if tempfile
273
- tempfile.close
274
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
- "explicitly with `tempfile.delete`"
278
- end
278
+ # models (e.g. Pet) or oneOf
279
+ klass = AdzerkDecisionSdk.const_get(return_type)
280
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
279
281
  end
280
282
  end
281
283
 
@@ -288,10 +290,10 @@ module AdzerkDecisionSdk
288
290
  filename.gsub(/.*[\/\\]/, '')
289
291
  end
290
292
 
291
- def build_request_url(path)
293
+ def build_request_url(path, opts = {})
292
294
  # Add leading and trailing slashes to path
293
295
  path = "/#{path}".gsub(/\/+/, '/')
294
- @config.base_url + path
296
+ @config.base_url(opts[:operation]) + path
295
297
  end
296
298
 
297
299
  # Update hearder and query params based on authentication settings.
@@ -306,7 +308,7 @@ module AdzerkDecisionSdk
306
308
  case auth_setting[:in]
307
309
  when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
308
310
  when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
309
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
311
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
310
312
  end
311
313
  end
312
314
  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.1.0
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
@@ -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.1.0
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]}."
@@ -14,17 +14,17 @@ module AdzerkDecisionSdk
14
14
  def get(request, opts = {})
15
15
  opts ||= {}
16
16
  header_params = opts[:header_params] || {}
17
- opts[:body] ||= request.respond_to?('to_hash') ? request.to_hash() : request
17
+ opts[:debug_body] ||= request.respond_to?('to_hash') ? request.to_hash() : request
18
18
 
19
- @logger.info("Processing request: #{opts[:body]}")
19
+ @logger.info("Processing request: #{opts[:debug_body]}")
20
20
 
21
- 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)
22
22
 
23
- 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
24
24
  fail ArgumentError, "Each request requires at least one placement"
25
25
  end
26
26
 
27
- opts[:body][:placements].each_with_index do |placement, idx|
27
+ opts[:debug_body][:placements].each_with_index do |placement, idx|
28
28
  if !placement.has_key?(:adTypes) or !placement[:adTypes] or placement[:adTypes].length() == 0
29
29
  fail ArgumentError, "Each placement needs at least one ad type"
30
30
  end
@@ -56,7 +56,7 @@ module AdzerkDecisionSdk
56
56
 
57
57
  opts[:header_params] = header_params
58
58
 
59
- @logger.info("Processed request: #{opts[:body]}")
59
+ @logger.info("Processed request: #{opts[:debug_body]}")
60
60
  @logger.info("Requesting with headers: #{opts[:header_params]}")
61
61
 
62
62
  response = @api.get_decisions(opts)
@@ -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.1.0
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.1.0
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,6 +36,11 @@ 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
  {
@@ -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