late-sdk 0.0.936 → 0.0.938

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -0
  3. data/docs/AdCampaignsApi.md +76 -0
  4. data/docs/GetAdCampaignDetails200Response.md +18 -0
  5. data/docs/GetLeadForm200Response.md +2 -2
  6. data/docs/GetLeadForm200ResponseForm.md +49 -0
  7. data/docs/LeadGenApi.md +19 -13
  8. data/docs/MetaLeadForm.md +58 -0
  9. data/docs/MetaLeadFormContextCard.md +28 -0
  10. data/docs/MetaLeadFormLegalContent.md +22 -0
  11. data/docs/MetaLeadFormLegalContentPrivacyPolicy.md +20 -0
  12. data/docs/MetaLeadFormQuestionsInner.md +34 -0
  13. data/docs/MetaLeadFormThankYouPage.md +38 -0
  14. data/lib/zernio-sdk/api/ad_campaigns_api.rb +73 -0
  15. data/lib/zernio-sdk/api/lead_gen_api.rb +21 -12
  16. data/lib/zernio-sdk/models/get_ad_campaign_details200_response.rb +148 -0
  17. data/lib/zernio-sdk/models/get_lead_form200_response.rb +1 -1
  18. data/lib/zernio-sdk/models/get_lead_form200_response_form.rb +104 -0
  19. data/lib/zernio-sdk/models/meta_lead_form.rb +337 -0
  20. data/lib/zernio-sdk/models/meta_lead_form_context_card.rb +228 -0
  21. data/lib/zernio-sdk/models/meta_lead_form_legal_content.rb +167 -0
  22. data/lib/zernio-sdk/models/meta_lead_form_legal_content_privacy_policy.rb +156 -0
  23. data/lib/zernio-sdk/models/meta_lead_form_questions_inner.rb +229 -0
  24. data/lib/zernio-sdk/models/meta_lead_form_thank_you_page.rb +238 -0
  25. data/lib/zernio-sdk/version.rb +1 -1
  26. data/lib/zernio-sdk.rb +8 -0
  27. data/openapi.yaml +160 -12
  28. data/spec/api/ad_campaigns_api_spec.rb +14 -0
  29. data/spec/api/lead_gen_api_spec.rb +8 -6
  30. data/spec/models/get_ad_campaign_details200_response_spec.rb +36 -0
  31. data/spec/models/get_lead_form200_response_form_spec.rb +32 -0
  32. data/spec/models/meta_lead_form_context_card_spec.rb +70 -0
  33. data/spec/models/meta_lead_form_legal_content_privacy_policy_spec.rb +42 -0
  34. data/spec/models/meta_lead_form_legal_content_spec.rb +48 -0
  35. data/spec/models/meta_lead_form_questions_inner_spec.rb +84 -0
  36. data/spec/models/meta_lead_form_spec.rb +156 -0
  37. data/spec/models/meta_lead_form_thank_you_page_spec.rb +96 -0
  38. data/zernio-sdk-0.0.938.gem +0 -0
  39. metadata +34 -2
  40. data/zernio-sdk-0.0.936.gem +0 -0
@@ -20,9 +20,9 @@ module Zernio
20
20
  @api_client = api_client
21
21
  end
22
22
  # Archive a lead form
23
- # Neither platform hard-deletes a form; this archives it (Meta status=ARCHIVED; LinkedIn state=ARCHIVED via PARTIAL_UPDATE).
23
+ # Neither platform hard-deletes a form; this archives it (Meta status=ARCHIVED; LinkedIn state=ARCHIVED via PARTIAL_UPDATE). Meta forms must belong to the Page the accountId manages.
24
24
  # @param form_id [String] Numeric form id (Meta leadgen_form id or LinkedIn leadForm id).
25
- # @param account_id [String] Connected facebook or linkedin ads account id (selects the platform).
25
+ # @param account_id [String] Connected Meta ads, facebook or linkedin ads account id (selects the platform). A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
26
26
  # @param [Hash] opts the optional parameters
27
27
  # @return [ArchiveLeadForm200Response]
28
28
  def archive_lead_form(form_id, account_id, opts = {})
@@ -31,9 +31,9 @@ module Zernio
31
31
  end
32
32
 
33
33
  # Archive a lead form
