turnkey_client 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d5671e438ba82d2f5b46634669fb20fc609a39abeb18b0f12c22f9f5614fc7b
4
- data.tar.gz: e6d70a75d50cc280fe228072decb4d751566cac868ce76d8f1404517819ff935
3
+ metadata.gz: 060fb86bfbd2f725f2ca429633b79c67799fea6e4baa92d34f3d79f36b4e687b
4
+ data.tar.gz: 87e0d6e7efc49ab21e94f17c23afbd6c6596792c1c4fccc4a3290d9d00d594a7
5
5
  SHA512:
6
- metadata.gz: 489cd3696b768296de9b7a3a0672267beb5d8429a8331aa7498a4b453c153be63f38a4a362907ba1cc8e7c14998a184461ffa84021326d7276374afdc5a1162f
7
- data.tar.gz: c6e609e128e68abbd6244137bb465bbebc7d2540513a1e01c11334ab85a599244409932d3418de8de913c74632eaa17f7f5c46117610c0f86521608d474bbb61
6
+ metadata.gz: 784ff5f92d4fc7dcb106a79dccfc2b65a54cccd369ab67886d9f9c401345e44dae7fdc6f2617e5772c3b58bc8aaf16ae83284aa4d8b6e322f2167750957bc331
7
+ data.tar.gz: 060dbbe77ebf9fc72fbe9c8e3c9631acf22d87163e4b0bccd186bd60005a04f75150cde07c75fd88918ab41ec54a35bd01d4629744df4ec68341b0226aae6620
@@ -15,8 +15,8 @@ module TurnkeyClient
15
15
  def initialize(api_client = ApiClient.default)
16
16
  @api_client = api_client
17
17
  end
18
- # Submit a transaction intent for broadcasting.
19
- # Submit a transaction intent describing a transaction you would like to broadcast.
18
+ # Broadcast EVM transaction
19
+ # Submit a transaction intent describing an EVM transaction you would like to broadcast.
20
20
  # @param body
21
21
  # @param [Hash] opts the optional parameters
22
22
  # @return [ActivityResponse]
@@ -25,8 +25,8 @@ module TurnkeyClient
25
25
  data
26
26
  end
27
27
 
28
- # Submit a transaction intent for broadcasting.
29
- # Submit a transaction intent describing a transaction you would like to broadcast.
28
+ # Broadcast EVM transaction
29
+ # Submit a transaction intent describing an EVM transaction you would like to broadcast.
30
30
  # @param body
31
31
  # @param [Hash] opts the optional parameters
32
32
  # @return [Array<(ActivityResponse, Integer, Hash)>] ActivityResponse data, response status code and response headers
@@ -73,7 +73,7 @@ module TurnkeyClient
73
73
  end
74
74
  return data, status_code, headers
75
75
  end
76
- # Get gas usage and limits.
76
+ # Get gas usage
77
77
  # Get gas usage and gas limits for either the parent organization or a sub-organization.
78
78
  # @param body
79
79
  # @param [Hash] opts the optional parameters
@@ -83,7 +83,7 @@ module TurnkeyClient
83
83
  data
84
84
  end
85
85
 
86
- # Get gas usage and limits.
86
+ # Get gas usage
87
87
  # Get gas usage and gas limits for either the parent organization or a sub-organization.
88
88
  # @param body
89
89
  # @param [Hash] opts the optional parameters
@@ -131,7 +131,7 @@ module TurnkeyClient
131
131
  end
132
132
  return data, status_code, headers
133
133
  end
134
- # Get nonces for an address.
134
+ # Get nonces
135
135
  # Get nonce values for an address on a given network. Can fetch the standard on-chain nonce and/or the gas station nonce used for sponsored transactions.
136
136
  # @param body
137
137
  # @param [Hash] opts the optional parameters
@@ -141,7 +141,7 @@ module TurnkeyClient
141
141
  data
142
142
  end
143
143
 
144
- # Get nonces for an address.
144
+ # Get nonces
145
145
  # Get nonce values for an address on a given network. Can fetch the standard on-chain nonce and/or the gas station nonce used for sponsored transactions.
146
146
  # @param body
147
147
  # @param [Hash] opts the optional parameters
@@ -189,8 +189,8 @@ module TurnkeyClient
189
189
  end
190
190
  return data, status_code, headers
191
191
  end
192
- # Submit a transaction intent for broadcasting.
193
- # Submit a transaction intent describing a transaction you would like to broadcast.
192
+ # Broadcast SVM transaction
193
+ # Submit a transaction intent describing an SVM transaction you would like to broadcast.
194
194
  # @param body
195
195
  # @param [Hash] opts the optional parameters
196
196
  # @return [ActivityResponse]
@@ -199,8 +199,8 @@ module TurnkeyClient
199
199
  data
200
200
  end
201
201
 
202
- # Submit a transaction intent for broadcasting.
203
- # Submit a transaction intent describing a transaction you would like to broadcast.
202
+ # Broadcast SVM transaction
203
+ # Submit a transaction intent describing an SVM transaction you would like to broadcast.
204
204
  # @param body
