late-sdk 0.0.770 → 0.0.772

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -0
  3. data/docs/AdCampaignsApi.md +72 -0
  4. data/docs/AnalyticsApi.md +2 -2
  5. data/docs/AttachCampaignAssets201Response.md +24 -0
  6. data/docs/AttachCampaignAssetsRequest.md +24 -0
  7. data/docs/AttachCampaignAssetsRequestSitelinksInner.md +24 -0
  8. data/docs/AttachCampaignAssetsRequestStructuredSnippetsInner.md +20 -0
  9. data/docs/CreateInboxConversationRequest.md +3 -1
  10. data/docs/CreateInboxConversationRequestTemplateButtonParamsInner.md +22 -0
  11. data/docs/CreateStandaloneAdRequest.md +4 -0
  12. data/docs/CreateStandaloneAdRequestStructuredSnippetsInner.md +20 -0
  13. data/docs/MessagesApi.md +1 -1
  14. data/docs/PostAnalytics.md +4 -0
  15. data/docs/TargetingSpec.md +2 -2
  16. data/lib/zernio-sdk/api/ad_campaigns_api.rb +74 -0
  17. data/lib/zernio-sdk/api/analytics_api.rb +3 -3
  18. data/lib/zernio-sdk/api/messages_api.rb +2 -2
  19. data/lib/zernio-sdk/models/ad_tree_campaign_optimization_goal.rb +1 -0
  20. data/lib/zernio-sdk/models/attach_campaign_assets201_response.rb +180 -0
  21. data/lib/zernio-sdk/models/attach_campaign_assets_request.rb +283 -0
  22. data/lib/zernio-sdk/models/attach_campaign_assets_request_sitelinks_inner.rb +282 -0
  23. data/lib/zernio-sdk/models/attach_campaign_assets_request_structured_snippets_inner.rb +234 -0
  24. data/lib/zernio-sdk/models/create_inbox_conversation_request.rb +33 -2
  25. data/lib/zernio-sdk/models/create_inbox_conversation_request_template_button_params_inner.rb +270 -0
  26. data/lib/zernio-sdk/models/create_standalone_ad_request.rb +81 -1
  27. data/lib/zernio-sdk/models/create_standalone_ad_request_structured_snippets_inner.rb +235 -0
  28. data/lib/zernio-sdk/models/post_analytics.rb +21 -1
  29. data/lib/zernio-sdk/models/targeting_spec.rb +2 -0
  30. data/lib/zernio-sdk/version.rb +1 -1
  31. data/lib/zernio-sdk.rb +6 -0
  32. data/openapi.yaml +167 -10
  33. data/spec/api/ad_campaigns_api_spec.rb +13 -0
  34. data/spec/api/analytics_api_spec.rb +1 -1
  35. data/spec/api/messages_api_spec.rb +1 -1
  36. data/spec/models/attach_campaign_assets201_response_spec.rb +54 -0
  37. data/spec/models/attach_campaign_assets_request_sitelinks_inner_spec.rb +54 -0
  38. data/spec/models/attach_campaign_assets_request_spec.rb +54 -0
  39. data/spec/models/attach_campaign_assets_request_structured_snippets_inner_spec.rb +46 -0
  40. data/spec/models/create_inbox_conversation_request_spec.rb +6 -0
  41. data/spec/models/create_inbox_conversation_request_template_button_params_inner_spec.rb +52 -0
  42. data/spec/models/create_standalone_ad_request_spec.rb +12 -0
  43. data/spec/models/create_standalone_ad_request_structured_snippets_inner_spec.rb +46 -0
  44. data/spec/models/post_analytics_spec.rb +12 -0
  45. data/zernio-sdk-0.0.772.gem +0 -0
  46. metadata +26 -2
  47. data/zernio-sdk-0.0.770.gem +0 -0
