authress-sdk 0.1.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/lib/swagger_client.rb +30 -0
  3. data/lib/swagger_client/api/access_records_api.rb +541 -0
  4. data/lib/swagger_client/api/accounts_api.rb +232 -0
  5. data/lib/swagger_client/api/metadata_api.rb +152 -0
  6. data/lib/swagger_client/api/resource_permissions_api.rb +250 -0
  7. data/lib/swagger_client/api/roles_api.rb +252 -0
  8. data/lib/swagger_client/api/service_clients_api.rb +418 -0
  9. data/lib/swagger_client/api/user_permissions_api.rb +340 -0
  10. data/lib/swagger_client/api_client.rb +388 -0
  11. data/lib/swagger_client/api_error.rb +57 -0
  12. data/lib/swagger_client/configuration.rb +205 -0
  13. data/lib/swagger_client/models/access_record.rb +351 -0
  14. data/lib/swagger_client/models/access_record_collection.rb +229 -0
  15. data/lib/swagger_client/models/access_record_collection_records.rb +351 -0
  16. data/lib/swagger_client/models/account.rb +268 -0
  17. data/lib/swagger_client/models/account_collection.rb +211 -0
  18. data/lib/swagger_client/models/account_collection_accounts.rb +268 -0
  19. data/lib/swagger_client/models/body.rb +236 -0
  20. data/lib/swagger_client/models/body_1.rb +229 -0
  21. data/lib/swagger_client/models/body_10.rb +246 -0
  22. data/lib/swagger_client/models/body_11.rb +246 -0
  23. data/lib/swagger_client/models/body_2.rb +213 -0
  24. data/lib/swagger_client/models/body_3.rb +351 -0
  25. data/lib/swagger_client/models/body_4.rb +351 -0
  26. data/lib/swagger_client/models/body_5.rb +225 -0
  27. data/lib/swagger_client/models/body_6.rb +255 -0
  28. data/lib/swagger_client/models/body_7.rb +255 -0
  29. data/lib/swagger_client/models/body_8.rb +227 -0
  30. data/lib/swagger_client/models/body_9.rb +223 -0
  31. data/lib/swagger_client/models/claim_request.rb +227 -0
  32. data/lib/swagger_client/models/claim_response.rb +197 -0
  33. data/lib/swagger_client/models/client.rb +246 -0
  34. data/lib/swagger_client/models/client_access_key.rb +242 -0
  35. data/lib/swagger_client/models/client_collection.rb +229 -0
  36. data/lib/swagger_client/models/client_collection_clients.rb +246 -0
  37. data/lib/swagger_client/models/identity.rb +228 -0
  38. data/lib/swagger_client/models/identity_collection.rb +213 -0
  39. data/lib/swagger_client/models/identity_collection_identities.rb +228 -0
  40. data/lib/swagger_client/models/identity_request.rb +223 -0
  41. data/lib/swagger_client/models/inline_response_200.rb +247 -0
  42. data/lib/swagger_client/models/inline_response_200_1.rb +236 -0
  43. data/lib/swagger_client/models/inline_response_200_10.rb +255 -0
  44. data/lib/swagger_client/models/inline_response_200_11.rb +211 -0
  45. data/lib/swagger_client/models/inline_response_200_12.rb +213 -0
  46. data/lib/swagger_client/models/inline_response_200_13.rb +229 -0
  47. data/lib/swagger_client/models/inline_response_200_14.rb +246 -0
  48. data/lib/swagger_client/models/inline_response_200_15.rb +242 -0
  49. data/lib/swagger_client/models/inline_response_200_2.rb +238 -0
  50. data/lib/swagger_client/models/inline_response_200_3.rb +260 -0
  51. data/lib/swagger_client/models/inline_response_200_4.rb +228 -0
  52. data/lib/swagger_client/models/inline_response_200_5.rb +213 -0
  53. data/lib/swagger_client/models/inline_response_200_6.rb +229 -0
  54. data/lib/swagger_client/models/inline_response_200_7.rb +229 -0
  55. data/lib/swagger_client/models/inline_response_200_8.rb +351 -0
  56. data/lib/swagger_client/models/inline_response_200_9.rb +268 -0
  57. data/lib/swagger_client/models/invite.rb +225 -0
  58. data/lib/swagger_client/models/link.rb +223 -0
  59. data/lib/swagger_client/models/metadata_object.rb +236 -0
  60. data/lib/swagger_client/models/permission_object.rb +258 -0
  61. data/lib/swagger_client/models/permission_response.rb +238 -0
  62. data/lib/swagger_client/models/resource_permission.rb +213 -0
  63. data/lib/swagger_client/models/resource_permission_collection.rb +228 -0
  64. data/lib/swagger_client/models/resource_permission_collection_links.rb +220 -0
  65. data/lib/swagger_client/models/resource_permission_collection_links_next.rb +223 -0
  66. data/lib/swagger_client/models/resource_permission_collection_resources.rb +213 -0
  67. data/lib/swagger_client/models/resource_users_collection.rb +229 -0
  68. data/lib/swagger_client/models/role.rb +255 -0
  69. data/lib/swagger_client/models/statement.rb +229 -0
  70. data/lib/swagger_client/models/token_request.rb +229 -0
  71. data/lib/swagger_client/models/user.rb +212 -0
  72. data/lib/swagger_client/models/user_resources.rb +247 -0
  73. data/lib/swagger_client/models/user_resources_resources.rb +207 -0
  74. data/lib/swagger_client/models/user_token.rb +260 -0
  75. data/lib/swagger_client/models/user_token_links.rb +211 -0
  76. data/lib/swagger_client/models/user_token_links_self.rb +223 -0
  77. data/lib/swagger_client/models/v1clients_options.rb +218 -0
  78. data/lib/swagger_client/models/v1records_account.rb +211 -0
  79. data/lib/swagger_client/models/v1records_links.rb +211 -0
  80. data/lib/swagger_client/models/v1records_links_self.rb +223 -0
  81. data/lib/swagger_client/models/v1records_users.rb +212 -0
  82. data/lib/swagger_client/models/v1resourcesresource_uri_permissions.rb +259 -0
  83. data/lib/swagger_client/models/v1roles_permissions.rb +258 -0
  84. data/lib/swagger_client/models/v1usersuser_idresourcesresource_urimetadata_account.rb +206 -0
  85. data/lib/swagger_client/models/v1usersuser_idtokens_resources.rb +212 -0
  86. data/lib/swagger_client/models/v1usersuser_idtokens_statements.rb +229 -0
  87. data/lib/swagger_client/version.rb +14 -0
  88. metadata +313 -0
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #Authress
3
+
4
+ #<p> <h2>Authorization</h2> <p>Authorization for Authress is handled one of two different ways. Both mechanisms use oauth2 <i>Bearer</i> tokens.</p> <br> <h4>Identity Provider JWT</h4> <p>Hook up your preferred identity provider directly to Authress. Authress will verify JWTs sourced from that identify provider and allow direct integration with these APIs. Any OIDC JWT provider works, Google, Auth0, Okta, etc... With this mechanism your web app can make direct calls to the permissions API on behalf of your users. <br> <a href=\"https://authress.io/app/#/manage?focus=identity\">Link identity provider</a> </p> <br> <h4>Authress Clients</h4> <p>Regardless of using direct identity provider integration, with the API you can create Authress clients which can call any of the methods on the API. Your users won't be able to directly make API calls, all web app integrations must go through a service which stores the Authress private key. <br> <a href=\"https://authress.io/app/#/manage?focus=clients\">Create Authress service client</a> </p> <br> <h2>Usage</h2> <h4>Billable APIs</h4> <p>Most of the api available is completely free. Use it to populate your roles and configure your account. You'll only be charged for the ones marked as Billable.</p> <p><ul> <li><i class=\"far fa-fw fa-money-bill-alt text-primary\"></i> <span class=\"text-primary\">Billable</span> - <small>These APIs count as calls for your account and will be charged.</small></li> <li><i class=\"fas fa-fw fa-angle-double-right text-secondary\"></i> <span class=\"text-secondary\">Free</span> - <small>These are totally free.</small></li> <li><i class=\"fas fa-fw fa-balance-scale text-secondary\"></i> <span class=\"text-secondary\">Condition</span> - <small>Are conditionally free, see api methods for details.</small></li> </ul></p> <br> <h4>API Access</h4> <p>Access to the following APIs is based on Authress permissions, not the application permissions assigned in Authress to the application services. Each resource is tagged with the required permission <span class=\"badge badge-outline-secondary\">Action: Resource</span> </p>
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: support@authress.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.23
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SwaggerClient
15
+ # The collective action and associate grants on a permission
16
+ class PermissionObject
17
+ # The action the permission grants, can be scoped using `:` and parent actions imply sub-resource permissions, action:* or action implies action:sub-action. This property is case-insensitive, it will always be cast to lowercase before comparing actions to user permissions.
18
+ attr_accessor :action
19
+
20
+ # Does this permission grant the user the ability to execute the action?
21
+ attr_accessor :allow
22
+
23
+ # Allows the user to give the permission to others without being able to execute the action.
24
+ attr_accessor :grant
25
+
26
+ # Allows delegating or granting the permission to others without being able to execute tha action.
27
+ attr_accessor :delegate
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'action' => :'action',
33
+ :'allow' => :'allow',
34
+ :'grant' => :'grant',
35
+ :'delegate' => :'delegate'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'action' => :'Object',
43
+ :'allow' => :'Object',
44
+ :'grant' => :'Object',
45
+ :'delegate' => :'Object'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerClient::PermissionObject` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerClient::PermissionObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'action')
71
+ self.action = attributes[:'action']
72
+ end
73
+
74
+ if attributes.key?(:'allow')
75
+ self.allow = attributes[:'allow']
76
+ end
77
+
78
+ if attributes.key?(:'grant')
79
+ self.grant = attributes[:'grant']
80
+ end
81
+
82
+ if attributes.key?(:'delegate')
83
+ self.delegate = attributes[:'delegate']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ if @action.nil?
92
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
93
+ end
94
+
95
+ if @allow.nil?
96
+ invalid_properties.push('invalid value for "allow", allow cannot be nil.')
97
+ end
98
+
99
+ if @grant.nil?
100
+ invalid_properties.push('invalid value for "grant", grant cannot be nil.')
101
+ end
102
+
103
+ if @delegate.nil?
104
+ invalid_properties.push('invalid value for "delegate", delegate cannot be nil.')
105
+ end
106
+
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ return false if @action.nil?
114
+ return false if @allow.nil?
115
+ return false if @grant.nil?
116
+ return false if @delegate.nil?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ action == o.action &&
126
+ allow == o.allow &&
127
+ grant == o.grant &&
128
+ delegate == o.delegate
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [action, allow, grant, delegate].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ new.build_from_hash(attributes)
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def build_from_hash(attributes)
154
+ return nil unless attributes.is_a?(Hash)
155
+ self.class.openapi_types.each_pair do |key, type|
156
+ if type =~ /\AArray<(.*)>/i
157
+ # check to ensure the input is an array given that the attribute
158
+ # is documented as an array but the input is not
159
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
160
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
161
+ end
162
+ elsif !attributes[self.class.attribute_map[key]].nil?
163
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
164
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
165
+ self.send("#{key}=", nil)
166
+ end
167
+ end
168
+
169
+ self
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def _deserialize(type, value)
177
+ case type.to_sym
178
+ when :DateTime
179
+ DateTime.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :Boolean
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ SwaggerClient.const_get(type).build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end end
258
+ end
@@ -0,0 +1,238 @@
1
+ =begin
2
+ #Authress
3
+
4
+ #<p> <h2>Authorization</h2> <p>Authorization for Authress is handled one of two different ways. Both mechanisms use oauth2 <i>Bearer</i> tokens.</p> <br> <h4>Identity Provider JWT</h4> <p>Hook up your preferred identity provider directly to Authress. Authress will verify JWTs sourced from that identify provider and allow direct integration with these APIs. Any OIDC JWT provider works, Google, Auth0, Okta, etc... With this mechanism your web app can make direct calls to the permissions API on behalf of your users. <br> <a href=\"https://authress.io/app/#/manage?focus=identity\">Link identity provider</a> </p> <br> <h4>Authress Clients</h4> <p>Regardless of using direct identity provider integration, with the API you can create Authress clients which can call any of the methods on the API. Your users won't be able to directly make API calls, all web app integrations must go through a service which stores the Authress private key. <br> <a href=\"https://authress.io/app/#/manage?focus=clients\">Create Authress service client</a> </p> <br> <h2>Usage</h2> <h4>Billable APIs</h4> <p>Most of the api available is completely free. Use it to populate your roles and configure your account. You'll only be charged for the ones marked as Billable.</p> <p><ul> <li><i class=\"far fa-fw fa-money-bill-alt text-primary\"></i> <span class=\"text-primary\">Billable</span> - <small>These APIs count as calls for your account and will be charged.</small></li> <li><i class=\"fas fa-fw fa-angle-double-right text-secondary\"></i> <span class=\"text-secondary\">Free</span> - <small>These are totally free.</small></li> <li><i class=\"fas fa-fw fa-balance-scale text-secondary\"></i> <span class=\"text-secondary\">Condition</span> - <small>Are conditionally free, see api methods for details.</small></li> </ul></p> <br> <h4>API Access</h4> <p>Access to the following APIs is based on Authress permissions, not the application permissions assigned in Authress to the application services. Each resource is tagged with the required permission <span class=\"badge badge-outline-secondary\">Action: Resource</span> </p>
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: support@authress.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.23
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SwaggerClient
15
+ # A collect of permissions that the user has to a resource.
16
+ class PermissionResponse
17
+ attr_accessor :account
18
+
19
+ attr_accessor :user_id
20
+
21
+ # A list of the permissions
22
+ attr_accessor :permissions
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'account' => :'account',
28
+ :'user_id' => :'userId',
29
+ :'permissions' => :'permissions'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'account' => :'Object',
37
+ :'user_id' => :'Object',
38
+ :'permissions' => :'Object'
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.openapi_nullable
44
+ Set.new([
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerClient::PermissionResponse` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerClient::PermissionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:'account')
64
+ self.account = attributes[:'account']
65
+ end
66
+
67
+ if attributes.key?(:'user_id')
68
+ self.user_id = attributes[:'user_id']
69
+ end
70
+
71
+ if attributes.key?(:'permissions')
72
+ if (value = attributes[:'permissions']).is_a?(Array)
73
+ self.permissions = value
74
+ end
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ if @user_id.nil?
83
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
84
+ end
85
+
86
+ if @permissions.nil?
87
+ invalid_properties.push('invalid value for "permissions", permissions cannot be nil.')
88
+ end
89
+
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ return false if @user_id.nil?
97
+ return false if @permissions.nil?
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ account == o.account &&
107
+ user_id == o.user_id &&
108
+ permissions == o.permissions
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [account, user_id, permissions].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
145
+ self.send("#{key}=", nil)
146
+ end
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ SwaggerClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ if value.nil?
212
+ is_nullable = self.class.openapi_nullable.include?(attr)
213
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
214
+ end
215
+
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end end
238
+ end