coinbase-sdk 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +70 -1
  3. data/lib/coinbase/address.rb +5 -1
  4. data/lib/coinbase/client/api/external_addresses_api.rb +0 -79
  5. data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
  6. data/lib/coinbase/client/api/stake_api.rb +0 -8
  7. data/lib/coinbase/client/api/transaction_history_api.rb +101 -0
  8. data/lib/coinbase/client/api/users_api.rb +79 -0
  9. data/lib/coinbase/client/api/validators_api.rb +4 -4
  10. data/lib/coinbase/client/api/wallets_api.rb +4 -4
  11. data/lib/coinbase/client/api/webhooks_api.rb +72 -2
  12. data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
  13. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +232 -0
  14. data/lib/coinbase/client/models/create_webhook_request.rb +10 -8
  15. data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
  16. data/lib/coinbase/client/models/multi_token_contract_options.rb +223 -0
  17. data/lib/coinbase/client/models/network_identifier.rb +2 -1
  18. data/lib/coinbase/client/models/nft_contract_options.rb +257 -0
  19. data/lib/coinbase/client/models/smart_contract.rb +378 -0
  20. data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
  21. data/lib/coinbase/client/models/smart_contract_options.rb +107 -0
  22. data/lib/coinbase/client/models/smart_contract_type.rb +42 -0
  23. data/lib/coinbase/client/models/staking_balance.rb +2 -2
  24. data/lib/coinbase/client/models/staking_reward.rb +2 -2
  25. data/lib/coinbase/client/models/token_contract_options.rb +257 -0
  26. data/lib/coinbase/client/models/update_webhook_request.rb +10 -8
  27. data/lib/coinbase/client/models/user.rb +231 -0
  28. data/lib/coinbase/client/models/webhook.rb +10 -1
  29. data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
  30. data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
  31. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
  32. data/lib/coinbase/client.rb +15 -0
  33. data/lib/coinbase/contract_invocation.rb +16 -17
  34. data/lib/coinbase/smart_contract.rb +264 -39
  35. data/lib/coinbase/transaction.rb +3 -0
  36. data/lib/coinbase/transfer.rb +1 -1
  37. data/lib/coinbase/version.rb +1 -1
  38. data/lib/coinbase/wallet.rb +45 -2
  39. data/lib/coinbase/webhook.rb +3 -7
  40. metadata +18 -2
