coinbase-sdk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address.rb +63 -44
  3. data/lib/coinbase/authenticator.rb +1 -1
  4. data/lib/coinbase/client/api/server_signers_api.rb +419 -0
  5. data/lib/coinbase/client/api/trades_api.rb +342 -0
  6. data/lib/coinbase/client/models/broadcast_trade_request.rb +222 -0
  7. data/lib/coinbase/client/models/create_address_request.rb +0 -14
  8. data/lib/coinbase/client/models/create_server_signer_request.rb +239 -0
  9. data/lib/coinbase/client/models/create_trade_request.rb +256 -0
  10. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  11. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +233 -0
  12. data/lib/coinbase/client/models/seed_creation_event.rb +240 -0
  13. data/lib/coinbase/client/models/seed_creation_event_result.rb +274 -0
  14. data/lib/coinbase/client/models/server_signer.rb +235 -0
  15. data/lib/coinbase/client/models/server_signer_event.rb +239 -0
  16. data/lib/coinbase/client/models/server_signer_event_event.rb +105 -0
  17. data/lib/coinbase/client/models/server_signer_event_list.rb +275 -0
  18. data/lib/coinbase/client/models/signature_creation_event.rb +363 -0
  19. data/lib/coinbase/client/models/signature_creation_event_result.rb +329 -0
  20. data/lib/coinbase/client/models/trade.rb +356 -0
  21. data/lib/coinbase/client/models/trade_list.rb +275 -0
  22. data/lib/coinbase/client/models/transaction.rb +294 -0
  23. data/lib/coinbase/client/models/transaction_type.rb +39 -0
  24. data/lib/coinbase/client/models/wallet.rb +55 -4
  25. data/lib/coinbase/client.rb +18 -0
  26. data/lib/coinbase/transfer.rb +21 -21
  27. data/lib/coinbase/user.rb +14 -89
  28. data/lib/coinbase/wallet.rb +176 -26
  29. data/lib/coinbase.rb +16 -4
  30. metadata +34 -2
