coinbase-sdk 0.6.0 → 0.10.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 +44 -0
  3. data/lib/coinbase/address.rb +13 -4
  4. data/lib/coinbase/client/api/external_addresses_api.rb +26 -27
  5. data/lib/coinbase/client/api/fund_api.rb +336 -0
  6. data/lib/coinbase/client/api/onchain_identity_api.rb +108 -0
  7. data/lib/coinbase/client/api/smart_contracts_api.rb +80 -0
  8. data/lib/coinbase/client/api/transaction_history_api.rb +101 -0
  9. data/lib/coinbase/client/api/webhooks_api.rb +70 -0
  10. data/lib/coinbase/client/models/create_fund_operation_request.rb +249 -0
  11. data/lib/coinbase/client/models/create_fund_quote_request.rb +239 -0
  12. data/lib/coinbase/client/models/create_wallet_webhook_request.rb +232 -0
  13. data/lib/coinbase/client/models/crypto_amount.rb +239 -0
  14. data/lib/coinbase/client/models/ethereum_token_transfer.rb +327 -0
  15. data/lib/coinbase/client/models/ethereum_transaction.rb +12 -1
  16. data/lib/coinbase/client/models/faucet_transaction.rb +20 -4
  17. data/lib/coinbase/client/models/fiat_amount.rb +240 -0
  18. data/lib/coinbase/client/models/fund_operation.rb +373 -0
  19. data/lib/coinbase/client/models/fund_operation_fees.rb +238 -0
  20. data/lib/coinbase/client/models/fund_operation_list.rb +275 -0
  21. data/lib/coinbase/client/models/fund_quote.rb +339 -0
  22. data/lib/coinbase/client/models/multi_token_contract_options.rb +223 -0
  23. data/lib/coinbase/client/models/network_identifier.rb +2 -1
  24. data/lib/coinbase/client/models/nft_contract_options.rb +21 -4
  25. data/lib/coinbase/client/models/onchain_name.rb +357 -0
  26. data/lib/coinbase/client/models/onchain_name_list.rb +262 -0
  27. data/lib/coinbase/client/models/read_contract_request.rb +249 -0
  28. data/lib/coinbase/client/models/smart_contract_options.rb +1 -0
  29. data/lib/coinbase/client/models/smart_contract_type.rb +2 -1
  30. data/lib/coinbase/client/models/solidity_value.rb +287 -0
  31. data/lib/coinbase/client/models/{feature.rb → token_transfer_type.rb} +10 -10
  32. data/lib/coinbase/client/models/update_webhook_request.rb +0 -7
  33. data/lib/coinbase/client.rb +19 -0
  34. data/lib/coinbase/faucet_transaction.rb +64 -4
  35. data/lib/coinbase/smart_contract.rb +149 -0
  36. data/lib/coinbase/transaction.rb +8 -2
  37. data/lib/coinbase/version.rb +1 -1
  38. data/lib/coinbase/wallet.rb +35 -1
  39. data/lib/coinbase/webhook.rb +3 -7
  40. metadata +21 -3