34
- # Neither platform hard-deletes a form; this archives it (Meta status=ARCHIVED; LinkedIn state=ARCHIVED via PARTIAL_UPDATE).
34
+ # Neither platform hard-deletes a form; this archives it (Meta status=ARCHIVED; LinkedIn state=ARCHIVED via PARTIAL_UPDATE). Meta forms must belong to the Page the accountId manages.
35
35
  # @param form_id [String] Numeric form id (Meta leadgen_form id or LinkedIn leadForm id).
36
- # @param account_id [String] Connected facebook or linkedin ads account id (selects the platform).
36
+ # @param account_id [String] Connected Meta ads, facebook or linkedin ads account id (selects the platform). A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
37
37
  # @param [Hash] opts the optional parameters
38
38
  # @return [Array<(ArchiveLeadForm200Response, Integer, Hash)>] ArchiveLeadForm200Response data, response status code and response headers
39
39
  def archive_lead_form_with_http_info(form_id, account_id, opts = {})
@@ -90,7 +90,7 @@ module Zernio
90
90
  end
91
91
 
92
92
  # Create a lead form
93
- # Creates a Lead Gen form. The form content goes inside `platformSpecificData` for both platforms (the shape is selected by the accountId's platform). Meta: created on the connected Facebook Page (a facebook account or a metaads business-login account with a selected Page) (POST /{page-id}/leadgen_forms); the old top-level Meta fields (questions, thankYou*, contextCard, …) are DEPRECATED but still accepted while platformSpecificData is absent; mixing both shapes is a 400. LinkedIn: created on the ad account's Company Page. NOT idempotent: a retry creates a second form. Meta prefilled question types (EMAIL, PHONE, FULL_NAME, …) must omit label/key; CUSTOM questions require both. LinkedIn exposes only free-text and multiple-choice questions via API (prefilled-from-profile fields are Campaign Manager UI-only). Requires the Ads add-on.
93
+ # Creates a Lead Gen form. The form content goes inside `platformSpecificData` for both platforms (the shape is selected by the accountId's platform). Meta: created on the connected Facebook Page (POST /{page-id}/leadgen_forms), where `accountId` may be the `metaads` ads connection (its Page comes from the Facebook account linked to the same profile) or the Facebook account itself; the old top-level Meta fields (questions, thankYou*, contextCard, …) are DEPRECATED but still accepted while platformSpecificData is absent; mixing both shapes is a 400. LinkedIn: created on the ad account's Company Page. NOT idempotent: a retry creates a second form. Meta prefilled question types (EMAIL, PHONE, FULL_NAME, …) must omit label/key; CUSTOM questions require both. LinkedIn exposes only free-text and multiple-choice questions via API (prefilled-from-profile fields are Campaign Manager UI-only). Requires the Ads add-on.
94
94
  # @param create_lead_form_request [CreateLeadFormRequest]
95
95
  # @param [Hash] opts the optional parameters
96
96
  # @return [CreateLeadForm200Response]
@@ -100,7 +100,7 @@ module Zernio
100
100
  end
101
101
 
102
102
  # Create a lead form
103
- # Creates a Lead Gen form. The form content goes inside &#x60;platformSpecificData&#x60; for both platforms (the shape is selected by the accountId&#39;s platform). Meta: created on the connected Facebook Page (a facebook account or a metaads business-login account with a selected Page) (POST /{page-id}/leadgen_forms); the old top-level Meta fields (questions, thankYou*, contextCard, …) are DEPRECATED but still accepted while platformSpecificData is absent; mixing both shapes is a 400. LinkedIn: created on the ad account&#39;s Company Page. NOT idempotent: a retry creates a second form. Meta prefilled question types (EMAIL, PHONE, FULL_NAME, …) must omit label/key; CUSTOM questions require both. LinkedIn exposes only free-text and multiple-choice questions via API (prefilled-from-profile fields are Campaign Manager UI-only). Requires the Ads add-on.
103
+ # Creates a Lead Gen form. The form content goes inside &#x60;platformSpecificData&#x60; for both platforms (the shape is selected by the accountId&#39;s platform). Meta: created on the connected Facebook Page (POST /{page-id}/leadgen_forms), where &#x60;accountId&#x60; may be the &#x60;metaads&#x60; ads connection (its Page comes from the Facebook account linked to the same profile) or the Facebook account itself; the old top-level Meta fields (questions, thankYou*, contextCard, …) are DEPRECATED but still accepted while platformSpecificData is absent; mixing both shapes is a 400. LinkedIn: created on the ad account&#39;s Company Page. NOT idempotent: a retry creates a second form. Meta prefilled question types (EMAIL, PHONE, FULL_NAME, …) must omit label/key; CUSTOM questions require both. LinkedIn exposes only free-text and multiple-choice questions via API (prefilled-from-profile fields are Campaign Manager UI-only). Requires the Ads add-on.
104
104
  # @param create_lead_form_request [CreateLeadFormRequest]