@@ -0,0 +1,270 @@
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 CreateInboxConversationRequestTemplateButtonParamsInner < ApiModelBase
18
+ # Zero-based position of the button in the approved template's buttons.
19
+ attr_accessor :index
20
+
21
+ # The button kind, which decides how the value is sent: copy_code sends it as the coupon_code payload, flow as the flow token, url as the dynamic suffix appended to the button's base URL.
22
+ attr_accessor :sub_type
23
+
24
+ # The value to send (e.g. the Pix copy-and-paste code for a copy_code button).
25
+ attr_accessor :value
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'index' => :'index',
53
+ :'sub_type' => :'subType',
54
+ :'value' => :'value'
55
+ }
56
+ end
57
+
58
+ # Returns attribute mapping this model knows about
59
+ def self.acceptable_attribute_map
60
+ attribute_map
61
+ end
62
+
63
+ # Returns all the JSON keys this model knows about
64
+ def self.acceptable_attributes
65
+ acceptable_attribute_map.values
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'index' => :'Integer',
72
+ :'sub_type' => :'String',
73
+ :'value' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::CreateInboxConversationRequestTemplateButtonParamsInner` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ acceptable_attribute_map = self.class.acceptable_attribute_map
92
+ attributes = attributes.each_with_object({}) { |(k, v), h|
93
+ if (!acceptable_attribute_map.key?(k.to_sym))
94
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::CreateInboxConversationRequestTemplateButtonParamsInner`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
95
+ end
96
+ h[k.to_sym] = v
97
+ }
98
+
99
+ if attributes.key?(:'index')
100
+ self.index = attributes[:'index']
101
+ else
102
+ self.index = nil
103
+ end
104
+
105
+ if attributes.key?(:'sub_type')
106
+ self.sub_type = attributes[:'sub_type']
107
+ else
108
+ self.sub_type = nil
109
+ end
110
+
111
+ if attributes.key?(:'value')
112
+ self.value = attributes[:'value']
113
+ else
114
+ self.value = nil
115
+ end
116
+ end
117
+
118
+ # Show invalid properties with the reasons. Usually used together with valid?
119
+ # @return Array for valid properties with the reasons
120
+ def list_invalid_properties
121
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
122
+ invalid_properties = Array.new
123
+ if @index.nil?
124
+ invalid_properties.push('invalid value for "index", index cannot be nil.')
125
+ end
126
+
127
+ if @index > 9
128
+ invalid_properties.push('invalid value for "index", must be smaller than or equal to 9.')
129
+ end
130
+
131
+ if @index < 0
132
+ invalid_properties.push('invalid value for "index", must be greater than or equal to 0.')
133
+ end
134
+
135
+ if @sub_type.nil?
136
+ invalid_properties.push('invalid value for "sub_type", sub_type cannot be nil.')
137
+ end
138
+
139
+ if @value.nil?
140
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
141
+ end
142
+
143
+ if @value.to_s.length < 1
144
+ invalid_properties.push('invalid value for "value", the character length must be greater than or equal to 1.')
145
+ end
146
+
147
+ invalid_properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ warn '[DEPRECATED] the `valid?` method is obsolete'
154
+ return false if @index.nil?
155
+ return false if @index > 9
156
+ return false if @index < 0
157
+ return false if @sub_type.nil?
158
+ sub_type_validator = EnumAttributeValidator.new('String', ["url", "copy_code", "flow"])
159
+ return false unless sub_type_validator.valid?(@sub_type)
160
+ return false if @value.nil?
161
+ return false if @value.to_s.length < 1
162
+ true
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] index Value to be assigned
167
+ def index=(index)
168
+ if index.nil?
169
+ fail ArgumentError, 'index cannot be nil'
170
+ end
171
+
172
+ if index > 9
173
+ fail ArgumentError, 'invalid value for "index", must be smaller than or equal to 9.'
174
+ end
175
+
176
+ if index < 0
177
+ fail ArgumentError, 'invalid value for "index", must be greater than or equal to 0.'
178
+ end
179
+
180
+ @index = index
181
+ end
182
+
183
+ # Custom attribute writer method checking allowed values (enum).
184
+ # @param [Object] sub_type Object to be assigned
185
+ def sub_type=(sub_type)
186
+ validator = EnumAttributeValidator.new('String', ["url", "copy_code", "flow"])
187
+ unless validator.valid?(sub_type)
188
+ fail ArgumentError, "invalid value for \"sub_type\", must be one of #{validator.allowable_values}."
189
+ end
190
+ @sub_type = sub_type
191
+ end
192
+
193
+ # Custom attribute writer method with validation
194
+ # @param [Object] value Value to be assigned
195
+ def value=(value)
196
+ if value.nil?
197
+ fail ArgumentError, 'value cannot be nil'
198
+ end
199
+
200
+ if value.to_s.length < 1
201
+ fail ArgumentError, 'invalid value for "value", the character length must be greater than or equal to 1.'
202
+ end
203
+
204
+ @value = value
205
+ end
206
+
207
+ # Checks equality by comparing each attribute.
208
+ # @param [Object] Object to be compared
209
+ def ==(o)
210
+ return true if self.equal?(o)
211
+ self.class == o.class &&
212
+ index == o.index &&
213
+ sub_type == o.sub_type &&
214
+ value == o.value
215
+ end
216
+
217
+ # @see the `==` method
218
+ # @param [Object] Object to be compared
219
+ def eql?(o)
220
+ self == o
221
+ end
222
+
223
+ # Calculates hash code according to all attributes.
224
+ # @return [Integer] Hash code
225
+ def hash
226
+ [index, sub_type, value].hash
227
+ end
228
+
229
+ # Builds the object from hash
230
+ # @param [Hash] attributes Model attributes in the form of hash
231
+ # @return [Object] Returns the model itself
232
+ def self.build_from_hash(attributes)
233
+ return nil unless attributes.is_a?(Hash)
234
+ attributes = attributes.transform_keys(&:to_sym)
235
+ transformed_hash = {}
236
+ openapi_types.each_pair do |key, type|
237
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
238
+ transformed_hash["#{key}"] = nil
239
+ elsif type =~ /\AArray<(.*)>/i
240
+ # check to ensure the input is an array given that the attribute
241
+ # is documented as an array but the input is not
242
+ if attributes[attribute_map[key]].is_a?(Array)
243
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
244
+ end
245
+ elsif !attributes[attribute_map[key]].nil?
246
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
247
+ end
248
+ end
249
+ new(transformed_hash)
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ if value.nil?
259
+ is_nullable = self.class.openapi_nullable.include?(attr)
260
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
261
+ end
262
+
263
+ hash[param] = _to_hash(value)
264
+ end
265
+ hash
266
+ end
267
+
268
+ end
269
+
270
+ end
@@ -217,6 +217,12 @@ module Zernio
217
217
  # 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.
