adzerk_decision_sdk 1.0.0.pre.beta.5 → 1.0.0.pre.beta.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -7
- data/README.md +58 -4
- data/adzerk_decision_sdk.gemspec +3 -4
- data/docs/ConsentRequest.md +10 -9
- data/docs/Content.md +16 -15
- data/docs/Decision.md +28 -27
- data/docs/DecisionApi.md +30 -13
- data/docs/DecisionRequest.md +44 -41
- data/docs/DecisionResponse.md +12 -11
- data/docs/Event.md +10 -9
- data/docs/MatchedPoint.md +10 -9
- data/docs/Placement.md +50 -41
- data/docs/PricingData.md +16 -15
- data/docs/User.md +8 -7
- data/docs/UserdbApi.md +259 -98
- data/lib/adzerk_decision_sdk/api/decision_api.rb +5 -4
- data/lib/adzerk_decision_sdk/api/userdb_api.rb +37 -28
- data/lib/adzerk_decision_sdk/api_client.rb +50 -48
- data/lib/adzerk_decision_sdk/api_error.rb +1 -1
- data/lib/adzerk_decision_sdk/client.rb +2 -1
- data/lib/adzerk_decision_sdk/configuration.rb +39 -10
- data/lib/adzerk_decision_sdk/decision_client.rb +16 -6
- data/lib/adzerk_decision_sdk/models/consent_request.rb +19 -7
- data/lib/adzerk_decision_sdk/models/content.rb +19 -7
- data/lib/adzerk_decision_sdk/models/decision.rb +19 -7
- data/lib/adzerk_decision_sdk/models/decision_request.rb +32 -10
- data/lib/adzerk_decision_sdk/models/decision_response.rb +19 -7
- data/lib/adzerk_decision_sdk/models/event.rb +19 -7
- data/lib/adzerk_decision_sdk/models/matched_point.rb +19 -7
- data/lib/adzerk_decision_sdk/models/placement.rb +67 -12
- data/lib/adzerk_decision_sdk/models/pricing_data.rb +19 -7
- data/lib/adzerk_decision_sdk/models/user.rb +19 -7
- data/lib/adzerk_decision_sdk/user_db_client.rb +2 -2
- data/lib/adzerk_decision_sdk/version.rb +1 -1
- data/spec/spec_helper.rb +91 -0
- metadata +11 -30
- 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:
|
9
|
+
OpenAPI Generator version: 5.1.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -53,15 +53,16 @@ module AdzerkDecisionSdk
|
|
53
53
|
form_params = opts[:form_params] || {}
|
54
54
|
|
55
55
|
# http body (model)
|
56
|
-
post_body = opts[:
|
56
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'decision_request'])
|
57
57
|
|
58
58
|
# return_type
|
59
|
-
return_type = opts[:
|
59
|
+
return_type = opts[:debug_return_type] || 'DecisionResponse'
|
60
60
|
|
61
61
|
# auth_names
|
62
|
-
auth_names = opts[:
|
62
|
+
auth_names = opts[:debug_auth_names] || []
|
63
63
|
|
64
64
|
new_options = opts.merge(
|
65
|
+
:operation => :"DecisionApi.get_decisions",
|
65
66
|
:header_params => header_params,
|
66
67
|
:query_params => query_params,
|
67
68
|
: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:
|
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[:
|
69
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])
|
70
70
|
|
71
71
|
# return_type
|
72
|
-
return_type = opts[:
|
72
|
+
return_type = opts[:debug_return_type] || 'File'
|
73
73
|
|
74
74
|
# auth_names
|
75
|
-
auth_names = opts[:
|
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[:
|
144
|
+
post_body = opts[:debug_body]
|
144
145
|
|
145
146
|
# return_type
|
146
|
-
return_type = opts[:
|
147
|
+
return_type = opts[:debug_return_type] || 'File'
|
147
148
|
|
148
149
|
# auth_names
|
149
|
-
auth_names = opts[:
|
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[:
|
224
|
+
post_body = opts[:debug_body]
|
223
225
|
|
224
226
|
# return_type
|
225
|
-
return_type = opts[:
|
227
|
+
return_type = opts[:debug_return_type] || 'File'
|
226
228
|
|
227
229
|
# auth_names
|
228
|
-
auth_names = opts[:
|
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[:
|
290
|
+
post_body = opts[:debug_body]
|
288
291
|
|
289
292
|
# return_type
|
290
|
-
return_type = opts[:
|
293
|
+
return_type = opts[:debug_return_type]
|
291
294
|
|
292
295
|
# auth_names
|
293
|
-
auth_names = opts[:
|
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[:
|
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[:
|
358
|
+
return_type = opts[:debug_return_type] || 'File'
|
355
359
|
|
356
360
|
# auth_names
|
357
|
-
auth_names = opts[:
|
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[:
|
430
|
+
post_body = opts[:debug_body]
|
426
431
|
|
427
432
|
# return_type
|
428
|
-
return_type = opts[:
|
433
|
+
return_type = opts[:debug_return_type] || 'File'
|
429
434
|
|
430
435
|
# auth_names
|
431
|
-
auth_names = opts[:
|
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[:
|
512
|
+
post_body = opts[:debug_body]
|
507
513
|
|
508
514
|
# return_type
|
509
|
-
return_type = opts[:
|
515
|
+
return_type = opts[:debug_return_type] || 'File'
|
510
516
|
|
511
517
|
# auth_names
|
512
|
-
auth_names = opts[:
|
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[:
|
580
|
+
post_body = opts[:debug_body]
|
574
581
|
|
575
582
|
# return_type
|
576
|
-
return_type = opts[:
|
583
|
+
return_type = opts[:debug_return_type] || 'File'
|
577
584
|
|
578
585
|
# auth_names
|
579
|
-
auth_names = opts[:
|
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[:
|
648
|
+
post_body = opts[:debug_body]
|
641
649
|
|
642
650
|
# return_type
|
643
|
-
return_type = opts[:
|
651
|
+
return_type = opts[:debug_return_type] || 'Object'
|
644
652
|
|
645
653
|
# auth_names
|
646
|
-
auth_names = opts[:
|
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:
|
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
|
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 '
|
258
|
+
when 'Time'
|
220
259
|
# parse date time (expecting ISO 8601 format)
|
221
|
-
|
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
|
240
|
-
AdzerkDecisionSdk.const_get(return_type)
|
241
|
-
|
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`
|
311
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
310
312
|
end
|
311
313
|
end
|
312
314
|
end
|
@@ -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['
|
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:
|
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
|
-
|
175
|
-
|
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]} #{
|
204
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
183
205
|
else
|
184
|
-
|
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('
|
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?
|
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]}."
|