forestvpn_cloud_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +139 -0
  4. data/Rakefile +10 -0
  5. data/docs/Action.md +32 -0
  6. data/docs/Activity.md +36 -0
  7. data/docs/Address.md +28 -0
  8. data/docs/Billing.md +24 -0
  9. data/docs/Country.md +26 -0
  10. data/docs/CreateBillingRequest.md +22 -0
  11. data/docs/CreateOrUpdateDataUsageLimitRequest.md +20 -0
  12. data/docs/CreateOrUpdatePaymentProfileRequest.md +34 -0
  13. data/docs/CreateOrUpdateProfileRequest.md +22 -0
  14. data/docs/DataUsageLimit.md +24 -0
  15. data/docs/Error.md +20 -0
  16. data/docs/GeoApi.md +77 -0
  17. data/docs/LimitsApi.md +447 -0
  18. data/docs/Location.md +28 -0
  19. data/docs/PaymentMethod.md +24 -0
  20. data/docs/PaymentProfile.md +32 -0
  21. data/docs/Profile.md +26 -0
  22. data/docs/ProfileStats.md +26 -0
  23. data/docs/ProfilesApi.md +996 -0
  24. data/docs/Project.md +22 -0
  25. data/docs/ResourceRef.md +20 -0
  26. data/docs/User.md +32 -0
  27. data/forestvpn_cloud_api.gemspec +39 -0
  28. data/git_push.sh +57 -0
  29. data/lib/forestvpn_cloud_api/api/geo_api.rb +77 -0
  30. data/lib/forestvpn_cloud_api/api/limits_api.rb +405 -0
  31. data/lib/forestvpn_cloud_api/api/profiles_api.rb +915 -0
  32. data/lib/forestvpn_cloud_api/api_client.rb +426 -0
  33. data/lib/forestvpn_cloud_api/api_error.rb +57 -0
  34. data/lib/forestvpn_cloud_api/configuration.rb +335 -0
  35. data/lib/forestvpn_cloud_api/models/action.rb +348 -0
  36. data/lib/forestvpn_cloud_api/models/activity.rb +360 -0
  37. data/lib/forestvpn_cloud_api/models/address.rb +269 -0
  38. data/lib/forestvpn_cloud_api/models/billing.rb +266 -0
  39. data/lib/forestvpn_cloud_api/models/country.rb +282 -0
  40. data/lib/forestvpn_cloud_api/models/create_billing_request.rb +252 -0
  41. data/lib/forestvpn_cloud_api/models/create_or_update_data_usage_limit_request.rb +230 -0
  42. data/lib/forestvpn_cloud_api/models/create_or_update_payment_profile_request.rb +328 -0
  43. data/lib/forestvpn_cloud_api/models/create_or_update_profile_request.rb +275 -0
  44. data/lib/forestvpn_cloud_api/models/data_usage_limit.rb +302 -0
  45. data/lib/forestvpn_cloud_api/models/error.rb +238 -0
  46. data/lib/forestvpn_cloud_api/models/location.rb +296 -0
  47. data/lib/forestvpn_cloud_api/models/payment_method.rb +261 -0
  48. data/lib/forestvpn_cloud_api/models/payment_profile.rb +313 -0
  49. data/lib/forestvpn_cloud_api/models/profile.rb +320 -0
  50. data/lib/forestvpn_cloud_api/models/profile_stats.rb +280 -0
  51. data/lib/forestvpn_cloud_api/models/project.rb +254 -0
  52. data/lib/forestvpn_cloud_api/models/resource_ref.rb +238 -0
  53. data/lib/forestvpn_cloud_api/models/user.rb +307 -0
  54. data/lib/forestvpn_cloud_api/version.rb +15 -0
  55. data/lib/forestvpn_cloud_api.rb +61 -0
  56. data/spec/api/geo_api_spec.rb +45 -0
  57. data/spec/api/limits_api_spec.rb +102 -0
  58. data/spec/api/profiles_api_spec.rb +195 -0
  59. data/spec/api_client_spec.rb +188 -0
  60. data/spec/configuration_spec.rb +42 -0
  61. data/spec/models/action_spec.rb +80 -0
  62. data/spec/models/activity_spec.rb +92 -0
  63. data/spec/models/address_spec.rb +64 -0
  64. data/spec/models/billing_spec.rb +52 -0
  65. data/spec/models/country_spec.rb +58 -0
  66. data/spec/models/create_billing_request_spec.rb +46 -0
  67. data/spec/models/create_or_update_data_usage_limit_request_spec.rb +40 -0
  68. data/spec/models/create_or_update_payment_profile_request_spec.rb +82 -0
  69. data/spec/models/create_or_update_profile_request_spec.rb +50 -0
  70. data/spec/models/data_usage_limit_spec.rb +56 -0
  71. data/spec/models/error_spec.rb +40 -0
  72. data/spec/models/location_spec.rb +64 -0
  73. data/spec/models/payment_method_spec.rb +52 -0
  74. data/spec/models/payment_profile_spec.rb +76 -0
  75. data/spec/models/profile_spec.rb +62 -0
  76. data/spec/models/profile_stats_spec.rb +58 -0
  77. data/spec/models/project_spec.rb +46 -0
  78. data/spec/models/resource_ref_spec.rb +40 -0
  79. data/spec/models/user_spec.rb +76 -0
  80. data/spec/spec_helper.rb +111 -0
  81. metadata +203 -0
