knievel 0.1.35 → 0.1.36
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +13 -4
- data/docs/DecisionAd.md +3 -1
- data/docs/DecisionCreative.md +34 -0
- data/docs/DecisionCreativeHtmlCreative.md +22 -0
- data/docs/DecisionCreativeImageCreative.md +28 -0
- data/docs/DecisionCreativeNativeCreative.md +24 -0
- data/docs/DecisionCreativeTemplatedCreative.md +26 -0
- data/docs/HtmlCreative.md +20 -0
- data/docs/ImageCreative.md +26 -0
- data/docs/NativeCreative.md +22 -0
- data/docs/TemplatedCreative.md +24 -0
- data/lib/knievel/models/decision_ad.rb +14 -4
- data/lib/knievel/models/decision_creative.rb +106 -0
- data/lib/knievel/models/decision_creative_html_creative.rb +215 -0
- data/lib/knievel/models/decision_creative_image_creative.rb +241 -0
- data/lib/knievel/models/decision_creative_native_creative.rb +227 -0
- data/lib/knievel/models/decision_creative_templated_creative.rb +255 -0
- data/lib/knievel/models/html_creative.rb +157 -0
- data/lib/knievel/models/image_creative.rb +183 -0
- data/lib/knievel/models/native_creative.rb +169 -0
- data/lib/knievel/models/templated_creative.rb +197 -0
- data/lib/knievel/version.rb +1 -1
- data/lib/knievel.rb +9 -0
- data/spec/models/decision_creative_html_creative_spec.rb +52 -0
- data/spec/models/decision_creative_image_creative_spec.rb +70 -0
- data/spec/models/decision_creative_native_creative_spec.rb +58 -0
- data/spec/models/decision_creative_spec.rb +21 -0
- data/spec/models/decision_creative_templated_creative_spec.rb +64 -0
- data/spec/models/html_creative_spec.rb +42 -0
- data/spec/models/image_creative_spec.rb +60 -0
- data/spec/models/native_creative_spec.rb +48 -0
- data/spec/models/templated_creative_spec.rb +54 -0
- metadata +38 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: efa4ab4f7b59830b13bd18b0558e36697dccde6fd51ea51cad9dc39d901eac07
|
|
4
|
+
data.tar.gz: 4f206915dec8020b087bc3f1adac51f2facdfe42bae6fa4c48fd2acdeccf8fa6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3909aced7854b5c2530e15351c606b39b4017fedfa86b0f9356e7f5c1bb1766d7ca5806476f98fefb64563ef103c39e83e4ca212001925b57e4712fb6efce6a
|
|
7
|
+
data.tar.gz: 0a8e4540d26ba8dac770911f32fe7ef665ea9e7d44ca86ba174fb0afe9a6fa855b8bb13de114b5d754c6c23f428c909b6a65d12944c2c16edc349d336412515f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
|
|
|
7
7
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
8
8
|
|
|
9
9
|
- API version: 0.1.31
|
|
10
|
-
- Package version: 0.1.
|
|
10
|
+
- Package version: 0.1.36
|
|
11
11
|
- Generator version: 7.23.0-SNAPSHOT
|
|
12
12
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
|
13
13
|
|
|
@@ -24,16 +24,16 @@ gem build knievel.gemspec
|
|
|
24
24
|
Then either install the gem locally:
|
|
25
25
|
|
|
26
26
|
```shell
|
|
27
|
-
gem install ./knievel-0.1.
|
|
27
|
+
gem install ./knievel-0.1.36.gem
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
(for development, run `gem install --dev ./knievel-0.1.
|
|
30
|
+
(for development, run `gem install --dev ./knievel-0.1.36.gem` to install the development dependencies)
|
|
31
31
|
|
|
32
32
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
|
33
33
|
|
|
34
34
|
Finally add this to the Gemfile:
|
|
35
35
|
|
|
36
|
-
gem 'knievel', '~> 0.1.
|
|
36
|
+
gem 'knievel', '~> 0.1.36'
|
|
37
37
|
|
|
38
38
|
### Install from Git
|
|
39
39
|
|
|
@@ -205,6 +205,11 @@ Class | Method | HTTP request | Description
|
|
|
205
205
|
- [Knievel::DecisionAd](docs/DecisionAd.md)
|
|
206
206
|
- [Knievel::DecisionBlock](docs/DecisionBlock.md)
|
|
207
207
|
- [Knievel::DecisionContext](docs/DecisionContext.md)
|
|
208
|
+
- [Knievel::DecisionCreative](docs/DecisionCreative.md)
|
|
209
|
+
- [Knievel::DecisionCreativeHtmlCreative](docs/DecisionCreativeHtmlCreative.md)
|
|
210
|
+
- [Knievel::DecisionCreativeImageCreative](docs/DecisionCreativeImageCreative.md)
|
|
211
|
+
- [Knievel::DecisionCreativeNativeCreative](docs/DecisionCreativeNativeCreative.md)
|
|
212
|
+
- [Knievel::DecisionCreativeTemplatedCreative](docs/DecisionCreativeTemplatedCreative.md)
|
|
208
213
|
- [Knievel::DecisionPlacement](docs/DecisionPlacement.md)
|
|
209
214
|
- [Knievel::DecisionsRequest](docs/DecisionsRequest.md)
|
|
210
215
|
- [Knievel::DecisionsResponse](docs/DecisionsResponse.md)
|
|
@@ -217,7 +222,10 @@ Class | Method | HTTP request | Description
|
|
|
217
222
|
- [Knievel::Flight](docs/Flight.md)
|
|
218
223
|
- [Knievel::FlightList](docs/FlightList.md)
|
|
219
224
|
- [Knievel::ForceOverride](docs/ForceOverride.md)
|
|
225
|
+
- [Knievel::HtmlCreative](docs/HtmlCreative.md)
|
|
226
|
+
- [Knievel::ImageCreative](docs/ImageCreative.md)
|
|
220
227
|
- [Knievel::IssuerSummary](docs/IssuerSummary.md)
|
|
228
|
+
- [Knievel::NativeCreative](docs/NativeCreative.md)
|
|
221
229
|
- [Knievel::OrgResponse](docs/OrgResponse.md)
|
|
222
230
|
- [Knievel::Priority](docs/Priority.md)
|
|
223
231
|
- [Knievel::PriorityList](docs/PriorityList.md)
|
|
@@ -225,6 +233,7 @@ Class | Method | HTTP request | Description
|
|
|
225
233
|
- [Knievel::ProjectResponse](docs/ProjectResponse.md)
|
|
226
234
|
- [Knievel::Site](docs/Site.md)
|
|
227
235
|
- [Knievel::SiteList](docs/SiteList.md)
|
|
236
|
+
- [Knievel::TemplatedCreative](docs/TemplatedCreative.md)
|
|
228
237
|
- [Knievel::TokenListResponse](docs/TokenListResponse.md)
|
|
229
238
|
- [Knievel::TokenSummary](docs/TokenSummary.md)
|
|
230
239
|
- [Knievel::UpdateAdLibraryItemRequest](docs/UpdateAdLibraryItemRequest.md)
|
data/docs/DecisionAd.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
| **site_id** | **Integer** | | |
|
|
14
14
|
| **click_url** | **String** | | |
|
|
15
15
|
| **impression_url** | **String** | | |
|
|
16
|
+
| **creative** | [**DecisionCreative**](DecisionCreative.md) | The selected ad's creative, typed by `kind` (`API.md` § 1 `oneOf`). `null` when the ad has no creative attached or the snapshot hasn't loaded it yet. For `templated` creatives the `body` is rendered server-side at decision time; the other kinds carry their stored fields verbatim. | [optional] |
|
|
16
17
|
|
|
17
18
|
## Example
|
|
18
19
|
|
|
@@ -28,7 +29,8 @@ instance = Knievel::DecisionAd.new(
|
|
|
28
29
|
priority_id: null,
|
|
29
30
|
site_id: null,
|
|
30
31
|
click_url: null,
|
|
31
|
-
impression_url: null
|
|
32
|
+
impression_url: null,
|
|
33
|
+
creative: null
|
|
32
34
|
)
|
|
33
35
|
```
|
|
34
36
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Knievel::DecisionCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **type** | **String** | | |
|
|
8
|
+
| **image_url** | **String** | | [optional] |
|
|
9
|
+
| **width** | **Integer** | | [optional] |
|
|
10
|
+
| **height** | **Integer** | | [optional] |
|
|
11
|
+
| **alt** | **String** | | [optional] |
|
|
12
|
+
| **click_through_url** | **String** | | [optional] |
|
|
13
|
+
| **body** | **String** | The template's Liquid source rendered against `values` plus the injected decision context (signed URLs, placement id, snapshot version) at decision time. | |
|
|
14
|
+
| **template** | **String** | The referenced template's name. | [optional] |
|
|
15
|
+
| **values** | **Object** | Echoed so callers can re-render or inspect. | |
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
require 'knievel'
|
|
21
|
+
|
|
22
|
+
instance = Knievel::DecisionCreative.new(
|
|
23
|
+
type: image,
|
|
24
|
+
image_url: null,
|
|
25
|
+
width: null,
|
|
26
|
+
height: null,
|
|
27
|
+
alt: null,
|
|
28
|
+
click_through_url: null,
|
|
29
|
+
body: null,
|
|
30
|
+
template: null,
|
|
31
|
+
values: null
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Knievel::DecisionCreativeHtmlCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **body** | **String** | Verbatim HTML stored on the creative, returned as-is. | [optional] |
|
|
8
|
+
| **click_through_url** | **String** | | [optional] |
|
|
9
|
+
| **type** | **String** | | |
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
require 'knievel'
|
|
15
|
+
|
|
16
|
+
instance = Knievel::DecisionCreativeHtmlCreative.new(
|
|
17
|
+
body: null,
|
|
18
|
+
click_through_url: null,
|
|
19
|
+
type: html
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Knievel::DecisionCreativeImageCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **image_url** | **String** | | [optional] |
|
|
8
|
+
| **width** | **Integer** | | [optional] |
|
|
9
|
+
| **height** | **Integer** | | [optional] |
|
|
10
|
+
| **alt** | **String** | | [optional] |
|
|
11
|
+
| **click_through_url** | **String** | | [optional] |
|
|
12
|
+
| **type** | **String** | | |
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
require 'knievel'
|
|
18
|
+
|
|
19
|
+
instance = Knievel::DecisionCreativeImageCreative.new(
|
|
20
|
+
image_url: null,
|
|
21
|
+
width: null,
|
|
22
|
+
height: null,
|
|
23
|
+
alt: null,
|
|
24
|
+
click_through_url: null,
|
|
25
|
+
type: image
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Knievel::DecisionCreativeNativeCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **template** | **String** | The referenced template's name; the caller renders `values` client-side using its own components. | [optional] |
|
|
8
|
+
| **values** | **Object** | | |
|
|
9
|
+
| **click_through_url** | **String** | | [optional] |
|
|
10
|
+
| **type** | **String** | | |
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
require 'knievel'
|
|
16
|
+
|
|
17
|
+
instance = Knievel::DecisionCreativeNativeCreative.new(
|
|
18
|
+
template: null,
|
|
19
|
+
values: null,
|
|
20
|
+
click_through_url: null,
|
|
21
|
+
type: native
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Knievel::DecisionCreativeTemplatedCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **template** | **String** | The referenced template's name. | [optional] |
|
|
8
|
+
| **values** | **Object** | Echoed so callers can re-render or inspect. | |
|
|
9
|
+
| **body** | **String** | The template's Liquid source rendered against `values` plus the injected decision context (signed URLs, placement id, snapshot version) at decision time. | |
|
|
10
|
+
| **click_through_url** | **String** | | [optional] |
|
|
11
|
+
| **type** | **String** | | |
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'knievel'
|
|
17
|
+
|
|
18
|
+
instance = Knievel::DecisionCreativeTemplatedCreative.new(
|
|
19
|
+
template: null,
|
|
20
|
+
values: null,
|
|
21
|
+
body: null,
|
|
22
|
+
click_through_url: null,
|
|
23
|
+
type: templated
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Knievel::HtmlCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **body** | **String** | Verbatim HTML stored on the creative, returned as-is. | [optional] |
|
|
8
|
+
| **click_through_url** | **String** | | [optional] |
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
require 'knievel'
|
|
14
|
+
|
|
15
|
+
instance = Knievel::HtmlCreative.new(
|
|
16
|
+
body: null,
|
|
17
|
+
click_through_url: null
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Knievel::ImageCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **image_url** | **String** | | [optional] |
|
|
8
|
+
| **width** | **Integer** | | [optional] |
|
|
9
|
+
| **height** | **Integer** | | [optional] |
|
|
10
|
+
| **alt** | **String** | | [optional] |
|
|
11
|
+
| **click_through_url** | **String** | | [optional] |
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'knievel'
|
|
17
|
+
|
|
18
|
+
instance = Knievel::ImageCreative.new(
|
|
19
|
+
image_url: null,
|
|
20
|
+
width: null,
|
|
21
|
+
height: null,
|
|
22
|
+
alt: null,
|
|
23
|
+
click_through_url: null
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Knievel::NativeCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **template** | **String** | The referenced template's name; the caller renders `values` client-side using its own components. | [optional] |
|
|
8
|
+
| **values** | **Object** | | |
|
|
9
|
+
| **click_through_url** | **String** | | [optional] |
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
require 'knievel'
|
|
15
|
+
|
|
16
|
+
instance = Knievel::NativeCreative.new(
|
|
17
|
+
template: null,
|
|
18
|
+
values: null,
|
|
19
|
+
click_through_url: null
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Knievel::TemplatedCreative
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **template** | **String** | The referenced template's name. | [optional] |
|
|
8
|
+
| **values** | **Object** | Echoed so callers can re-render or inspect. | |
|
|
9
|
+
| **body** | **String** | The template's Liquid source rendered against `values` plus the injected decision context (signed URLs, placement id, snapshot version) at decision time. | |
|
|
10
|
+
| **click_through_url** | **String** | | [optional] |
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
require 'knievel'
|
|
16
|
+
|
|
17
|
+
instance = Knievel::TemplatedCreative.new(
|
|
18
|
+
template: null,
|
|
19
|
+
values: null,
|
|
20
|
+
body: null,
|
|
21
|
+
click_through_url: null
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
@@ -33,6 +33,9 @@ module Knievel
|
|
|
33
33
|
|
|
34
34
|
attr_accessor :impression_url
|
|
35
35
|
|
|
36
|
+
# The selected ad's creative, typed by `kind` (`API.md` § 1 `oneOf`). `null` when the ad has no creative attached or the snapshot hasn't loaded it yet. For `templated` creatives the `body` is rendered server-side at decision time; the other kinds carry their stored fields verbatim.
|
|
37
|
+
attr_accessor :creative
|
|
38
|
+
|
|
36
39
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
37
40
|
def self.attribute_map
|
|
38
41
|
{
|
|
@@ -44,7 +47,8 @@ module Knievel
|
|
|
44
47
|
:'priority_id' => :'priority_id',
|
|
45
48
|
:'site_id' => :'site_id',
|
|
46
49
|
:'click_url' => :'click_url',
|
|
47
|
-
:'impression_url' => :'impression_url'
|
|
50
|
+
:'impression_url' => :'impression_url',
|
|
51
|
+
:'creative' => :'creative'
|
|
48
52
|
}
|
|
49
53
|
end
|
|
50
54
|
|
|
@@ -69,7 +73,8 @@ module Knievel
|
|
|
69
73
|
:'priority_id' => :'Integer',
|
|
70
74
|
:'site_id' => :'Integer',
|
|
71
75
|
:'click_url' => :'String',
|
|
72
|
-
:'impression_url' => :'String'
|
|
76
|
+
:'impression_url' => :'String',
|
|
77
|
+
:'creative' => :'DecisionCreative'
|
|
73
78
|
}
|
|
74
79
|
end
|
|
75
80
|
|
|
@@ -148,6 +153,10 @@ module Knievel
|
|
|
148
153
|
else
|
|
149
154
|
self.impression_url = nil
|
|
150
155
|
end
|
|
156
|
+
|
|
157
|
+
if attributes.key?(:'creative')
|
|
158
|
+
self.creative = attributes[:'creative']
|
|
159
|
+
end
|
|
151
160
|
end
|
|
152
161
|
|
|
153
162
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -313,7 +322,8 @@ module Knievel
|
|
|
313
322
|
priority_id == o.priority_id &&
|
|
314
323
|
site_id == o.site_id &&
|
|
315
324
|
click_url == o.click_url &&
|
|
316
|
-
impression_url == o.impression_url
|
|
325
|
+
impression_url == o.impression_url &&
|
|
326
|
+
creative == o.creative
|
|
317
327
|
end
|
|
318
328
|
|
|
319
329
|
# @see the `==` method
|
|
@@ -325,7 +335,7 @@ module Knievel
|
|
|
325
335
|
# Calculates hash code according to all attributes.
|
|
326
336
|
# @return [Integer] Hash code
|
|
327
337
|
def hash
|
|
328
|
-
[ad_id, creative_id, flight_id, campaign_id, advertiser_id, priority_id, site_id, click_url, impression_url].hash
|
|
338
|
+
[ad_id, creative_id, flight_id, campaign_id, advertiser_id, priority_id, site_id, click_url, impression_url, creative].hash
|
|
329
339
|
end
|
|
330
340
|
|
|
331
341
|
# Builds the object from hash
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#knievel
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.31
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.23.0-SNAPSHOT
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Knievel
|
|
17
|
+
# The decision response's typed creative block — a discriminated union on `type` mirroring `API.md` § 1 / § 3.5. The four arms match the four creative `kind`s.
|
|
18
|
+
module DecisionCreative
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
21
|
+
def openapi_any_of
|
|
22
|
+
[
|
|
23
|
+
:'DecisionCreativeHtmlCreative',
|
|
24
|
+
:'DecisionCreativeImageCreative',
|
|
25
|
+
:'DecisionCreativeNativeCreative',
|
|
26
|
+
:'DecisionCreativeTemplatedCreative'
|
|
27
|
+
]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Builds the object
|
|
31
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
32
|
+
# @return [Object] Returns the model or the data itself
|
|
33
|
+
def build(data)
|
|
34
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
35
|
+
# Note:
|
|
36
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
37
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
38
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
39
|
+
# - TODO: logging when debugging is set.
|
|
40
|
+
openapi_any_of.each do |klass|
|
|
41
|
+
begin
|
|
42
|
+
next if klass == :AnyType # "nullable: true"
|
|
43
|
+
return find_and_cast_into_type(klass, data)
|
|
44
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
54
|
+
|
|
55
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
56
|
+
def find_and_cast_into_type(klass, data)
|
|
57
|
+
return if data.nil?
|
|
58
|
+
|
|
59
|
+
case klass.to_s
|
|
60
|
+
when 'Boolean'
|
|
61
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
62
|
+
when 'Float'
|
|
63
|
+
return data if data.instance_of?(Float)
|
|
64
|
+
when 'Integer'
|
|
65
|
+
return data if data.instance_of?(Integer)
|
|
66
|
+
when 'Time'
|
|
67
|
+
return Time.parse(data)
|
|
68
|
+
when 'Date'
|
|
69
|
+
return Date.iso8601(data)
|
|
70
|
+
when 'String'
|
|
71
|
+
return data if data.instance_of?(String)
|
|
72
|
+
when 'Object' # "type: object"
|
|
73
|
+
return data if data.instance_of?(Hash)
|
|
74
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
75
|
+
if data.instance_of?(Array)
|
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
77
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
78
|
+
end
|
|
79
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
80
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
81
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
82
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
83
|
+
end
|
|
84
|
+
else # model
|
|
85
|
+
const = Knievel.const_get(klass)
|
|
86
|
+
if const
|
|
87
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
88
|
+
model = const.build(data)
|
|
89
|
+
return model if model
|
|
90
|
+
else
|
|
91
|
+
# raise if data contains keys that are not known to the model
|
|
92
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
93
|
+
model = const.build_from_hash(data)
|
|
94
|
+
return model if model
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
raise # if no match by now, raise
|
|
100
|
+
rescue
|
|
101
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|