218
218
  attr_accessor :sitelinks
219
219
 
220
+ # Google Search only. Short callout texts (max 25 chars each) that appear as non-clickable annotations under the ad, e.g. \"Free shipping\", \"24/7 support\". Each becomes one Asset (`callout_asset`) plus a CampaignAsset link with field_type CALLOUT. Response's creative.callouts[] echoes each input plus its Google resourceName.
221
+ attr_accessor :callouts
222
+
223
+ # Google Search only. Structured snippets — one header from Google's predefined list plus 3-10 values (max 25 chars each). Each becomes one Asset (`structured_snippet_asset`) plus a CampaignAsset link with field_type STRUCTURED_SNIPPET.
224
+ attr_accessor :structured_snippets
225
+
220
226
  # Meta only. Controls the Advantage audience feature (targeting_automation). 0 = disabled (default), 1 = enabled. Meta Marketing API requires this field on all ad set creation requests.
221
227
  attr_accessor :advantage_audience
222
228
 
@@ -355,6 +361,8 @@ module Zernio
355
361
  :'additional_headlines' => :'additionalHeadlines',
356
362
  :'additional_descriptions' => :'additionalDescriptions',
357
363
  :'sitelinks' => :'sitelinks',
364
+ :'callouts' => :'callouts',
365
+ :'structured_snippets' => :'structuredSnippets',
358
366
  :'advantage_audience' => :'advantageAudience',
359
367
  :'attribution_spec' => :'attributionSpec',
360
368
  :'gender' => :'gender',
@@ -457,6 +465,8 @@ module Zernio
457
465
  :'additional_headlines' => :'Array<String>',
458
466
  :'additional_descriptions' => :'Array<String>',
459
467
  :'sitelinks' => :'Array<CreateStandaloneAdRequestSitelinksInner>',
468
+ :'callouts' => :'Array<String>',
469
+ :'structured_snippets' => :'Array<CreateStandaloneAdRequestStructuredSnippetsInner>',
460
470
  :'advantage_audience' => :'Integer',
461
471
  :'attribution_spec' => :'Array<CreateStandaloneAdRequestAttributionSpecInner>',
462
472
  :'gender' => :'String',
