late-sdk 0.0.926 → 0.0.928
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/README.md +3 -0
- data/docs/AdCampaignsApi.md +2 -2
- data/docs/GooglePmaxAssetGroupUpdate.md +30 -0
- data/docs/GooglePmaxAssetGroupUpdateImages.md +22 -0
- data/docs/UpdateAdRequest.md +5 -3
- data/docs/UpdateAdRequestCreative.md +6 -0
- data/docs/UpdateAdRequestTargeting.md +5 -1
- data/docs/UpdateAdRequestTargetingLocations.md +49 -0
- data/lib/zernio-sdk/api/ad_campaigns_api.rb +4 -4
- data/lib/zernio-sdk/models/google_pmax_asset_group_update.rb +375 -0
- data/lib/zernio-sdk/models/google_pmax_asset_group_update_images.rb +259 -0
- data/lib/zernio-sdk/models/update_ad_request.rb +29 -19
- data/lib/zernio-sdk/models/update_ad_request_creative.rb +87 -1
- data/lib/zernio-sdk/models/update_ad_request_targeting.rb +23 -1
- data/lib/zernio-sdk/models/update_ad_request_targeting_locations.rb +105 -0
- data/lib/zernio-sdk/version.rb +1 -1
- data/lib/zernio-sdk.rb +3 -0
- data/openapi.yaml +158 -16
- data/spec/api/ad_campaigns_api_spec.rb +2 -2
- data/spec/models/google_pmax_asset_group_update_images_spec.rb +48 -0
- data/spec/models/google_pmax_asset_group_update_spec.rb +72 -0
- data/spec/models/update_ad_request_creative_spec.rb +18 -0
- data/spec/models/update_ad_request_spec.rb +6 -0
- data/spec/models/update_ad_request_targeting_locations_spec.rb +32 -0
- data/spec/models/update_ad_request_targeting_spec.rb +12 -0
- data/zernio-sdk-0.0.928.gem +0 -0
- metadata +14 -2
- data/zernio-sdk-0.0.926.gem +0 -0
|
@@ -15,15 +15,18 @@ require 'time'
|
|
|
15
15
|
|
|
16
16
|
module Zernio
|
|
17
17
|
class UpdateAdRequest < ApiModelBase
|
|
18
|
-
# Google
|
|
18
|
+
# Google Search and Display only. Replaces the complete headline list. Search takes 3-15, Display 1-5 and rejects pinnedField; the count is checked once the ad's channel is known. No padding or truncation on update.
|
|
19
19
|
attr_accessor :headlines
|
|
20
20
|
|
|
21
|
-
# Google
|
|
21
|
+
# Google Search and Display only. Replaces the complete description list. Search takes 2-4, Display 1-5 and rejects pinnedField. No padding or truncation on update.
|
|
22
22
|
attr_accessor :descriptions
|
|
23
23
|
|
|
24
|
-
# Google
|
|
24
|
+
# Google Search and Display only. Replaces final URLs. Omitted lists stay unchanged. For Performance Max use assetGroup.finalUrl.
|
|
25
25
|
attr_accessor :final_urls
|
|
26
26
|
|
|
27
|
+
# Google Performance Max only. Replaces whole asset roles on the ad's asset group. Returns 422 on any other platform or channel.
|
|
28
|
+
attr_accessor :asset_group
|
|
29
|
+
|
|
27
30
|
attr_accessor :status
|
|
28
31
|
|
|
29
32
|
attr_accessor :budget
|
|
@@ -63,6 +66,7 @@ module Zernio
|
|
|
63
66
|
:'headlines' => :'headlines',
|
|
64
67
|
:'descriptions' => :'descriptions',
|
|
65
68
|
:'final_urls' => :'finalUrls',
|
|
69
|
+
:'asset_group' => :'assetGroup',
|
|
66
70
|
:'status' => :'status',
|
|
67
71
|
:'budget' => :'budget',
|
|
68
72
|
:'targeting' => :'targeting',
|
|
@@ -87,6 +91,7 @@ module Zernio
|
|
|
87
91
|
:'headlines' => :'Array<GoogleRsaHeadline>',
|
|
88
92
|
:'descriptions' => :'Array<GoogleRsaDescription>',
|
|
89
93
|
:'final_urls' => :'Array<String>',
|
|
94
|
+
:'asset_group' => :'GooglePmaxAssetGroupUpdate',
|
|
90
95
|
:'status' => :'String',
|
|
91
96
|
:'budget' => :'UpdateAdRequestBudget',
|
|
92
97
|
:'targeting' => :'UpdateAdRequestTargeting',
|
|
@@ -135,6 +140,10 @@ module Zernio
|
|
|
135
140
|
end
|
|
136
141
|
end
|
|
137
142
|
|
|
143
|
+
if attributes.key?(:'asset_group')
|
|
144
|
+
self.asset_group = attributes[:'asset_group']
|
|
145
|
+
end
|
|
146
|
+
|
|
138
147
|
if attributes.key?(:'status')
|
|
139
148
|
self.status = attributes[:'status']
|
|
140
149
|
end
|
|
@@ -165,16 +174,16 @@ module Zernio
|
|
|
165
174
|
invalid_properties.push('invalid value for "headlines", number of items must be less than or equal to 15.')
|
|
166
175
|
end
|
|
167
176
|
|
|
168
|
-
if !@headlines.nil? && @headlines.length <
|
|
169
|
-
invalid_properties.push('invalid value for "headlines", number of items must be greater than or equal to
|
|
177
|
+
if !@headlines.nil? && @headlines.length < 1
|
|
178
|
+
invalid_properties.push('invalid value for "headlines", number of items must be greater than or equal to 1.')
|
|
170
179
|
end
|
|
171
180
|
|
|
172
|
-
if !@descriptions.nil? && @descriptions.length >
|
|
173
|
-
invalid_properties.push('invalid value for "descriptions", number of items must be less than or equal to
|
|
181
|
+
if !@descriptions.nil? && @descriptions.length > 5
|
|
182
|
+
invalid_properties.push('invalid value for "descriptions", number of items must be less than or equal to 5.')
|
|
174
183
|
end
|
|
175
184
|
|
|
176
|
-
if !@descriptions.nil? && @descriptions.length <
|
|
177
|
-
invalid_properties.push('invalid value for "descriptions", number of items must be greater than or equal to
|
|
185
|
+
if !@descriptions.nil? && @descriptions.length < 1
|
|
186
|
+
invalid_properties.push('invalid value for "descriptions", number of items must be greater than or equal to 1.')
|
|
178
187
|
end
|
|
179
188
|
|
|
180
189
|
if !@final_urls.nil? && @final_urls.length < 1
|
|
@@ -193,9 +202,9 @@ module Zernio
|
|
|
193
202
|
def valid?
|
|
194
203
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
195
204
|
return false if !@headlines.nil? && @headlines.length > 15
|
|
196
|
-
return false if !@headlines.nil? && @headlines.length <
|
|
197
|
-
return false if !@descriptions.nil? && @descriptions.length >
|
|
198
|
-
return false if !@descriptions.nil? && @descriptions.length <
|
|
205
|
+
return false if !@headlines.nil? && @headlines.length < 1
|
|
206
|
+
return false if !@descriptions.nil? && @descriptions.length > 5
|
|
207
|
+
return false if !@descriptions.nil? && @descriptions.length < 1
|
|
199
208
|
return false if !@final_urls.nil? && @final_urls.length < 1
|
|
200
209
|
status_validator = EnumAttributeValidator.new('String', ["active", "paused"])
|
|
201
210
|
return false unless status_validator.valid?(@status)
|
|
@@ -214,8 +223,8 @@ module Zernio
|
|
|
214
223
|
fail ArgumentError, 'invalid value for "headlines", number of items must be less than or equal to 15.'
|
|
215
224
|
end
|
|
216
225
|
|
|
217
|
-
if headlines.length <
|
|
218
|
-
fail ArgumentError, 'invalid value for "headlines", number of items must be greater than or equal to
|
|
226
|
+
if headlines.length < 1
|
|
227
|
+
fail ArgumentError, 'invalid value for "headlines", number of items must be greater than or equal to 1.'
|
|
219
228
|
end
|
|
220
229
|
|
|
221
230
|
@headlines = headlines
|
|
@@ -228,12 +237,12 @@ module Zernio
|
|
|
228
237
|
fail ArgumentError, 'descriptions cannot be nil'
|
|
229
238
|
end
|
|
230
239
|
|
|
231
|
-
if descriptions.length >
|
|
232
|
-
fail ArgumentError, 'invalid value for "descriptions", number of items must be less than or equal to
|
|
240
|
+
if descriptions.length > 5
|
|
241
|
+
fail ArgumentError, 'invalid value for "descriptions", number of items must be less than or equal to 5.'
|
|
233
242
|
end
|
|
234
243
|
|
|
235
|
-
if descriptions.length <
|
|
236
|
-
fail ArgumentError, 'invalid value for "descriptions", number of items must be greater than or equal to
|
|
244
|
+
if descriptions.length < 1
|
|
245
|
+
fail ArgumentError, 'invalid value for "descriptions", number of items must be greater than or equal to 1.'
|
|
237
246
|
end
|
|
238
247
|
|
|
239
248
|
@descriptions = descriptions
|
|
@@ -285,6 +294,7 @@ module Zernio
|
|
|
285
294
|
headlines == o.headlines &&
|
|
286
295
|
descriptions == o.descriptions &&
|
|
287
296
|
final_urls == o.final_urls &&
|
|
297
|
+
asset_group == o.asset_group &&
|
|
288
298
|
status == o.status &&
|
|
289
299
|
budget == o.budget &&
|
|
290
300
|
targeting == o.targeting &&
|
|
@@ -301,7 +311,7 @@ module Zernio
|
|
|
301
311
|
# Calculates hash code according to all attributes.
|
|
302
312
|
# @return [Integer] Hash code
|
|
303
313
|
def hash
|
|
304
|
-
[headlines, descriptions, final_urls, status, budget, targeting, creative, name].hash
|
|
314
|
+
[headlines, descriptions, final_urls, asset_group, status, budget, targeting, creative, name].hash
|
|
305
315
|
end
|
|
306
316
|
|
|
307
317
|
# Builds the object from hash
|
|
@@ -24,6 +24,15 @@ module Zernio
|
|
|
24
24
|
# Meta and LinkedIn (TikTok has no headline slot)
|
|
25
25
|
attr_accessor :headline
|
|
26
26
|
|
|
27
|
+
# Google Display only. Replaces the responsive display ad's long headline.
|
|
28
|
+
attr_accessor :long_headline
|
|
29
|
+
|
|
30
|
+
# Google Display only. Replaces the responsive display ad's business name.
|
|
31
|
+
attr_accessor :business_name
|
|
32
|
+
|
|
33
|
+
# Google Display only. Uploaded as a new square (1:1) marketing image asset that replaces the current one.
|
|
34
|
+
attr_accessor :square_image_url
|
|
35
|
+
|
|
27
36
|
attr_accessor :body
|
|
28
37
|
|
|
29
38
|
# Link description slot (Meta `link_data.description` / `video_data.link_description`, LinkedIn creative description).
|
|
@@ -71,6 +80,9 @@ module Zernio
|
|
|
71
80
|
:'promotion' => :'promotion',
|
|
72
81
|
:'creative_features' => :'creativeFeatures',
|
|
73
82
|
:'headline' => :'headline',
|
|
83
|
+
:'long_headline' => :'longHeadline',
|
|
84
|
+
:'business_name' => :'businessName',
|
|
85
|
+
:'square_image_url' => :'squareImageUrl',
|
|
74
86
|
:'body' => :'body',
|
|
75
87
|
:'description' => :'description',
|
|
76
88
|
:'call_to_action' => :'callToAction',
|
|
@@ -98,6 +110,9 @@ module Zernio
|
|
|
98
110
|
:'promotion' => :'MetaPromotion',
|
|
99
111
|
:'creative_features' => :'Hash<String, String>',
|
|
100
112
|
:'headline' => :'String',
|
|
113
|
+
:'long_headline' => :'String',
|
|
114
|
+
:'business_name' => :'String',
|
|
115
|
+
:'square_image_url' => :'String',
|
|
101
116
|
:'body' => :'String',
|
|
102
117
|
:'description' => :'String',
|
|
103
118
|
:'call_to_action' => :'String',
|
|
@@ -145,6 +160,18 @@ module Zernio
|
|
|
145
160
|
self.headline = attributes[:'headline']
|
|
146
161
|
end
|
|
147
162
|
|
|
163
|
+
if attributes.key?(:'long_headline')
|
|
164
|
+
self.long_headline = attributes[:'long_headline']
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if attributes.key?(:'business_name')
|
|
168
|
+
self.business_name = attributes[:'business_name']
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if attributes.key?(:'square_image_url')
|
|
172
|
+
self.square_image_url = attributes[:'square_image_url']
|
|
173
|
+
end
|
|
174
|
+
|
|
148
175
|
if attributes.key?(:'body')
|
|
149
176
|
self.body = attributes[:'body']
|
|
150
177
|
end
|
|
@@ -183,6 +210,22 @@ module Zernio
|
|
|
183
210
|
def list_invalid_properties
|
|
184
211
|
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
185
212
|
invalid_properties = Array.new
|
|
213
|
+
if !@long_headline.nil? && @long_headline.to_s.length > 90
|
|
214
|
+
invalid_properties.push('invalid value for "long_headline", the character length must be smaller than or equal to 90.')
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
if !@long_headline.nil? && @long_headline.to_s.length < 1
|
|
218
|
+
invalid_properties.push('invalid value for "long_headline", the character length must be greater than or equal to 1.')
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
if !@business_name.nil? && @business_name.to_s.length > 25
|
|
222
|
+
invalid_properties.push('invalid value for "business_name", the character length must be smaller than or equal to 25.')
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
if !@business_name.nil? && @business_name.to_s.length < 1
|
|
226
|
+
invalid_properties.push('invalid value for "business_name", the character length must be greater than or equal to 1.')
|
|
227
|
+
end
|
|
228
|
+
|
|
186
229
|
if !@description.nil? && @description.to_s.length > 255
|
|
187
230
|
invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.')
|
|
188
231
|
end
|
|
@@ -194,10 +237,50 @@ module Zernio
|
|
|
194
237
|
# @return true if the model is valid
|
|
195
238
|
def valid?
|
|
196
239
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
240
|
+
return false if !@long_headline.nil? && @long_headline.to_s.length > 90
|
|
241
|
+
return false if !@long_headline.nil? && @long_headline.to_s.length < 1
|
|
242
|
+
return false if !@business_name.nil? && @business_name.to_s.length > 25
|
|
243
|
+
return false if !@business_name.nil? && @business_name.to_s.length < 1
|
|
197
244
|
return false if !@description.nil? && @description.to_s.length > 255
|
|
198
245
|
true
|
|
199
246
|
end
|
|
200
247
|
|
|
248
|
+
# Custom attribute writer method with validation
|
|
249
|
+
# @param [Object] long_headline Value to be assigned
|
|
250
|
+
def long_headline=(long_headline)
|
|
251
|
+
if long_headline.nil?
|
|
252
|
+
fail ArgumentError, 'long_headline cannot be nil'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
if long_headline.to_s.length > 90
|
|
256
|
+
fail ArgumentError, 'invalid value for "long_headline", the character length must be smaller than or equal to 90.'
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
if long_headline.to_s.length < 1
|
|
260
|
+
fail ArgumentError, 'invalid value for "long_headline", the character length must be greater than or equal to 1.'
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
@long_headline = long_headline
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Custom attribute writer method with validation
|
|
267
|
+
# @param [Object] business_name Value to be assigned
|
|
268
|
+
def business_name=(business_name)
|
|
269
|
+
if business_name.nil?
|
|
270
|
+
fail ArgumentError, 'business_name cannot be nil'
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
if business_name.to_s.length > 25
|
|
274
|
+
fail ArgumentError, 'invalid value for "business_name", the character length must be smaller than or equal to 25.'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
if business_name.to_s.length < 1
|
|
278
|
+
fail ArgumentError, 'invalid value for "business_name", the character length must be greater than or equal to 1.'
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
@business_name = business_name
|
|
282
|
+
end
|
|
283
|
+
|
|
201
284
|
# Custom attribute writer method with validation
|
|
202
285
|
# @param [Object] description Value to be assigned
|
|
203
286
|
def description=(description)
|
|
@@ -220,6 +303,9 @@ module Zernio
|
|
|
220
303
|
promotion == o.promotion &&
|
|
221
304
|
creative_features == o.creative_features &&
|
|
222
305
|
headline == o.headline &&
|
|
306
|
+
long_headline == o.long_headline &&
|
|
307
|
+
business_name == o.business_name &&
|
|
308
|
+
square_image_url == o.square_image_url &&
|
|
223
309
|
body == o.body &&
|
|
224
310
|
description == o.description &&
|
|
225
311
|
call_to_action == o.call_to_action &&
|
|
@@ -239,7 +325,7 @@ module Zernio
|
|
|
239
325
|
# Calculates hash code according to all attributes.
|
|
240
326
|
# @return [Integer] Hash code
|
|
241
327
|
def hash
|
|
242
|
-
[promotion, creative_features, headline, body, description, call_to_action, link_url, image_url, video_url, video_id, existing_creative_id].hash
|
|
328
|
+
[promotion, creative_features, headline, long_headline, business_name, square_image_url, body, description, call_to_action, link_url, image_url, video_url, video_id, existing_creative_id].hash
|
|
243
329
|
end
|
|
244
330
|
|
|
245
331
|
# Builds the object from hash
|
|
@@ -29,8 +29,14 @@ module Zernio
|
|
|
29
29
|
|
|
30
30
|
attr_accessor :age_max
|
|
31
31
|
|
|
32
|
+
# ISO 3166-1 alpha-2 codes. On Google this is the FULL new country set for the campaign (same contract as `locations`); on LinkedIn it replaces the campaign's geo criteria.
|
|
32
33
|
attr_accessor :countries
|
|
33
34
|
|
|
35
|
+
attr_accessor :locations
|
|
36
|
+
|
|
37
|
+
# Google only. The FULL new language set for the campaign, as Google language codes (ISO 639-1, plus variants such as `zh_CN`). An unknown code returns 400.
|
|
38
|
+
attr_accessor :languages
|
|
39
|
+
|
|
34
40
|
# Interest objects from /v1/ads/interests. Each must include id and name.
|
|
35
41
|
attr_accessor :interests
|
|
36
42
|
|
|
@@ -68,6 +74,8 @@ module Zernio
|
|
|
68
74
|
:'age_min' => :'ageMin',
|
|
69
75
|
:'age_max' => :'ageMax',
|
|
70
76
|
:'countries' => :'countries',
|
|
77
|
+
:'locations' => :'locations',
|
|
78
|
+
:'languages' => :'languages',
|
|
71
79
|
:'interests' => :'interests',
|
|
72
80
|
:'advantage_audience' => :'advantage_audience'
|
|
73
81
|
}
|
|
@@ -92,6 +100,8 @@ module Zernio
|
|
|
92
100
|
:'age_min' => :'Integer',
|
|
93
101
|
:'age_max' => :'Integer',
|
|
94
102
|
:'countries' => :'Array<String>',
|
|
103
|
+
:'locations' => :'UpdateAdRequestTargetingLocations',
|
|
104
|
+
:'languages' => :'Array<String>',
|
|
95
105
|
:'interests' => :'Array<UpdateAdRequestTargetingInterestsInner>',
|
|
96
106
|
:'advantage_audience' => :'Integer'
|
|
97
107
|
}
|
|
@@ -151,6 +161,16 @@ module Zernio
|
|
|
151
161
|
end
|
|
152
162
|
end
|
|
153
163
|
|
|
164
|
+
if attributes.key?(:'locations')
|
|
165
|
+
self.locations = attributes[:'locations']
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if attributes.key?(:'languages')
|
|
169
|
+
if (value = attributes[:'languages']).is_a?(Array)
|
|
170
|
+
self.languages = value
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
154
174
|
if attributes.key?(:'interests')
|
|
155
175
|
if (value = attributes[:'interests']).is_a?(Array)
|
|
156
176
|
self.interests = value
|
|
@@ -256,6 +276,8 @@ module Zernio
|
|
|
256
276
|
age_min == o.age_min &&
|
|
257
277
|
age_max == o.age_max &&
|
|
258
278
|
countries == o.countries &&
|
|
279
|
+
locations == o.locations &&
|
|
280
|
+
languages == o.languages &&
|
|
259
281
|
interests == o.interests &&
|
|
260
282
|
advantage_audience == o.advantage_audience
|
|
261
283
|
end
|
|
@@ -269,7 +291,7 @@ module Zernio
|
|
|
269
291
|
# Calculates hash code according to all attributes.
|
|
270
292
|
# @return [Integer] Hash code
|
|
271
293
|
def hash
|
|
272
|
-
[keywords, negative_keywords, devices, age_min, age_max, countries, interests, advantage_audience].hash
|
|
294
|
+
[keywords, negative_keywords, devices, age_min, age_max, countries, locations, languages, interests, advantage_audience].hash
|
|
273
295
|
end
|
|
274
296
|
|
|
275
297
|
# Builds the object from hash
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Zernio API
|
|
3
|
+
|
|
4
|
+
#API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema).
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.4
|
|
7
|
+
Contact: support@zernio.com
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.19.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Zernio
|
|
17
|
+
# Google and LinkedIn. The FULL new location set for the campaign. Bare country-code array, or an object with countries/regions/cities/zips/metros key lists (`key` from GET /v1/ads/targeting/search?dimension=geo). Equivalent to the top-level geo fields; sending both returns 400. Empty returns 400, `customLocations` returns 422.
|
|
18
|
+
module UpdateAdRequestTargetingLocations
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
21
|
+
def openapi_one_of
|
|
22
|
+
[
|
|
23
|
+
:'Array<String>',
|
|
24
|
+
:'UpdateCampaignTargetingRequestTargetingLocationsOneOf'
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the object
|
|
29
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
30
|
+
# @return [Object] Returns the model or the data itself
|
|
31
|
+
def build(data)
|
|
32
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
33
|
+
# Note:
|
|
34
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
35
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
36
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
37
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
38
|
+
# - TODO: logging when debugging is set.
|
|
39
|
+
openapi_one_of.each do |klass|
|
|
40
|
+
begin
|
|
41
|
+
next if klass == :AnyType # "nullable: true"
|
|
42
|
+
return find_and_cast_into_type(klass, data)
|
|
43
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
53
|
+
|
|
54
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
55
|
+
def find_and_cast_into_type(klass, data)
|
|
56
|
+
return if data.nil?
|
|
57
|
+
|
|
58
|
+
case klass.to_s
|
|
59
|
+
when 'Boolean'
|
|
60
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
61
|
+
when 'Float'
|
|
62
|
+
return data if data.instance_of?(Float)
|
|
63
|
+
when 'Integer'
|
|
64
|
+
return data if data.instance_of?(Integer)
|
|
65
|
+
when 'Time'
|
|
66
|
+
return Time.parse(data)
|
|
67
|
+
when 'Date'
|
|
68
|
+
return Date.iso8601(data)
|
|
69
|
+
when 'String'
|
|
70
|
+
return data if data.instance_of?(String)
|
|
71
|
+
when 'Object' # "type: object"
|
|
72
|
+
return data if data.instance_of?(Hash)
|
|
73
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
74
|
+
if data.instance_of?(Array)
|
|
75
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
76
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
77
|
+
end
|
|
78
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
79
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
80
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
81
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
82
|
+
end
|
|
83
|
+
else # model
|
|
84
|
+
const = Zernio.const_get(klass)
|
|
85
|
+
if const
|
|
86
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
|
87
|
+
model = const.build(data)
|
|
88
|
+
return model if model
|
|
89
|
+
else
|
|
90
|
+
# raise if data contains keys that are not known to the model
|
|
91
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
92
|
+
model = const.build_from_hash(data)
|
|
93
|
+
return model if model
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
raise # if no match by now, raise
|
|
99
|
+
rescue
|
|
100
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
data/lib/zernio-sdk/version.rb
CHANGED
data/lib/zernio-sdk.rb
CHANGED
|
@@ -936,6 +936,8 @@ require 'zernio-sdk/models/google_pmax_asset_group'
|
|
|
936
936
|
require 'zernio-sdk/models/google_pmax_asset_group_assets_inner'
|
|
937
937
|
require 'zernio-sdk/models/google_pmax_asset_group_input'
|
|
938
938
|
require 'zernio-sdk/models/google_pmax_asset_group_input_images'
|
|
939
|
+
require 'zernio-sdk/models/google_pmax_asset_group_update'
|
|
940
|
+
require 'zernio-sdk/models/google_pmax_asset_group_update_images'
|
|
939
941
|
require 'zernio-sdk/models/google_rsa_description'
|
|
940
942
|
require 'zernio-sdk/models/google_rsa_headline'
|
|
941
943
|
require 'zernio-sdk/models/google_sitelink'
|
|
@@ -1671,6 +1673,7 @@ require 'zernio-sdk/models/update_ad_request_targeting_devices_inner_one_of'
|
|
|
1671
1673
|
require 'zernio-sdk/models/update_ad_request_targeting_interests_inner'
|
|
1672
1674
|
require 'zernio-sdk/models/update_ad_request_targeting_keywords_inner'
|
|
1673
1675
|
require 'zernio-sdk/models/update_ad_request_targeting_keywords_inner_one_of'
|
|
1676
|
+
require 'zernio-sdk/models/update_ad_request_targeting_locations'
|
|
1674
1677
|
require 'zernio-sdk/models/update_ad_set200_response'
|
|
1675
1678
|
require 'zernio-sdk/models/update_ad_set_request'
|
|
1676
1679
|
require 'zernio-sdk/models/update_ad_set_request_budget'
|