vgs_api_client 0.0.1.alpha202205220107 → 0.0.1.alpha202205221656

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,409 +0,0 @@
1
- =begin
2
- #Vault HTTP API
3
-
4
- #The VGS Vault HTTP API is used for storing, retrieving, and managing sensitive data (aka Tokenization) within a VGS Vault. The VGS API is organized around REST. Our API is built with a predictable resource-oriented structure, uses JSON-encoded requests and responses, follows standard HTTP verbs/responses, and uses industry standard authentication. ## What is VGS Storing sensitive data on your company’s infrastructure often comes with a heavy compliance burden. For instance, storing payments data yourself greatly increases the amount of work needed to become PCI compliant. It also increases your security risk in general. To combat this, companies will minimize the amount of sensitive information they have to handle or store. VGS provides multiple methods for minimizing the sensitive information that needs to be stored which allows customers to secure any type of data for any use-case. **Tokenization** is a method that focuses on securing the storage of data. This is the quickest way to get started and is free. [Get started with Tokenization](https://www.verygoodsecurity.com/docs/tokenization/getting-started). **Zero Data** is a unique method invented by VGS in 2016 that securely stores data like Tokenization, however it also removes the customer’s environment from PCI scope completely providing maximum security, and minimum compliance scope. [Get started with Zero Data](https://www.verygoodsecurity.com/docs/getting-started/before-you-start). Additionally, for scenarios where neither technology is a complete solution, for instance with legacy systems, VGS provides a compliance product which guarantees customers are able to meet their compliance needs no matter what may happen. [Get started with Control](https://www.verygoodsecurity.com/docs/control). ## Learn about Tokenization - [Create an Account for Free Tokenization](https://dashboard.verygoodsecurity.com/tokenization) - [Try a Tokenization Demo](https://www.verygoodsecurity.com/docs/tokenization/getting-started) - [Install a Tokenization SDK](https://www.verygoodsecurity.com/docs/tokenization/client-libraries) ### Authentication This API uses `Basic` authentication. Credentials to access the API can be generated on the [dashboard](https://dashboard.verygoodsecurity.com) by going to the Settings section of the vault of your choosing. [Docs » Guides » Access credentials](https://www.verygoodsecurity.com/docs/settings/access-credentials) ## Resource Limits ### Data Limits This API allows storing data up to 32MB in size. ### Rate Limiting The API allows up to 3,000 requests per minute. Requests are associated with the vault, regardless of the access credentials used to authenticate the request. Your current rate limit is included as HTTP headers in every API response: | Header Name | Description | |-------------------------|----------------------------------------------------------| | `x-ratelimit-remaining` | The number of requests remaining in the 1-minute window. | If you exceed the rate limit, the API will reject the request with HTTP [429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). ### Errors The API uses standard HTTP status codes to indicate whether the request succeeded or not. In case of failure, the response body will be JSON in a predefined format. For example, trying to create too many aliases at once results in the following response: ```json { \"errors\": [ { \"status\": 400, \"title\": \"Bad request\", \"detail\": \"Too many values (limit: 20)\", \"href\": \"https://api.sandbox.verygoodvault.com/aliases\" } ] } ```
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: support@verygoodsecurity.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.4.0
10
-
11
- =end
12
-
13
- require 'cgi'
14
-
15
- module VgsApiClient
16
- class FunctionsApi
17
- attr_accessor :api_client
18
-
19
- def initialize(api_client = ApiClient.default)
20
- @api_client = api_client
21
- end
22
- # Creates a new function
23
- # Creates a new function.
24
- # @param [Hash] opts the optional parameters
25
- # @option opts [CreateFunctionRequest] :create_function_request
26
- # @return [InlineResponse2002]
27
- def create_function(opts = {})
28
- data, _status_code, _headers = create_function_with_http_info(opts)
29
- data
30
- end
31
-
32
- # Creates a new function
33
- # Creates a new function.
34
- # @param [Hash] opts the optional parameters
35
- # @option opts [CreateFunctionRequest] :create_function_request
36
- # @return [Array<(InlineResponse2002, Integer, Hash)>] InlineResponse2002 data, response status code and response headers
37
- def create_function_with_http_info(opts = {})
38
- if @api_client.config.debugging
39
- @api_client.config.logger.debug 'Calling API: FunctionsApi.create_function ...'
40
- end
41
- # resource path
42
- local_var_path = '/functions'
43
-
44
- # query parameters
45
- query_params = opts[:query_params] || {}
46
-
47
- # header parameters
48
- header_params = opts[:header_params] || {}
49
- # HTTP header 'Accept' (if needed)
50
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
- # HTTP header 'Content-Type'
52
- content_type = @api_client.select_header_content_type(['application/json'])
53
- if !content_type.nil?
54
- header_params['Content-Type'] = content_type
55
- end
56
-
57
- # form parameters
58
- form_params = opts[:form_params] || {}
59
-
60
- # http body (model)
61
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_function_request'])
62
-
63
- # return_type
64
- return_type = opts[:debug_return_type] || 'InlineResponse2002'
65
-
66
- # auth_names
67
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
68
-
69
- new_options = opts.merge(
70
- :operation => :"FunctionsApi.create_function",
71
- :header_params => header_params,
72
- :query_params => query_params,
73
- :form_params => form_params,
74
- :body => post_body,
75
- :auth_names => auth_names,
76
- :return_type => return_type
77
- )
78
-
79
- data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
80
- if @api_client.config.debugging
81
- @api_client.config.logger.debug "API called: FunctionsApi#create_function\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
- end
83
- return data, status_code, headers
84
- end
85
-
86
- # Deletes a function
87
- # Removes a single alias.
88
- # @param function_name [String] Name of function to operate on
89
- # @param [Hash] opts the optional parameters
90
- # @return [nil]
91
- def delete_function(function_name, opts = {})
92
- delete_function_with_http_info(function_name, opts)
93
- nil
94
- end
95
-
96
- # Deletes a function
97
- # Removes a single alias.
98
- # @param function_name [String] Name of function to operate on
99
- # @param [Hash] opts the optional parameters
100
- # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
101
- def delete_function_with_http_info(function_name, opts = {})
102
- if @api_client.config.debugging
103
- @api_client.config.logger.debug 'Calling API: FunctionsApi.delete_function ...'
104
- end
105
- # verify the required parameter 'function_name' is set
106
- if @api_client.config.client_side_validation && function_name.nil?
107
- fail ArgumentError, "Missing the required parameter 'function_name' when calling FunctionsApi.delete_function"
108
- end
109
- # resource path
110
- local_var_path = '/functions/{functionName}'.sub('{' + 'functionName' + '}', CGI.escape(function_name.to_s))
111
-
112
- # query parameters
113
- query_params = opts[:query_params] || {}
114
-
115
- # header parameters
116
- header_params = opts[:header_params] || {}
117
- # HTTP header 'Accept' (if needed)
118
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
119
-
120
- # form parameters
121
- form_params = opts[:form_params] || {}
122
-
123
- # http body (model)
124
- post_body = opts[:debug_body]
125
-
126
- # return_type
127
- return_type = opts[:debug_return_type]
128
-
129
- # auth_names
130
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
131
-
132
- new_options = opts.merge(
133
- :operation => :"FunctionsApi.delete_function",
134
- :header_params => header_params,
135
- :query_params => query_params,
136
- :form_params => form_params,
137
- :body => post_body,
138
- :auth_names => auth_names,
139
- :return_type => return_type
140
- )
141
-
142
- data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
143
- if @api_client.config.debugging
144
- @api_client.config.logger.debug "API called: FunctionsApi#delete_function\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
145
- end
146
- return data, status_code, headers
147
- end
148
-
149
- # Retrieve a single function
150
- # Retrieves a function
151
- # @param function_name [String] Name of function to operate on
152
- # @param [Hash] opts the optional parameters
153
- # @return [InlineResponse2003]
154
- def get_function(function_name, opts = {})
155
- data, _status_code, _headers = get_function_with_http_info(function_name, opts)
156
- data
157
- end
158
-
159
- # Retrieve a single function
160
- # Retrieves a function
161
- # @param function_name [String] Name of function to operate on
162
- # @param [Hash] opts the optional parameters
163
- # @return [Array<(InlineResponse2003, Integer, Hash)>] InlineResponse2003 data, response status code and response headers
164
- def get_function_with_http_info(function_name, opts = {})
165
- if @api_client.config.debugging
166
- @api_client.config.logger.debug 'Calling API: FunctionsApi.get_function ...'
167
- end
168
- # verify the required parameter 'function_name' is set
169
- if @api_client.config.client_side_validation && function_name.nil?
170
- fail ArgumentError, "Missing the required parameter 'function_name' when calling FunctionsApi.get_function"
171
- end
172
- # resource path
173
- local_var_path = '/functions/{functionName}'.sub('{' + 'functionName' + '}', CGI.escape(function_name.to_s))
174
-
175
- # query parameters
176
- query_params = opts[:query_params] || {}
177
-
178
- # header parameters
179
- header_params = opts[:header_params] || {}
180
- # HTTP header 'Accept' (if needed)
181
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
182
-
183
- # form parameters
184
- form_params = opts[:form_params] || {}
185
-
186
- # http body (model)
187
- post_body = opts[:debug_body]
188
-
189
- # return_type
190
- return_type = opts[:debug_return_type] || 'InlineResponse2003'
191
-
192
- # auth_names
193
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
194
-
195
- new_options = opts.merge(
196
- :operation => :"FunctionsApi.get_function",
197
- :header_params => header_params,
198
- :query_params => query_params,
199
- :form_params => form_params,
200
- :body => post_body,
201
- :auth_names => auth_names,
202
- :return_type => return_type
203
- )
204
-
205
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
206
- if @api_client.config.debugging
207
- @api_client.config.logger.debug "API called: FunctionsApi#get_function\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
208
- end
209
- return data, status_code, headers
210
- end
211
-
212
- # Invoke a function
213
- # Invokes a function
214
- # @param function_name [String] Name of function to operate on
215
- # @param [Hash] opts the optional parameters
216
- # @option opts [String] :body
217
- # @return [File]
218
- def invoke_function(function_name, opts = {})
219
- data, _status_code, _headers = invoke_function_with_http_info(function_name, opts)
220
- data
221
- end
222
-
223
- # Invoke a function
224
- # Invokes a function
225
- # @param function_name [String] Name of function to operate on
226
- # @param [Hash] opts the optional parameters
227
- # @option opts [String] :body
228
- # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
229
- def invoke_function_with_http_info(function_name, opts = {})
230
- if @api_client.config.debugging
231
- @api_client.config.logger.debug 'Calling API: FunctionsApi.invoke_function ...'
232
- end
233
- # verify the required parameter 'function_name' is set
234
- if @api_client.config.client_side_validation && function_name.nil?
235
- fail ArgumentError, "Missing the required parameter 'function_name' when calling FunctionsApi.invoke_function"
236
- end
237
- # resource path
238
- local_var_path = '/functions/{functionName}/invocations'.sub('{' + 'functionName' + '}', CGI.escape(function_name.to_s))
239
-
240
- # query parameters
241
- query_params = opts[:query_params] || {}
242
-
243
- # header parameters
244
- header_params = opts[:header_params] || {}
245
- # HTTP header 'Accept' (if needed)
246
- header_params['Accept'] = @api_client.select_header_accept(['*', 'application/http', 'text/plain', 'application/json'])
247
- # HTTP header 'Content-Type'
248
- content_type = @api_client.select_header_content_type(['application/http', 'application/x-www-form-urlencoded', 'text/plain'])
249
- if !content_type.nil?
250
- header_params['Content-Type'] = content_type
251
- end
252
-
253
- # form parameters
254
- form_params = opts[:form_params] || {}
255
-
256
- # http body (model)
257
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])
258
-
259
- # return_type
260
- return_type = opts[:debug_return_type] || 'File'
261
-
262
- # auth_names
263
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
264
-
265
- new_options = opts.merge(
266
- :operation => :"FunctionsApi.invoke_function",
267
- :header_params => header_params,
268
- :query_params => query_params,
269
- :form_params => form_params,
270
- :body => post_body,
271
- :auth_names => auth_names,
272
- :return_type => return_type
273
- )
274
-
275
- data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
276
- if @api_client.config.debugging
277
- @api_client.config.logger.debug "API called: FunctionsApi#invoke_function\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
278
- end
279
- return data, status_code, headers
280
- end
281
-
282
- # Lists all functions
283
- # Lists all functions
284
- # @param [Hash] opts the optional parameters
285
- # @return [InlineResponse2002]
286
- def list_functions(opts = {})
287
- data, _status_code, _headers = list_functions_with_http_info(opts)
288
- data
289
- end
290
-
291
- # Lists all functions
292
- # Lists all functions
293
- # @param [Hash] opts the optional parameters
294
- # @return [Array<(InlineResponse2002, Integer, Hash)>] InlineResponse2002 data, response status code and response headers
295
- def list_functions_with_http_info(opts = {})
296
- if @api_client.config.debugging
297
- @api_client.config.logger.debug 'Calling API: FunctionsApi.list_functions ...'
298
- end
299
- # resource path
300
- local_var_path = '/functions'
301
-
302
- # query parameters
303
- query_params = opts[:query_params] || {}
304
-
305
- # header parameters
306
- header_params = opts[:header_params] || {}
307
- # HTTP header 'Accept' (if needed)
308
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
309
-
310
- # form parameters
311
- form_params = opts[:form_params] || {}
312
-
313
- # http body (model)
314
- post_body = opts[:debug_body]
315
-
316
- # return_type
317
- return_type = opts[:debug_return_type] || 'InlineResponse2002'
318
-
319
- # auth_names
320
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
321
-
322
- new_options = opts.merge(
323
- :operation => :"FunctionsApi.list_functions",
324
- :header_params => header_params,
325
- :query_params => query_params,
326
- :form_params => form_params,
327
- :body => post_body,
328
- :auth_names => auth_names,
329
- :return_type => return_type
330
- )
331
-
332
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
333
- if @api_client.config.debugging
334
- @api_client.config.logger.debug "API called: FunctionsApi#list_functions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
335
- end
336
- return data, status_code, headers
337
- end
338
-
339
- # Update function
340
- # Update an existing function definition
341
- # @param function_name [String] Name of function to operate on
342
- # @param [Hash] opts the optional parameters
343
- # @option opts [UpdateFunctionRequestPayload] :update_function_request_payload
344
- # @return [nil]
345
- def update_function(function_name, opts = {})
346
- update_function_with_http_info(function_name, opts)
347
- nil
348
- end
349
-
350
- # Update function
351
- # Update an existing function definition
352
- # @param function_name [String] Name of function to operate on
353
- # @param [Hash] opts the optional parameters
354
- # @option opts [UpdateFunctionRequestPayload] :update_function_request_payload
355
- # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
356
- def update_function_with_http_info(function_name, opts = {})
357
- if @api_client.config.debugging
358
- @api_client.config.logger.debug 'Calling API: FunctionsApi.update_function ...'
359
- end
360
- # verify the required parameter 'function_name' is set
361
- if @api_client.config.client_side_validation && function_name.nil?
362
- fail ArgumentError, "Missing the required parameter 'function_name' when calling FunctionsApi.update_function"
363
- end
364
- # resource path
365
- local_var_path = '/functions/{functionName}'.sub('{' + 'functionName' + '}', CGI.escape(function_name.to_s))
366
-
367
- # query parameters
368
- query_params = opts[:query_params] || {}
369
-
370
- # header parameters
371
- header_params = opts[:header_params] || {}
372
- # HTTP header 'Accept' (if needed)
373
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
374
- # HTTP header 'Content-Type'
375
- content_type = @api_client.select_header_content_type(['application/json'])
376
- if !content_type.nil?
377
- header_params['Content-Type'] = content_type
378
- end
379
-
380
- # form parameters
381
- form_params = opts[:form_params] || {}
382
-
383
- # http body (model)
384
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'update_function_request_payload'])
385
-
386
- # return_type
387
- return_type = opts[:debug_return_type]
388
-
389
- # auth_names
390
- auth_names = opts[:debug_auth_names] || ['BasicAuth']
391
-
392
- new_options = opts.merge(
393
- :operation => :"FunctionsApi.update_function",
394
- :header_params => header_params,
395
- :query_params => query_params,
396
- :form_params => form_params,
397
- :body => post_body,
398
- :auth_names => auth_names,
399
- :return_type => return_type
400
- )
401
-
402
- data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
403
- if @api_client.config.debugging
404
- @api_client.config.logger.debug "API called: FunctionsApi#update_function\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
405
- end
406
- return data, status_code, headers
407
- end
408
- end
409
- end
@@ -1,253 +0,0 @@
1
- =begin
2
- #Vault HTTP API
3
-
4
- #The VGS Vault HTTP API is used for storing, retrieving, and managing sensitive data (aka Tokenization) within a VGS Vault. The VGS API is organized around REST. Our API is built with a predictable resource-oriented structure, uses JSON-encoded requests and responses, follows standard HTTP verbs/responses, and uses industry standard authentication. ## What is VGS Storing sensitive data on your company’s infrastructure often comes with a heavy compliance burden. For instance, storing payments data yourself greatly increases the amount of work needed to become PCI compliant. It also increases your security risk in general. To combat this, companies will minimize the amount of sensitive information they have to handle or store. VGS provides multiple methods for minimizing the sensitive information that needs to be stored which allows customers to secure any type of data for any use-case. **Tokenization** is a method that focuses on securing the storage of data. This is the quickest way to get started and is free. [Get started with Tokenization](https://www.verygoodsecurity.com/docs/tokenization/getting-started). **Zero Data** is a unique method invented by VGS in 2016 that securely stores data like Tokenization, however it also removes the customer’s environment from PCI scope completely providing maximum security, and minimum compliance scope. [Get started with Zero Data](https://www.verygoodsecurity.com/docs/getting-started/before-you-start). Additionally, for scenarios where neither technology is a complete solution, for instance with legacy systems, VGS provides a compliance product which guarantees customers are able to meet their compliance needs no matter what may happen. [Get started with Control](https://www.verygoodsecurity.com/docs/control). ## Learn about Tokenization - [Create an Account for Free Tokenization](https://dashboard.verygoodsecurity.com/tokenization) - [Try a Tokenization Demo](https://www.verygoodsecurity.com/docs/tokenization/getting-started) - [Install a Tokenization SDK](https://www.verygoodsecurity.com/docs/tokenization/client-libraries) ### Authentication This API uses `Basic` authentication. Credentials to access the API can be generated on the [dashboard](https://dashboard.verygoodsecurity.com) by going to the Settings section of the vault of your choosing. [Docs » Guides » Access credentials](https://www.verygoodsecurity.com/docs/settings/access-credentials) ## Resource Limits ### Data Limits This API allows storing data up to 32MB in size. ### Rate Limiting The API allows up to 3,000 requests per minute. Requests are associated with the vault, regardless of the access credentials used to authenticate the request. Your current rate limit is included as HTTP headers in every API response: | Header Name | Description | |-------------------------|----------------------------------------------------------| | `x-ratelimit-remaining` | The number of requests remaining in the 1-minute window. | If you exceed the rate limit, the API will reject the request with HTTP [429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). ### Errors The API uses standard HTTP status codes to indicate whether the request succeeded or not. In case of failure, the response body will be JSON in a predefined format. For example, trying to create too many aliases at once results in the following response: ```json { \"errors\": [ { \"status\": 400, \"title\": \"Bad request\", \"detail\": \"Too many values (limit: 20)\", \"href\": \"https://api.sandbox.verygoodvault.com/aliases\" } ] } ```
5
-
6
- The version of the OpenAPI document: 1.0.0
7
- Contact: support@verygoodsecurity.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.4.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module VgsApiClient
17
- class CreateFunctionRequest
18
- attr_accessor :data
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :'data' => :'data'
24
- }
25
- end
26
-
27
- # Returns all the JSON keys this model knows about
28
- def self.acceptable_attributes
29
- attribute_map.values
30
- end
31
-
32
- # Attribute type mapping.
33
- def self.openapi_types
34
- {
35
- :'data' => :'Array<OneOfCreateFunctionRequestPayload>'
36
- }
37
- end
38
-
39
- # List of attributes with nullable: true
40
- def self.openapi_nullable
41
- Set.new([
42
- ])
43
- end
44
-
45
- # Initializes the object
46
- # @param [Hash] attributes Model attributes in the form of hash
47
- def initialize(attributes = {})
48
- if (!attributes.is_a?(Hash))
49
- fail ArgumentError, "The input argument (attributes) must be a hash in `VgsApiClient::CreateFunctionRequest` initialize method"
50
- end
51
-
52
- # check to see if the attribute exists and convert string to symbol for hash key
53
- attributes = attributes.each_with_object({}) { |(k, v), h|
54
- if (!self.class.attribute_map.key?(k.to_sym))
55
- fail ArgumentError, "`#{k}` is not a valid attribute in `VgsApiClient::CreateFunctionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
- end
57
- h[k.to_sym] = v
58
- }
59
-
60
- if attributes.key?(:'data')
61
- if (value = attributes[:'data']).is_a?(Array)
62
- self.data = value
63
- end
64
- end
65
- end
66
-
67
- # Show invalid properties with the reasons. Usually used together with valid?
68
- # @return Array for valid properties with the reasons
69
- def list_invalid_properties
70
- invalid_properties = Array.new
71
- if @data.nil?
72
- invalid_properties.push('invalid value for "data", data cannot be nil.')
73
- end
74
-
75
- if @data.length > 20
76
- invalid_properties.push('invalid value for "data", number of items must be less than or equal to 20.')
77
- end
78
-
79
- if @data.length < 1
80
- invalid_properties.push('invalid value for "data", number of items must be greater than or equal to 1.')
81
- end
82
-
83
- invalid_properties
84
- end
85
-
86
- # Check to see if the all the properties in the model are valid
87
- # @return true if the model is valid
88
- def valid?
89
- return false if @data.nil?
90
- return false if @data.length > 20
91
- return false if @data.length < 1
92
- true
93
- end
94
-
95
- # Custom attribute writer method with validation
96
- # @param [Object] data Value to be assigned
97
- def data=(data)
98
- if data.nil?
99
- fail ArgumentError, 'data cannot be nil'
100
- end
101
-
102
- if data.length > 20
103
- fail ArgumentError, 'invalid value for "data", number of items must be less than or equal to 20.'
104
- end
105
-
106
- if data.length < 1
107
- fail ArgumentError, 'invalid value for "data", number of items must be greater than or equal to 1.'
108
- end
109
-
110
- @data = data
111
- end
112
-
113
- # Checks equality by comparing each attribute.
114
- # @param [Object] Object to be compared
115
- def ==(o)
116
- return true if self.equal?(o)
117
- self.class == o.class &&
118
- data == o.data
119
- end
120
-
121
- # @see the `==` method
122
- # @param [Object] Object to be compared
123
- def eql?(o)
124
- self == o
125
- end
126
-
127
- # Calculates hash code according to all attributes.
128
- # @return [Integer] Hash code
129
- def hash
130
- [data].hash
131
- end
132
-
133
- # Builds the object from hash
134
- # @param [Hash] attributes Model attributes in the form of hash
135
- # @return [Object] Returns the model itself
136
- def self.build_from_hash(attributes)
137
- new.build_from_hash(attributes)
138
- end
139
-
140
- # Builds the object from hash
141
- # @param [Hash] attributes Model attributes in the form of hash
142
- # @return [Object] Returns the model itself
143
- def build_from_hash(attributes)
144
- return nil unless attributes.is_a?(Hash)
145
- self.class.openapi_types.each_pair do |key, type|
146
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
147
- self.send("#{key}=", nil)
148
- elsif type =~ /\AArray<(.*)>/i
149
- # check to ensure the input is an array given that the attribute
150
- # is documented as an array but the input is not
151
- if attributes[self.class.attribute_map[key]].is_a?(Array)
152
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
153
- end
154
- elsif !attributes[self.class.attribute_map[key]].nil?
155
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
156
- end
157
- end
158
-
159
- self
160
- end
161
-
162
- # Deserializes the data based on type
163
- # @param string type Data type
164
- # @param string value Value to be deserialized
165
- # @return [Object] Deserialized data
166
- def _deserialize(type, value)
167
- case type.to_sym
168
- when :Time
169
- Time.parse(value)
170
- when :Date
171
- Date.parse(value)
172
- when :String
173
- value.to_s
174
- when :Integer
175
- value.to_i
176
- when :Float
177
- value.to_f
178
- when :Boolean
179
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
180
- true
181
- else
182
- false
183
- end
184
- when :Object
185
- # generic object (usually a Hash), return directly
186
- value
187
- when /\AArray<(?<inner_type>.+)>\z/
188
- inner_type = Regexp.last_match[:inner_type]
189
- value.map { |v| _deserialize(inner_type, v) }
190
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
191
- k_type = Regexp.last_match[:k_type]
192
- v_type = Regexp.last_match[:v_type]
193
- {}.tap do |hash|
194
- value.each do |k, v|
195
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
196
- end
197
- end
198
- else # model
199
- # models (e.g. Pet) or oneOf
200
- klass = VgsApiClient.const_get(type)
201
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
202
- end
203
- end
204
-
205
- # Returns the string representation of the object
206
- # @return [String] String presentation of the object
207
- def to_s
208
- to_hash.to_s
209
- end
210
-
211
- # to_body is an alias to to_hash (backward compatibility)
212
- # @return [Hash] Returns the object in the form of hash
213
- def to_body
214
- to_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
- # Outputs non-array value in the form of hash
234
- # For object, use to_hash. Otherwise, just return the value
235
- # @param [Object] value Any valid value
236
- # @return [Hash] Returns the value in the form of hash
237
- def _to_hash(value)
238
- if value.is_a?(Array)
239
- value.compact.map { |v| _to_hash(v) }
240
- elsif value.is_a?(Hash)
241
- {}.tap do |hash|
242
- value.each { |k, v| hash[k] = _to_hash(v) }
243
- end
244
- elsif value.respond_to? :to_hash
245
- value.to_hash
246
- else
247
- value
248
- end
249
- end
250
-
251
- end
252
-
253
- end