appnigma-sdk 0.1.0

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +359 -0
  4. data/lib/appnigma/checks.rb +90 -0
  5. data/lib/appnigma/client.rb +118 -0
  6. data/lib/appnigma/connections.rb +31 -0
  7. data/lib/appnigma/constants.rb +80 -0
  8. data/lib/appnigma/crm.rb +40 -0
  9. data/lib/appnigma/errors.rb +135 -0
  10. data/lib/appnigma/generated/api/default_api.rb +972 -0
  11. data/lib/appnigma/generated/api_client.rb +441 -0
  12. data/lib/appnigma/generated/api_error.rb +58 -0
  13. data/lib/appnigma/generated/api_model_base.rb +88 -0
  14. data/lib/appnigma/generated/configuration.rb +392 -0
  15. data/lib/appnigma/generated/models/connection_status.rb +41 -0
  16. data/lib/appnigma/generated/models/create_connection_link_input.rb +265 -0
  17. data/lib/appnigma/generated/models/create_connection_link_output.rb +205 -0
  18. data/lib/appnigma/generated/models/crm_company.rb +322 -0
  19. data/lib/appnigma/generated/models/crm_company_get_output.rb +177 -0
  20. data/lib/appnigma/generated/models/crm_company_list_output.rb +192 -0
  21. data/lib/appnigma/generated/models/crm_contact.rb +404 -0
  22. data/lib/appnigma/generated/models/crm_contact_get_output.rb +177 -0
  23. data/lib/appnigma/generated/models/crm_contact_list_output.rb +192 -0
  24. data/lib/appnigma/generated/models/crm_custom_field.rb +189 -0
  25. data/lib/appnigma/generated/models/crm_deal.rb +479 -0
  26. data/lib/appnigma/generated/models/crm_deal_get_output.rb +177 -0
  27. data/lib/appnigma/generated/models/crm_deal_list_output.rb +192 -0
  28. data/lib/appnigma/generated/models/crm_email.rb +249 -0
  29. data/lib/appnigma/generated/models/crm_get_input.rb +272 -0
  30. data/lib/appnigma/generated/models/crm_labelled.rb +190 -0
  31. data/lib/appnigma/generated/models/crm_list_input.rb +303 -0
  32. data/lib/appnigma/generated/models/crm_phone.rb +249 -0
  33. data/lib/appnigma/generated/models/function_entry.rb +346 -0
  34. data/lib/appnigma/generated/models/function_owner.rb +105 -0
  35. data/lib/appnigma/generated/models/function_owner_one_of.rb +201 -0
  36. data/lib/appnigma/generated/models/function_owner_one_of1.rb +227 -0
  37. data/lib/appnigma/generated/models/get_connection_output.rb +251 -0
  38. data/lib/appnigma/generated/models/get_guide_output.rb +178 -0
  39. data/lib/appnigma/generated/models/json_value.rb +106 -0
  40. data/lib/appnigma/generated/models/list_functions_output.rb +179 -0
  41. data/lib/appnigma/generated/models/platform_request_input.rb +314 -0
  42. data/lib/appnigma/generated/models/platform_request_input_body.rb +104 -0
  43. data/lib/appnigma/generated/models/platform_request_output.rb +221 -0
  44. data/lib/appnigma/generated/models/post_input.rb +327 -0
  45. data/lib/appnigma/generated/models/post_input_record_value.rb +104 -0
  46. data/lib/appnigma/generated/models/post_output.rb +203 -0
  47. data/lib/appnigma/generated/models/pull_input.rb +335 -0
  48. data/lib/appnigma/generated/models/pull_output.rb +191 -0
  49. data/lib/appnigma/generated/models/pull_output_records_inner.rb +205 -0
  50. data/lib/appnigma/generated/models/run_input.rb +332 -0
  51. data/lib/appnigma/generated/models/run_output.rb +164 -0
  52. data/lib/appnigma/generated/models/sdk_error.rb +177 -0
  53. data/lib/appnigma/generated/models/sdk_error_error.rb +254 -0
  54. data/lib/appnigma/generated/models/sdk_error_error_details.rb +211 -0
  55. data/lib/appnigma/generated/models/sdk_problem.rb +205 -0
  56. data/lib/appnigma/generated/version.rb +15 -0
  57. data/lib/appnigma/generated.rb +82 -0
  58. data/lib/appnigma/names.rb +62 -0
  59. data/lib/appnigma/retry.rb +80 -0
  60. data/lib/appnigma/transport.rb +138 -0
  61. data/lib/appnigma/version.rb +9 -0
  62. data/lib/appnigma.rb +16 -0
  63. metadata +155 -0
