coinbase-sdk 0.7.0 → 0.10.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address.rb +8 -3
  3. data/lib/coinbase/client/api/external_addresses_api.rb +78 -0
  4. data/lib/coinbase/client/api/fund_api.rb +336 -0
  5. data/lib/coinbase/client/api/onchain_identity_api.rb +108 -0
  6. data/lib/coinbase/client/api/smart_contracts_api.rb +80 -0
  7. data/lib/coinbase/client/api/webhooks_api.rb +5 -5
  8. data/lib/coinbase/client/models/create_fund_operation_request.rb +249 -0
  9. data/lib/coinbase/client/models/create_fund_quote_request.rb +239 -0
  10. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +1 -1
  11. data/lib/coinbase/client/models/crypto_amount.rb +239 -0
  12. data/lib/coinbase/client/models/ethereum_token_transfer.rb +327 -0
  13. data/lib/coinbase/client/models/ethereum_transaction.rb +12 -1
  14. data/lib/coinbase/client/models/faucet_transaction.rb +20 -4
  15. data/lib/coinbase/client/models/fiat_amount.rb +240 -0
  16. data/lib/coinbase/client/models/fund_operation.rb +373 -0
  17. data/lib/coinbase/client/models/fund_operation_fees.rb +238 -0
  18. data/lib/coinbase/client/models/fund_operation_list.rb +275 -0
  19. data/lib/coinbase/client/models/fund_quote.rb +339 -0
  20. data/lib/coinbase/client/models/onchain_name.rb +357 -0
  21. data/lib/coinbase/client/models/onchain_name_list.rb +262 -0
  22. data/lib/coinbase/client/models/read_contract_request.rb +249 -0
  23. data/lib/coinbase/client/models/solidity_value.rb +287 -0
  24. data/lib/coinbase/client/models/token_transfer_type.rb +43 -0
  25. data/lib/coinbase/client/models/update_webhook_request.rb +0 -7
  26. data/lib/coinbase/client.rb +17 -0
  27. data/lib/coinbase/faucet_transaction.rb +64 -4
  28. data/lib/coinbase/smart_contract.rb +95 -0
  29. data/lib/coinbase/transaction.rb +8 -2
  30. data/lib/coinbase/version.rb +1 -1
  31. metadata +18 -2
@@ -23,7 +23,7 @@ module Coinbase::Client
23
23
  # Create a new webhook scoped to a wallet
24
24
  # @param wallet_id [String] The ID of the wallet to create the webhook for.
25
25
  # @param [Hash] opts the optional parameters
26
- # @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
26
+ # @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
27
27
  # @return [Webhook]
28
28
  def create_wallet_webhook(wallet_id, opts = {})
29
29
  data, _status_code, _headers = create_wallet_webhook_with_http_info(wallet_id, opts)
@@ -34,7 +34,7 @@ module Coinbase::Client
34
34
  # Create a new webhook scoped to a wallet
35
35
  # @param wallet_id [String] The ID of the wallet to create the webhook for.
36
36
  # @param [Hash] opts the optional parameters
37
- # @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
37
+ # @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
38
38
  # @return [Array<(Webhook, Integer, Hash)>] Webhook data, response status code and response headers
39
39
  def create_wallet_webhook_with_http_info(wallet_id, opts = {})
40
40
  if @api_client.config.debugging
@@ -57,7 +57,7 @@ module Coinbase::Client
57
57
  # HTTP header 'Content-Type'
58
58
  content_type = @api_client.select_header_content_type(['application/json'])
59
59
  if !content_type.nil?
60
- header_params['Content-Type'] = content_type
60
+ header_params['Content-Type'] = content_type
61
61
  end
62
62
 
63
63
  # form parameters
@@ -121,7 +121,7 @@ module Coinbase::Client
121
121
  # HTTP header 'Content-Type'
122
122
  content_type = @api_client.select_header_content_type(['application/json'])
123
123
  if !content_type.nil?
124
- header_params['Content-Type'] = content_type
124
+ header_params['Content-Type'] = content_type
125
125
  end
126
126
 
127
127
  # form parameters
@@ -321,7 +321,7 @@ module Coinbase::Client
321
321
  # HTTP header 'Content-Type'