@@ -833,6 +843,18 @@ module Zernio
833
843
  end
834
844
  end
835
845
 
846
+ if attributes.key?(:'callouts')
847
+ if (value = attributes[:'callouts']).is_a?(Array)
848
+ self.callouts = value
849
+ end
850
+ end
851
+
852
+ if attributes.key?(:'structured_snippets')
853
+ if (value = attributes[:'structured_snippets']).is_a?(Array)
854
+ self.structured_snippets = value
855
+ end
856
+ end
857
+
836
858
  if attributes.key?(:'advantage_audience')
837
859
  self.advantage_audience = attributes[:'advantage_audience']
838
860
  end
@@ -995,6 +1017,22 @@ module Zernio
995
1017
  invalid_properties.push('invalid value for "sitelinks", number of items must be greater than or equal to 2.')
996
1018
  end
997
1019
 
1020
+ if !@callouts.nil? && @callouts.length > 20
1021
+ invalid_properties.push('invalid value for "callouts", number of items must be less than or equal to 20.')
1022
+ end
1023
+
1024
+ if !@callouts.nil? && @callouts.length < 1
1025
+ invalid_properties.push('invalid value for "callouts", number of items must be greater than or equal to 1.')
1026
+ end
1027
+
1028
+ if !@structured_snippets.nil? && @structured_snippets.length > 20
1029
+ invalid_properties.push('invalid value for "structured_snippets", number of items must be less than or equal to 20.')
1030
+ end
1031
+
1032
+ if !@structured_snippets.nil? && @structured_snippets.length < 1
1033
+ invalid_properties.push('invalid value for "structured_snippets", number of items must be greater than or equal to 1.')
1034
+ end
1035
+
998
1036
  if !@attribution_spec.nil? && @attribution_spec.length > 3
999
1037
  invalid_properties.push('invalid value for "attribution_spec", number of items must be less than or equal to 3.')
1000
1038
  end
@@ -1066,6 +1104,10 @@ module Zernio
1066
1104
  return false unless campaign_type_validator.valid?(@campaign_type)
1067
1105
  return false if !@sitelinks.nil? && @sitelinks.length > 20
1068
1106
  return false if !@sitelinks.nil? && @sitelinks.length < 2
1107
+ return false if !@callouts.nil? && @callouts.length > 20
1108
+ return false if !@callouts.nil? && @callouts.length < 1
1109
+ return false if !@structured_snippets.nil? && @structured_snippets.length > 20
1110
+ return false if !@structured_snippets.nil? && @structured_snippets.length < 1
1069
1111
  advantage_audience_validator = EnumAttributeValidator.new('Integer', [0, 1])
1070
1112
  return false unless advantage_audience_validator.valid?(@advantage_audience)
1071
1113
  return false if !@attribution_spec.nil? && @attribution_spec.length > 3
@@ -1420,6 +1462,42 @@ module Zernio
1420
1462
  @sitelinks = sitelinks
1421
1463
  end
1422
1464
 
1465
+ # Custom attribute writer method with validation
1466
+ # @param [Object] callouts Value to be assigned
1467
+ def callouts=(callouts)
1468
+ if callouts.nil?
1469
+ fail ArgumentError, 'callouts cannot be nil'
1470
+ end
1471
+
1472
+ if callouts.length > 20
1473
+ fail ArgumentError, 'invalid value for "callouts", number of items must be less than or equal to 20.'
1474
+ end
1475
+
1476
+ if callouts.length < 1
1477
+ fail ArgumentError, 'invalid value for "callouts", number of items must be greater than or equal to 1.'
1478
+ end
1479
+
1480
+ @callouts = callouts
1481
+ end
1482
+
1483
+ # Custom attribute writer method with validation
1484
+ # @param [Object] structured_snippets Value to be assigned
1485
+ def structured_snippets=(structured_snippets)
1486
+ if structured_snippets.nil?
1487
+ fail ArgumentError, 'structured_snippets cannot be nil'
1488
+ end
1489
+
1490
+ if structured_snippets.length > 20
1491
+ fail ArgumentError, 'invalid value for "structured_snippets", number of items must be less than or equal to 20.'
1492
+ end
1493
+
1494
+ if structured_snippets.length < 1
1495
+ fail ArgumentError, 'invalid value for "structured_snippets", number of items must be greater than or equal to 1.'
1496
+ end
1497
+
1498
+ @structured_snippets = structured_snippets
1499
+ end
1500
+
1423
1501
  # Custom attribute writer method checking allowed values (enum).