@@ -0,0 +1,274 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # The result to a SeedCreationEvent.
18
+ class SeedCreationEventResult
19
+ # The ID of the wallet that the seed was created for
20
+ attr_accessor :wallet_id
21
+
22
+ # The ID of the user that the wallet belongs to
23
+ attr_accessor :wallet_user_id
24
+
25
+ # The extended public key for the first master key derived from seed.
26
+ attr_accessor :extended_public_key
27
+
28
+ # The ID of the seed in Server-Signer used to generate the extended public key.
29
+ attr_accessor :seed_id
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'wallet_id' => :'wallet_id',
35
+ :'wallet_user_id' => :'wallet_user_id',
36
+ :'extended_public_key' => :'extended_public_key',
37
+ :'seed_id' => :'seed_id'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'wallet_id' => :'String',
50
+ :'wallet_user_id' => :'String',
51
+ :'extended_public_key' => :'String',
52
+ :'seed_id' => :'String'
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 `Coinbase::Client::SeedCreationEventResult` 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 `Coinbase::Client::SeedCreationEventResult`. 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?(:'wallet_id')
78
+ self.wallet_id = attributes[:'wallet_id']
79
+ else
80
+ self.wallet_id = nil
81
+ end
82
+
83
+ if attributes.key?(:'wallet_user_id')
84
+ self.wallet_user_id = attributes[:'wallet_user_id']
85
+ else
86
+ self.wallet_user_id = nil
87
+ end
88
+
89
+ if attributes.key?(:'extended_public_key')
90
+ self.extended_public_key = attributes[:'extended_public_key']
91
+ else
92
+ self.extended_public_key = nil
93
+ end
94
+
95
+ if attributes.key?(:'seed_id')
96
+ self.seed_id = attributes[:'seed_id']
97
+ else
98
+ self.seed_id = nil
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
106
+ invalid_properties = Array.new
107
+ if @wallet_id.nil?
108
+ invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
109
+ end
110
+
111
+ if @wallet_user_id.nil?
112
+ invalid_properties.push('invalid value for "wallet_user_id", wallet_user_id cannot be nil.')
113
+ end
114
+
115
+ if @extended_public_key.nil?
116
+ invalid_properties.push('invalid value for "extended_public_key", extended_public_key cannot be nil.')
117
+ end
118
+
119
+ if @seed_id.nil?
120
+ invalid_properties.push('invalid value for "seed_id", seed_id cannot be nil.')
121
+ end
122
+
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ warn '[DEPRECATED] the `valid?` method is obsolete'
130
+ return false if @wallet_id.nil?
131
+ return false if @wallet_user_id.nil?
132
+ return false if @extended_public_key.nil?
133
+ return false if @seed_id.nil?
134
+ true
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ wallet_id == o.wallet_id &&
143
+ wallet_user_id == o.wallet_user_id &&
144
+ extended_public_key == o.extended_public_key &&
145
+ seed_id == o.seed_id
146
+ end
147
+
148
+ # @see the `==` method
149
+ # @param [Object] Object to be compared
150
+ def eql?(o)
151
+ self == o
152
+ end
153
+
154
+ # Calculates hash code according to all attributes.
155
+ # @return [Integer] Hash code
156
+ def hash
157
+ [wallet_id, wallet_user_id, extended_public_key, seed_id].hash
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def self.build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ attributes = attributes.transform_keys(&:to_sym)
166
+ transformed_hash = {}
167
+ openapi_types.each_pair do |key, type|
168
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
169
+ transformed_hash["#{key}"] = nil
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[attribute_map[key]].is_a?(Array)
174
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
175
+ end
176
+ elsif !attributes[attribute_map[key]].nil?
177
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
178
+ end
179
+ end
180
+ new(transformed_hash)
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def self._deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = Coinbase::Client.const_get(type)
222
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -0,0 +1,235 @@
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.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # A Server-Signer assigned to sign transactions in a wallet.
18
+ class ServerSigner
19
+ # The ID of the server-signer
20
+ attr_accessor :server_signer_id
21
+
22
+ # The IDs of the wallets that the server-signer can sign for
23
+ attr_accessor :wallets
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'server_signer_id' => :'server_signer_id',
29
+ :'wallets' => :'wallets'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'server_signer_id' => :'String',
42
+ :'wallets' => :'Array<String>'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::ServerSigner` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::ServerSigner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'server_signer_id')
68
+ self.server_signer_id = attributes[:'server_signer_id']
69
+ else
70
+ self.server_signer_id = nil
71
+ end
72
+
73
+ if attributes.key?(:'wallets')
74
+ if (value = attributes[:'wallets']).is_a?(Array)
75
+ self.wallets = value
76
+ end
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
84
+ invalid_properties = Array.new
85
+ if @server_signer_id.nil?
86
+ invalid_properties.push('invalid value for "server_signer_id", server_signer_id cannot be nil.')
87
+ end
88
+
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
+ warn '[DEPRECATED] the `valid?` method is obsolete'
96
+ return false if @server_signer_id.nil?
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ server_signer_id == o.server_signer_id &&
106
+ wallets == o.wallets
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [server_signer_id, wallets].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ attributes = attributes.transform_keys(&:to_sym)
127
+ transformed_hash = {}
128
+ openapi_types.each_pair do |key, type|
129
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
130
+ transformed_hash["#{key}"] = nil
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[attribute_map[key]].is_a?(Array)
135
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
136
+ end
137
+ elsif !attributes[attribute_map[key]].nil?
138
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
139
+ end
140
+ end
141
+ new(transformed_hash)
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def self._deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ # models (e.g. Pet) or oneOf
182
+ klass = Coinbase::Client.const_get(type)
183
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.compact.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to? :to_hash
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+
233
+ end
234
+
235
+ end