coinbase-sdk 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +24 -17
  3. data/lib/coinbase/address.rb +17 -19
  4. data/lib/coinbase/asset.rb +11 -8
  5. data/lib/coinbase/client/api/addresses_api.rb +1 -1
  6. data/lib/coinbase/client/api/assets_api.rb +1 -1
  7. data/lib/coinbase/client/api/contract_events_api.rb +18 -10
  8. data/lib/coinbase/client/api/external_addresses_api.rb +1 -1
  9. data/lib/coinbase/client/api/networks_api.rb +1 -1
  10. data/lib/coinbase/client/api/server_signers_api.rb +1 -1
  11. data/lib/coinbase/client/api/stake_api.rb +1 -242
  12. data/lib/coinbase/client/api/trades_api.rb +1 -1
  13. data/lib/coinbase/client/api/transfers_api.rb +1 -1
  14. data/lib/coinbase/client/api/users_api.rb +1 -1
  15. data/lib/coinbase/client/api/validators_api.rb +3 -3
  16. data/lib/coinbase/client/api/wallet_stake_api.rb +263 -0
  17. data/lib/coinbase/client/api/wallets_api.rb +1 -1
  18. data/lib/coinbase/client/api/webhooks_api.rb +1 -1
  19. data/lib/coinbase/client/api_client.rb +1 -1
  20. data/lib/coinbase/client/api_error.rb +1 -1
  21. data/lib/coinbase/client/configuration.rb +11 -1
  22. data/lib/coinbase/client/models/address.rb +22 -5
  23. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  24. data/lib/coinbase/client/models/address_historical_balance_list.rb +1 -1
  25. data/lib/coinbase/client/models/address_list.rb +1 -1
  26. data/lib/coinbase/client/models/asset.rb +1 -1
  27. data/lib/coinbase/client/models/balance.rb +1 -1
  28. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  29. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  30. data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
  31. data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
  32. data/lib/coinbase/client/models/contract_event.rb +100 -9
  33. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  34. data/lib/coinbase/client/models/create_address_request.rb +15 -5
  35. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  36. data/lib/coinbase/client/models/create_staking_operation_request.rb +1 -1
  37. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  38. data/lib/coinbase/client/models/create_transfer_request.rb +1 -1
  39. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  40. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  41. data/lib/coinbase/client/models/create_webhook_request.rb +1 -1
  42. data/lib/coinbase/client/models/error.rb +1 -1
  43. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +12 -12
  44. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  45. data/lib/coinbase/client/models/feature.rb +3 -2
  46. data/lib/coinbase/client/models/feature_set.rb +1 -1
  47. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +1 -1
  48. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  49. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  50. data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
  51. data/lib/coinbase/client/models/historical_balance.rb +1 -1
  52. data/lib/coinbase/client/models/network.rb +15 -5
  53. data/lib/coinbase/client/models/network_identifier.rb +1 -1
  54. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  55. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  56. data/lib/coinbase/client/models/server_signer.rb +1 -1
  57. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  58. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  59. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  60. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  61. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  62. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  63. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  64. data/lib/coinbase/client/models/sponsored_send.rb +1 -1
  65. data/lib/coinbase/client/models/staking_balance.rb +1 -1
  66. data/lib/coinbase/client/models/staking_context.rb +1 -1
  67. data/lib/coinbase/client/models/staking_context_context.rb +1 -1
  68. data/lib/coinbase/client/models/staking_operation.rb +3 -3
  69. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  70. data/lib/coinbase/client/models/staking_reward.rb +1 -1
  71. data/lib/coinbase/client/models/staking_reward_format.rb +1 -1
  72. data/lib/coinbase/client/models/staking_reward_usd_value.rb +1 -1
  73. data/lib/coinbase/client/models/trade.rb +1 -1
  74. data/lib/coinbase/client/models/trade_list.rb +1 -1
  75. data/lib/coinbase/client/models/transaction.rb +16 -6
  76. data/lib/coinbase/client/models/transaction_type.rb +1 -1
  77. data/lib/coinbase/client/models/transfer.rb +1 -1
  78. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  79. data/lib/coinbase/client/models/update_webhook_request.rb +1 -1
  80. data/lib/coinbase/client/models/user.rb +1 -1
  81. data/lib/coinbase/client/models/validator.rb +24 -3
  82. data/lib/coinbase/client/models/validator_details.rb +1 -1
  83. data/lib/coinbase/client/models/validator_list.rb +1 -1
  84. data/lib/coinbase/client/models/validator_status.rb +52 -0
  85. data/lib/coinbase/client/models/wallet.rb +1 -1
  86. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  87. data/lib/coinbase/client/models/webhook.rb +1 -1
  88. data/lib/coinbase/client/models/webhook_event_filter.rb +1 -1
  89. data/lib/coinbase/client/models/webhook_event_type.rb +1 -1
  90. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  91. data/lib/coinbase/client/version.rb +1 -1
  92. data/lib/coinbase/client.rb +3 -1
  93. data/lib/coinbase/constants.rb +0 -10
  94. data/lib/coinbase/contract_event.rb +104 -0
  95. data/lib/coinbase/correlation.rb +30 -0
  96. data/lib/coinbase/destination.rb +11 -9
  97. data/lib/coinbase/errors.rb +7 -0
  98. data/lib/coinbase/middleware.rb +2 -0
  99. data/lib/coinbase/network.rb +103 -20
  100. data/lib/coinbase/smart_contract.rb +106 -0
  101. data/lib/coinbase/staking_balance.rb +11 -5
  102. data/lib/coinbase/staking_operation.rb +134 -36
  103. data/lib/coinbase/staking_reward.rb +1 -1
  104. data/lib/coinbase/trade.rb +10 -9
  105. data/lib/coinbase/transaction.rb +6 -0
  106. data/lib/coinbase/transfer.rb +11 -10
  107. data/lib/coinbase/validator.rb +18 -10
  108. data/lib/coinbase/version.rb +5 -0
  109. data/lib/coinbase/wallet.rb +137 -145
  110. data/lib/coinbase/webhook.rb +181 -0
  111. data/lib/coinbase.rb +50 -19
  112. metadata +9 -9
  113. data/lib/coinbase/client/models/ethereum_validator.rb +0 -374
  114. data/lib/coinbase/client/models/get_validator200_response.rb +0 -221
  115. data/lib/coinbase/client/models/get_validator200_response_validator.rb +0 -214
  116. data/lib/coinbase/client/models/native_eth_staking_context.rb +0 -254
  117. data/lib/coinbase/client/models/partial_eth_staking_context.rb +0 -254
  118. data/lib/coinbase/client/models/validator_list_data.rb +0 -216
  119. data/lib/coinbase/user.rb +0 -65
