late-sdk 0.0.900 → 0.0.901
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 +60 -6
- data/docs/AdAccountsApi.md +657 -19
- data/docs/AdCampaignsApi.md +521 -9
- data/docs/AdCreative.md +6 -0
- data/docs/AddAccountCalloutsRequest.md +3 -3
- data/docs/AddAccountSitelinks201Response.md +20 -0
- data/docs/AddAccountSitelinks201ResponseSitelinksInner.md +26 -0
- data/docs/AddAccountSitelinksRequest.md +22 -0
- data/docs/AddAccountStructuredSnippets201Response.md +20 -0
- data/docs/AddAccountStructuredSnippets201ResponseStructuredSnippetsInner.md +22 -0
- data/docs/AddAccountStructuredSnippetsRequest.md +22 -0
- data/docs/AttachAdGroupAssets201Response.md +24 -0
- data/docs/AttachCampaignAssetsRequest.md +4 -4
- data/docs/CreateStandaloneAdRequest.md +4 -4
- data/docs/CreateStandaloneAdRequestAdditionalDescriptionsInner.md +49 -0
- data/docs/CreateStandaloneAdRequestAdditionalHeadlinesInner.md +49 -0
- data/docs/GetAd200Response.md +5 -1
- data/docs/GoogleAssetUpdate.md +26 -0
- data/docs/GoogleRsaDescription.md +20 -0
- data/docs/GoogleRsaHeadline.md +20 -0
- data/docs/{AttachCampaignAssetsRequestSitelinksInner.md → GoogleSitelink.md} +2 -2
- data/docs/{AttachCampaignAssetsRequestStructuredSnippetsInner.md → GoogleStructuredSnippet.md} +2 -2
- data/docs/ListAccountCallouts200Response.md +2 -2
- data/docs/ListAccountCallouts200ResponseCalloutsInner.md +3 -3
- data/docs/ListAccountSitelinks200Response.md +24 -0
- data/docs/ListAccountSitelinks200ResponseSitelinksInner.md +32 -0
- data/docs/ListAccountStructuredSnippets200Response.md +24 -0
- data/docs/ListAccountStructuredSnippets200ResponseStructuredSnippetsInner.md +28 -0
- data/docs/ListAdGroupAssets200Response.md +28 -0
- data/docs/ListAdGroupAssets200ResponseCalloutsInner.md +22 -0
- data/docs/ListAdGroupAssets200ResponseSitelinksInner.md +28 -0
- data/docs/ListAdGroupAssets200ResponseStructuredSnippetsInner.md +24 -0
- data/docs/ListCampaignAssets200Response.md +28 -0
- data/docs/ListCampaignAssets200ResponseCalloutsInner.md +22 -0
- data/docs/ListCampaignAssets200ResponseSitelinksInner.md +28 -0
- data/docs/ListCampaignAssets200ResponseStructuredSnippetsInner.md +24 -0
- data/docs/RemoveAccountCalloutRequest.md +3 -3
- data/docs/RemoveAdGroupAssetsRequest.md +24 -0
- data/docs/RemoveCampaignAssets200Response.md +18 -0
- data/docs/RemoveCampaignAssetsRequest.md +24 -0
- data/docs/UpdateAccountCallouts200Response.md +20 -0
- data/docs/UpdateAccountCalloutsRequest.md +22 -0
- data/docs/UpdateAccountCalloutsRequestUpdatesInner.md +20 -0
- data/docs/UpdateAccountCalloutsRequestUpdatesInnerCalloutAsset.md +18 -0
- data/docs/UpdateAccountSitelinksRequest.md +22 -0
- data/docs/UpdateAccountSitelinksRequestUpdatesInner.md +22 -0
- data/docs/UpdateAccountSitelinksRequestUpdatesInnerSitelinkAsset.md +24 -0
- data/docs/UpdateAccountStructuredSnippetsRequest.md +22 -0
- data/docs/UpdateAccountStructuredSnippetsRequestUpdatesInner.md +20 -0
- data/docs/UpdateAdRequest.md +6 -0
- data/docs/UpdateCampaignAssets200Response.md +18 -0
- data/docs/UpdateCampaignAssetsRequest.md +22 -0
- data/lib/zernio-sdk/api/ad_accounts_api.rb +656 -16
- data/lib/zernio-sdk/api/ad_campaigns_api.rb +586 -10
- data/lib/zernio-sdk/models/ad_creative.rb +112 -1
- data/lib/zernio-sdk/models/add_account_callouts_request.rb +34 -3
- data/lib/zernio-sdk/models/add_account_sitelinks201_response.rb +158 -0
- data/lib/zernio-sdk/models/add_account_sitelinks201_response_sitelinks_inner.rb +267 -0
- data/lib/zernio-sdk/models/add_account_sitelinks_request.rb +253 -0
- data/lib/zernio-sdk/models/add_account_structured_snippets201_response.rb +158 -0
- data/lib/zernio-sdk/models/add_account_structured_snippets201_response_structured_snippets_inner.rb +229 -0
- data/lib/zernio-sdk/models/add_account_structured_snippets_request.rb +253 -0
- data/lib/zernio-sdk/models/attach_ad_group_assets201_response.rb +180 -0
- data/lib/zernio-sdk/models/attach_campaign_assets_request.rb +37 -5
- data/lib/zernio-sdk/models/create_standalone_ad_request.rb +4 -4
- data/lib/zernio-sdk/models/create_standalone_ad_request_additional_descriptions_inner.rb +104 -0
- data/lib/zernio-sdk/models/create_standalone_ad_request_additional_headlines_inner.rb +104 -0
- data/lib/zernio-sdk/models/get_ad200_response.rb +25 -4
- data/lib/zernio-sdk/models/google_asset_update.rb +234 -0
- data/lib/zernio-sdk/models/google_rsa_description.rb +226 -0
- data/lib/zernio-sdk/models/google_rsa_headline.rb +226 -0
- data/lib/zernio-sdk/models/{attach_campaign_assets_request_sitelinks_inner.rb → google_sitelink.rb} +3 -3
- data/lib/zernio-sdk/models/{attach_campaign_assets_request_structured_snippets_inner.rb → google_structured_snippet.rb} +3 -3
- data/lib/zernio-sdk/models/list_account_callouts200_response.rb +2 -2
- data/lib/zernio-sdk/models/list_account_callouts200_response_callouts_inner.rb +13 -14
- data/lib/zernio-sdk/models/list_account_sitelinks200_response.rb +179 -0
- data/lib/zernio-sdk/models/list_account_sitelinks200_response_sitelinks_inner.rb +210 -0
- data/lib/zernio-sdk/models/list_account_structured_snippets200_response.rb +179 -0
- data/lib/zernio-sdk/models/list_account_structured_snippets200_response_structured_snippets_inner.rb +194 -0
- data/lib/zernio-sdk/models/list_ad_group_assets200_response.rb +201 -0
- data/lib/zernio-sdk/models/list_ad_group_assets200_response_callouts_inner.rb +165 -0
- data/lib/zernio-sdk/models/list_ad_group_assets200_response_sitelinks_inner.rb +192 -0
- data/lib/zernio-sdk/models/list_ad_group_assets200_response_structured_snippets_inner.rb +176 -0
- data/lib/zernio-sdk/models/list_campaign_assets200_response.rb +201 -0
- data/lib/zernio-sdk/models/list_campaign_assets200_response_callouts_inner.rb +165 -0
- data/lib/zernio-sdk/models/list_campaign_assets200_response_sitelinks_inner.rb +192 -0
- data/lib/zernio-sdk/models/list_campaign_assets200_response_structured_snippets_inner.rb +176 -0
- data/lib/zernio-sdk/models/remove_account_callout_request.rb +45 -3
- data/lib/zernio-sdk/models/remove_ad_group_assets_request.rb +281 -0
- data/lib/zernio-sdk/models/remove_campaign_assets200_response.rb +147 -0
- data/lib/zernio-sdk/models/remove_campaign_assets_request.rb +281 -0
- data/lib/zernio-sdk/models/update_account_callouts200_response.rb +156 -0
- data/lib/zernio-sdk/models/update_account_callouts_request.rb +253 -0
- data/lib/zernio-sdk/models/update_account_callouts_request_updates_inner.rb +186 -0
- data/lib/zernio-sdk/models/update_account_callouts_request_updates_inner_callout_asset.rb +182 -0
- data/lib/zernio-sdk/models/update_account_sitelinks_request.rb +253 -0
- data/lib/zernio-sdk/models/update_account_sitelinks_request_updates_inner.rb +216 -0
- data/lib/zernio-sdk/models/update_account_sitelinks_request_updates_inner_sitelink_asset.rb +241 -0
- data/lib/zernio-sdk/models/update_account_structured_snippets_request.rb +253 -0
- data/lib/zernio-sdk/models/update_account_structured_snippets_request_updates_inner.rb +186 -0
- data/lib/zernio-sdk/models/update_ad_request.rb +112 -1
- data/lib/zernio-sdk/models/update_campaign_assets200_response.rb +147 -0
- data/lib/zernio-sdk/models/update_campaign_assets_request.rb +253 -0
- data/lib/zernio-sdk/version.rb +1 -1
- data/lib/zernio-sdk.rb +40 -2
- data/openapi.yaml +2010 -320
- data/spec/api/ad_accounts_api_spec.rb +118 -8
- data/spec/api/ad_campaigns_api_spec.rb +98 -5
- data/spec/models/ad_creative_spec.rb +18 -0
- data/spec/models/add_account_sitelinks201_response_sitelinks_inner_spec.rb +60 -0
- data/spec/models/add_account_sitelinks201_response_spec.rb +42 -0
- data/spec/models/add_account_sitelinks_request_spec.rb +48 -0
- data/spec/models/add_account_structured_snippets201_response_spec.rb +42 -0
- data/spec/models/add_account_structured_snippets201_response_structured_snippets_inner_spec.rb +52 -0
- data/spec/models/add_account_structured_snippets_request_spec.rb +48 -0
- data/spec/models/attach_ad_group_assets201_response_spec.rb +54 -0
- data/spec/models/create_standalone_ad_request_additional_descriptions_inner_spec.rb +32 -0
- data/spec/models/create_standalone_ad_request_additional_headlines_inner_spec.rb +32 -0
- data/spec/models/get_ad200_response_spec.rb +12 -0
- data/spec/models/google_asset_update_spec.rb +60 -0
- data/spec/models/google_rsa_description_spec.rb +46 -0
- data/spec/models/google_rsa_headline_spec.rb +46 -0
- data/spec/models/{attach_campaign_assets_request_sitelinks_inner_spec.rb → google_sitelink_spec.rb} +6 -6
- data/spec/models/{attach_campaign_assets_request_structured_snippets_inner_spec.rb → google_structured_snippet_spec.rb} +6 -6
- data/spec/models/list_account_callouts200_response_callouts_inner_spec.rb +2 -2
- data/spec/models/list_account_sitelinks200_response_sitelinks_inner_spec.rb +78 -0
- data/spec/models/list_account_sitelinks200_response_spec.rb +54 -0
- data/spec/models/list_account_structured_snippets200_response_spec.rb +54 -0
- data/spec/models/list_account_structured_snippets200_response_structured_snippets_inner_spec.rb +66 -0
- data/spec/models/list_ad_group_assets200_response_callouts_inner_spec.rb +48 -0
- data/spec/models/list_ad_group_assets200_response_sitelinks_inner_spec.rb +66 -0
- data/spec/models/list_ad_group_assets200_response_spec.rb +66 -0
- data/spec/models/list_ad_group_assets200_response_structured_snippets_inner_spec.rb +54 -0
- data/spec/models/list_campaign_assets200_response_callouts_inner_spec.rb +48 -0
- data/spec/models/list_campaign_assets200_response_sitelinks_inner_spec.rb +66 -0
- data/spec/models/list_campaign_assets200_response_spec.rb +66 -0
- data/spec/models/list_campaign_assets200_response_structured_snippets_inner_spec.rb +54 -0
- data/spec/models/remove_ad_group_assets_request_spec.rb +54 -0
- data/spec/models/remove_campaign_assets200_response_spec.rb +36 -0
- data/spec/models/remove_campaign_assets_request_spec.rb +54 -0
- data/spec/models/update_account_callouts200_response_spec.rb +42 -0
- data/spec/models/update_account_callouts_request_spec.rb +48 -0
- data/spec/models/update_account_callouts_request_updates_inner_callout_asset_spec.rb +36 -0
- data/spec/models/update_account_callouts_request_updates_inner_spec.rb +42 -0
- data/spec/models/update_account_sitelinks_request_spec.rb +48 -0
- data/spec/models/update_account_sitelinks_request_updates_inner_sitelink_asset_spec.rb +54 -0
- data/spec/models/update_account_sitelinks_request_updates_inner_spec.rb +48 -0
- data/spec/models/update_account_structured_snippets_request_spec.rb +48 -0
- data/spec/models/update_account_structured_snippets_request_updates_inner_spec.rb +42 -0
- data/spec/models/update_ad_request_spec.rb +18 -0
- data/spec/models/update_campaign_assets200_response_spec.rb +36 -0
- data/spec/models/update_campaign_assets_request_spec.rb +48 -0
- data/zernio-sdk-0.0.901.gem +0 -0
- metadata +162 -10
- data/zernio-sdk-0.0.900.gem +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
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
|
+
class AddAccountStructuredSnippetsRequest < ApiModelBase
|
|
18
|
+
# Zernio Google Ads connection id.
|
|
19
|
+
attr_accessor :account_id
|
|
20
|
+
|
|
21
|
+
# Google customer id without dashes. Required when the connection has multiple customers.
|
|
22
|
+
attr_accessor :customer_id
|
|
23
|
+
|
|
24
|
+
attr_accessor :structured_snippets
|
|
25
|
+
|
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
27
|
+
def self.attribute_map
|
|
28
|
+
{
|
|
29
|
+
:'account_id' => :'accountId',
|
|
30
|
+
:'customer_id' => :'customerId',
|
|
31
|
+
:'structured_snippets' => :'structuredSnippets'
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns attribute mapping this model knows about
|
|
36
|
+
def self.acceptable_attribute_map
|
|
37
|
+
attribute_map
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns all the JSON keys this model knows about
|
|
41
|
+
def self.acceptable_attributes
|
|
42
|
+
acceptable_attribute_map.values
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Attribute type mapping.
|
|
46
|
+
def self.openapi_types
|
|
47
|
+
{
|
|
48
|
+
:'account_id' => :'String',
|
|
49
|
+
:'customer_id' => :'String',
|
|
50
|
+
:'structured_snippets' => :'Array<GoogleStructuredSnippet>'
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# List of attributes with nullable: true
|
|
55
|
+
def self.openapi_nullable
|
|
56
|
+
Set.new([
|
|
57
|
+
])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Initializes the object
|
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
62
|
+
def initialize(attributes = {})
|
|
63
|
+
if (!attributes.is_a?(Hash))
|
|
64
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::AddAccountStructuredSnippetsRequest` initialize method"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
68
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
69
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
70
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
71
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::AddAccountStructuredSnippetsRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
72
|
+
end
|
|
73
|
+
h[k.to_sym] = v
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if attributes.key?(:'account_id')
|
|
77
|
+
self.account_id = attributes[:'account_id']
|
|
78
|
+
else
|
|
79
|
+
self.account_id = nil
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:'customer_id')
|
|
83
|
+
self.customer_id = attributes[:'customer_id']
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if attributes.key?(:'structured_snippets')
|
|
87
|
+
if (value = attributes[:'structured_snippets']).is_a?(Array)
|
|
88
|
+
self.structured_snippets = value
|
|
89
|
+
end
|
|
90
|
+
else
|
|
91
|
+
self.structured_snippets = nil
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
96
|
+
# @return Array for valid properties with the reasons
|
|
97
|
+
def list_invalid_properties
|
|
98
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
99
|
+
invalid_properties = Array.new
|
|
100
|
+
if @account_id.nil?
|
|
101
|
+
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
pattern = Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
105
|
+
if @account_id !~ pattern
|
|
106
|
+
invalid_properties.push("invalid value for \"account_id\", must conform to the pattern #{pattern}.")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
pattern = Regexp.new(/^\d+$/)
|
|
110
|
+
if !@customer_id.nil? && @customer_id !~ pattern
|
|
111
|
+
invalid_properties.push("invalid value for \"customer_id\", must conform to the pattern #{pattern}.")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
if @structured_snippets.nil?
|
|
115
|
+
invalid_properties.push('invalid value for "structured_snippets", structured_snippets cannot be nil.')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if @structured_snippets.length > 20
|
|
119
|
+
invalid_properties.push('invalid value for "structured_snippets", number of items must be less than or equal to 20.')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if @structured_snippets.length < 1
|
|
123
|
+
invalid_properties.push('invalid value for "structured_snippets", number of items must be greater than or equal to 1.')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
invalid_properties
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Check to see if the all the properties in the model are valid
|
|
130
|
+
# @return true if the model is valid
|
|
131
|
+
def valid?
|
|
132
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
133
|
+
return false if @account_id.nil?
|
|
134
|
+
return false if @account_id !~ Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
135
|
+
return false if !@customer_id.nil? && @customer_id !~ Regexp.new(/^\d+$/)
|
|
136
|
+
return false if @structured_snippets.nil?
|
|
137
|
+
return false if @structured_snippets.length > 20
|
|
138
|
+
return false if @structured_snippets.length < 1
|
|
139
|
+
true
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Custom attribute writer method with validation
|
|
143
|
+
# @param [Object] account_id Value to be assigned
|
|
144
|
+
def account_id=(account_id)
|
|
145
|
+
if account_id.nil?
|
|
146
|
+
fail ArgumentError, 'account_id cannot be nil'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
pattern = Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
150
|
+
if account_id !~ pattern
|
|
151
|
+
fail ArgumentError, "invalid value for \"account_id\", must conform to the pattern #{pattern}."
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
@account_id = account_id
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Custom attribute writer method with validation
|
|
158
|
+
# @param [Object] customer_id Value to be assigned
|
|
159
|
+
def customer_id=(customer_id)
|
|
160
|
+
if customer_id.nil?
|
|
161
|
+
fail ArgumentError, 'customer_id cannot be nil'
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
pattern = Regexp.new(/^\d+$/)
|
|
165
|
+
if customer_id !~ pattern
|
|
166
|
+
fail ArgumentError, "invalid value for \"customer_id\", must conform to the pattern #{pattern}."
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
@customer_id = customer_id
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Custom attribute writer method with validation
|
|
173
|
+
# @param [Object] structured_snippets Value to be assigned
|
|
174
|
+
def structured_snippets=(structured_snippets)
|
|
175
|
+
if structured_snippets.nil?
|
|
176
|
+
fail ArgumentError, 'structured_snippets cannot be nil'
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if structured_snippets.length > 20
|
|
180
|
+
fail ArgumentError, 'invalid value for "structured_snippets", number of items must be less than or equal to 20.'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
if structured_snippets.length < 1
|
|
184
|
+
fail ArgumentError, 'invalid value for "structured_snippets", number of items must be greater than or equal to 1.'
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
@structured_snippets = structured_snippets
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Checks equality by comparing each attribute.
|
|
191
|
+
# @param [Object] Object to be compared
|
|
192
|
+
def ==(o)
|
|
193
|
+
return true if self.equal?(o)
|
|
194
|
+
self.class == o.class &&
|
|
195
|
+
account_id == o.account_id &&
|
|
196
|
+
customer_id == o.customer_id &&
|
|
197
|
+
structured_snippets == o.structured_snippets
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# @see the `==` method
|
|
201
|
+
# @param [Object] Object to be compared
|
|
202
|
+
def eql?(o)
|
|
203
|
+
self == o
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Calculates hash code according to all attributes.
|
|
207
|
+
# @return [Integer] Hash code
|
|
208
|
+
def hash
|
|
209
|
+
[account_id, customer_id, structured_snippets].hash
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Builds the object from hash
|
|
213
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
214
|
+
# @return [Object] Returns the model itself
|
|
215
|
+
def self.build_from_hash(attributes)
|
|
216
|
+
return nil unless attributes.is_a?(Hash)
|
|
217
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
218
|
+
transformed_hash = {}
|
|
219
|
+
openapi_types.each_pair do |key, type|
|
|
220
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
221
|
+
transformed_hash["#{key}"] = nil
|
|
222
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
223
|
+
# check to ensure the input is an array given that the attribute
|
|
224
|
+
# is documented as an array but the input is not
|
|
225
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
226
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
227
|
+
end
|
|
228
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
229
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
new(transformed_hash)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Returns the object in the form of hash
|
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
|
237
|
+
def to_hash
|
|
238
|
+
hash = {}
|
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
240
|
+
value = self.send(attr)
|
|
241
|
+
if value.nil?
|
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
hash[param] = _to_hash(value)
|
|
247
|
+
end
|
|
248
|
+
hash
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
end
|
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
class AttachAdGroupAssets201Response < ApiModelBase
|
|
18
|
+
attr_accessor :ad_group_id
|
|
19
|
+
|
|
20
|
+
attr_accessor :sitelink_asset_resource_names
|
|
21
|
+
|
|
22
|
+
attr_accessor :callout_asset_resource_names
|
|
23
|
+
|
|
24
|
+
attr_accessor :structured_snippet_asset_resource_names
|
|
25
|
+
|
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
27
|
+
def self.attribute_map
|
|
28
|
+
{
|
|
29
|
+
:'ad_group_id' => :'adGroupId',
|
|
30
|
+
:'sitelink_asset_resource_names' => :'sitelinkAssetResourceNames',
|
|
31
|
+
:'callout_asset_resource_names' => :'calloutAssetResourceNames',
|
|
32
|
+
:'structured_snippet_asset_resource_names' => :'structuredSnippetAssetResourceNames'
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns attribute mapping this model knows about
|
|
37
|
+
def self.acceptable_attribute_map
|
|
38
|
+
attribute_map
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns all the JSON keys this model knows about
|
|
42
|
+
def self.acceptable_attributes
|
|
43
|
+
acceptable_attribute_map.values
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Attribute type mapping.
|
|
47
|
+
def self.openapi_types
|
|
48
|
+
{
|
|
49
|
+
:'ad_group_id' => :'String',
|
|
50
|
+
:'sitelink_asset_resource_names' => :'Array<String>',
|
|
51
|
+
:'callout_asset_resource_names' => :'Array<String>',
|
|
52
|
+
:'structured_snippet_asset_resource_names' => :'Array<String>'
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# List of attributes with nullable: true
|
|
57
|
+
def self.openapi_nullable
|
|
58
|
+
Set.new([
|
|
59
|
+
])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Initializes the object
|
|
63
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
64
|
+
def initialize(attributes = {})
|
|
65
|
+
if (!attributes.is_a?(Hash))
|
|
66
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::AttachAdGroupAssets201Response` initialize method"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
70
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
72
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
73
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::AttachAdGroupAssets201Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
74
|
+
end
|
|
75
|
+
h[k.to_sym] = v
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:'ad_group_id')
|
|
79
|
+
self.ad_group_id = attributes[:'ad_group_id']
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:'sitelink_asset_resource_names')
|
|
83
|
+
if (value = attributes[:'sitelink_asset_resource_names']).is_a?(Array)
|
|
84
|
+
self.sitelink_asset_resource_names = value
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:'callout_asset_resource_names')
|
|
89
|
+
if (value = attributes[:'callout_asset_resource_names']).is_a?(Array)
|
|
90
|
+
self.callout_asset_resource_names = value
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if attributes.key?(:'structured_snippet_asset_resource_names')
|
|
95
|
+
if (value = attributes[:'structured_snippet_asset_resource_names']).is_a?(Array)
|
|
96
|
+
self.structured_snippet_asset_resource_names = value
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
102
|
+
# @return Array for valid properties with the reasons
|
|
103
|
+
def list_invalid_properties
|
|
104
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
105
|
+
invalid_properties = Array.new
|
|
106
|
+
invalid_properties
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Check to see if the all the properties in the model are valid
|
|
110
|
+
# @return true if the model is valid
|
|
111
|
+
def valid?
|
|
112
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
113
|
+
true
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Checks equality by comparing each attribute.
|
|
117
|
+
# @param [Object] Object to be compared
|
|
118
|
+
def ==(o)
|
|
119
|
+
return true if self.equal?(o)
|
|
120
|
+
self.class == o.class &&
|
|
121
|
+
ad_group_id == o.ad_group_id &&
|
|
122
|
+
sitelink_asset_resource_names == o.sitelink_asset_resource_names &&
|
|
123
|
+
callout_asset_resource_names == o.callout_asset_resource_names &&
|
|
124
|
+
structured_snippet_asset_resource_names == o.structured_snippet_asset_resource_names
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# @see the `==` method
|
|
128
|
+
# @param [Object] Object to be compared
|
|
129
|
+
def eql?(o)
|
|
130
|
+
self == o
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Calculates hash code according to all attributes.
|
|
134
|
+
# @return [Integer] Hash code
|
|
135
|
+
def hash
|
|
136
|
+
[ad_group_id, sitelink_asset_resource_names, callout_asset_resource_names, structured_snippet_asset_resource_names].hash
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Builds the object from hash
|
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
141
|
+
# @return [Object] Returns the model itself
|
|
142
|
+
def self.build_from_hash(attributes)
|
|
143
|
+
return nil unless attributes.is_a?(Hash)
|
|
144
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
145
|
+
transformed_hash = {}
|
|
146
|
+
openapi_types.each_pair do |key, type|
|
|
147
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
148
|
+
transformed_hash["#{key}"] = nil
|
|
149
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
150
|
+
# check to ensure the input is an array given that the attribute
|
|
151
|
+
# is documented as an array but the input is not
|
|
152
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
153
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
154
|
+
end
|
|
155
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
156
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
new(transformed_hash)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Returns the object in the form of hash
|
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
|
164
|
+
def to_hash
|
|
165
|
+
hash = {}
|
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
167
|
+
value = self.send(attr)
|
|
168
|
+
if value.nil?
|
|
169
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
170
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
hash[param] = _to_hash(value)
|
|
174
|
+
end
|
|
175
|
+
hash
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
@@ -14,14 +14,14 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module Zernio
|
|
17
|
+
# Provide at least one of sitelinks, callouts or structuredSnippets. Sitelink description1 and description2 must be supplied together.
|
|
17
18
|
class AttachCampaignAssetsRequest < ApiModelBase
|
|
18
|
-
# Zernio Google Ads
|
|
19
|
+
# Zernio Google Ads connection id.
|
|
19
20
|
attr_accessor :account_id
|
|
20
21
|
|
|
21
|
-
#
|
|
22
|
+
# Google customer id without dashes. Required when the connection has multiple customers.
|
|
22
23
|
attr_accessor :customer_id
|
|
23
24
|
|
|
24
|
-
# See POST /v1/ads/create sitelinks, same shape.
|
|
25
25
|
attr_accessor :sitelinks
|
|
26
26
|
|
|
27
27
|
attr_accessor :callouts
|
|
@@ -54,9 +54,9 @@ module Zernio
|
|
|
54
54
|
{
|
|
55
55
|
:'account_id' => :'String',
|
|
56
56
|
:'customer_id' => :'String',
|
|
57
|
-
:'sitelinks' => :'Array<
|
|
57
|
+
:'sitelinks' => :'Array<GoogleSitelink>',
|
|
58
58
|
:'callouts' => :'Array<String>',
|
|
59
|
-
:'structured_snippets' => :'Array<
|
|
59
|
+
:'structured_snippets' => :'Array<GoogleStructuredSnippet>'
|
|
60
60
|
}
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -120,6 +120,16 @@ module Zernio
|
|
|
120
120
|
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
pattern = Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
124
|
+
if @account_id !~ pattern
|
|
125
|
+
invalid_properties.push("invalid value for \"account_id\", must conform to the pattern #{pattern}.")
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
pattern = Regexp.new(/^\d+$/)
|
|
129
|
+
if !@customer_id.nil? && @customer_id !~ pattern
|
|
130
|
+
invalid_properties.push("invalid value for \"customer_id\", must conform to the pattern #{pattern}.")
|
|
131
|
+
end
|
|
132
|
+
|
|
123
133
|
if !@sitelinks.nil? && @sitelinks.length > 20
|
|
124
134
|
invalid_properties.push('invalid value for "sitelinks", number of items must be less than or equal to 20.')
|
|
125
135
|
end
|
|
@@ -152,6 +162,8 @@ module Zernio
|
|
|
152
162
|
def valid?
|
|
153
163
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
154
164
|
return false if @account_id.nil?
|
|
165
|
+
return false if @account_id !~ Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
166
|
+
return false if !@customer_id.nil? && @customer_id !~ Regexp.new(/^\d+$/)
|
|
155
167
|
return false if !@sitelinks.nil? && @sitelinks.length > 20
|
|
156
168
|
return false if !@sitelinks.nil? && @sitelinks.length < 2
|
|
157
169
|
return false if !@callouts.nil? && @callouts.length > 20
|
|
@@ -168,9 +180,29 @@ module Zernio
|
|
|
168
180
|
fail ArgumentError, 'account_id cannot be nil'
|
|
169
181
|
end
|
|
170
182
|
|
|
183
|
+
pattern = Regexp.new(/^[a-fA-F0-9]{24}$/)
|
|
184
|
+
if account_id !~ pattern
|
|
185
|
+
fail ArgumentError, "invalid value for \"account_id\", must conform to the pattern #{pattern}."
|
|
186
|
+
end
|
|
187
|
+
|
|
171
188
|
@account_id = account_id
|
|
172
189
|
end
|
|
173
190
|
|
|
191
|
+
# Custom attribute writer method with validation
|
|
192
|
+
# @param [Object] customer_id Value to be assigned
|
|
193
|
+
def customer_id=(customer_id)
|
|
194
|
+
if customer_id.nil?
|
|
195
|
+
fail ArgumentError, 'customer_id cannot be nil'
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
pattern = Regexp.new(/^\d+$/)
|
|
199
|
+
if customer_id !~ pattern
|
|
200
|
+
fail ArgumentError, "invalid value for \"customer_id\", must conform to the pattern #{pattern}."
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
@customer_id = customer_id
|
|
204
|
+
end
|
|
205
|
+
|
|
174
206
|
# Custom attribute writer method with validation
|
|
175
207
|
# @param [Object] sitelinks Value to be assigned
|
|
176
208
|
def sitelinks=(sitelinks)
|
|
@@ -237,10 +237,10 @@ module Zernio
|
|
|
237
237
|
# Google Search only; other platforms return 400. Campaign-level negative keywords (campaign_criterion.negative), created alongside the ad group. Editable later via PUT /v1/ads/campaigns/{campaignId}/negative-keywords.
|
|
238
238
|
attr_accessor :campaign_negative_keywords
|
|
239
239
|
|
|
240
|
-
# Google Search RSA only. Extra headlines.
|
|
240
|
+
# Google Search RSA only. Extra text assets as strings or objects with text and optional pinnedField. Existing string input remains supported. The effective create lists, including primary text and deduplication, must contain 3-15 headlines and 2-4 descriptions; excess entries return 400.
|
|
241
241
|
attr_accessor :additional_headlines
|
|
242
242
|
|
|
243
|
-
# Google Search RSA only. Extra descriptions.
|
|
243
|
+
# Google Search RSA only. Extra text assets as strings or objects with text and optional pinnedField. Existing string input remains supported. The effective create lists, including primary text and deduplication, must contain 3-15 headlines and 2-4 descriptions; excess entries return 400.
|
|
244
244
|
attr_accessor :additional_descriptions
|
|
245
245
|
|
|
246
246
|
# Google Search only. Sitelink assets to create and attach at the campaign level. Each entry becomes an Asset (with sitelink_asset + Asset.final_urls) plus a CampaignAsset link (field_type SITELINK). Approval is async: Google reviews assets after creation; poll asset.policy_summary later to read the verdict. Google requires at least two sitelinks to surface them on an ad; four or more is Google's own recommendation for maximum visibility. The response's creative.sitelinks[] echoes each input plus its Google resourceName.
|
|
@@ -531,8 +531,8 @@ module Zernio
|
|
|
531
531
|
:'keywords' => :'Array<KeywordEntry>',
|
|
532
532
|
:'negative_keywords' => :'Array<KeywordEntry>',
|
|
533
533
|
:'campaign_negative_keywords' => :'Array<KeywordEntry>',
|
|
534
|
-
:'additional_headlines' => :'Array<
|
|
535
|
-
:'additional_descriptions' => :'Array<
|
|
534
|
+
:'additional_headlines' => :'Array<CreateStandaloneAdRequestAdditionalHeadlinesInner>',
|
|
535
|
+
:'additional_descriptions' => :'Array<CreateStandaloneAdRequestAdditionalDescriptionsInner>',
|
|
536
536
|
:'sitelinks' => :'Array<CreateStandaloneAdRequestSitelinksInner>',
|
|
537
537
|
:'callouts' => :'Array<String>',
|
|
538
538
|
:'structured_snippets' => :'Array<CreateStandaloneAdRequestStructuredSnippetsInner>',
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
module CreateStandaloneAdRequestAdditionalDescriptionsInner
|
|
18
|
+
class << self
|
|
19
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
20
|
+
def openapi_one_of
|
|
21
|
+
[
|
|
22
|
+
:'GoogleRsaDescription',
|
|
23
|
+
:'String'
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Builds the object
|
|
28
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
29
|
+
# @return [Object] Returns the model or the data itself
|
|
30
|
+
def build(data)
|
|
31
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
32
|
+
# Note:
|
|
33
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
34
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
+
# - TODO: logging when debugging is set.
|
|
38
|
+
openapi_one_of.each do |klass|
|
|
39
|
+
begin
|
|
40
|
+
next if klass == :AnyType # "nullable: true"
|
|
41
|
+
return find_and_cast_into_type(klass, data)
|
|
42
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
52
|
+
|
|
53
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
54
|
+
def find_and_cast_into_type(klass, data)
|
|
55
|
+
return if data.nil?
|
|
56
|
+
|
|
57
|
+
case klass.to_s
|
|
58
|
+
when 'Boolean'
|
|
59
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
60
|
+
when 'Float'
|
|
61
|
+
return data if data.instance_of?(Float)
|
|
62
|
+
when 'Integer'
|
|
63
|
+
return data if data.instance_of?(Integer)
|
|
64
|
+
when 'Time'
|
|
65
|
+
return Time.parse(data)
|
|
66
|
+
when 'Date'
|
|
67
|
+
return Date.iso8601(data)
|
|
68
|
+
when 'String'
|
|
69
|
+
return data if data.instance_of?(String)
|
|
70
|
+
when 'Object' # "type: object"
|
|
71
|
+
return data if data.instance_of?(Hash)
|
|
72
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
73
|
+
if data.instance_of?(Array)
|
|
74
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
75
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
76
|
+
end
|
|
77
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
78
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
79
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
80
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
81
|
+
end
|
|
82
|
+
else # model
|
|
83
|
+
const = Zernio.const_get(klass)
|
|
84
|
+
if const
|
|
85
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
|
86
|
+
model = const.build(data)
|
|
87
|
+
return model if model
|
|
88
|
+
else
|
|
89
|
+
# raise if data contains keys that are not known to the model
|
|
90
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
91
|
+
model = const.build_from_hash(data)
|
|
92
|
+
return model if model
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
raise # if no match by now, raise
|
|
98
|
+
rescue
|
|
99
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|