@@ -0,0 +1,249 @@
1
+ =begin
2
+ #Appnigma SDK API
3
+
4
+ #The routes a customer's product calls through an Appnigma SDK. Every answer carries a request id in X-Request-Id; quote it when you write to support.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Appnigma::Generated
17
+ class CrmPhone < ApiModelBase
18
+ attr_accessor :value
19
+
20
+ attr_accessor :type
21
+
22
+ attr_accessor :primary
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'value' => :'value',
50
+ :'type' => :'type',
51
+ :'primary' => :'primary'
52
+ }
53
+ end
54
+
55
+ # Returns attribute mapping this model knows about
56
+ def self.acceptable_attribute_map
57
+ attribute_map
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ acceptable_attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'value' => :'String',
69
+ :'type' => :'String',
70
+ :'primary' => :'Boolean'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ :'type',
78
+ ])
79
+ end
80
+
81
+ # Returns attribute type mapping
82
+ def self.acceptable_openapi_types
83
+ openapi_types
84
+ end
85
+
86
+ # Returns the nullable attributes
87
+ def self.acceptable_openapi_nullable
88
+ openapi_nullable
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Appnigma::Generated::CrmPhone` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ acceptable_attribute_map = self.class.acceptable_attribute_map
100
+ attributes = attributes.each_with_object({}) { |(k, v), h|
101
+ if (!acceptable_attribute_map.key?(k.to_sym))
102
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Appnigma::Generated::CrmPhone`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
103
+ end
104
+ h[k.to_sym] = v
105
+ }
106
+
107
+ if attributes.key?(:'value')
108
+ self.value = attributes[:'value']
109
+ else
110
+ self.value = nil
111
+ end
112
+
113
+ if attributes.key?(:'type')
114
+ self.type = attributes[:'type']
115
+ else
116
+ self.type = nil
117
+ end
118
+
119
+ if attributes.key?(:'primary')
120
+ self.primary = attributes[:'primary']
121
+ else
122
+ self.primary = nil
123
+ end
124
+ end
125
+
126
+ # Show invalid properties with the reasons. Usually used together with valid?
127
+ # @return Array for valid properties with the reasons
128
+ def list_invalid_properties
129
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
130
+ invalid_properties = Array.new
131
+ if @value.nil?
132
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
133
+ end
134
+
135
+ if @primary.nil?
136
+ invalid_properties.push('invalid value for "primary", primary cannot be nil.')
137
+ end
138
+
139
+ invalid_properties
140
+ end
141
+
142
+ # Check to see if the all the properties in the model are valid
143
+ # @return true if the model is valid
144
+ def valid?
145
+ warn '[DEPRECATED] the `valid?` method is obsolete'
146
+ return false if @value.nil?
147
+ type_validator = EnumAttributeValidator.new('String', ["work", "mobile", "home", "fax", "other"])
148
+ return false unless type_validator.valid?(@type)
149
+ return false if @primary.nil?
150
+ true
151
+ end
152
+
153
+ # Custom attribute writer method with validation
154
+ # @param [Object] value Value to be assigned
155
+ def value=(value)
156
+ if value.nil?
157
+ fail ArgumentError, 'value cannot be nil'
158
+ end
159
+
160
+ @value = value
161
+ end
162
+
163
+ # Custom attribute writer method checking allowed values (enum).
164
+ # @param [Object] type Object to be assigned
165
+ def type=(type)
166
+ validator = EnumAttributeValidator.new('String', ["work", "mobile", "home", "fax", "other"])
167
+ unless validator.valid?(type)
168
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
169
+ end
170
+ @type = type
171
+ end
172
+
173
+ # Custom attribute writer method with validation
174
+ # @param [Object] primary Value to be assigned
175
+ def primary=(primary)
176
+ if primary.nil?
177
+ fail ArgumentError, 'primary cannot be nil'
178
+ end
179
+
180
+ @primary = primary
181
+ end
182
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(o)
186
+ return true if self.equal?(o)
187
+ self.class == o.class &&
188
+ value == o.value &&
189
+ type == o.type &&
190
+ primary == o.primary
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Integer] Hash code
201
+ def hash
202
+ [value, type, primary].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def self.build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ attributes = attributes.transform_keys(&:to_sym)
211
+ # include attributes inherited from allOf parents (the nearest declaration wins)
212
+ map = acceptable_attribute_map
213
+ transformed_hash = {}
214
+ acceptable_openapi_types.each_pair do |key, type|
215
+ if attributes.key?(map[key]) && attributes[map[key]].nil?
216
+ transformed_hash["#{key}"] = nil
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[map[key]].is_a?(Array)
221
+ transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
222
+ end
223
+ elsif !attributes[map[key]].nil?
224
+ transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
225
+ end
226
+ end
227
+ new(transformed_hash)
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ # include attributes inherited from allOf parents (the nearest declaration wins)
235
+ self.class.acceptable_attribute_map.each_pair do |attr, param|
236
+ value = self.send(attr)
237
+ if value.nil?
238
+ is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
239
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
+ end
241
+
242
+ hash[param] = _to_hash(value)
243
+ end
244
+ hash
245
+ end
246
+
247
+ end
248
+
249
+ end
@@ -0,0 +1,346 @@
1
+ =begin
2
+ #Appnigma SDK API
3
+
4
+ #The routes a customer's product calls through an Appnigma SDK. Every answer carries a request id in X-Request-Id; quote it when you write to support.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Appnigma::Generated
17
+ class FunctionEntry < ApiModelBase
18
+ # The platform key the function runs on
19
+ attr_accessor :platform
20
+
21
+ # The function's name, the same as its file name
22
+ attr_accessor :name
23
+
24
+ attr_accessor :version
25
+
26
+ attr_accessor :description
27
+
28
+ # JSON Schema of what the function takes as input
29
+ attr_accessor :input_schema
30
+
31
+ # JSON Schema of what the function answers
32
+ attr_accessor :output_schema
33
+
34
+ attr_accessor :owner
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'platform' => :'platform',
40
+ :'name' => :'name',
41
+ :'version' => :'version',
42
+ :'description' => :'description',
43
+ :'input_schema' => :'inputSchema',
44
+ :'output_schema' => :'outputSchema',
45
+ :'owner' => :'owner'
46
+ }
47
+ end
48
+
49
+ # Returns attribute mapping this model knows about
50
+ def self.acceptable_attribute_map
51
+ attribute_map
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ acceptable_attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'platform' => :'String',
63
+ :'name' => :'String',
64
+ :'version' => :'Integer',
65
+ :'description' => :'String',
66
+ :'input_schema' => :'Object',
67
+ :'output_schema' => :'Object',
68
+ :'owner' => :'FunctionOwner'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Returns attribute type mapping
79
+ def self.acceptable_openapi_types
80
+ openapi_types
81
+ end
82
+
83
+ # Returns the nullable attributes
84
+ def self.acceptable_openapi_nullable
85
+ openapi_nullable
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Appnigma::Generated::FunctionEntry` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ acceptable_attribute_map = self.class.acceptable_attribute_map
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!acceptable_attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Appnigma::Generated::FunctionEntry`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'platform')
105
+ self.platform = attributes[:'platform']
106
+ else
107
+ self.platform = nil
108
+ end
109
+
110
+ if attributes.key?(:'name')
111
+ self.name = attributes[:'name']
112
+ else
113
+ self.name = nil
114
+ end
115
+
116
+ if attributes.key?(:'version')
117
+ self.version = attributes[:'version']
118
+ else
119
+ self.version = nil
120
+ end
121
+
122
+ if attributes.key?(:'description')
123
+ self.description = attributes[:'description']
124
+ else
125
+ self.description = nil
126
+ end
127
+
128
+ if attributes.key?(:'input_schema')
129
+ self.input_schema = attributes[:'input_schema']
130
+ else
131
+ self.input_schema = nil
132
+ end
133
+
134
+ if attributes.key?(:'output_schema')
135
+ self.output_schema = attributes[:'output_schema']
136
+ else
137
+ self.output_schema = nil
138
+ end
139
+
140
+ if attributes.key?(:'owner')
141
+ self.owner = attributes[:'owner']
142
+ else
143
+ self.owner = nil
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
151
+ invalid_properties = Array.new
152
+ if @platform.nil?
153
+ invalid_properties.push('invalid value for "platform", platform cannot be nil.')
154
+ end
155
+
156
+ if @name.nil?
157
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
158
+ end
159
+
160
+ if @version.nil?
161
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
162
+ end
163
+
164
+ if @version < 1
165
+ invalid_properties.push('invalid value for "version", must be greater than or equal to 1.')
166
+ end
167
+
168
+ if @description.nil?
169
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
170
+ end
171
+
172
+ if @input_schema.nil?
173
+ invalid_properties.push('invalid value for "input_schema", input_schema cannot be nil.')
174
+ end
175
+
176
+ if @output_schema.nil?
177
+ invalid_properties.push('invalid value for "output_schema", output_schema cannot be nil.')
178
+ end
179
+
180
+ if @owner.nil?
181
+ invalid_properties.push('invalid value for "owner", owner cannot be nil.')
182
+ end
183
+
184
+ invalid_properties
185
+ end
186
+
187
+ # Check to see if the all the properties in the model are valid
188
+ # @return true if the model is valid
189
+ def valid?
190
+ warn '[DEPRECATED] the `valid?` method is obsolete'
191
+ return false if @platform.nil?
192
+ return false if @name.nil?
193
+ return false if @version.nil?
194
+ return false if @version < 1
195
+ return false if @description.nil?
196
+ return false if @input_schema.nil?
197
+ return false if @output_schema.nil?
198
+ return false if @owner.nil?
199
+ true
200
+ end
201
+
202
+ # Custom attribute writer method with validation
203
+ # @param [Object] platform Value to be assigned
204
+ def platform=(platform)
205
+ if platform.nil?
206
+ fail ArgumentError, 'platform cannot be nil'
207
+ end
208
+
209
+ @platform = platform
210
+ end
211
+
212
+ # Custom attribute writer method with validation
213
+ # @param [Object] name Value to be assigned
214
+ def name=(name)
215
+ if name.nil?
216
+ fail ArgumentError, 'name cannot be nil'
217
+ end
218
+
219
+ @name = name
220
+ end
221
+
222
+ # Custom attribute writer method with validation
223
+ # @param [Object] version Value to be assigned
224
+ def version=(version)
225
+ if version.nil?
226
+ fail ArgumentError, 'version cannot be nil'
227
+ end
228
+
229
+ if version < 1
230
+ fail ArgumentError, 'invalid value for "version", must be greater than or equal to 1.'
231
+ end
232
+
233
+ @version = version
234
+ end
235
+
236
+ # Custom attribute writer method with validation
237
+ # @param [Object] description Value to be assigned
238
+ def description=(description)
239
+ if description.nil?
240
+ fail ArgumentError, 'description cannot be nil'
241
+ end
242
+
243
+ @description = description
244
+ end
245
+
246
+ # Custom attribute writer method with validation
247
+ # @param [Object] input_schema Value to be assigned
248
+ def input_schema=(input_schema)
249
+ if input_schema.nil?
250
+ fail ArgumentError, 'input_schema cannot be nil'
251
+ end
252
+
253
+ @input_schema = input_schema
254
+ end
255
+
256
+ # Custom attribute writer method with validation
257
+ # @param [Object] output_schema Value to be assigned
258
+ def output_schema=(output_schema)
259
+ if output_schema.nil?
260
+ fail ArgumentError, 'output_schema cannot be nil'
261
+ end
262
+
263
+ @output_schema = output_schema
264
+ end
265
+
266
+ # Custom attribute writer method with validation
267
+ # @param [Object] owner Value to be assigned
268
+ def owner=(owner)
269
+ if owner.nil?
270
+ fail ArgumentError, 'owner cannot be nil'
271
+ end
272
+
273
+ @owner = owner
274
+ end
275
+
276
+ # Checks equality by comparing each attribute.
277
+ # @param [Object] Object to be compared
278
+ def ==(o)
279
+ return true if self.equal?(o)
280
+ self.class == o.class &&
281
+ platform == o.platform &&
282
+ name == o.name &&
283
+ version == o.version &&
284
+ description == o.description &&
285
+ input_schema == o.input_schema &&
286
+ output_schema == o.output_schema &&
287
+ owner == o.owner
288
+ end
289
+
290
+ # @see the `==` method
291
+ # @param [Object] Object to be compared
292
+ def eql?(o)
293
+ self == o
294
+ end
295
+
296
+ # Calculates hash code according to all attributes.
297
+ # @return [Integer] Hash code
298
+ def hash
299
+ [platform, name, version, description, input_schema, output_schema, owner].hash
300
+ end
301
+
302
+ # Builds the object from hash
303
+ # @param [Hash] attributes Model attributes in the form of hash
304
+ # @return [Object] Returns the model itself
305
+ def self.build_from_hash(attributes)
306
+ return nil unless attributes.is_a?(Hash)
307
+ attributes = attributes.transform_keys(&:to_sym)
308
+ # include attributes inherited from allOf parents (the nearest declaration wins)
309
+ map = acceptable_attribute_map
310
+ transformed_hash = {}
311
+ acceptable_openapi_types.each_pair do |key, type|
312
+ if attributes.key?(map[key]) && attributes[map[key]].nil?
313
+ transformed_hash["#{key}"] = nil
314
+ elsif type =~ /\AArray<(.*)>/i
315
+ # check to ensure the input is an array given that the attribute
316
+ # is documented as an array but the input is not
317
+ if attributes[map[key]].is_a?(Array)
318
+ transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
319
+ end
320
+ elsif !attributes[map[key]].nil?
321
+ transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
322
+ end
323
+ end
324
+ new(transformed_hash)
325
+ end
326
+
327
+ # Returns the object in the form of hash
328
+ # @return [Hash] Returns the object in the form of hash
329
+ def to_hash
330
+ hash = {}
331
+ # include attributes inherited from allOf parents (the nearest declaration wins)
332
+ self.class.acceptable_attribute_map.each_pair do |attr, param|
333
+ value = self.send(attr)
334
+ if value.nil?
335
+ is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
336
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
337
+ end
338
+
339
+ hash[param] = _to_hash(value)
340
+ end
341
+ hash
342
+ end
343
+
344
+ end
345
+
346
+ end
@@ -0,0 +1,105 @@
1
+ =begin
2
+ #Appnigma SDK API
3
+
4
+ #The routes a customer's product calls through an Appnigma SDK. Every answer carries a request id in X-Request-Id; quote it when you write to support.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.26.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Appnigma::Generated
17
+ # Who the function is for: the whole customer, or one end customer.
18
+ module FunctionOwner
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'FunctionOwnerOneOf',
24
+ :'FunctionOwnerOneOf1'
25
+ ]
26
+ end
27
+
28
+ # Builds the object
29
+ # @param [Mixed] Data to be matched against the list of oneOf items
30
+ # @return [Object] Returns the model or the data itself
31
+ def build(data)
32
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
33
+ # Note:
34
+ # - We do not attempt to check whether exactly one item matches.
35
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
36
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
37
+ # - TODO: scalar values are de facto behaving as if they were nullable.
38
+ # - TODO: logging when debugging is set.
39
+ openapi_one_of.each do |klass|
40
+ begin
41
+ next if klass == :AnyType # "nullable: true"
42
+ return find_and_cast_into_type(klass, data)
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.iso8601(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Appnigma::Generated.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end