@@ -0,0 +1,107 @@
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
+ # Options for smart contract creation
18
+ module SmartContractOptions
19
+ class << self
20
+ # List of class defined in oneOf (OpenAPI v3)
21
+ def openapi_one_of
22
+ [
23
+ :'MultiTokenContractOptions',
24
+ :'NFTContractOptions',
25
+ :'TokenContractOptions'
26
+ ]
27
+ end
28
+
29
+ # Builds the object
30
+ # @param [Mixed] Data to be matched against the list of oneOf items
31
+ # @return [Object] Returns the model or the data itself
32
+ def build(data)
33
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
34
+ # Note:
35
+ # - We do not attempt to check whether exactly one item matches.
36
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
37
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
38
+ # - TODO: scalar values are de facto behaving as if they were nullable.
39
+ # - TODO: logging when debugging is set.
40
+ openapi_one_of.each do |klass|
41
+ begin
42
+ next if klass == :AnyType # "nullable: true"
43
+ typed_data = find_and_cast_into_type(klass, data)
44
+ return typed_data if typed_data
45
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
46
+ end
47
+ end
48
+
49
+ openapi_one_of.include?(:AnyType) ? data : nil
50
+ end
51
+
52
+ private
53
+
54
+ SchemaMismatchError = Class.new(StandardError)
55
+
56
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
57
+ def find_and_cast_into_type(klass, data)
58
+ return if data.nil?
59
+
60
+ case klass.to_s
61
+ when 'Boolean'
62
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
63
+ when 'Float'
64
+ return data if data.instance_of?(Float)
65
+ when 'Integer'
66
+ return data if data.instance_of?(Integer)
67
+ when 'Time'
68
+ return Time.parse(data)
69
+ when 'Date'
70
+ return Date.parse(data)
71
+ when 'String'
72
+ return data if data.instance_of?(String)
73
+ when 'Object' # "type: object"
74
+ return data if data.instance_of?(Hash)
75
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
76
+ if data.instance_of?(Array)
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
79
+ end
80
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
81
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
82
+ sub_type = Regexp.last_match[:sub_type]
83
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
84
+ end
85
+ else # model
86
+ const = Coinbase::Client.const_get(klass)
87
+ if const
88
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
89
+ model = const.build(data)
90
+ return model if model
91
+ else
92
+ # raise if data contains keys that are not known to the model
93
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
94
+ model = const.build_from_hash(data)
95
+ return model if model
96
+ end
97
+ end
98
+ end
99
+
100
+ raise # if no match by now, raise
101
+ rescue
102
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
103
+ end
104
+ end
105
+ end
106
+
107
+ end
@@ -0,0 +1,42 @@
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 SmartContractType
18
+ ERC20 = "erc20".freeze
19
+ ERC721 = "erc721".freeze
20
+ ERC1155 = "erc1155".freeze
21
+ UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
22
+
23
+ def self.all_vars
24
+ @all_vars ||= [ERC20, ERC721, ERC1155, UNKNOWN_DEFAULT_OPEN_API].freeze
25
+ end
26
+
27
+ # Builds the enum from string
28
+ # @param [String] The enum value in the form of the string
29
+ # @return [String] The enum value
30
+ def self.build_from_hash(value)
31
+ new.build_from_hash(value)
32
+ end
33
+
34
+ # Builds the enum from string
35
+ # @param [String] The enum value in the form of the string
36
+ # @return [String] The enum value
37
+ def build_from_hash(value)
38
+ return value if SmartContractType.all_vars.include?(value)
39
+ raise "Invalid ENUM value #{value} for class #SmartContractType"
40
+ end
41
+ end
42
+ end
@@ -19,7 +19,7 @@ module Coinbase::Client
19
19
  # The onchain address for which the staking balances are being fetched.
20
20
  attr_accessor :address
21
21
 
22
- # The date of the staking balance in format 'YYYY-MM-DD' in UTC.
22
+ # The timestamp of the staking balance in UTC.
23
23
  attr_accessor :date
24
24
 
25
25
  attr_accessor :bonded_stake
@@ -49,7 +49,7 @@ module Coinbase::Client
49
49
  def self.openapi_types
