sky_api 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +190 -0
  4. data/Rakefile +10 -0
  5. data/docs/Address.md +17 -0
  6. data/docs/ApiV1PendingTxsTransaction.md +29 -0
  7. data/docs/ApiV1PendingTxsTransactionOutputs.md +23 -0
  8. data/docs/BlockSchema.md +21 -0
  9. data/docs/BlockSchemaBody.md +17 -0
  10. data/docs/BlockVerboseSchema.md +21 -0
  11. data/docs/BlockVerboseSchemaBody.md +17 -0
  12. data/docs/BlockVerboseSchemaHeader.md +31 -0
  13. data/docs/DefaultApi.md +2767 -0
  14. data/docs/InlineResponse200.md +17 -0
  15. data/docs/InlineResponse2001.md +17 -0
  16. data/docs/InlineResponse20010.md +25 -0
  17. data/docs/InlineResponse2002.md +29 -0
  18. data/docs/InlineResponse2003.md +17 -0
  19. data/docs/InlineResponse2004.md +17 -0
  20. data/docs/InlineResponse2005.md +21 -0
  21. data/docs/InlineResponse2006.md +17 -0
  22. data/docs/InlineResponse2007.md +17 -0
  23. data/docs/InlineResponse2008.md +17 -0
  24. data/docs/InlineResponse2008Data.md +17 -0
  25. data/docs/InlineResponse2009.md +17 -0
  26. data/docs/InlineResponseDefault.md +19 -0
  27. data/docs/NetworkConnectionSchema.md +41 -0
  28. data/docs/NetworkConnectionSchemaUnconfirmedVerifyTransaction.md +21 -0
  29. data/docs/Transaction.md +21 -0
  30. data/docs/TransactionEncoded.md +25 -0
  31. data/docs/TransactionEncodedS.md +21 -0
  32. data/docs/TransactionStatus.md +23 -0
  33. data/docs/TransactionTxn.md +31 -0
  34. data/docs/TransactionV2ParamsAddress.md +17 -0
  35. data/docs/TransactionV2ParamsAddressHoursSelection.md +17 -0
  36. data/docs/TransactionV2ParamsUnspent.md +23 -0
  37. data/docs/TransactionV2ParamsUnspentHoursSelection.md +21 -0
  38. data/docs/TransactionV2ParamsUnspentTo.md +19 -0
  39. data/docs/TransactionVerbose.md +21 -0
  40. data/docs/TransactionVerboseTxn.md +35 -0
  41. data/docs/TransactionVerboseTxnInputs.md +25 -0
  42. data/docs/TransactionVerifyRequest.md +19 -0
  43. data/docs/WalletTransactionRequest.md +25 -0
  44. data/docs/WalletTransactionRequestHoursSelection.md +21 -0
  45. data/docs/WalletTransactionRequestWallet.md +23 -0
  46. data/docs/WalletTransactionSignRequest.md +23 -0
  47. data/git_push.sh +55 -0
  48. data/lib/sky_api.rb +81 -0
  49. data/lib/sky_api/api/default_api.rb +3371 -0
  50. data/lib/sky_api/api_client.rb +387 -0
  51. data/lib/sky_api/api_error.rb +57 -0
  52. data/lib/sky_api/configuration.rb +259 -0
  53. data/lib/sky_api/models/address.rb +201 -0
  54. data/lib/sky_api/models/api_v1_pending_txs_transaction.rb +256 -0
  55. data/lib/sky_api/models/api_v1_pending_txs_transaction_outputs.rb +223 -0
  56. data/lib/sky_api/models/block_schema.rb +214 -0
  57. data/lib/sky_api/models/block_schema_body.rb +198 -0
  58. data/lib/sky_api/models/block_verbose_schema.rb +214 -0
  59. data/lib/sky_api/models/block_verbose_schema_body.rb +198 -0
  60. data/lib/sky_api/models/block_verbose_schema_header.rb +259 -0
  61. data/lib/sky_api/models/inline_response200.rb +196 -0
  62. data/lib/sky_api/models/inline_response2001.rb +198 -0
  63. data/lib/sky_api/models/inline_response20010.rb +232 -0
  64. data/lib/sky_api/models/inline_response2002.rb +261 -0
  65. data/lib/sky_api/models/inline_response2003.rb +196 -0
  66. data/lib/sky_api/models/inline_response2004.rb +198 -0
  67. data/lib/sky_api/models/inline_response2005.rb +217 -0
  68. data/lib/sky_api/models/inline_response2006.rb +198 -0
  69. data/lib/sky_api/models/inline_response2007.rb +196 -0
  70. data/lib/sky_api/models/inline_response2008.rb +196 -0
  71. data/lib/sky_api/models/inline_response2008_data.rb +196 -0
  72. data/lib/sky_api/models/inline_response2009.rb +196 -0
  73. data/lib/sky_api/models/inline_response_default.rb +205 -0
  74. data/lib/sky_api/models/network_connection_schema.rb +338 -0
  75. data/lib/sky_api/models/network_connection_schema_unconfirmed_verify_transaction.rb +215 -0
  76. data/lib/sky_api/models/transaction.rb +214 -0
  77. data/lib/sky_api/models/transaction_encoded.rb +232 -0
  78. data/lib/sky_api/models/transaction_encoded_s.rb +214 -0
  79. data/lib/sky_api/models/transaction_status.rb +225 -0
  80. data/lib/sky_api/models/transaction_txn.rb +266 -0
  81. data/lib/sky_api/models/transaction_v2_params_address.rb +196 -0
  82. data/lib/sky_api/models/transaction_v2_params_address_hours_selection.rb +196 -0
  83. data/lib/sky_api/models/transaction_v2_params_unspent.rb +227 -0
  84. data/lib/sky_api/models/transaction_v2_params_unspent_hours_selection.rb +214 -0
  85. data/lib/sky_api/models/transaction_v2_params_unspent_to.rb +205 -0
  86. data/lib/sky_api/models/transaction_verbose.rb +214 -0
  87. data/lib/sky_api/models/transaction_verbose_txn.rb +284 -0
  88. data/lib/sky_api/models/transaction_verbose_txn_inputs.rb +232 -0
  89. data/lib/sky_api/models/transaction_verify_request.rb +205 -0
  90. data/lib/sky_api/models/wallet_transaction_request.rb +234 -0
  91. data/lib/sky_api/models/wallet_transaction_request_hours_selection.rb +214 -0
  92. data/lib/sky_api/models/wallet_transaction_request_wallet.rb +227 -0
  93. data/lib/sky_api/models/wallet_transaction_sign_request.rb +225 -0
  94. data/lib/sky_api/version.rb +15 -0
  95. data/sky_api.gemspec +45 -0
  96. data/spec/api/default_api_spec.rb +652 -0
  97. data/spec/api_client_spec.rb +226 -0
  98. data/spec/configuration_spec.rb +42 -0
  99. data/spec/models/address_spec.rb +41 -0
  100. data/spec/models/api_v1_pending_txs_transaction_outputs_spec.rb +59 -0
  101. data/spec/models/api_v1_pending_txs_transaction_spec.rb +77 -0
  102. data/spec/models/block_schema_body_spec.rb +41 -0
  103. data/spec/models/block_schema_spec.rb +53 -0
  104. data/spec/models/block_verbose_schema_body_spec.rb +41 -0
  105. data/spec/models/block_verbose_schema_header_spec.rb +83 -0
  106. data/spec/models/block_verbose_schema_spec.rb +53 -0
  107. data/spec/models/inline_response20010_spec.rb +65 -0
  108. data/spec/models/inline_response2001_spec.rb +41 -0
  109. data/spec/models/inline_response2002_spec.rb +77 -0
  110. data/spec/models/inline_response2003_spec.rb +41 -0
  111. data/spec/models/inline_response2004_spec.rb +41 -0
  112. data/spec/models/inline_response2005_spec.rb +53 -0
  113. data/spec/models/inline_response2006_spec.rb +41 -0
  114. data/spec/models/inline_response2007_spec.rb +41 -0
  115. data/spec/models/inline_response2008_data_spec.rb +41 -0
  116. data/spec/models/inline_response2008_spec.rb +41 -0
  117. data/spec/models/inline_response2009_spec.rb +41 -0
  118. data/spec/models/inline_response200_spec.rb +41 -0
  119. data/spec/models/inline_response_default_spec.rb +47 -0
  120. data/spec/models/network_connection_schema_spec.rb +117 -0
  121. data/spec/models/network_connection_schema_unconfirmed_verify_transaction_spec.rb +53 -0
  122. data/spec/models/transaction_encoded_s_spec.rb +53 -0
  123. data/spec/models/transaction_encoded_spec.rb +65 -0
  124. data/spec/models/transaction_spec.rb +53 -0
  125. data/spec/models/transaction_status_spec.rb +59 -0
  126. data/spec/models/transaction_txn_spec.rb +83 -0
  127. data/spec/models/transaction_v2_params_address_hours_selection_spec.rb +41 -0
  128. data/spec/models/transaction_v2_params_address_spec.rb +41 -0
  129. data/spec/models/transaction_v2_params_unspent_hours_selection_spec.rb +53 -0
  130. data/spec/models/transaction_v2_params_unspent_spec.rb +59 -0
  131. data/spec/models/transaction_v2_params_unspent_to_spec.rb +47 -0
  132. data/spec/models/transaction_verbose_spec.rb +53 -0
  133. data/spec/models/transaction_verbose_txn_inputs_spec.rb +65 -0
  134. data/spec/models/transaction_verbose_txn_spec.rb +95 -0
  135. data/spec/models/transaction_verify_request_spec.rb +47 -0
  136. data/spec/models/wallet_transaction_request_hours_selection_spec.rb +53 -0
  137. data/spec/models/wallet_transaction_request_spec.rb +65 -0
  138. data/spec/models/wallet_transaction_request_wallet_spec.rb +59 -0
  139. data/spec/models/wallet_transaction_sign_request_spec.rb +59 -0
  140. data/spec/spec_helper.rb +111 -0
  141. metadata +407 -0
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #Skycoin REST API.
3
+
4
+ #Skycoin is a next-generation cryptocurrency.
5
+
6
+ The version of the OpenAPI document: 0.26.0
7
+ Contact: contact@skycoin.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SkyApi
16
+ # TransactionVerbose has readable transaction data. It adds TransactionStatus to a BlockTransactionVerbose
17
+ class TransactionVerboseTxn
18
+ attr_accessor :status
19
+
20
+ attr_accessor :fee
21
+
22
+ attr_accessor :inner_hash
23
+
24
+ attr_accessor :inputs
25
+
26
+ attr_accessor :length
27
+
28
+ attr_accessor :outputs
29
+
30
+ attr_accessor :sigs
31
+
32
+ attr_accessor :timestamp
33
+
34
+ attr_accessor :txid
35
+
36
+ attr_accessor :type
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'status' => :'status',
42
+ :'fee' => :'fee',
43
+ :'inner_hash' => :'inner_hash',
44
+ :'inputs' => :'inputs',
45
+ :'length' => :'length',
46
+ :'outputs' => :'outputs',
47
+ :'sigs' => :'sigs',
48
+ :'timestamp' => :'timestamp',
49
+ :'txid' => :'txid',
50
+ :'type' => :'type'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'status' => :'TransactionStatus',
58
+ :'fee' => :'Integer',
59
+ :'inner_hash' => :'String',
60
+ :'inputs' => :'Array<TransactionVerboseTxnInputs>',
61
+ :'length' => :'Integer',
62
+ :'outputs' => :'Array<Object>',
63
+ :'sigs' => :'Array<String>',
64
+ :'timestamp' => :'Integer',
65
+ :'txid' => :'String',
66
+ :'type' => :'Integer'
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 `SkyApi::TransactionVerboseTxn` 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 `SkyApi::TransactionVerboseTxn`. 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?(:'status')
86
+ self.status = attributes[:'status']
87
+ end
88
+
89
+ if attributes.key?(:'fee')
90
+ self.fee = attributes[:'fee']
91
+ end
92
+
93
+ if attributes.key?(:'inner_hash')
94
+ self.inner_hash = attributes[:'inner_hash']
95
+ end
96
+
97
+ if attributes.key?(:'inputs')
98
+ if (value = attributes[:'inputs']).is_a?(Array)
99
+ self.inputs = value
100
+ end
101
+ end
102
+
103
+ if attributes.key?(:'length')
104
+ self.length = attributes[:'length']
105
+ end
106
+
107
+ if attributes.key?(:'outputs')
108
+ if (value = attributes[:'outputs']).is_a?(Array)
109
+ self.outputs = value
110
+ end
111
+ end
112
+
113
+ if attributes.key?(:'sigs')
114
+ if (value = attributes[:'sigs']).is_a?(Array)
115
+ self.sigs = value
116
+ end
117
+ end
118
+
119
+ if attributes.key?(:'timestamp')
120
+ self.timestamp = attributes[:'timestamp']
121
+ end
122
+
123
+ if attributes.key?(:'txid')
124
+ self.txid = attributes[:'txid']
125
+ end
126
+
127
+ if attributes.key?(:'type')
128
+ self.type = attributes[:'type']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ true
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ status == o.status &&
151
+ fee == o.fee &&
152
+ inner_hash == o.inner_hash &&
153
+ inputs == o.inputs &&
154
+ length == o.length &&
155
+ outputs == o.outputs &&
156
+ sigs == o.sigs &&
157
+ timestamp == o.timestamp &&
158
+ txid == o.txid &&
159
+ type == o.type
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Integer] Hash code
170
+ def hash
171
+ [status, fee, inner_hash, inputs, length, outputs, sigs, timestamp, txid, type].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def self.build_from_hash(attributes)
178
+ new.build_from_hash(attributes)
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def build_from_hash(attributes)
185
+ return nil unless attributes.is_a?(Hash)
186
+ self.class.openapi_types.each_pair do |key, type|
187
+ if type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
191
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
192
+ end
193
+ elsif !attributes[self.class.attribute_map[key]].nil?
194
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
195
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def _deserialize(type, value)
206
+ case type.to_sym
207
+ when :DateTime
208
+ DateTime.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ SkyApi.const_get(type).build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ next if value.nil?
261
+ hash[param] = _to_hash(value)
262
+ end
263
+ hash
264
+ end
265
+
266
+ # Outputs non-array value in the form of hash
267
+ # For object, use to_hash. Otherwise, just return the value
268
+ # @param [Object] value Any valid value
269
+ # @return [Hash] Returns the value in the form of hash
270
+ def _to_hash(value)
271
+ if value.is_a?(Array)
272
+ value.compact.map { |v| _to_hash(v) }
273
+ elsif value.is_a?(Hash)
274
+ {}.tap do |hash|
275
+ value.each { |k, v| hash[k] = _to_hash(v) }
276
+ end
277
+ elsif value.respond_to? :to_hash
278
+ value.to_hash
279
+ else
280
+ value
281
+ end
282
+ end
283
+ end
284
+ end
@@ -0,0 +1,232 @@
1
+ =begin
2
+ #Skycoin REST API.
3
+
4
+ #Skycoin is a next-generation cryptocurrency.
5
+
6
+ The version of the OpenAPI document: 0.26.0
7
+ Contact: contact@skycoin.net
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SkyApi
16
+ class TransactionVerboseTxnInputs
17
+ attr_accessor :uxid
18
+
19
+ attr_accessor :owner
20
+
21
+ attr_accessor :coins
22
+
23
+ attr_accessor :hours
24
+
25
+ attr_accessor :calculated_hours
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'uxid' => :'uxid',
31
+ :'owner' => :'owner',
32
+ :'coins' => :'coins',
33
+ :'hours' => :'hours',
34
+ :'calculated_hours' => :'calculated_hours'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'uxid' => :'String',
42
+ :'owner' => :'String',
43
+ :'coins' => :'String',
44
+ :'hours' => :'Integer',
45
+ :'calculated_hours' => :'Integer'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SkyApi::TransactionVerboseTxnInputs` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SkyApi::TransactionVerboseTxnInputs`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'uxid')
65
+ self.uxid = attributes[:'uxid']
66
+ end
67
+
68
+ if attributes.key?(:'owner')
69
+ self.owner = attributes[:'owner']
70
+ end
71
+
72
+ if attributes.key?(:'coins')
73
+ self.coins = attributes[:'coins']
74
+ end
75
+
76
+ if attributes.key?(:'hours')
77
+ self.hours = attributes[:'hours']
78
+ end
79
+
80
+ if attributes.key?(:'calculated_hours')
81
+ self.calculated_hours = attributes[:'calculated_hours']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ uxid == o.uxid &&
104
+ owner == o.owner &&
105
+ coins == o.coins &&
106
+ hours == o.hours &&
107
+ calculated_hours == o.calculated_hours
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [uxid, owner, coins, hours, calculated_hours].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ new.build_from_hash(attributes)
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ self.class.openapi_types.each_pair do |key, type|
135
+ if type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
139
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
140
+ end
141
+ elsif !attributes[self.class.attribute_map[key]].nil?
142
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
143
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
144
+ end
145
+
146
+ self
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def _deserialize(type, value)
154
+ case type.to_sym
155
+ when :DateTime
156
+ DateTime.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ SkyApi.const_get(type).build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ next if value.nil?
209
+ hash[param] = _to_hash(value)
210
+ end
211
+ hash
212
+ end
213
+
214
+ # Outputs non-array value in the form of hash
215
+ # For object, use to_hash. Otherwise, just return the value
216
+ # @param [Object] value Any valid value
217
+ # @return [Hash] Returns the value in the form of hash
218
+ def _to_hash(value)
219
+ if value.is_a?(Array)
220
+ value.compact.map { |v| _to_hash(v) }
221
+ elsif value.is_a?(Hash)
222
+ {}.tap do |hash|
223
+ value.each { |k, v| hash[k] = _to_hash(v) }
224
+ end
225
+ elsif value.respond_to? :to_hash
226
+ value.to_hash
227
+ else
228
+ value
229
+ end
230
+ end
231
+ end
232
+ end