@@ -0,0 +1,108 @@
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 OnchainIdentityApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Obtains onchain identity for an address on a specific network
23
+ # Obtains onchain identity for an address on a specific network
24
+ # @param network_id [String] The ID of the blockchain network
25
+ # @param address_id [String] The ID of the address to fetch the identity for
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [Array<String>] :roles A filter by role of the names related to this address (managed or owned)
28
+ # @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.
29
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
30
+ # @return [OnchainNameList]
31
+ def resolve_identity_by_address(network_id, address_id, opts = {})
32
+ data, _status_code, _headers = resolve_identity_by_address_with_http_info(network_id, address_id, opts)
33
+ data
34
+ end
35
+
36
+ # Obtains onchain identity for an address on a specific network
37
+ # Obtains onchain identity for an address on a specific network
38
+ # @param network_id [String] The ID of the blockchain network
39
+ # @param address_id [String] The ID of the address to fetch the identity for
40
+ # @param [Hash] opts the optional parameters
41
+ # @option opts [Array<String>] :roles A filter by role of the names related to this address (managed or owned)
42
+ # @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.
43
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
44
+ # @return [Array<(OnchainNameList, Integer, Hash)>] OnchainNameList data, response status code and response headers
45
+ def resolve_identity_by_address_with_http_info(network_id, address_id, opts = {})
46
+ if @api_client.config.debugging
47
+ @api_client.config.logger.debug 'Calling API: OnchainIdentityApi.resolve_identity_by_address ...'
48
+ end
49
+ # verify the required parameter 'network_id' is set
50
+ if @api_client.config.client_side_validation && network_id.nil?
51
+ fail ArgumentError, "Missing the required parameter 'network_id' when calling OnchainIdentityApi.resolve_identity_by_address"
52
+ end
53
+ # verify the required parameter 'address_id' is set
54
+ if @api_client.config.client_side_validation && address_id.nil?
55
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling OnchainIdentityApi.resolve_identity_by_address"
56
+ end
57
+ allowable_values = ["managed", "owned", "unknown_default_open_api"]
58
+ if @api_client.config.client_side_validation && opts[:'roles'] && !opts[:'roles'].all? { |item| allowable_values.include?(item) }
59
+ fail ArgumentError, "invalid value for \"roles\", must include one of #{allowable_values}"
60
+ end
61
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000
62
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling OnchainIdentityApi.resolve_identity_by_address, the character length must be smaller than or equal to 5000.'
63
+ end
64
+
65
+ # resource path
66
+ local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/identity'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s))
67
+
68
+ # query parameters
69
+ query_params = opts[:query_params] || {}
70
+ query_params[:'roles'] = @api_client.build_collection_param(opts[:'roles'], :csv) if !opts[:'roles'].nil?
71
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
72
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
73
+
74
+ # header parameters
75
+ header_params = opts[:header_params] || {}
76
+ # HTTP header 'Accept' (if needed)
77
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
78
+
79
+ # form parameters
80
+ form_params = opts[:form_params] || {}
81
+
82
+ # http body (model)
83
+ post_body = opts[:debug_body]
84
+
85
+ # return_type
86
+ return_type = opts[:debug_return_type] || 'OnchainNameList'
87
+
88
+ # auth_names
89
+ auth_names = opts[:debug_auth_names] || []
90
+
91
+ new_options = opts.merge(
92
+ :operation => :"OnchainIdentityApi.resolve_identity_by_address",
93
+ :header_params => header_params,
94
+ :query_params => query_params,
95
+ :form_params => form_params,
96
+ :body => post_body,
97
+ :auth_names => auth_names,
98
+ :return_type => return_type
99
+ )
100
+
101
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
102
+ if @api_client.config.debugging
103
+ @api_client.config.logger.debug "API called: OnchainIdentityApi#resolve_identity_by_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
104
+ end
105
+ return data, status_code, headers
106
+ end
107
+ end
108
+ end
@@ -328,5 +328,85 @@ module Coinbase::Client
328
328
  end
329
329
  return data, status_code, headers
330
330
  end
331
+
332
+ # Read data from a smart contract
333
+ # Perform a read operation on a smart contract without creating a transaction
334
+ # @param network_id [String]
335
+ # @param contract_address [String]
336
+ # @param read_contract_request [ReadContractRequest]
337
+ # @param [Hash] opts the optional parameters
338
+ # @return [SolidityValue]
339
+ def read_contract(network_id, contract_address, read_contract_request, opts = {})
340
+ data, _status_code, _headers = read_contract_with_http_info(network_id, contract_address, read_contract_request, opts)
341
+ data
342
+ end
343
+
344
+ # Read data from a smart contract
345
+ # Perform a read operation on a smart contract without creating a transaction
346
+ # @param network_id [String]
347
+ # @param contract_address [String]
348
+ # @param read_contract_request [ReadContractRequest]
349
+ # @param [Hash] opts the optional parameters
350
+ # @return [Array<(SolidityValue, Integer, Hash)>] SolidityValue data, response status code and response headers
351
+ def read_contract_with_http_info(network_id, contract_address, read_contract_request, opts = {})
352
+ if @api_client.config.debugging
353
+ @api_client.config.logger.debug 'Calling API: SmartContractsApi.read_contract ...'
354
+ end
355
+ # verify the required parameter 'network_id' is set
356
+ if @api_client.config.client_side_validation && network_id.nil?
357
+ fail ArgumentError, "Missing the required parameter 'network_id' when calling SmartContractsApi.read_contract"
358
+ end
359
+ # verify the required parameter 'contract_address' is set
360
+ if @api_client.config.client_side_validation && contract_address.nil?
361
+ fail ArgumentError, "Missing the required parameter 'contract_address' when calling SmartContractsApi.read_contract"
362
+ end
363
+ # verify the required parameter 'read_contract_request' is set
364
+ if @api_client.config.client_side_validation && read_contract_request.nil?
365
+ fail ArgumentError, "Missing the required parameter 'read_contract_request' when calling SmartContractsApi.read_contract"
366
+ end
367
+ # resource path
368
+ local_var_path = '/v1/networks/{network_id}/smart_contracts/{contract_address}/read'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'contract_address' + '}', CGI.escape(contract_address.to_s))
369
+
370
+ # query parameters
371
+ query_params = opts[:query_params] || {}
372
+
373
+ # header parameters
374
+ header_params = opts[:header_params] || {}
375
+ # HTTP header 'Accept' (if needed)
376
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
377
+ # HTTP header 'Content-Type'
378
+ content_type = @api_client.select_header_content_type(['application/json'])
379
+ if !content_type.nil?
380
+ header_params['Content-Type'] = content_type
381
+ end
382
+
383
+ # form parameters
384
+ form_params = opts[:form_params] || {}
385
+
386
+ # http body (model)
387
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(read_contract_request)
388
+
389
+ # return_type
390
+ return_type = opts[:debug_return_type] || 'SolidityValue'
391
+
392
+ # auth_names
393
+ auth_names = opts[:debug_auth_names] || []
394
+
395
+ new_options = opts.merge(
396
+ :operation => :"SmartContractsApi.read_contract",
397
+ :header_params => header_params,
398
+ :query_params => query_params,
399
+ :form_params => form_params,
400
+ :body => post_body,
401
+ :auth_names => auth_names,
402
+ :return_type => return_type
403
+ )
404
+
405
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
406
+ if @api_client.config.debugging
407
+ @api_client.config.logger.debug "API called: SmartContractsApi#read_contract\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
408
+ end
409
+ return data, status_code, headers
410
+ end
331
411
  end