1424
1502
  # @param [Object] advantage_audience Object to be assigned
1425
1503
  def advantage_audience=(advantage_audience)
@@ -1587,6 +1665,8 @@ module Zernio
1587
1665
  additional_headlines == o.additional_headlines &&
1588
1666
  additional_descriptions == o.additional_descriptions &&
1589
1667
  sitelinks == o.sitelinks &&
1668
+ callouts == o.callouts &&
1669
+ structured_snippets == o.structured_snippets &&
1590
1670
  advantage_audience == o.advantage_audience &&
1591
1671
  attribution_spec == o.attribution_spec &&
1592
1672
  gender == o.gender &&
@@ -1613,7 +1693,7 @@ module Zernio
1613
1693
  # Calculates hash code according to all attributes.
1614
1694
  # @return [Integer] Hash code
1615
1695
  def hash
1616
- [account_id, ad_account_id, name, campaign_name, ad_set_name, ad_name, tracking, goal, optimization_goal, billing_event, buying_type, rf_prediction_id, creative_features, multi_advertiser, validate_only, budget_amount, budget_type, status, campaign_status, budget_level, currency, headline, long_headline, body, description, call_to_action, link_url, lead_gen_form_id, image_url, images, video, creatives, ad_set_id, existing_campaign_id, existing_creative_id, business_name, board_id, organization_id, targeting, countries, cities, regions, age_min, age_max, interests, zips, metros, custom_locations, behaviors, income_tier, languages, placements, saved_targeting_id, raw_targeting, special_ad_categories, special_ad_category_country, end_date, start_date, instagram_account_id, dynamic_creative, carousel_cards, default_locale, translations, placement_assets, audience_id, campaign_type, keywords, negative_keywords, additional_headlines, additional_descriptions, sitelinks, advantage_audience, attribution_spec, gender, bid_strategy, bid_amount, roas_average_floor, value_rule_set_id, value_rules_applied, platform_specific_data, dsa_beneficiary, dsa_payor, brand_identity, identity_type, smart_plus, promoted_object].hash
1696
+ [account_id, ad_account_id, name, campaign_name, ad_set_name, ad_name, tracking, goal, optimization_goal, billing_event, buying_type, rf_prediction_id, creative_features, multi_advertiser, validate_only, budget_amount, budget_type, status, campaign_status, budget_level, currency, headline, long_headline, body, description, call_to_action, link_url, lead_gen_form_id, image_url, images, video, creatives, ad_set_id, existing_campaign_id, existing_creative_id, business_name, board_id, organization_id, targeting, countries, cities, regions, age_min, age_max, interests, zips, metros, custom_locations, behaviors, income_tier, languages, placements, saved_targeting_id, raw_targeting, special_ad_categories, special_ad_category_country, end_date, start_date, instagram_account_id, dynamic_creative, carousel_cards, default_locale, translations, placement_assets, audience_id, campaign_type, keywords, negative_keywords, additional_headlines, additional_descriptions, sitelinks, callouts, structured_snippets, advantage_audience, attribution_spec, gender, bid_strategy, bid_amount, roas_average_floor, value_rule_set_id, value_rules_applied, platform_specific_data, dsa_beneficiary, dsa_payor, brand_identity, identity_type, smart_plus, promoted_object].hash
1617
1697
  end
1618
1698
 
1619
1699
  # Builds the object from hash