@@ -1,254 +0,0 @@
1
- =begin
2
- #Coinbase Platform API
3
-
4
- #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
5
-
6
- The version of the OpenAPI document: 0.0.1-alpha
7
- Contact: yuga.cohler@coinbase.com
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.6.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Coinbase::Client
17
- # The partial eth staking context.
18
- class PartialEthStakingContext
19
- attr_accessor :stakeable_balance
20
-
21
- attr_accessor :unstakeable_balance
22
-
23
- attr_accessor :claimable_balance
24
-
25
- # Attribute mapping from ruby-style variable name to JSON key.
26
- def self.attribute_map
27
- {
28
- :'stakeable_balance' => :'stakeable_balance',
29
- :'unstakeable_balance' => :'unstakeable_balance',
30
- :'claimable_balance' => :'claimable_balance'
31
- }
32
- end
33
-
34
- # Returns all the JSON keys this model knows about
35
- def self.acceptable_attributes
36
- attribute_map.values
37
- end
38
-
39
- # Attribute type mapping.
40
- def self.openapi_types
41
- {
42
- :'stakeable_balance' => :'Balance',
43
- :'unstakeable_balance' => :'Balance',
44
- :'claimable_balance' => :'Balance'
45
- }
46
- end
47
-
48
- # List of attributes with nullable: true
49
- def self.openapi_nullable
50
- Set.new([
51
- ])
52
- end
53
-
54
- # Initializes the object
55
- # @param [Hash] attributes Model attributes in the form of hash
56
- def initialize(attributes = {})
57
- if (!attributes.is_a?(Hash))
58
- fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::PartialEthStakingContext` initialize method"
59
- end
60
-
61
- # check to see if the attribute exists and convert string to symbol for hash key
62
- attributes = attributes.each_with_object({}) { |(k, v), h|
63
- if (!self.class.attribute_map.key?(k.to_sym))
64
- fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::PartialEthStakingContext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
- end
66
- h[k.to_sym] = v
67
- }
68
-
69
- if attributes.key?(:'stakeable_balance')
70
- self.stakeable_balance = attributes[:'stakeable_balance']
71
- else
72
- self.stakeable_balance = nil
73
- end
74
-
75
- if attributes.key?(:'unstakeable_balance')
76
- self.unstakeable_balance = attributes[:'unstakeable_balance']
77
- else
78
- self.unstakeable_balance = nil
79
- end
80
-
81
- if attributes.key?(:'claimable_balance')
82
- self.claimable_balance = attributes[:'claimable_balance']
83
- else
84
- self.claimable_balance = nil
85
- end
86
- end
87
-
88
- # Show invalid properties with the reasons. Usually used together with valid?
89
- # @return Array for valid properties with the reasons
90
- def list_invalid_properties
91
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
92
- invalid_properties = Array.new
93
- if @stakeable_balance.nil?
94
- invalid_properties.push('invalid value for "stakeable_balance", stakeable_balance cannot be nil.')
95
- end
96
-
97
- if @unstakeable_balance.nil?
98
- invalid_properties.push('invalid value for "unstakeable_balance", unstakeable_balance cannot be nil.')
99
- end
100
-
101
- if @claimable_balance.nil?
102
- invalid_properties.push('invalid value for "claimable_balance", claimable_balance cannot be nil.')
103
- end
104
-
105
- invalid_properties
106
- end
107
-
108
- # Check to see if the all the properties in the model are valid
109
- # @return true if the model is valid
110
- def valid?
111
- warn '[DEPRECATED] the `valid?` method is obsolete'
112
- return false if @stakeable_balance.nil?
113
- return false if @unstakeable_balance.nil?
114
- return false if @claimable_balance.nil?
115
- true
116
- end
117
-
118
- # Checks equality by comparing each attribute.
119
- # @param [Object] Object to be compared
120
- def ==(o)
121
- return true if self.equal?(o)
122
- self.class == o.class &&
123
- stakeable_balance == o.stakeable_balance &&
124
- unstakeable_balance == o.unstakeable_balance &&
125
- claimable_balance == o.claimable_balance
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
- [stakeable_balance, unstakeable_balance, claimable_balance].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
- return nil unless attributes.is_a?(Hash)
145
- attributes = attributes.transform_keys(&:to_sym)
146
- transformed_hash = {}
147
- openapi_types.each_pair do |key, type|
148
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
149
- transformed_hash["#{key}"] = nil
150
- elsif type =~ /\AArray<(.*)>/i
151
- # check to ensure the input is an array given that the attribute
152
- # is documented as an array but the input is not
153
- if attributes[attribute_map[key]].is_a?(Array)
154
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
155
- end
156
- elsif !attributes[attribute_map[key]].nil?
157
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
158
- end
159
- end
160
- new(transformed_hash)
161
- end
162
-
163
- # Deserializes the data based on type
164
- # @param string type Data type
165
- # @param string value Value to be deserialized
166
- # @return [Object] Deserialized data
167
- def self._deserialize(type, value)
168
- case type.to_sym
169
- when :Time
170
- Time.parse(value)
171
- when :Date
172
- Date.parse(value)
173
- when :String
174
- value.to_s
175
- when :Integer
176
- value.to_i
177
- when :Float
178
- value.to_f
179
- when :Boolean
180
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
- true
182
- else
183
- false
184
- end
185
- when :Object
186
- # generic object (usually a Hash), return directly
187
- value
188
- when /\AArray<(?<inner_type>.+)>\z/
189
- inner_type = Regexp.last_match[:inner_type]
190
- value.map { |v| _deserialize(inner_type, v) }
191
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
- k_type = Regexp.last_match[:k_type]
193
- v_type = Regexp.last_match[:v_type]
194
- {}.tap do |hash|
195
- value.each do |k, v|
196
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
- end
198
- end
199
- else # model
200
- # models (e.g. Pet) or oneOf
201
- klass = Coinbase::Client.const_get(type)
202
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
203
- end
204
- end
205
-
206
- # Returns the string representation of the object
207
- # @return [String] String presentation of the object
208
- def to_s
209
- to_hash.to_s
210
- end
211
-
212
- # to_body is an alias to to_hash (backward compatibility)
213
- # @return [Hash] Returns the object in the form of hash
214
- def to_body
215
- to_hash
216
- end
217
-
218
- # Returns the object in the form of hash
219
- # @return [Hash] Returns the object in the form of hash
220
- def to_hash
221
- hash = {}
222
- self.class.attribute_map.each_pair do |attr, param|
223
- value = self.send(attr)
224
- if value.nil?
225
- is_nullable = self.class.openapi_nullable.include?(attr)
226
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
227
- end
228
-
229
- hash[param] = _to_hash(value)
230
- end
231
- hash
232
- end
233
-
234
- # Outputs non-array value in the form of hash
235
- # For object, use to_hash. Otherwise, just return the value
236
- # @param [Object] value Any valid value
237
- # @return [Hash] Returns the value in the form of hash
238
- def _to_hash(value)
239
- if value.is_a?(Array)
240
- value.compact.map { |v| _to_hash(v) }
241
- elsif value.is_a?(Hash)
242
- {}.tap do |hash|
243
- value.each { |k, v| hash[k] = _to_hash(v) }
244
- end
245
- elsif value.respond_to? :to_hash
246
- value.to_hash
247
- else
248
- value
249
- end
250
- end
251
-
252
- end
253
-
254
- end
@@ -1,216 +0,0 @@
1
- =begin
2
- #Coinbase Platform API
3
-
4
- #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
5
-
6
- The version of the OpenAPI document: 0.0.1-alpha
7
- Contact: yuga.cohler@coinbase.com
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.6.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Coinbase::Client
17
- class ValidatorListData
18
- attr_accessor :ethereum_validators
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :'ethereum_validators' => :'ethereum_validators'
24
- }
25
- end
26
-
27
- # Returns all the JSON keys this model knows about
28
- def self.acceptable_attributes
29
- attribute_map.values
30
- end
31
-
32
- # Attribute type mapping.
33
- def self.openapi_types
34
- {
35
- :'ethereum_validators' => :'Array<EthereumValidator>'
36
- }
37
- end
38
-
39
- # List of attributes with nullable: true
40
- def self.openapi_nullable
41
- Set.new([
42
- ])
43
- end
44
-
45
- # Initializes the object
46
- # @param [Hash] attributes Model attributes in the form of hash
47
- def initialize(attributes = {})
48
- if (!attributes.is_a?(Hash))
49
- fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::ValidatorListData` initialize method"
50
- end
51
-
52
- # check to see if the attribute exists and convert string to symbol for hash key
53
- attributes = attributes.each_with_object({}) { |(k, v), h|
54
- if (!self.class.attribute_map.key?(k.to_sym))
55
- fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::ValidatorListData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
- end
57
- h[k.to_sym] = v
58
- }
59
-
60
- if attributes.key?(:'ethereum_validators')
61
- if (value = attributes[:'ethereum_validators']).is_a?(Array)
62
- self.ethereum_validators = value
63
- end
64
- end
65
- end
66
-
67
- # Show invalid properties with the reasons. Usually used together with valid?
68
- # @return Array for valid properties with the reasons
69
- def list_invalid_properties
70
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
- invalid_properties = Array.new
72
- invalid_properties
73
- end
74
-
75
- # Check to see if the all the properties in the model are valid
76
- # @return true if the model is valid
77
- def valid?
78
- warn '[DEPRECATED] the `valid?` method is obsolete'
79
- true
80
- end
81
-
82
- # Checks equality by comparing each attribute.
83
- # @param [Object] Object to be compared
84
- def ==(o)
85
- return true if self.equal?(o)
86
- self.class == o.class &&
87
- ethereum_validators == o.ethereum_validators
88
- end
89
-
90
- # @see the `==` method
91
- # @param [Object] Object to be compared
92
- def eql?(o)
93
- self == o
94
- end
95
-
96
- # Calculates hash code according to all attributes.
97
- # @return [Integer] Hash code
98
- def hash
99
- [ethereum_validators].hash
100
- end
101
-
102
- # Builds the object from hash
103
- # @param [Hash] attributes Model attributes in the form of hash
104
- # @return [Object] Returns the model itself
105
- def self.build_from_hash(attributes)
106
- return nil unless attributes.is_a?(Hash)
107
- attributes = attributes.transform_keys(&:to_sym)
108
- transformed_hash = {}
109
- openapi_types.each_pair do |key, type|
110
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
111
- transformed_hash["#{key}"] = nil
112
- elsif type =~ /\AArray<(.*)>/i
113
- # check to ensure the input is an array given that the attribute
114
- # is documented as an array but the input is not
115
- if attributes[attribute_map[key]].is_a?(Array)
116
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
117
- end
118
- elsif !attributes[attribute_map[key]].nil?
119
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
120
- end
121
- end
122
- new(transformed_hash)
123
- end
124
-
125
- # Deserializes the data based on type
126
- # @param string type Data type
127
- # @param string value Value to be deserialized
128
- # @return [Object] Deserialized data
129
- def self._deserialize(type, value)
130
- case type.to_sym
131
- when :Time
132
- Time.parse(value)
133
- when :Date
134
- Date.parse(value)
135
- when :String
136
- value.to_s
137
- when :Integer
138
- value.to_i
139
- when :Float
140
- value.to_f
141
- when :Boolean
142
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
- true
144
- else
145
- false
146
- end
147
- when :Object
148
- # generic object (usually a Hash), return directly
149
- value
150
- when /\AArray<(?<inner_type>.+)>\z/
151
- inner_type = Regexp.last_match[:inner_type]
152
- value.map { |v| _deserialize(inner_type, v) }
153
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
- k_type = Regexp.last_match[:k_type]
155
- v_type = Regexp.last_match[:v_type]
156
- {}.tap do |hash|
157
- value.each do |k, v|
158
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
- end
160
- end
161
- else # model
162
- # models (e.g. Pet) or oneOf
163
- klass = Coinbase::Client.const_get(type)
164
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
165
- end
166
- end
167
-
168
- # Returns the string representation of the object
169
- # @return [String] String presentation of the object
170
- def to_s
171
- to_hash.to_s
172
- end
173
-
174
- # to_body is an alias to to_hash (backward compatibility)
175
- # @return [Hash] Returns the object in the form of hash
176
- def to_body
177
- to_hash
178
- end
179
-
180
- # Returns the object in the form of hash
181
- # @return [Hash] Returns the object in the form of hash
182
- def to_hash
183
- hash = {}
184
- self.class.attribute_map.each_pair do |attr, param|
185
- value = self.send(attr)
186
- if value.nil?
187
- is_nullable = self.class.openapi_nullable.include?(attr)
188
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
- end
190
-
191
- hash[param] = _to_hash(value)
192
- end
193
- hash
194
- end
195
-
196
- # Outputs non-array value in the form of hash
197
- # For object, use to_hash. Otherwise, just return the value
198
- # @param [Object] value Any valid value
199
- # @return [Hash] Returns the value in the form of hash
200
- def _to_hash(value)
201
- if value.is_a?(Array)
202
- value.compact.map { |v| _to_hash(v) }
203
- elsif value.is_a?(Hash)
204
- {}.tap do |hash|
205
- value.each { |k, v| hash[k] = _to_hash(v) }
206
- end
207
- elsif value.respond_to? :to_hash
208
- value.to_hash
209
- else
210
- value
211
- end
212
- end
213
-
214
- end
215
-
216
- end
data/lib/coinbase/user.rb DELETED
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'client'
4
- require_relative 'wallet'
5
-
6
- module Coinbase
7
- # A representation of a User. Users have Wallets, which can hold balances of Assets. Access the default User through
8
- # Coinbase#default_user.
9
- class User
10
- # Returns a new User object. Do not use this method directly. Instead, use Coinbase#default_user.
11
- # @param model [Coinbase::Client::User] the underlying User object
12
- def initialize(model)
13
- @model = model
14
- end
15
-
16
- # Returns the User ID.
17
- # @return [String] the User ID
18
- def id
19
- @model.id
20
- end
21
-
22
- # Creates a new Wallet belonging to the User.
23
- # @param network_id [String] (Optional) the ID of the blockchain network. Defaults to 'base-sepolia'.
24
- # @return [Coinbase::Wallet] the new Wallet
25
- def create_wallet(create_wallet_options = {})
26
- # For ruby 2.7 compatibility we cannot pass in keyword args when the create wallet
27
- # options is empty
28
- return Wallet.create if create_wallet_options.empty?
29
-
30
- Wallet.create(**create_wallet_options)
31
- end
32
-
33
- # Imports a Wallet belonging to the User.
34
- # @param data [Coinbase::Wallet::Data] the Wallet data to import
35
- # @return [Coinbase::Wallet] the imported Wallet
36
- def import_wallet(data)
37
- Wallet.import(data)
38
- end
39
-
40
- # Enumerates the Wallets belonging to the User.
41
- # @return [Enumerator<Coinbase::Wallet>] the Wallets belonging to the User
42
- def wallets
43
- Wallet.list
44
- end
45
-
46
- # Returns the Wallet with the given ID.
47
- # @param wallet_id [String] the ID of the Wallet
48
- # @return [Coinbase::Wallet] the unhydrated Wallet
49
- def wallet(wallet_id)
50
- Wallet.fetch(wallet_id)
51
- end
52
-
53
- # Returns a string representation of the User.
54
- # @return [String] a string representation of the User
55
- def to_s
56
- "Coinbase::User{user_id: '#{id}'}"
57
- end
58
-
59
- # Same as to_s.
60
- # @return [String] a string representation of the User
61
- def inspect
62
- to_s
63
- end
64
- end
65
- end