50
50
  {
51
51
  :'address' => :'String',
52
- :'date' => :'Date',
52
+ :'date' => :'Time',
53
53
  :'bonded_stake' => :'Balance',
54
54
  :'unbonded_balance' => :'Balance',
55
55
  :'participant_type' => :'String'
@@ -19,7 +19,7 @@ module Coinbase::Client
19
19
  # The onchain address for which the staking rewards are being fetched.
20
20
  attr_accessor :address_id
21
21
 
22
- # The date of the reward in format 'YYYY-MM-DD' in UTC.
22
+ # The timestamp of the reward in UTC.
23
23
  attr_accessor :date
24
24
 
25
25
  # The reward amount in requested \"format\". Default is USD.
@@ -75,7 +75,7 @@ module Coinbase::Client
75
75
  def self.openapi_types
76
76
  {
77
77
  :'address_id' => :'String',
78
- :'date' => :'Date',
78
+ :'date' => :'Time',
79
79
  :'amount' => :'String',
80
80
  :'state' => :'String',
81
81
  :'format' => :'StakingRewardFormat',
@@ -0,0 +1,257 @@
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
+ # Options for token contract creation
18
+ class TokenContractOptions
19
+ # The name of the token
20
+ attr_accessor :name
21
+
22
+ # The symbol of the token
23
+ attr_accessor :symbol
24
+
25
+ # The total supply of the token denominated in the whole amount of the token.
26
+ attr_accessor :total_supply
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'name' => :'name',
32
+ :'symbol' => :'symbol',
33
+ :'total_supply' => :'total_supply'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'name' => :'String',
46
+ :'symbol' => :'String',
47
+ :'total_supply' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::TokenContractOptions` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::TokenContractOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'name')
73
+ self.name = attributes[:'name']
74
+ else
75
+ self.name = nil
76
+ end
77
+
78
+ if attributes.key?(:'symbol')
79
+ self.symbol = attributes[:'symbol']
80
+ else
81
+ self.symbol = nil
82
+ end
83
+
84
+ if attributes.key?(:'total_supply')
85
+ self.total_supply = attributes[:'total_supply']
86
+ else
87
+ self.total_supply = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @name.nil?
97
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
98
+ end
99
+
100
+ if @symbol.nil?
101
+ invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
102
+ end
103
+
104
+ if @total_supply.nil?
105
+ invalid_properties.push('invalid value for "total_supply", total_supply cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @name.nil?
116
+ return false if @symbol.nil?
117
+ return false if @total_supply.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ name == o.name &&
127
+ symbol == o.symbol &&
128
+ total_supply == o.total_supply
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [name, symbol, total_supply].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif 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[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Coinbase::Client.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -15,6 +15,8 @@ require 'time'
15
15
 
16
16
  module Coinbase::Client
17
17
  class UpdateWebhookRequest
18
+ attr_accessor :event_type_filter
19
+
18
20
  # Webhook will monitor all events that matches any one of the event filters.
19
21
  attr_accessor :event_filters
20
22
 
@@ -24,6 +26,7 @@ module Coinbase::Client
24
26
  # Attribute mapping from ruby-style variable name to JSON key.
25
27
  def self.attribute_map
26
28
  {
29
+ :'event_type_filter' => :'event_type_filter',
27
30
  :'event_filters' => :'event_filters',
28
31
  :'notification_uri' => :'notification_uri'
29
32
  }
@@ -37,6 +40,7 @@ module Coinbase::Client
37
40
  # Attribute type mapping.
38
41
  def self.openapi_types
39
42
  {
43
+ :'event_type_filter' => :'WebhookEventTypeFilter',
40
44
  :'event_filters' => :'Array<WebhookEventFilter>',
41
45
  :'notification_uri' => :'String'
42
46
  }
@@ -63,12 +67,14 @@ module Coinbase::Client
63
67
  h[k.to_sym] = v
64
68
  }
65
69
 
70
+ if attributes.key?(:'event_type_filter')
71
+ self.event_type_filter = attributes[:'event_type_filter']
72
+ end
73
+
66
74
  if attributes.key?(:'event_filters')
67
75
  if (value = attributes[:'event_filters']).is_a?(Array)
68
76
  self.event_filters = value
69
77
  end
70
- else
71
- self.event_filters = nil
72
78
  end
73
79
 
74
80
  if attributes.key?(:'notification_uri')
@@ -83,10 +89,6 @@ module Coinbase::Client
83
89
  def list_invalid_properties
84
90
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
85
91
  invalid_properties = Array.new
86
- if @event_filters.nil?
87
- invalid_properties.push('invalid value for "event_filters", event_filters cannot be nil.')
88
- end
89
-
90
92
  if @notification_uri.nil?
91
93
  invalid_properties.push('invalid value for "notification_uri", notification_uri cannot be nil.')
92
94
  end
@@ -98,7 +100,6 @@ module Coinbase::Client
98
100
  # @return true if the model is valid
99
101
  def valid?
100
102
  warn '[DEPRECATED] the `valid?` method is obsolete'
101
- return false if @event_filters.nil?
102
103
  return false if @notification_uri.nil?
103
104
  true
104
105
  end
@@ -108,6 +109,7 @@ module Coinbase::Client
108
109
  def ==(o)
109
110
  return true if self.equal?(o)
110
111
  self.class == o.class &&
112
+ event_type_filter == o.event_type_filter &&
111
113
  event_filters == o.event_filters &&
112
114
  notification_uri == o.notification_uri
113
115
  end
@@ -121,7 +123,7 @@ module Coinbase::Client
121
123
  # Calculates hash code according to all attributes.
122
124
  # @return [Integer] Hash code
123
125
  def hash
124
- [event_filters, notification_uri].hash
126
+ [event_type_filter, event_filters, notification_uri].hash
125
127
  end
126
128
 
127
129
  # Builds the object from hash