@@ -0,0 +1,235 @@
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 CreateStandaloneAdRequestStructuredSnippetsInner < ApiModelBase
18
+ # One of Google's 13 predefined snippet headers.
19
+ attr_accessor :header
20
+
21
+ attr_accessor :values
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'header' => :'header',
49
+ :'values' => :'values'
50
+ }
51
+ end
52
+
53
+ # Returns attribute mapping this model knows about
54
+ def self.acceptable_attribute_map
55
+ attribute_map
56
+ end
57
+
58
+ # Returns all the JSON keys this model knows about
59
+ def self.acceptable_attributes
60
+ acceptable_attribute_map.values
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'header' => :'String',
67
+ :'values' => :'Array<String>'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::CreateStandaloneAdRequestStructuredSnippetsInner` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ acceptable_attribute_map = self.class.acceptable_attribute_map
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!acceptable_attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::CreateStandaloneAdRequestStructuredSnippetsInner`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'header')
94
+ self.header = attributes[:'header']
95
+ else
96
+ self.header = nil
97
+ end
98
+
99
+ if attributes.key?(:'values')
100
+ if (value = attributes[:'values']).is_a?(Array)
101
+ self.values = value
102
+ end
103
+ else
104
+ self.values = nil
105
+ end
106
+ end
107
+
108
+ # Show invalid properties with the reasons. Usually used together with valid?
109
+ # @return Array for valid properties with the reasons
110
+ def list_invalid_properties
111
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
112
+ invalid_properties = Array.new
113
+ if @header.nil?
114
+ invalid_properties.push('invalid value for "header", header cannot be nil.')
115
+ end
116
+
117
+ if @values.nil?
118
+ invalid_properties.push('invalid value for "values", values cannot be nil.')
119
+ end
120
+
121
+ if @values.length > 10
122
+ invalid_properties.push('invalid value for "values", number of items must be less than or equal to 10.')
123
+ end
124
+
125
+ if @values.length < 3
126
+ invalid_properties.push('invalid value for "values", number of items must be greater than or equal to 3.')
127
+ end
128
+
129
+ invalid_properties
130
+ end
131
+
132
+ # Check to see if the all the properties in the model are valid
133
+ # @return true if the model is valid
134
+ def valid?
135
+ warn '[DEPRECATED] the `valid?` method is obsolete'
136
+ return false if @header.nil?
137
+ header_validator = EnumAttributeValidator.new('String', ["Amenities", "Brands", "Courses", "Degree programs", "Destinations", "Featured hotels", "Insurance coverage", "Models", "Neighborhoods", "Service catalog", "Shows", "Styles", "Types"])
138
+ return false unless header_validator.valid?(@header)
139
+ return false if @values.nil?
140
+ return false if @values.length > 10
141
+ return false if @values.length < 3
142
+ true
143
+ end
144
+
145
+ # Custom attribute writer method checking allowed values (enum).
146
+ # @param [Object] header Object to be assigned
147
+ def header=(header)
148
+ validator = EnumAttributeValidator.new('String', ["Amenities", "Brands", "Courses", "Degree programs", "Destinations", "Featured hotels", "Insurance coverage", "Models", "Neighborhoods", "Service catalog", "Shows", "Styles", "Types"])
149
+ unless validator.valid?(header)
150
+ fail ArgumentError, "invalid value for \"header\", must be one of #{validator.allowable_values}."
151
+ end
152
+ @header = header
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] values Value to be assigned
157
+ def values=(values)
158
+ if values.nil?
159
+ fail ArgumentError, 'values cannot be nil'
160
+ end
161
+
162
+ if values.length > 10
163
+ fail ArgumentError, 'invalid value for "values", number of items must be less than or equal to 10.'
164
+ end
165
+
166
+ if values.length < 3
167
+ fail ArgumentError, 'invalid value for "values", number of items must be greater than or equal to 3.'
168
+ end
169
+
170
+ @values = values
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ header == o.header &&
179
+ values == o.values
180
+ end
181
+
182
+ # @see the `==` method
183
+ # @param [Object] Object to be compared
184
+ def eql?(o)
185
+ self == o
186
+ end
187
+
188
+ # Calculates hash code according to all attributes.
189
+ # @return [Integer] Hash code
190
+ def hash
191
+ [header, values].hash
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def self.build_from_hash(attributes)
198
+ return nil unless attributes.is_a?(Hash)
199
+ attributes = attributes.transform_keys(&:to_sym)
200
+ transformed_hash = {}
201
+ openapi_types.each_pair do |key, type|
202
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
203
+ transformed_hash["#{key}"] = nil
204
+ elsif type =~ /\AArray<(.*)>/i
205
+ # check to ensure the input is an array given that the attribute
206
+ # is documented as an array but the input is not
207
+ if attributes[attribute_map[key]].is_a?(Array)
208
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
209
+ end
210
+ elsif !attributes[attribute_map[key]].nil?
211
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
212
+ end
213
+ end
214
+ new(transformed_hash)
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = self.send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+ hash
231
+ end
232
+
233
+ end
234
+
235
+ end