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,79 @@
|
|
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 'cgi'
|
14
|
+
|
15
|
+
module Coinbase::Client
|
16
|
+
class UsersApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Get current user
|
23
|
+
# Get current user
|
24
|
+
# @param [Hash] opts the optional parameters
|
25
|
+
# @return [User]
|
26
|
+
def get_current_user(opts = {})
|
27
|
+
data, _status_code, _headers = get_current_user_with_http_info(opts)
|
28
|
+
data
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get current user
|
32
|
+
# Get current user
|
33
|
+
# @param [Hash] opts the optional parameters
|
34
|
+
# @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
|
35
|
+
def get_current_user_with_http_info(opts = {})
|
36
|
+
if @api_client.config.debugging
|
37
|
+
@api_client.config.logger.debug 'Calling API: UsersApi.get_current_user ...'
|
38
|
+
end
|
39
|
+
# resource path
|
40
|
+
local_var_path = '/v1/users/me'
|
41
|
+
|
42
|
+
# query parameters
|
43
|
+
query_params = opts[:query_params] || {}
|
44
|
+
|
45
|
+
# header parameters
|
46
|
+
header_params = opts[:header_params] || {}
|
47
|
+
# HTTP header 'Accept' (if needed)
|
48
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
49
|
+
|
50
|
+
# form parameters
|
51
|
+
form_params = opts[:form_params] || {}
|
52
|
+
|
53
|
+
# http body (model)
|
54
|
+
post_body = opts[:debug_body]
|
55
|
+
|
56
|
+
# return_type
|
57
|
+
return_type = opts[:debug_return_type] || 'User'
|
58
|
+
|
59
|
+
# auth_names
|
60
|
+
auth_names = opts[:debug_auth_names] || []
|
61
|
+
|
62
|
+
new_options = opts.merge(
|
63
|
+
:operation => :"UsersApi.get_current_user",
|
64
|
+
:header_params => header_params,
|
65
|
+
:query_params => query_params,
|
66
|
+
:form_params => form_params,
|
67
|
+
:body => post_body,
|
68
|
+
:auth_names => auth_names,
|
69
|
+
:return_type => return_type
|
70
|
+
)
|
71
|
+
|
72
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
73
|
+
if @api_client.config.debugging
|
74
|
+
@api_client.config.logger.debug "API called: UsersApi#get_current_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
75
|
+
end
|
76
|
+
return data, status_code, headers
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -20,7 +20,7 @@ module Coinbase::Client
|
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
22
|
# Get a validator belonging to the CDP project
|
23
|
-
# Get a validator belonging to the
|
23
|
+
# Get a validator belonging to the user for a given network, asset and id.
|
24
24
|
# @param network_id [String] The ID of the blockchain network.
|
25
25
|
# @param asset_id [String] The symbol of the asset to get the validator for.
|
26
26
|
# @param validator_id [String] The unique id of the validator to fetch details for.
|
@@ -32,7 +32,7 @@ module Coinbase::Client
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# Get a validator belonging to the CDP project
|
35
|
-
# Get a validator belonging to the
|
35
|
+
# Get a validator belonging to the user for a given network, asset and id.
|
36
36
|
# @param network_id [String] The ID of the blockchain network.
|
37
37
|
# @param asset_id [String] The symbol of the asset to get the validator for.
|
38
38
|
# @param validator_id [String] The unique id of the validator to fetch details for.
|
@@ -95,7 +95,7 @@ module Coinbase::Client
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# List validators belonging to the CDP project
|
98
|
-
# List validators belonging to the
|
98
|
+
# List validators belonging to the user for a given network and asset.
|
99
99
|
# @param network_id [String] The ID of the blockchain network.
|
100
100
|
# @param asset_id [String] The symbol of the asset to get the validators for.
|
101
101
|
# @param [Hash] opts the optional parameters
|
@@ -109,7 +109,7 @@ module Coinbase::Client
|
|
109
109
|
end
|
110
110
|
|
111
111
|
# List validators belonging to the CDP project
|
112
|
-
# List validators belonging to the
|
112
|
+
# List validators belonging to the user for a given network and asset.
|
113
113
|
# @param network_id [String] The ID of the blockchain network.
|
114
114
|
# @param asset_id [String] The symbol of the asset to get the validators for.
|
115
115
|
# @param [Hash] opts the optional parameters
|
@@ -20,7 +20,7 @@ module Coinbase::Client
|
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
22
|
# Create a new wallet
|
23
|
-
# Create a new wallet scoped to the
|
23
|
+
# Create a new wallet scoped to the user.
|
24
24
|
# @param [Hash] opts the optional parameters
|
25
25
|
# @option opts [CreateWalletRequest] :create_wallet_request
|
26
26
|
# @return [Wallet]
|
@@ -30,7 +30,7 @@ module Coinbase::Client
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Create a new wallet
|
33
|
-
# Create a new wallet scoped to the
|
33
|
+
# Create a new wallet scoped to the user.
|
34
34
|
# @param [Hash] opts the optional parameters
|
35
35
|
# @option opts [CreateWalletRequest] :create_wallet_request
|
36
36
|
# @return [Array<(Wallet, Integer, Hash)>] Wallet data, response status code and response headers
|
@@ -279,7 +279,7 @@ module Coinbase::Client
|
|
279
279
|
end
|
280
280
|
|
281
281
|
# List wallets
|
282
|
-
# List wallets belonging to the
|
282
|
+
# List wallets belonging to the user.
|
283
283
|
# @param [Hash] opts the optional parameters
|
284
284
|
# @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
|
285
285
|
# @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
|
@@ -290,7 +290,7 @@ module Coinbase::Client
|
|
290
290
|
end
|
291
291
|
|
292
292
|
# List wallets
|
293
|
-
# List wallets belonging to the
|
293
|
+
# List wallets belonging to the user.
|
294
294
|
# @param [Hash] opts the optional parameters
|
295
295
|
# @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
|
296
296
|
# @option opts [String] :page A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
|
@@ -19,6 +19,76 @@ module Coinbase::Client
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
|
+
# Create a new webhook scoped to a wallet
|
23
|
+
# Create a new webhook scoped to a wallet
|
24
|
+
# @param wallet_id [String] The ID of the wallet to create the webhook for.
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
|
27
|
+
# @return [Webhook]
|
28
|
+
def create_wallet_webhook(wallet_id, opts = {})
|
29
|
+
data, _status_code, _headers = create_wallet_webhook_with_http_info(wallet_id, opts)
|
30
|
+
data
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a new webhook scoped to a wallet
|
34
|
+
# Create a new webhook scoped to a wallet
|
35
|
+
# @param wallet_id [String] The ID of the wallet to create the webhook for.
|
36
|
+
# @param [Hash] opts the optional parameters
|
37
|
+
# @option opts [CreateWalletWebhookRequest] :create_wallet_webhook_request
|
38
|
+
# @return [Array<(Webhook, Integer, Hash)>] Webhook data, response status code and response headers
|
39
|
+
def create_wallet_webhook_with_http_info(wallet_id, opts = {})
|
40
|
+
if @api_client.config.debugging
|
41
|
+
@api_client.config.logger.debug 'Calling API: WebhooksApi.create_wallet_webhook ...'
|
42
|
+
end
|
43
|
+
# verify the required parameter 'wallet_id' is set
|
44
|
+
if @api_client.config.client_side_validation && wallet_id.nil?
|
45
|
+
fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WebhooksApi.create_wallet_webhook"
|
46
|
+
end
|
47
|
+
# resource path
|
48
|
+
local_var_path = '/v1/wallets/{wallet_id}/webhooks'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s))
|
49
|
+
|
50
|
+
# query parameters
|
51
|
+
query_params = opts[:query_params] || {}
|
52
|
+
|
53
|
+
# header parameters
|
54
|
+
header_params = opts[:header_params] || {}
|
55
|
+
# HTTP header 'Accept' (if needed)
|
56
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
57
|
+
# HTTP header 'Content-Type'
|
58
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
59
|
+
if !content_type.nil?
|
60
|
+
header_params['Content-Type'] = content_type
|
61
|
+
end
|
62
|
+
|
63
|
+
# form parameters
|
64
|
+
form_params = opts[:form_params] || {}
|
65
|
+
|
66
|
+
# http body (model)
|
67
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_wallet_webhook_request'])
|
68
|
+
|
69
|
+
# return_type
|
70
|
+
return_type = opts[:debug_return_type] || 'Webhook'
|
71
|
+
|
72
|
+
# auth_names
|
73
|
+
auth_names = opts[:debug_auth_names] || []
|
74
|
+
|
75
|
+
new_options = opts.merge(
|
76
|
+
:operation => :"WebhooksApi.create_wallet_webhook",
|
77
|
+
:header_params => header_params,
|
78
|
+
:query_params => query_params,
|
79
|
+
:form_params => form_params,
|
80
|
+
:body => post_body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => return_type
|
83
|
+
)
|
84
|
+
|
85
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
86
|
+
if @api_client.config.debugging
|
87
|
+
@api_client.config.logger.debug "API called: WebhooksApi#create_wallet_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
88
|
+
end
|
89
|
+
return data, status_code, headers
|
90
|
+
end
|
91
|
+
|
22
92
|
# Create a new webhook
|
23
93
|
# Create a new webhook
|
24
94
|
# @param [Hash] opts the optional parameters
|
@@ -51,7 +121,7 @@ module Coinbase::Client
|
|
51
121
|
# HTTP header 'Content-Type'
|
52
122
|
content_type = @api_client.select_header_content_type(['application/json'])
|
53
123
|
if !content_type.nil?
|
54
|
-
|
124
|
+
header_params['Content-Type'] = content_type
|
55
125
|
end
|
56
126
|
|
57
127
|
# form parameters
|
@@ -251,7 +321,7 @@ module Coinbase::Client
|
|
251
321
|
# HTTP header 'Content-Type'
|
252
322
|
content_type = @api_client.select_header_content_type(['application/json'])
|
253
323
|
if !content_type.nil?
|
254
|
-
|
324
|
+
header_params['Content-Type'] = content_type
|
255
325
|
end
|
256
326
|
|
257
327
|
# form parameters
|
@@ -0,0 +1,259 @@
|
|
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 CreateSmartContractRequest
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
attr_accessor :options
|
21
|
+
|
22
|
+
class EnumAttributeValidator
|
23
|
+
attr_reader :datatype
|
24
|
+
attr_reader :allowable_values
|
25
|
+
|
26
|
+
def initialize(datatype, allowable_values)
|
27
|
+
@allowable_values = allowable_values.map do |value|
|
28
|
+
case datatype.to_s
|
29
|
+
when /Integer/i
|
30
|
+
value.to_i
|
31
|
+
when /Float/i
|
32
|
+
value.to_f
|
33
|
+
else
|
34
|
+
value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid?(value)
|
40
|
+
!value || allowable_values.include?(value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
45
|
+
def self.attribute_map
|
46
|
+
{
|
47
|
+
:'type' => :'type',
|
48
|
+
:'options' => :'options'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns all the JSON keys this model knows about
|
53
|
+
def self.acceptable_attributes
|
54
|
+
attribute_map.values
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute type mapping.
|
58
|
+
def self.openapi_types
|
59
|
+
{
|
60
|
+
:'type' => :'SmartContractType',
|
61
|
+
:'options' => :'SmartContractOptions'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# List of attributes with nullable: true
|
66
|
+
def self.openapi_nullable
|
67
|
+
Set.new([
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateSmartContractRequest` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateSmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'type')
|
87
|
+
self.type = attributes[:'type']
|
88
|
+
else
|
89
|
+
self.type = nil
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'options')
|
93
|
+
self.options = attributes[:'options']
|
94
|
+
else
|
95
|
+
self.options = nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
100
|
+
# @return Array for valid properties with the reasons
|
101
|
+
def list_invalid_properties
|
102
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
103
|
+
invalid_properties = Array.new
|
104
|
+
if @type.nil?
|
105
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
106
|
+
end
|
107
|
+
|
108
|
+
if @options.nil?
|
109
|
+
invalid_properties.push('invalid value for "options", options cannot be nil.')
|
110
|
+
end
|
111
|
+
|
112
|
+
invalid_properties
|
113
|
+
end
|
114
|
+
|
115
|
+
# Check to see if the all the properties in the model are valid
|
116
|
+
# @return true if the model is valid
|
117
|
+
def valid?
|
118
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
119
|
+
return false if @type.nil?
|
120
|
+
return false if @options.nil?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
# Checks equality by comparing each attribute.
|
125
|
+
# @param [Object] Object to be compared
|
126
|
+
def ==(o)
|
127
|
+
return true if self.equal?(o)
|
128
|
+
self.class == o.class &&
|
129
|
+
type == o.type &&
|
130
|
+
options == o.options
|
131
|
+
end
|
132
|
+
|
133
|
+
# @see the `==` method
|
134
|
+
# @param [Object] Object to be compared
|
135
|
+
def eql?(o)
|
136
|
+
self == o
|
137
|
+
end
|
138
|
+
|
139
|
+
# Calculates hash code according to all attributes.
|
140
|
+
# @return [Integer] Hash code
|
141
|
+
def hash
|
142
|
+
[type, options].hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def self.build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
attributes = attributes.transform_keys(&:to_sym)
|
151
|
+
transformed_hash = {}
|
152
|
+
openapi_types.each_pair do |key, type|
|
153
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
154
|
+
transformed_hash["#{key}"] = nil
|
155
|
+
elsif type =~ /\AArray<(.*)>/i
|
156
|
+
# check to ensure the input is an array given that the attribute
|
157
|
+
# is documented as an array but the input is not
|
158
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
159
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
160
|
+
end
|
161
|
+
elsif !attributes[attribute_map[key]].nil?
|
162
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
new(transformed_hash)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Deserializes the data based on type
|
169
|
+
# @param string type Data type
|
170
|
+
# @param string value Value to be deserialized
|
171
|
+
# @return [Object] Deserialized data
|
172
|
+
def self._deserialize(type, value)
|
173
|
+
case type.to_sym
|
174
|
+
when :Time
|
175
|
+
Time.parse(value)
|
176
|
+
when :Date
|
177
|
+
Date.parse(value)
|
178
|
+
when :String
|
179
|
+
value.to_s
|
180
|
+
when :Integer
|
181
|
+
value.to_i
|
182
|
+
when :Float
|
183
|
+
value.to_f
|
184
|
+
when :Boolean
|
185
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
186
|
+
true
|
187
|
+
else
|
188
|
+
false
|
189
|
+
end
|
190
|
+
when :Object
|
191
|
+
# generic object (usually a Hash), return directly
|
192
|
+
value
|
193
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
194
|
+
inner_type = Regexp.last_match[:inner_type]
|
195
|
+
value.map { |v| _deserialize(inner_type, v) }
|
196
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
197
|
+
k_type = Regexp.last_match[:k_type]
|
198
|
+
v_type = Regexp.last_match[:v_type]
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each do |k, v|
|
201
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
else # model
|
205
|
+
# models (e.g. Pet) or oneOf
|
206
|
+
klass = Coinbase::Client.const_get(type)
|
207
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
if value.nil?
|
230
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
231
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
232
|
+
end
|
233
|
+
|
234
|
+
hash[param] = _to_hash(value)
|
235
|
+
end
|
236
|
+
hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Outputs non-array value in the form of hash
|
240
|
+
# For object, use to_hash. Otherwise, just return the value
|
241
|
+
# @param [Object] value Any valid value
|
242
|
+
# @return [Hash] Returns the value in the form of hash
|
243
|
+
def _to_hash(value)
|
244
|
+
if value.is_a?(Array)
|
245
|
+
value.compact.map { |v| _to_hash(v) }
|
246
|
+
elsif value.is_a?(Hash)
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
249
|
+
end
|
250
|
+
elsif value.respond_to? :to_hash
|
251
|
+
value.to_hash
|
252
|
+
else
|
253
|
+
value
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|