@@ -0,0 +1,360 @@
1
+ =begin
2
+ #ForestVPN Cloud API
3
+
4
+ #ForestVPN Cloud - it's a Google Cloud but for VPN apps. Ready to use VPN Cloud Platform minimizes efforts to build fast, secure, and modern VPN apps.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: support@forestvpn.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ForestVPNCloudAPI
17
+ class Activity
18
+ attr_accessor :id
19
+
20
+ attr_accessor :action_type
21
+
22
+ attr_accessor :resource_type
23
+
24
+ attr_accessor :user
25
+
26
+ attr_accessor :api_token
27
+
28
+ attr_accessor :project
29
+
30
+ # Source IP Address. Last 3 digits is hidden by security reason.
31
+ attr_accessor :source_ip
32
+
33
+ attr_accessor :status
34
+
35
+ attr_accessor :created_at
36
+
37
+ attr_accessor :finished_at
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'id' => :'id',
65
+ :'action_type' => :'action_type',
66
+ :'resource_type' => :'resource_type',
67
+ :'user' => :'user',
68
+ :'api_token' => :'api_token',
69
+ :'project' => :'project',
70
+ :'source_ip' => :'source_ip',
71
+ :'status' => :'status',
72
+ :'created_at' => :'created_at',
73
+ :'finished_at' => :'finished_at'
74
+ }
75
+ end
76
+
77
+ # Returns all the JSON keys this model knows about
78
+ def self.acceptable_attributes
79
+ attribute_map.values
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'id' => :'String',
86
+ :'action_type' => :'String',
87
+ :'resource_type' => :'String',
88
+ :'user' => :'User',
89
+ :'api_token' => :'String',
90
+ :'project' => :'Project',
91
+ :'source_ip' => :'String',
92
+ :'status' => :'String',
93
+ :'created_at' => :'Time',
94
+ :'finished_at' => :'Time'
95
+ }
96
+ end
97
+
98
+ # List of attributes with nullable: true
99
+ def self.openapi_nullable
100
+ Set.new([
101
+ ])
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ if (!attributes.is_a?(Hash))
108
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ForestVPNCloudAPI::Activity` initialize method"
109
+ end
110
+
111
+ # check to see if the attribute exists and convert string to symbol for hash key
112
+ attributes = attributes.each_with_object({}) { |(k, v), h|
113
+ if (!self.class.attribute_map.key?(k.to_sym))
114
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ForestVPNCloudAPI::Activity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
115
+ end
116
+ h[k.to_sym] = v
117
+ }
118
+
119
+ if attributes.key?(:'id')
120
+ self.id = attributes[:'id']
121
+ end
122
+
123
+ if attributes.key?(:'action_type')
124
+ self.action_type = attributes[:'action_type']
125
+ end
126
+
127
+ if attributes.key?(:'resource_type')
128
+ self.resource_type = attributes[:'resource_type']
129
+ end
130
+
131
+ if attributes.key?(:'user')
132
+ self.user = attributes[:'user']
133
+ end
134
+
135
+ if attributes.key?(:'api_token')
136
+ self.api_token = attributes[:'api_token']
137
+ end
138
+
139
+ if attributes.key?(:'project')
140
+ self.project = attributes[:'project']
141
+ end
142
+
143
+ if attributes.key?(:'source_ip')
144
+ self.source_ip = attributes[:'source_ip']
145
+ end
146
+
147
+ if attributes.key?(:'status')
148
+ self.status = attributes[:'status']
149
+ end
150
+
151
+ if attributes.key?(:'created_at')
152
+ self.created_at = attributes[:'created_at']
153
+ end
154
+
155
+ if attributes.key?(:'finished_at')
156
+ self.finished_at = attributes[:'finished_at']
157
+ end
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def list_invalid_properties
163
+ invalid_properties = Array.new
164
+ if @id.nil?
165
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
166
+ end
167
+
168
+ if @resource_type.nil?
169
+ invalid_properties.push('invalid value for "resource_type", resource_type cannot be nil.')
170
+ end
171
+
172
+ if @source_ip.nil?
173
+ invalid_properties.push('invalid value for "source_ip", source_ip cannot be nil.')
174
+ end
175
+
176
+ if @status.nil?
177
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
178
+ end
179
+
180
+ if @created_at.nil?
181
+ invalid_properties.push('invalid value for "created_at", created_at 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
+ return false if @id.nil?
191
+ return false if @resource_type.nil?
192
+ return false if @source_ip.nil?
193
+ return false if @status.nil?
194
+ status_validator = EnumAttributeValidator.new('String', ["running", "failed", "success"])
195
+ return false unless status_validator.valid?(@status)
196
+ return false if @created_at.nil?
197
+ true
198
+ end
199
+
200
+ # Custom attribute writer method checking allowed values (enum).
201
+ # @param [Object] status Object to be assigned
202
+ def status=(status)
203
+ validator = EnumAttributeValidator.new('String', ["running", "failed", "success"])
204
+ unless validator.valid?(status)
205
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
206
+ end
207
+ @status = status
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ id == o.id &&
216
+ action_type == o.action_type &&
217
+ resource_type == o.resource_type &&
218
+ user == o.user &&
219
+ api_token == o.api_token &&
220
+ project == o.project &&
221
+ source_ip == o.source_ip &&
222
+ status == o.status &&
223
+ created_at == o.created_at &&
224
+ finished_at == o.finished_at
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [id, action_type, resource_type, user, api_token, project, source_ip, status, created_at, finished_at].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ new.build_from_hash(attributes)
244
+ end
245
+
246
+ # Builds the object from hash
247
+ # @param [Hash] attributes Model attributes in the form of hash
248
+ # @return [Object] Returns the model itself
249
+ def build_from_hash(attributes)
250
+ return nil unless attributes.is_a?(Hash)
251
+ attributes = attributes.transform_keys(&:to_sym)
252
+ self.class.openapi_types.each_pair do |key, type|
253
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
254
+ self.send("#{key}=", nil)
255
+ elsif type =~ /\AArray<(.*)>/i
256
+ # check to ensure the input is an array given that the attribute
257
+ # is documented as an array but the input is not
258
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
259
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
260
+ end
261
+ elsif !attributes[self.class.attribute_map[key]].nil?
262
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
263
+ end
264
+ end
265
+
266
+ self
267
+ end
268
+
269
+ # Deserializes the data based on type
270
+ # @param string type Data type
271
+ # @param string value Value to be deserialized
272
+ # @return [Object] Deserialized data
273
+ def _deserialize(type, value)
274
+ case type.to_sym
275
+ when :Time
276
+ Time.parse(value)
277
+ when :Date
278
+ Date.parse(value)
279
+ when :String
280
+ value.to_s
281
+ when :Integer
282
+ value.to_i
283
+ when :Float
284
+ value.to_f
285
+ when :Boolean
286
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
287
+ true
288
+ else
289
+ false
290
+ end
291
+ when :Object
292
+ # generic object (usually a Hash), return directly
293
+ value
294
+ when /\AArray<(?<inner_type>.+)>\z/
295
+ inner_type = Regexp.last_match[:inner_type]
296
+ value.map { |v| _deserialize(inner_type, v) }
297
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
298
+ k_type = Regexp.last_match[:k_type]
299
+ v_type = Regexp.last_match[:v_type]
300
+ {}.tap do |hash|
301
+ value.each do |k, v|
302
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
303
+ end
304
+ end
305
+ else # model
306
+ # models (e.g. Pet) or oneOf
307
+ klass = ForestVPNCloudAPI.const_get(type)
308
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
309
+ end
310
+ end
311
+
312
+ # Returns the string representation of the object
313
+ # @return [String] String presentation of the object
314
+ def to_s
315
+ to_hash.to_s
316
+ end
317
+
318
+ # to_body is an alias to to_hash (backward compatibility)
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_body
321
+ to_hash
322
+ end
323
+
324
+ # Returns the object in the form of hash
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_hash
327
+ hash = {}
328
+ self.class.attribute_map.each_pair do |attr, param|
329
+ value = self.send(attr)
330
+ if value.nil?
331
+ is_nullable = self.class.openapi_nullable.include?(attr)
332
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
333
+ end
334
+
335
+ hash[param] = _to_hash(value)
336
+ end
337
+ hash
338
+ end
339
+
340
+ # Outputs non-array value in the form of hash
341
+ # For object, use to_hash. Otherwise, just return the value
342
+ # @param [Object] value Any valid value
343
+ # @return [Hash] Returns the value in the form of hash
344
+ def _to_hash(value)
345
+ if value.is_a?(Array)
346
+ value.compact.map { |v| _to_hash(v) }
347
+ elsif value.is_a?(Hash)
348
+ {}.tap do |hash|
349
+ value.each { |k, v| hash[k] = _to_hash(v) }
350
+ end
351
+ elsif value.respond_to? :to_hash
352
+ value.to_hash
353
+ else
354
+ value
355
+ end
356
+ end
357
+
358
+ end
359
+
360
+ end
@@ -0,0 +1,269 @@
1
+ =begin
2
+ #ForestVPN Cloud API
3
+
4
+ #ForestVPN Cloud - it's a Google Cloud but for VPN apps. Ready to use VPN Cloud Platform minimizes efforts to build fast, secure, and modern VPN apps.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+ Contact: support@forestvpn.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ForestVPNCloudAPI
17
+ class Address
18
+ # City, district, suburb, town, or village.
19
+ attr_accessor :city
20
+
21
+ attr_accessor :country
22
+
23
+ # Address line 1 (e.g., street, PO Box, or company name).
24
+ attr_accessor :line1
25
+
26
+ # Address line 2 (e.g., apartment, suite, unit, or building).
27
+ attr_accessor :line2
28
+
29
+ # ZIP or postal code.
30
+ attr_accessor :postal_code
31
+
32
+ # State, county, province, or region.
33
+ attr_accessor :state
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'city' => :'city',
39
+ :'country' => :'country',
40
+ :'line1' => :'line1',
41
+ :'line2' => :'line2',
42
+ :'postal_code' => :'postal_code',
43
+ :'state' => :'state'
44
+ }
45
+ end
46
+
47
+ # Returns all the JSON keys this model knows about
48
+ def self.acceptable_attributes
49
+ attribute_map.values
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'city' => :'String',
56
+ :'country' => :'Country',
57
+ :'line1' => :'String',
58
+ :'line2' => :'String',
59
+ :'postal_code' => :'String',
60
+ :'state' => :'String'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ ])
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ForestVPNCloudAPI::Address` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ForestVPNCloudAPI::Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'city')
86
+ self.city = attributes[:'city']
87
+ end
88
+
89
+ if attributes.key?(:'country')
90
+ self.country = attributes[:'country']
91
+ end
92
+
93
+ if attributes.key?(:'line1')
94
+ self.line1 = attributes[:'line1']
95
+ end
96
+
97
+ if attributes.key?(:'line2')
98
+ self.line2 = attributes[:'line2']
99
+ end
100
+
101
+ if attributes.key?(:'postal_code')
102
+ self.postal_code = attributes[:'postal_code']
103
+ end
104
+
105
+ if attributes.key?(:'state')
106
+ self.state = attributes[:'state']
107
+ end
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properties with the reasons
112
+ def list_invalid_properties
113
+ invalid_properties = Array.new
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ true
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ city == o.city &&
129
+ country == o.country &&
130
+ line1 == o.line1 &&
131
+ line2 == o.line2 &&
132
+ postal_code == o.postal_code &&
133
+ state == o.state
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(o)
139
+ self == o
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Integer] Hash code
144
+ def hash
145
+ [city, country, line1, line2, postal_code, state].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def self.build_from_hash(attributes)
152
+ new.build_from_hash(attributes)
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ attributes = attributes.transform_keys(&:to_sym)
161
+ self.class.openapi_types.each_pair do |key, type|
162
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
163
+ self.send("#{key}=", nil)
164
+ elsif type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
168
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
169
+ end
170
+ elsif !attributes[self.class.attribute_map[key]].nil?
171
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
172
+ end
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def _deserialize(type, value)
183
+ case type.to_sym
184
+ when :Time
185
+ Time.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ # models (e.g. Pet) or oneOf
216
+ klass = ForestVPNCloudAPI.const_get(type)
217
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
218
+ end
219
+ end
220
+
221
+ # Returns the string representation of the object
222
+ # @return [String] String presentation of the object
223
+ def to_s
224
+ to_hash.to_s
225
+ end
226
+
227
+ # to_body is an alias to to_hash (backward compatibility)
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_body
230
+ to_hash
231
+ end
232
+
233
+ # Returns the object in the form of hash
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_hash
236
+ hash = {}
237
+ self.class.attribute_map.each_pair do |attr, param|
238
+ value = self.send(attr)
239
+ if value.nil?
240
+ is_nullable = self.class.openapi_nullable.include?(attr)
241
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
242
+ end
243
+
244
+ hash[param] = _to_hash(value)
245
+ end
246
+ hash
247
+ end
248
+
249
+ # Outputs non-array value in the form of hash
250
+ # For object, use to_hash. Otherwise, just return the value
251
+ # @param [Object] value Any valid value
252
+ # @return [Hash] Returns the value in the form of hash
253
+ def _to_hash(value)
254
+ if value.is_a?(Array)
255
+ value.compact.map { |v| _to_hash(v) }
256
+ elsif value.is_a?(Hash)
257
+ {}.tap do |hash|
258
+ value.each { |k, v| hash[k] = _to_hash(v) }
259
+ end
260
+ elsif value.respond_to? :to_hash
261
+ value.to_hash
262
+ else
263
+ value
264
+ end
265
+ end
266
+
267
+ end
268
+
269
+ end