105
105
  # @param [Hash] opts the optional parameters
106
106
  # @return [Array<(CreateLeadForm200Response, Integer, Hash)>] CreateLeadForm200Response data, response status code and response headers
@@ -232,9 +232,11 @@ module Zernio
232
232
  end
233
233
 
234
234
  # Get a lead form
235
+ # Returns the full form, including the thank-you page, so a form can be diffed against what was created. Meta forms are scoped to the Page the accountId manages: a form on any other Page is a 404, never a read.
235
236
  # @param form_id [String] Numeric form id (Meta leadgen_form id or LinkedIn leadForm id).
236
- # @param account_id [String] Connected facebook or linkedin ads account id (selects the platform).
237
+ # @param account_id [String] Connected Meta ads, facebook or linkedin ads account id (selects the platform). A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
237
238
  # @param [Hash] opts the optional parameters
239
+ # @option opts [String] :fields Meta only. A Graph field selection passed through verbatim to GET /{form-id}, replacing the default projection, so fields Meta adds later are reachable without an API change. Field names, commas and {} expansion only; anything else (Graph field modifiers such as .limit(), or characters that could open another query parameter) is a 400. Ownership of the form is verified before the selection runs, so this cannot reach any Page but the one accountId manages. Unknown field names are rejected by Meta as a 400.
238
240
  # @return [GetLeadForm200Response]
239
241
  def get_lead_form(form_id, account_id, opts = {})
240
242
  data, _status_code, _headers = get_lead_form_with_http_info(form_id, account_id, opts)
@@ -242,9 +244,11 @@ module Zernio
242
244
  end
243
245
 
244
246
  # Get a lead form
247
+ # Returns the full form, including the thank-you page, so a form can be diffed against what was created. Meta forms are scoped to the Page the accountId manages: a form on any other Page is a 404, never a read.
245
248
  # @param form_id [String] Numeric form id (Meta leadgen_form id or LinkedIn leadForm id).
246
- # @param account_id [String] Connected facebook or linkedin ads account id (selects the platform).
249
+ # @param account_id [String] Connected Meta ads, facebook or linkedin ads account id (selects the platform). A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
247
250
  # @param [Hash] opts the optional parameters
251
+ # @option opts [String] :fields Meta only. A Graph field selection passed through verbatim to GET /{form-id}, replacing the default projection, so fields Meta adds later are reachable without an API change. Field names, commas and {} expansion only; anything else (Graph field modifiers such as .limit(), or characters that could open another query parameter) is a 400. Ownership of the form is verified before the selection runs, so this cannot reach any Page but the one accountId manages. Unknown field names are rejected by Meta as a 400.
248
252
  # @return [Array<(GetLeadForm200Response, Integer, Hash)>] GetLeadForm200Response data, response status code and response headers
249
253
  def get_lead_form_with_http_info(form_id, account_id, opts = {})
250
254
  if @api_client.config.debugging
@@ -258,12 +262,17 @@ module Zernio
258
262
  if @api_client.config.client_side_validation && account_id.nil?
259
263
  fail ArgumentError, "Missing the required parameter 'account_id' when calling LeadGenApi.get_lead_form"
260
264
  end
265
+ if @api_client.config.client_side_validation && !opts[:'fields'].nil? && opts[:'fields'].to_s.length > 2000
266
+ fail ArgumentError, 'invalid value for "opts[:"fields"]" when calling LeadGenApi.get_lead_form, the character length must be smaller than or equal to 2000.'
267
+ end
268
+
261
269
  # resource path
262
270
  local_var_path = '/v1/ads/lead-forms/{formId}'.sub('{' + 'formId' + '}', CGI.escape(form_id.to_s))
263
271
 
264
272
  # query parameters
265
273
  query_params = opts[:query_params] || {}
266
274
  query_params[:'accountId'] = account_id
275
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
267
276
 
268
277
  # header parameters
269
278
  header_params = opts[:header_params] || {}
