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