322
322
  content_type = @api_client.select_header_content_type(['application/json'])
323
323
  if !content_type.nil?
324
- header_params['Content-Type'] = content_type
324
+ header_params['Content-Type'] = content_type
325
325
  end
326
326
 
327
327
  # form parameters
@@ -0,0 +1,249 @@
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
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class CreateFundOperationRequest
18
+ # The amount of the asset to fund the address with in atomic units.
19
+ attr_accessor :amount
20
+
21
+ # The ID of the asset to fund the address with.
22
+ attr_accessor :asset_id
23
+
24
+ # The Optional ID of the fund quote to fund the address with. If omitted we will generate a quote and immediately execute it.
25
+ attr_accessor :fund_quote_id
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'amount' => :'amount',
31
+ :'asset_id' => :'asset_id',
32
+ :'fund_quote_id' => :'fund_quote_id'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'amount' => :'String',
45
+ :'asset_id' => :'String',
46
+ :'fund_quote_id' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateFundOperationRequest` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateFundOperationRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'amount')
72
+ self.amount = attributes[:'amount']
73
+ else
74
+ self.amount = nil
75
+ end
76
+
77
+ if attributes.key?(:'asset_id')
78
+ self.asset_id = attributes[:'asset_id']
79
+ else
80
+ self.asset_id = nil
81
+ end
82
+
83
+ if attributes.key?(:'fund_quote_id')
84
+ self.fund_quote_id = attributes[:'fund_quote_id']
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 @amount.nil?
94
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
95
+ end
96
+
97
+ if @asset_id.nil?
98
+ invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
99
+ end
100
+
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ warn '[DEPRECATED] the `valid?` method is obsolete'
108
+ return false if @amount.nil?
109
+ return false if @asset_id.nil?
110
+ true
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ amount == o.amount &&
119
+ asset_id == o.asset_id &&
120
+ fund_quote_id == o.fund_quote_id
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [amount, asset_id, fund_quote_id].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ attributes = attributes.transform_keys(&:to_sym)
141
+ transformed_hash = {}
142
+ openapi_types.each_pair do |key, type|
143
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
144
+ transformed_hash["#{key}"] = nil
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[attribute_map[key]].is_a?(Array)
149
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
150
+ end
151
+ elsif !attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
153
+ end
154
+ end
155
+ new(transformed_hash)
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def self._deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = Coinbase::Client.const_get(type)
197
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end
@@ -0,0 +1,239 @@
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
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class CreateFundQuoteRequest
18
+ # The amount of the asset to fund the address with in atomic units.
19
+ attr_accessor :amount
20
+
21
+ # The ID of the asset to fund the address with.
22
+ attr_accessor :asset_id
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'amount' => :'amount',
28
+ :'asset_id' => :'asset_id'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'amount' => :'String',
41
+ :'asset_id' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateFundQuoteRequest` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateFundQuoteRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'amount')
67
+ self.amount = attributes[:'amount']
68
+ else
69
+ self.amount = nil
70
+ end
71
+
72
+ if attributes.key?(:'asset_id')
73
+ self.asset_id = attributes[:'asset_id']
74
+ else
75
+ self.asset_id = nil
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ if @amount.nil?
85
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
86
+ end
87
+
88
+ if @asset_id.nil?
89
+ invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ warn '[DEPRECATED] the `valid?` method is obsolete'
99
+ return false if @amount.nil?
100
+ return false if @asset_id.nil?
101
+ true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ amount == o.amount &&
110
+ asset_id == o.asset_id
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [amount, asset_id].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ openapi_types.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash["#{key}"] = nil
135
+ elsif 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[attribute_map[key]].is_a?(Array)
139
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+ new(transformed_hash)
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def self._deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = Coinbase::Client.const_get(type)
187
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end
@@ -15,7 +15,7 @@ require 'time'
15
15
 
16
16
  module Coinbase::Client
17
17
  class CreateWalletWebhookRequest
18
- # The URL to which the notifications will be sent
18
+ # The URL to which the notifications will be sent.
19
19
  attr_accessor :notification_uri
20
20
 
21
21
  # The custom header to be used for x-webhook-signature header on callbacks, so developers can verify the requests are coming from Coinbase.