205
205
  # @param [Hash] opts the optional parameters
206
206
  # @return [Array<(ActivityResponse, Integer, Hash)>] ActivityResponse data, response status code and response headers
@@ -537,6 +537,64 @@ module TurnkeyClient
537
537
  end
538
538
  return data, status_code, headers
539
539
  end
540
+ # Get balances
541
+ # Get balances of supported assets for an address on the specified network. Only non-zero balances are returned. This feature is in beta - please contact support for access.
542
+ # @param body
543
+ # @param [Hash] opts the optional parameters
544
+ # @return [GetWalletAddressBalancesResponse]
545
+ def get_wallet_address_balances(body, opts = {})
546
+ data, _status_code, _headers = get_wallet_address_balances_with_http_info(body, opts)
547
+ data
548
+ end
549
+
550
+ # Get balances
551
+ # Get balances of supported assets for an address on the specified network. Only non-zero balances are returned. This feature is in beta - please contact support for access.
552
+ # @param body
553
+ # @param [Hash] opts the optional parameters
554
+ # @return [Array<(GetWalletAddressBalancesResponse, Integer, Hash)>] GetWalletAddressBalancesResponse data, response status code and response headers
555
+ def get_wallet_address_balances_with_http_info(body, opts = {})
556
+ if @api_client.config.debugging
557
+ @api_client.config.logger.debug 'Calling API: WalletsApi.get_wallet_address_balances ...'
558
+ end
559
+ # verify the required parameter 'body' is set
560
+ if @api_client.config.client_side_validation && body.nil?
561
+ fail ArgumentError, "Missing the required parameter 'body' when calling WalletsApi.get_wallet_address_balances"
562
+ end
563
+ # resource path
564
+ local_var_path = '/public/v1/query/get_wallet_address_balances'
565
+
566
+ # query parameters
567
+ query_params = opts[:query_params] || {}
568
+
569
+ # header parameters
570
+ header_params = opts[:header_params] || {}
571
+ # HTTP header 'Accept' (if needed)
572
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
573
+ # HTTP header 'Content-Type'
574
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
575
+
576
+ # form parameters
577
+ form_params = opts[:form_params] || {}
578
+
579
+ # http body (model)
580
+ post_body = opts[:body] || @api_client.object_to_http_body(body)
581
+
582
+ return_type = opts[:return_type] || 'GetWalletAddressBalancesResponse'
583
+
584
+ auth_names = opts[:auth_names] || ['ApiKeyAuth', 'AuthenticatorAuth']
585
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
586
+ :header_params => header_params,
587
+ :query_params => query_params,
588
+ :form_params => form_params,
589
+ :body => post_body,
590
+ :auth_names => auth_names,
591
+ :return_type => return_type)
592
+
593
+ if @api_client.config.debugging
594
+ @api_client.config.logger.debug "API called: WalletsApi#get_wallet_address_balances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
595
+ end
596
+ return data, status_code, headers
597
+ end
540
598
  # List wallets
541
599
  # List all wallets within an organization.
542
600
  # @param body
@@ -711,6 +769,64 @@ module TurnkeyClient
711
769
  end
712
770
  return data, status_code, headers
713
771
  end
772
+ # List supported assets
773
+ # List supported assets for the specified network. This feature is in beta - please contact support for access.
774
+ # @param body
775
+ # @param [Hash] opts the optional parameters
776
+ # @return [ListSupportedAssetsResponse]
777
+ def list_supported_assets(body, opts = {})
778
+ data, _status_code, _headers = list_supported_assets_with_http_info(body, opts)
779
+ data
780
+ end
781
+
782
+ # List supported assets
783
+ # List supported assets for the specified network. This feature is in beta - please contact support for access.
784
+ # @param body
785
+ # @param [Hash] opts the optional parameters
786
+ # @return [Array<(ListSupportedAssetsResponse, Integer, Hash)>] ListSupportedAssetsResponse data, response status code and response headers
787
+ def list_supported_assets_with_http_info(body, opts = {})
788
+ if @api_client.config.debugging
789
+ @api_client.config.logger.debug 'Calling API: WalletsApi.list_supported_assets ...'
790
+ end
791
+ # verify the required parameter 'body' is set
792
+ if @api_client.config.client_side_validation && body.nil?
793
+ fail ArgumentError, "Missing the required parameter 'body' when calling WalletsApi.list_supported_assets"
794
+ end
795
+ # resource path
796
+ local_var_path = '/public/v1/query/list_supported_assets'
797
+
798
+ # query parameters
799
+ query_params = opts[:query_params] || {}
800
+
801
+ # header parameters
802
+ header_params = opts[:header_params] || {}
803
+ # HTTP header 'Accept' (if needed)
804
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
805
+ # HTTP header 'Content-Type'
806
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
807
+
808
+ # form parameters
809
+ form_params = opts[:form_params] || {}
810
+
811
+ # http body (model)
812
+ post_body = opts[:body] || @api_client.object_to_http_body(body)
813
+
814
+ return_type = opts[:return_type] || 'ListSupportedAssetsResponse'
815
+
816
+ auth_names = opts[:auth_names] || ['ApiKeyAuth', 'AuthenticatorAuth']
817
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
818
+ :header_params => header_params,
819
+ :query_params => query_params,
820
+ :form_params => form_params,
821
+ :body => post_body,
822
+ :auth_names => auth_names,
823
+ :return_type => return_type)
824
+
825
+ if @api_client.config.debugging
826
+ @api_client.config.logger.debug "API called: WalletsApi#list_supported_assets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
827
+ end
828
+ return data, status_code, headers
829
+ end
714
830
  # Update wallet