@@ -387,8 +396,8 @@ module Zernio
387
396
  end
388
397
 
389
398
  # List lead forms
390
- # Lists the Lead Gen forms owned by the account. Meta: forms on the connected Facebook Page, including a Page selected on a metaads business-login connection. LinkedIn: forms owned by the ad account's Company Page. Pass `adAccountId` (LinkedIn forms are org-owned). Requires the Ads add-on.
391
- # @param account_id [String] Connected Facebook, Meta ads business-login or LinkedIn ads account ID.
399
+ # Lists the Lead Gen forms owned by the account. Meta: forms on the connected Facebook Page. Pass either the `metaads` ads connection (the Page is taken from the Facebook account linked to it) or the Facebook account itself. LinkedIn: forms owned by the ad account's Company Page. Pass `adAccountId` (LinkedIn forms are org-owned). Requires the Ads add-on.
400
+ # @param account_id [String] Connected Meta ads, Facebook or LinkedIn ads account ID. A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
392
401
  # @param [Hash] opts the optional parameters
393
402
  # @option opts [String] :ad_account_id LinkedIn only: the LinkedIn ad account id (used to resolve the owning organization). Required for LinkedIn.
394
403
  # @option opts [Integer] :limit (default to 25)
@@ -400,8 +409,8 @@ module Zernio
400
409
  end
401
410
 
402
411
  # List lead forms
403
- # Lists the Lead Gen forms owned by the account. Meta: forms on the connected Facebook Page, including a Page selected on a metaads business-login connection. LinkedIn: forms owned by the ad account&#39;s Company Page. Pass &#x60;adAccountId&#x60; (LinkedIn forms are org-owned). Requires the Ads add-on.
404
- # @param account_id [String] Connected Facebook, Meta ads business-login or LinkedIn ads account ID.
412
+ # Lists the Lead Gen forms owned by the account. Meta: forms on the connected Facebook Page. Pass either the &#x60;metaads&#x60; ads connection (the Page is taken from the Facebook account linked to it) or the Facebook account itself. LinkedIn: forms owned by the ad account&#39;s Company Page. Pass &#x60;adAccountId&#x60; (LinkedIn forms are org-owned). Requires the Ads add-on.
413
+ # @param account_id [String] Connected Meta ads, Facebook or LinkedIn ads account ID. A Meta ads connection resolves its Page through the Facebook account linked to the same profile.
405
414
  # @param [Hash] opts the optional parameters
406
415
  # @option opts [String] :ad_account_id LinkedIn only: the LinkedIn ad account id (used to resolve the owning organization). Required for LinkedIn.
407
416
  # @option opts [Integer] :limit (default to 25)
@@ -0,0 +1,148 @@
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 GetAdCampaignDetails200Response < ApiModelBase
18
+ # Raw Meta campaign; keys are the requested Graph fields.
19
+ attr_accessor :campaign
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'campaign' => :'campaign'
25
+ }
26
+ end
27
+
28
+ # Returns attribute mapping this model knows about
29
+ def self.acceptable_attribute_map
30
+ attribute_map
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ acceptable_attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'campaign' => :'Object'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::GetAdCampaignDetails200Response` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ acceptable_attribute_map = self.class.acceptable_attribute_map
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!acceptable_attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::GetAdCampaignDetails200Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'campaign')
68
+ self.campaign = attributes[:'campaign']
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
76
+ invalid_properties = Array.new
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ campaign == o.campaign
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [campaign].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Returns the object in the form of hash
131
+ # @return [Hash] Returns the object in the form of hash
132
+ def to_hash
133
+ hash = {}
134
+ self.class.attribute_map.each_pair do |attr, param|
135
+ value = self.send(attr)
136
+ if value.nil?
137
+ is_nullable = self.class.openapi_nullable.include?(attr)
138
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
139
+ end
140
+
141
+ hash[param] = _to_hash(value)
142
+ end
143
+ hash
144
+ end
145
+
146
+ end
147
+
148
+ end
@@ -41,7 +41,7 @@ module Zernio
41
41
  def self.openapi_types
42
42
  {
43
43
  :'status' => :'String',
44
- :'form' => :'Object'
44
+ :'form' => :'GetLeadForm200ResponseForm'
45
45
  }
46
46
  end
47
47
 
@@ -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 GetLeadForm200ResponseForm
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'MetaLeadForm',
23
+ :'Object'
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