332
412
  end
@@ -0,0 +1,101 @@
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 TransactionHistoryApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # List transactions for an address.
23
+ # List all transactions that interact with the address.
24
+ # @param network_id [String] The ID of the blockchain network
25
+ # @param address_id [String] The ID of the address to fetch the transactions for.
26
+ # @param [Hash] opts the optional parameters
27
+ # @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.
28
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
29
+ # @return [AddressTransactionList]
30
+ def list_address_transactions(network_id, address_id, opts = {})
31
+ data, _status_code, _headers = list_address_transactions_with_http_info(network_id, address_id, opts)
32
+ data
33
+ end
34
+
35
+ # List transactions for an address.
36
+ # List all transactions that interact with the address.
37
+ # @param network_id [String] The ID of the blockchain network
38
+ # @param address_id [String] The ID of the address to fetch the transactions for.
39
+ # @param [Hash] opts the optional parameters
40
+ # @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.
41
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
42
+ # @return [Array<(AddressTransactionList, Integer, Hash)>] AddressTransactionList data, response status code and response headers
43
+ def list_address_transactions_with_http_info(network_id, address_id, opts = {})
44
+ if @api_client.config.debugging
45
+ @api_client.config.logger.debug 'Calling API: TransactionHistoryApi.list_address_transactions ...'
46
+ end
47
+ # verify the required parameter 'network_id' is set
48
+ if @api_client.config.client_side_validation && network_id.nil?
49
+ fail ArgumentError, "Missing the required parameter 'network_id' when calling TransactionHistoryApi.list_address_transactions"
50
+ end
51
+ # verify the required parameter 'address_id' is set
52
+ if @api_client.config.client_side_validation && address_id.nil?
53
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling TransactionHistoryApi.list_address_transactions"
54
+ end
55
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000
56
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling TransactionHistoryApi.list_address_transactions, the character length must be smaller than or equal to 5000.'
57
+ end
58
+
59
+ # resource path
60
+ local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/transactions'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s))
61
+
62
+ # query parameters
63
+ query_params = opts[:query_params] || {}
64
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
65
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
66
+
67
+ # header parameters
68
+ header_params = opts[:header_params] || {}
69
+ # HTTP header 'Accept' (if needed)
70
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
71
+
72
+ # form parameters
73
+ form_params = opts[:form_params] || {}
74
+
75
+ # http body (model)
76
+ post_body = opts[:debug_body]
77
+
78
+ # return_type
79
+ return_type = opts[:debug_return_type] || 'AddressTransactionList'
80
+
81
+ # auth_names
82
+ auth_names = opts[:debug_auth_names] || []
83
+
84
+ new_options = opts.merge(
85
+ :operation => :"TransactionHistoryApi.list_address_transactions",
86
+ :header_params => header_params,
87
+ :query_params => query_params,
88
+ :form_params => form_params,
89
+ :body => post_body,
90
+ :auth_names => auth_names,
91
+ :return_type => return_type
92
+ )
93
+
94
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug "API called: TransactionHistoryApi#list_address_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
97
+ end
98
+ return data, status_code, headers
99
+ end
100
+ end
101
+ end
@@ -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
@@ -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