715
831
  # Update a wallet for an organization.
716
832
  # @param body
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #API Reference
3
+
4
+ #Review our [API Introduction](../api-introduction) to get started.
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module TurnkeyClient
14
+ class AssetBalance
15
+ # The caip-19 asset identifier
16
+ attr_accessor :caip19
17
+
18
+ # The asset symbol
19
+ attr_accessor :symbol
20
+
21
+ # The balance in atomic units
22
+ attr_accessor :balance
23
+
24
+ # The number of decimals this asset uses
25
+ attr_accessor :decimals
26
+
27
+ attr_accessor :display
28
+
29
+ # The asset name
30
+ attr_accessor :name
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'caip19' => :'caip19',
36
+ :'symbol' => :'symbol',
37
+ :'balance' => :'balance',
38
+ :'decimals' => :'decimals',
39
+ :'display' => :'display',
40
+ :'name' => :'name'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'caip19' => :'Object',
48
+ :'symbol' => :'Object',
49
+ :'balance' => :'Object',
50
+ :'decimals' => :'Object',
51
+ :'display' => :'Object',
52
+ :'name' => :'Object'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::AssetBalance` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::AssetBalance`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'caip19')
78
+ self.caip19 = attributes[:'caip19']
79
+ end
80
+
81
+ if attributes.key?(:'symbol')
82
+ self.symbol = attributes[:'symbol']
83
+ end
84
+
85
+ if attributes.key?(:'balance')
86
+ self.balance = attributes[:'balance']
87
+ end
88
+
89
+ if attributes.key?(:'decimals')
90
+ self.decimals = attributes[:'decimals']
91
+ end
92
+
93
+ if attributes.key?(:'display')
94
+ self.display = attributes[:'display']
95
+ end
96
+
97
+ if attributes.key?(:'name')
98
+ self.name = attributes[:'name']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ caip19 == o.caip19 &&
121
+ symbol == o.symbol &&
122
+ balance == o.balance &&
123
+ decimals == o.decimals &&
124
+ display == o.display &&
125
+ name == o.name
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Integer] Hash code
136
+ def hash
137
+ [caip19, symbol, balance, decimals, display, name].hash
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 self.build_from_hash(attributes)
144
+ new.build_from_hash(attributes)
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
162
+ self.send("#{key}=", nil)
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :DateTime
176
+ DateTime.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ TurnkeyClient.const_get(type).build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end end
255
+ end
@@ -0,0 +1,216 @@
1
+ =begin
2
+ #API Reference
3
+
4
+ #Review our [API Introduction](../api-introduction) to get started.
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module TurnkeyClient
14
+ class AssetBalanceDisplay
15
+ # USD value for display purposes only. Do not do any arithmetic or calculations with these, as the results could be imprecise.
16
+ attr_accessor :usd
17
+
18
+ # Normalized crypto value for display purposes only. Do not do any arithmetic or calculations with these, as the results could be imprecise.
19
+ attr_accessor :crypto
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'usd' => :'usd',
25
+ :'crypto' => :'crypto'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.openapi_types
31
+ {
32
+ :'usd' => :'Object',
33
+ :'crypto' => :'Object'
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([
40
+ ])
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ if (!attributes.is_a?(Hash))
47
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::AssetBalanceDisplay` initialize method"
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::AssetBalanceDisplay`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ end
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:'usd')
59
+ self.usd = attributes[:'usd']
60
+ end
61
+
62
+ if attributes.key?(:'crypto')
63
+ self.crypto = attributes[:'crypto']
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
+ invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ true
78
+ end
79
+
80
+ # Checks equality by comparing each attribute.
81
+ # @param [Object] Object to be compared
82
+ def ==(o)
83
+ return true if self.equal?(o)
84
+ self.class == o.class &&
85
+ usd == o.usd &&
86
+ crypto == o.crypto
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Integer] Hash code
97
+ def hash
98
+ [usd, crypto].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def self.build_from_hash(attributes)
105
+ new.build_from_hash(attributes)
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ self.class.openapi_types.each_pair do |key, type|
114
+ if type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
123
+ self.send("#{key}=", nil)
124
+ end
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ TurnkeyClient.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end end
216
+ end