From e4fdeec0a09bd33c8dbe5f0fe75b58331413cb2f Mon Sep 17 00:00:00 2001 From: Jayasudha Jayakumaran Date: Tue, 23 Apr 2024 14:48:39 -0700 Subject: [PATCH 1/2] update ruby client for cdp --- lib/coinbase/client.rb | 57 +- lib/coinbase/client/.DS_Store | Bin 0 -> 6148 bytes lib/coinbase/client/api/addresses_api.rb | 378 ++++++++++ lib/coinbase/client/api/users_api.rb | 118 +-- lib/coinbase/client/api/wallets_api.rb | 338 +++++++++ lib/coinbase/client/api_client.rb | 702 +++++++++--------- lib/coinbase/client/api_error.rb | 93 +-- lib/coinbase/client/configuration.rb | 2 +- lib/coinbase/client/models/address.rb | 273 +++++++ .../client/models/address_balance_list.rb | 275 +++++++ lib/coinbase/client/models/address_list.rb | 275 +++++++ lib/coinbase/client/models/asset.rb | 260 +++++++ lib/coinbase/client/models/balance.rb | 239 ++++++ .../client/models/create_address_request.rb | 239 ++++++ .../client/models/create_wallet_request.rb | 221 ++++++ lib/coinbase/client/models/error.rb | 278 +++++++ lib/coinbase/client/models/user.rb | 375 +++++----- lib/coinbase/client/models/wallet.rb | 232 ++++++ lib/coinbase/client/models/wallet_list.rb | 275 +++++++ lib/coinbase/client/version.rb | 27 +- 20 files changed, 3984 insertions(+), 673 deletions(-) create mode 100644 lib/coinbase/client/.DS_Store create mode 100644 lib/coinbase/client/api/addresses_api.rb create mode 100644 lib/coinbase/client/api/wallets_api.rb create mode 100644 lib/coinbase/client/models/address.rb create mode 100644 lib/coinbase/client/models/address_balance_list.rb create mode 100644 lib/coinbase/client/models/address_list.rb create mode 100644 lib/coinbase/client/models/asset.rb create mode 100644 lib/coinbase/client/models/balance.rb create mode 100644 lib/coinbase/client/models/create_address_request.rb create mode 100644 lib/coinbase/client/models/create_wallet_request.rb create mode 100644 lib/coinbase/client/models/error.rb create mode 100644 lib/coinbase/client/models/wallet.rb create mode 100644 lib/coinbase/client/models/wallet_list.rb diff --git a/lib/coinbase/client.rb b/lib/coinbase/client.rb index 5708b06b..f73c4264 100644 --- a/lib/coinbase/client.rb +++ b/lib/coinbase/client.rb @@ -1,11 +1,14 @@ -# frozen_string_literal: true +=begin +#Coinbase Platform API -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end # Common files require 'coinbase/client/api_client' @@ -14,26 +17,36 @@ require 'coinbase/client/configuration' # Models +Coinbase::Client.autoload :Address, 'coinbase/client/models/address' +Coinbase::Client.autoload :AddressBalanceList, 'coinbase/client/models/address_balance_list' +Coinbase::Client.autoload :AddressList, 'coinbase/client/models/address_list' +Coinbase::Client.autoload :Asset, 'coinbase/client/models/asset' +Coinbase::Client.autoload :Balance, 'coinbase/client/models/balance' +Coinbase::Client.autoload :CreateAddressRequest, 'coinbase/client/models/create_address_request' +Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request' +Coinbase::Client.autoload :Error, 'coinbase/client/models/error' Coinbase::Client.autoload :User, 'coinbase/client/models/user' +Coinbase::Client.autoload :Wallet, 'coinbase/client/models/wallet' +Coinbase::Client.autoload :WalletList, 'coinbase/client/models/wallet_list' # APIs +Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api' Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api' +Coinbase::Client.autoload :WalletsApi, 'coinbase/client/api/wallets_api' -module Coinbase - module Client - class << self - # Customize default settings for the SDK using block. - # Coinbase::Client.configure do |config| - # config.username = "xxx" - # config.password = "xxx" - # end - # If no block given, return the default Configuration object. - def configure - if block_given? - yield(Configuration.default) - else - Configuration.default - end +module Coinbase::Client + class << self + # Customize default settings for the SDK using block. + # Coinbase::Client.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default end end end diff --git a/lib/coinbase/client/.DS_Store b/lib/coinbase/client/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d3028a31322d756bf67afdd5012c6da7dceb90ee GIT binary patch literal 6148 zcmeHKOG?B*5Up|s35YODH$q=w^a62+J9l#d9V0rBkig*1MUJ93@DAchT)6QDZhX~M z%PG->h%z)mmcf9CdeF3G&SGTAF`b_`bvuya_o`&? zBRZp&mepl{|2KCVOWhR3qG}e;y9Y0iM}2GgjkUe%XT3!jZBtDRm2^QBt&&yw zWcAVBUwi-XX}xxmqi!}k_{t~Q2j9y+T$}-Cz!`7`{wD*tvqiEUMem&fXTTYFXF$$} zfF_t5c8c-nKo?5@;27#C7)vc7F~Kl5>=a>vu!aIPl&!>I4TnCMUvAhbYB;eKA8aeH zix-ZoBY%kQ#JQsP&VVzJGBDEVMDG7%{4#?@ej4I4XTTZwV+`=Pm=`mAl-;eLK2Pr2 vfOd)|B7U6=AQ&f)08Hc@*^5TC2N}aJH|!K8i|AuG&>sSk5bvCUA7J1Ou4+f$ literal 0 HcmV?d00001 diff --git a/lib/coinbase/client/api/addresses_api.rb b/lib/coinbase/client/api/addresses_api.rb new file mode 100644 index 00000000..ad1f707c --- /dev/null +++ b/lib/coinbase/client/api/addresses_api.rb @@ -0,0 +1,378 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'cgi' + +module Coinbase::Client + class AddressesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create a new address + # Create a new address scoped to the wallet. + # @param wallet_id [String] The ID of the wallet to create the address in. + # @param [Hash] opts the optional parameters + # @option opts [CreateAddressRequest] :create_address_request + # @return [Address] + def create_address(wallet_id, opts = {}) + data, _status_code, _headers = create_address_with_http_info(wallet_id, opts) + data + end + + # Create a new address + # Create a new address scoped to the wallet. + # @param wallet_id [String] The ID of the wallet to create the address in. + # @param [Hash] opts the optional parameters + # @option opts [CreateAddressRequest] :create_address_request + # @return [Array<(Address, Integer, Hash)>] Address data, response status code and response headers + def create_address_with_http_info(wallet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AddressesApi.create_address ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling AddressesApi.create_address" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_address_request']) + + # return_type + return_type = opts[:debug_return_type] || 'Address' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"AddressesApi.create_address", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AddressesApi#create_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get address by onchain address + # Get address + # @param wallet_id [String] The ID of the wallet the address belongs to. + # @param address_id [String] The onchain address of the address that is being fetched. + # @param [Hash] opts the optional parameters + # @return [Address] + def get_address(wallet_id, address_id, opts = {}) + data, _status_code, _headers = get_address_with_http_info(wallet_id, address_id, opts) + data + end + + # Get address by onchain address + # Get address + # @param wallet_id [String] The ID of the wallet the address belongs to. + # @param address_id [String] The onchain address of the address that is being fetched. + # @param [Hash] opts the optional parameters + # @return [Array<(Address, Integer, Hash)>] Address data, response status code and response headers + def get_address_with_http_info(wallet_id, address_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AddressesApi.get_address ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling AddressesApi.get_address" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling AddressesApi.get_address" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Address' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"AddressesApi.get_address", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AddressesApi#get_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get address balance for asset + # Get address balance + # @param wallet_id [String] The ID of the wallet to fetch the balance for + # @param address_id [String] The onchain address of the address that is being fetched. + # @param asset_id [String] The symbol of the asset to fetch the balance for + # @param [Hash] opts the optional parameters + # @return [Balance] + def get_address_balance(wallet_id, address_id, asset_id, opts = {}) + data, _status_code, _headers = get_address_balance_with_http_info(wallet_id, address_id, asset_id, opts) + data + end + + # Get address balance for asset + # Get address balance + # @param wallet_id [String] The ID of the wallet to fetch the balance for + # @param address_id [String] The onchain address of the address that is being fetched. + # @param asset_id [String] The symbol of the asset to fetch the balance for + # @param [Hash] opts the optional parameters + # @return [Array<(Balance, Integer, Hash)>] Balance data, response status code and response headers + def get_address_balance_with_http_info(wallet_id, address_id, asset_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AddressesApi.get_address_balance ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling AddressesApi.get_address_balance" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling AddressesApi.get_address_balance" + end + # verify the required parameter 'asset_id' is set + if @api_client.config.client_side_validation && asset_id.nil? + fail ArgumentError, "Missing the required parameter 'asset_id' when calling AddressesApi.get_address_balance" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/balances/{asset_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Balance' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"AddressesApi.get_address_balance", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AddressesApi#get_address_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get all balances for address + # Get address balances + # @param wallet_id [String] The ID of the wallet to fetch the balances for + # @param address_id [String] The onchain address of the address that is being fetched. + # @param [Hash] opts the optional parameters + # @return [AddressBalanceList] + def list_address_balances(wallet_id, address_id, opts = {}) + data, _status_code, _headers = list_address_balances_with_http_info(wallet_id, address_id, opts) + data + end + + # Get all balances for address + # Get address balances + # @param wallet_id [String] The ID of the wallet to fetch the balances for + # @param address_id [String] The onchain address of the address that is being fetched. + # @param [Hash] opts the optional parameters + # @return [Array<(AddressBalanceList, Integer, Hash)>] AddressBalanceList data, response status code and response headers + def list_address_balances_with_http_info(wallet_id, address_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AddressesApi.list_address_balances ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling AddressesApi.list_address_balances" + end + # verify the required parameter 'address_id' is set + if @api_client.config.client_side_validation && address_id.nil? + fail ArgumentError, "Missing the required parameter 'address_id' when calling AddressesApi.list_address_balances" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/balances'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AddressBalanceList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"AddressesApi.list_address_balances", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AddressesApi#list_address_balances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List addresses in a wallet. + # List addresses in the wallet. + # @param wallet_id [String] The ID of the wallet whose addresess to fetch + # @param [Hash] opts the optional parameters + # @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. + # @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. + # @return [AddressList] + def list_addresses(wallet_id, opts = {}) + data, _status_code, _headers = list_addresses_with_http_info(wallet_id, opts) + data + end + + # List addresses in a wallet. + # List addresses in the wallet. + # @param wallet_id [String] The ID of the wallet whose addresess to fetch + # @param [Hash] opts the optional parameters + # @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. + # @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. + # @return [Array<(AddressList, Integer, Hash)>] AddressList data, response status code and response headers + def list_addresses_with_http_info(wallet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AddressesApi.list_addresses ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling AddressesApi.list_addresses" + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling AddressesApi.list_addresses, the character length must be smaller than or equal to 5000.' + end + + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AddressList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"AddressesApi.list_addresses", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AddressesApi#list_addresses\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/coinbase/client/api/users_api.rb b/lib/coinbase/client/api/users_api.rb index 9d55dc5f..73080e3a 100644 --- a/lib/coinbase/client/api/users_api.rb +++ b/lib/coinbase/client/api/users_api.rb @@ -1,77 +1,79 @@ -# frozen_string_literal: true +=begin +#Coinbase Platform API -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end require 'cgi' -module Coinbase - module Client - class UsersApi - attr_accessor :api_client +module Coinbase::Client + class UsersApi + attr_accessor :api_client - def initialize(api_client = ApiClient.default) - @api_client = api_client - end + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Get current user + # Get current user + # @param [Hash] opts the optional parameters + # @return [User] + def get_current_user(opts = {}) + data, _status_code, _headers = get_current_user_with_http_info(opts) + data + end - # Get current user - # Get current user - # @param [Hash] opts the optional parameters - # @return [User] - def get_current_user(opts = {}) - data, _status_code, _headers = get_current_user_with_http_info(opts) - data + # Get current user + # Get current user + # @param [Hash] opts the optional parameters + # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers + def get_current_user_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsersApi.get_current_user ...' end + # resource path + local_var_path = '/v1/users/me' - # Get current user - # Get current user - # @param [Hash] opts the optional parameters - # @return [Array<(User, Integer, Hash)>] User data, response status code and response headers - def get_current_user_with_http_info(opts = {}) - @api_client.config.logger.debug 'Calling API: UsersApi.get_current_user ...' if @api_client.config.debugging - # resource path - local_var_path = '/v1/users/me' - - # query parameters - query_params = opts[:query_params] || {} + # query parameters + query_params = opts[:query_params] || {} - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) - # form parameters - form_params = opts[:form_params] || {} + # form parameters + form_params = opts[:form_params] || {} - # http body (model) - post_body = opts[:debug_body] + # http body (model) + post_body = opts[:debug_body] - # return_type - return_type = opts[:debug_return_type] || 'User' + # return_type + return_type = opts[:debug_return_type] || 'User' - # auth_names - auth_names = opts[:debug_auth_names] || [] + # auth_names + auth_names = opts[:debug_auth_names] || [] - new_options = opts.merge( - operation: :"UsersApi.get_current_user", - header_params: header_params, - query_params: query_params, - form_params: form_params, - body: post_body, - auth_names: auth_names, - return_type: return_type - ) + new_options = opts.merge( + :operation => :"UsersApi.get_current_user", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) - data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: UsersApi#get_current_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - [data, status_code, headers] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UsersApi#get_current_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end + return data, status_code, headers end end end diff --git a/lib/coinbase/client/api/wallets_api.rb b/lib/coinbase/client/api/wallets_api.rb new file mode 100644 index 00000000..838382ca --- /dev/null +++ b/lib/coinbase/client/api/wallets_api.rb @@ -0,0 +1,338 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'cgi' + +module Coinbase::Client + class WalletsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create a new wallet + # Create a new wallet scoped to the user. + # @param [Hash] opts the optional parameters + # @option opts [CreateWalletRequest] :create_wallet_request + # @return [Wallet] + def create_wallet(opts = {}) + data, _status_code, _headers = create_wallet_with_http_info(opts) + data + end + + # Create a new wallet + # Create a new wallet scoped to the user. + # @param [Hash] opts the optional parameters + # @option opts [CreateWalletRequest] :create_wallet_request + # @return [Array<(Wallet, Integer, Hash)>] Wallet data, response status code and response headers + def create_wallet_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: WalletsApi.create_wallet ...' + end + # resource path + local_var_path = '/v1/wallets' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_wallet_request']) + + # return_type + return_type = opts[:debug_return_type] || 'Wallet' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"WalletsApi.create_wallet", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: WalletsApi#create_wallet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get wallet by ID + # Get wallet + # @param wallet_id [String] The ID of the wallet to fetch + # @param [Hash] opts the optional parameters + # @return [Wallet] + def get_wallet(wallet_id, opts = {}) + data, _status_code, _headers = get_wallet_with_http_info(wallet_id, opts) + data + end + + # Get wallet by ID + # Get wallet + # @param wallet_id [String] The ID of the wallet to fetch + # @param [Hash] opts the optional parameters + # @return [Array<(Wallet, Integer, Hash)>] Wallet data, response status code and response headers + def get_wallet_with_http_info(wallet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: WalletsApi.get_wallet ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.get_wallet" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Wallet' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"WalletsApi.get_wallet", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: WalletsApi#get_wallet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get the balance of an asset in the wallet + # Get the aggregated balance of an asset across all of the addresses in the wallet. + # @param wallet_id [String] The ID of the wallet to fetch the balance for + # @param asset_id [String] The symbol of the asset to fetch the balance for + # @param [Hash] opts the optional parameters + # @return [Balance] + def get_wallet_balance(wallet_id, asset_id, opts = {}) + data, _status_code, _headers = get_wallet_balance_with_http_info(wallet_id, asset_id, opts) + data + end + + # Get the balance of an asset in the wallet + # Get the aggregated balance of an asset across all of the addresses in the wallet. + # @param wallet_id [String] The ID of the wallet to fetch the balance for + # @param asset_id [String] The symbol of the asset to fetch the balance for + # @param [Hash] opts the optional parameters + # @return [Array<(Balance, Integer, Hash)>] Balance data, response status code and response headers + def get_wallet_balance_with_http_info(wallet_id, asset_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: WalletsApi.get_wallet_balance ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.get_wallet_balance" + end + # verify the required parameter 'asset_id' is set + if @api_client.config.client_side_validation && asset_id.nil? + fail ArgumentError, "Missing the required parameter 'asset_id' when calling WalletsApi.get_wallet_balance" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/balances/{asset_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Balance' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"WalletsApi.get_wallet_balance", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: WalletsApi#get_wallet_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List wallet balances + # List the balances of all of the addresses in the wallet aggregated by asset. + # @param wallet_id [String] The ID of the wallet to fetch the balances for + # @param [Hash] opts the optional parameters + # @return [AddressBalanceList] + def list_wallet_balances(wallet_id, opts = {}) + data, _status_code, _headers = list_wallet_balances_with_http_info(wallet_id, opts) + data + end + + # List wallet balances + # List the balances of all of the addresses in the wallet aggregated by asset. + # @param wallet_id [String] The ID of the wallet to fetch the balances for + # @param [Hash] opts the optional parameters + # @return [Array<(AddressBalanceList, Integer, Hash)>] AddressBalanceList data, response status code and response headers + def list_wallet_balances_with_http_info(wallet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: WalletsApi.list_wallet_balances ...' + end + # verify the required parameter 'wallet_id' is set + if @api_client.config.client_side_validation && wallet_id.nil? + fail ArgumentError, "Missing the required parameter 'wallet_id' when calling WalletsApi.list_wallet_balances" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/balances'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AddressBalanceList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"WalletsApi.list_wallet_balances", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: WalletsApi#list_wallet_balances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List wallets + # List wallets belonging to the user. + # @param [Hash] opts the optional parameters + # @return [WalletList] + def list_wallets(opts = {}) + data, _status_code, _headers = list_wallets_with_http_info(opts) + data + end + + # List wallets + # List wallets belonging to the user. + # @param [Hash] opts the optional parameters + # @return [Array<(WalletList, Integer, Hash)>] WalletList data, response status code and response headers + def list_wallets_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: WalletsApi.list_wallets ...' + end + # resource path + local_var_path = '/v1/wallets' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'WalletList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"WalletsApi.list_wallets", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: WalletsApi#list_wallets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/coinbase/client/api_client.rb b/lib/coinbase/client/api_client.rb index c74819bb..c1aafb61 100644 --- a/lib/coinbase/client/api_client.rb +++ b/lib/coinbase/client/api_client.rb @@ -1,11 +1,14 @@ -# frozen_string_literal: true +=begin +#Coinbase Platform API -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end require 'date' require 'json' @@ -16,409 +19,412 @@ require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0') require 'marcel' -module Coinbase - module Client - class ApiClient - # The Configuration object holding settings to be used in the API client. - attr_accessor :config - - # Defines the headers to be used in HTTP requests of all API calls by default. - # - # @return [Hash] - attr_accessor :default_headers - - # Initializes the ApiClient - # @option config [Configuration] Configuration for initializing the object, default to Configuration.default - def initialize(config = Configuration.default) - @config = config - @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" - @default_headers = { - 'Content-Type' => 'application/json', - 'User-Agent' => @user_agent - } - end - def self.default - @@default ||= ApiClient.new - end +module Coinbase::Client + class ApiClient + # The Configuration object holding settings to be used in the API client. + attr_accessor :config + + # Defines the headers to be used in HTTP requests of all API calls by default. + # + # @return [Hash] + attr_accessor :default_headers + + # Initializes the ApiClient + # @option config [Configuration] Configuration for initializing the object, default to Configuration.default + def initialize(config = Configuration.default) + @config = config + @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" + @default_headers = { + 'Content-Type' => 'application/json', + 'User-Agent' => @user_agent + } + end - # Call an API with given options. - # - # @return [Array<(Object, Integer, Hash)>] an array of 3 elements: - # the data deserialized from response body (could be nil), response status code and response headers. - def call_api(http_method, path, opts = {}) - stream = nil - begin - response = connection(opts).public_send(http_method.to_sym.downcase) do |req| - request = build_request(http_method, path, req, opts) - stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary' - end + def self.default + @@default ||= ApiClient.new + end - config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" if config.debugging - - unless response.success? - if response.status.zero? && response.respond_to?(:return_message) - # Errors from libcurl will be made visible here - raise ApiError.new(code: 0, - message: response.return_message) - else - raise ApiError.new(code: response.status, - response_headers: response.headers, - response_body: response.body), - response.reason_phrase - end - end - rescue Faraday::TimeoutError - raise ApiError, 'Connection timed out' - rescue Faraday::ConnectionFailed - raise ApiError, 'Connection failed' + # Call an API with given options. + # + # @return [Array<(Object, Integer, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. + def call_api(http_method, path, opts = {}) + stream = nil + begin + response = connection(opts).public_send(http_method.to_sym.downcase) do |req| + request = build_request(http_method, path, req, opts) + stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary' end - data = if opts[:return_type] == 'File' || opts[:return_type] == 'Binary' - deserialize_file(response, stream) - elsif opts[:return_type] - deserialize(response, opts[:return_type]) - end - [data, response.status, response.headers] - end - - # Builds the HTTP request - # - # @param [String] http_method HTTP method/verb (e.g. POST) - # @param [String] path URL path (e.g. /account/new) - # @option opts [Hash] :header_params Header parameters - # @option opts [Hash] :query_params Query parameters - # @option opts [Hash] :form_params Query parameters - # @option opts [Object] :body HTTP body (JSON/XML) - # @return [Faraday::Request] A Faraday Request - def build_request(http_method, path, request, opts = {}) - url = build_request_url(path, opts) - http_method = http_method.to_sym.downcase - - header_params = @default_headers.merge(opts[:header_params] || {}) - query_params = opts[:query_params] || {} - form_params = opts[:form_params] || {} - - update_params_for_auth! header_params, query_params, opts[:auth_names] - - if %i[post patch put delete].include?(http_method) - req_body = build_request_body(header_params, form_params, opts[:body]) - config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" if config.debugging + if config.debugging + config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" end - request.headers = header_params - request.body = req_body - - # Overload default options only if provided - request.options.params_encoder = config.params_encoder if config.params_encoder - request.options.timeout = config.timeout if config.timeout - - request.url url - request.params = query_params - request - end - # Builds the HTTP request body - # - # @param [Hash] header_params Header parameters - # @param [Hash] form_params Query parameters - # @param [Object] body HTTP body (JSON/XML) - # @return [String] HTTP body data in the form of string - def build_request_body(header_params, form_params, body) - # http form - if header_params['Content-Type'] == 'application/x-www-form-urlencoded' - data = URI.encode_www_form(form_params) - elsif header_params['Content-Type'] == 'multipart/form-data' - data = {} - form_params.each do |key, value| - data[key] = case value - when ::File, ::Tempfile - Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path))) - when ::Array, nil - # let Faraday handle Array and nil parameters - value - else - value.to_s - end + unless response.success? + if response.status == 0 && response.respond_to?(:return_message) + # Errors from libcurl will be made visible here + fail ApiError.new(code: 0, + message: response.return_message) + else + fail ApiError.new(code: response.status, + response_headers: response.headers, + response_body: response.body), + response.reason_phrase end - elsif body - data = body.is_a?(String) ? body : body.to_json - else - data = nil end - data + rescue Faraday::TimeoutError + fail ApiError.new('Connection timed out') + rescue Faraday::ConnectionFailed + fail ApiError.new('Connection failed') end - def download_file(request) - stream = [] + if opts[:return_type] == 'File' || opts[:return_type] == 'Binary' + data = deserialize_file(response, stream) + elsif opts[:return_type] + data = deserialize(response, opts[:return_type]) + else + data = nil + end + return data, response.status, response.headers + end - # handle streaming Responses - request.options.on_data = proc do |chunk, _overall_received_bytes| - stream << chunk + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Faraday::Request] A Faraday Request + def build_request(http_method, path, request, opts = {}) + url = build_request_url(path, opts) + http_method = http_method.to_sym.downcase + + header_params = @default_headers.merge(opts[:header_params] || {}) + query_params = opts[:query_params] || {} + form_params = opts[:form_params] || {} + + update_params_for_auth! header_params, query_params, opts[:auth_names] + + if [:post, :patch, :put, :delete].include?(http_method) + req_body = build_request_body(header_params, form_params, opts[:body]) + if config.debugging + config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" end - stream end + request.headers = header_params + request.body = req_body - def deserialize_file(response, stream) - body = response.body - if @config.return_binary_data == true - # return byte stream - encoding = body.encoding - stream.join.force_encoding(encoding) - else - # return file instead of binary data - content_disposition = response.headers['Content-Disposition'] - if content_disposition && content_disposition =~ /filename=/i - filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] - prefix = sanitize_filename(filename) + # Overload default options only if provided + request.options.params_encoder = config.params_encoder if config.params_encoder + request.options.timeout = config.timeout if config.timeout + + request.url url + request.params = query_params + request + end + + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string + def build_request_body(header_params, form_params, body) + # http form + if header_params['Content-Type'] == 'application/x-www-form-urlencoded' + data = URI.encode_www_form(form_params) + elsif header_params['Content-Type'] == 'multipart/form-data' + data = {} + form_params.each do |key, value| + case value + when ::File, ::Tempfile + data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path))) + when ::Array, nil + # let Faraday handle Array and nil parameters + data[key] = value else - prefix = 'download-' + data[key] = value.to_s end - prefix += '-' unless prefix.end_with?('-') - encoding = body.encoding - tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) - tempfile.write(stream.join.force_encoding(encoding)) - tempfile.close - config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ - "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ - "will be deleted automatically with GC. It's also recommended to delete the temp file "\ - 'explicitly with `tempfile.delete`' - tempfile end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil end + data + end + + def download_file(request) + stream = [] - def connection(opts) - opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + # handle streaming Responses + request.options.on_data = Proc.new do |chunk, overall_received_bytes| + stream << chunk end + stream + end - def connection_multipart - @connection_multipart ||= build_connection do |conn| - conn.request :multipart - conn.request :url_encoded + def deserialize_file(response, stream) + body = response.body + if @config.return_binary_data == true + # return byte stream + encoding = body.encoding + stream.join.force_encoding(encoding) + else + # return file instead of binary data + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + tempfile.write(stream.join.force_encoding(encoding)) + tempfile.close + config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" + tempfile end + end - def connection_regular - @connection_regular ||= build_connection - end + def connection(opts) + opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + end - def build_connection - Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn| - basic_auth(conn) - config.configure_middleware(conn) - yield(conn) if block_given? - conn.adapter(Faraday.default_adapter) - config.configure_connection(conn) - end + def connection_multipart + @connection_multipart ||= build_connection do |conn| + conn.request :multipart + conn.request :url_encoded end + end + + def connection_regular + @connection_regular ||= build_connection + end - def ssl_options - { - ca_file: config.ssl_ca_file, - verify: config.ssl_verify, - verify_mode: config.ssl_verify_mode, - client_cert: config.ssl_client_cert, - client_key: config.ssl_client_key - } + def build_connection + Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn| + basic_auth(conn) + config.configure_middleware(conn) + yield(conn) if block_given? + conn.adapter(Faraday.default_adapter) + config.configure_connection(conn) end + end - def basic_auth(conn) - return unless config.username && config.password + def ssl_options + { + ca_file: config.ssl_ca_file, + verify: config.ssl_verify, + verify_mode: config.ssl_verify_mode, + client_cert: config.ssl_client_cert, + client_key: config.ssl_client_key + } + end + def basic_auth(conn) + if config.username && config.password if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0') conn.request(:authorization, :basic, config.username, config.password) else conn.request(:basic_auth, config.username, config.password) end end + end - # Check if the given MIME is a JSON MIME. - # JSON MIME examples: - # application/json - # application/json; charset=UTF8 - # APPLICATION/JSON - # */* - # @param [String] mime MIME - # @return [Boolean] True if the MIME is application/json - def json_mime?(mime) - (mime == '*/*') || !(mime =~ %r{Application/.*json(?!p)(;.*)?}i).nil? - end - - # Deserialize the response to the given return type. - # - # @param [Response] response HTTP response - # @param [String] return_type some examples: "User", "Array", "Hash" - def deserialize(response, return_type) - body = response.body - return nil if body.nil? || body.empty? + # Check if the given MIME is a JSON MIME. + # JSON MIME examples: + # application/json + # application/json; charset=UTF8 + # APPLICATION/JSON + # */* + # @param [String] mime MIME + # @return [Boolean] True if the MIME is application/json + def json_mime?(mime) + (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? + end - # return response body directly for String return type - return body.to_s if return_type == 'String' + # Deserialize the response to the given return type. + # + # @param [Response] response HTTP response + # @param [String] return_type some examples: "User", "Array", "Hash" + def deserialize(response, return_type) + body = response.body + return nil if body.nil? || body.empty? - # ensuring a default content type - content_type = response.headers['Content-Type'] || 'application/json' + # return response body directly for String return type + return body.to_s if return_type == 'String' - raise "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' - begin - data = JSON.parse("[#{body}]", symbolize_names: true)[0] - rescue JSON::ParserError => e - raise e unless %w[String Date Time].include?(return_type) + fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + begin + data = JSON.parse("[#{body}]", :symbolize_names => true)[0] + rescue JSON::ParserError => e + if %w(String Date Time).include?(return_type) data = body - end - - convert_to_type data, return_type - end - - # Convert data to the given return type. - # @param [Object] data Data to be converted - # @param [String] return_type Return type - # @return [Mixed] Data in a particular type - def convert_to_type(data, return_type) - return nil if data.nil? - - case return_type - when 'String' - data.to_s - when 'Integer' - data.to_i - when 'Float' - data.to_f - when 'Boolean' - data == true - when 'Time' - # parse date time (expecting ISO 8601 format) - Time.parse data - when 'Date' - # parse date time (expecting ISO 8601 format) - Date.parse data - when 'Object' - # generic object (usually a Hash), return directly - data - when /\AArray<(.+)>\z/ - # e.g. Array - sub_type = ::Regexp.last_match(1) - data.map { |item| convert_to_type(item, sub_type) } - when /\AHash\z/ - # e.g. Hash - sub_type = ::Regexp.last_match(1) - {}.tap do |hash| - data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } - end else - # models (e.g. Pet) or oneOf - klass = Coinbase::Client.const_get(return_type) - klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) + raise e end end - # Sanitize filename by removing path. - # e.g. ../../sun.gif becomes sun.gif - # - # @param [String] filename the filename to be sanitized - # @return [String] the sanitized filename - def sanitize_filename(filename) - filename.gsub(%r{.*[/\\]}, '') - end - - def build_request_url(path, opts = {}) - # Add leading and trailing slashes to path - path = "/#{path}".gsub(%r{/+}, '/') - @config.base_url(opts[:operation]) + path - end + convert_to_type data, return_type + end - # Update header and query params based on authentication settings. - # - # @param [Hash] header_params Header parameters - # @param [Hash] query_params Query parameters - # @param [String] auth_names Authentication scheme name - def update_params_for_auth!(header_params, query_params, auth_names) - Array(auth_names).each do |auth_name| - auth_setting = @config.auth_settings[auth_name] - next unless auth_setting - - case auth_setting[:in] - when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] - when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] - else raise ArgumentError, 'Authentication token must be in `query` or `header`' - end + # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type + def convert_to_type(data, return_type) + return nil if data.nil? + case return_type + when 'String' + data.to_s + when 'Integer' + data.to_i + when 'Float' + data.to_f + when 'Boolean' + data == true + when 'Time' + # parse date time (expecting ISO 8601 format) + Time.parse data + when 'Date' + # parse date time (expecting ISO 8601 format) + Date.parse data + when 'Object' + # generic object (usually a Hash), return directly + data + when /\AArray<(.+)>\z/ + # e.g. Array + sub_type = $1 + data.map { |item| convert_to_type(item, sub_type) } + when /\AHash\\z/ + # e.g. Hash + sub_type = $1 + {}.tap do |hash| + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } end + else + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(return_type) + klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) end + end - # Sets user agent in HTTP header - # - # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) - def user_agent=(user_agent) - @user_agent = user_agent - @default_headers['User-Agent'] = @user_agent - end + # Sanitize filename by removing path. + # e.g. ../../sun.gif becomes sun.gif + # + # @param [String] filename the filename to be sanitized + # @return [String] the sanitized filename + def sanitize_filename(filename) + filename.gsub(/.*[\/\\]/, '') + end - # Return Accept header based on an array of accepts provided. - # @param [Array] accepts array for Accept - # @return [String] the Accept header (e.g. application/json) - def select_header_accept(accepts) - return nil if accepts.nil? || accepts.empty? + def build_request_url(path, opts = {}) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(/\/+/, '/') + @config.base_url(opts[:operation]) + path + end - # use JSON when present, otherwise use all of the provided - json_accept = accepts.find { |s| json_mime?(s) } - json_accept || accepts.join(',') + # Update header and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] query_params Query parameters + # @param [String] auth_names Authentication scheme name + def update_params_for_auth!(header_params, query_params, auth_names) + Array(auth_names).each do |auth_name| + auth_setting = @config.auth_settings[auth_name] + next unless auth_setting + case auth_setting[:in] + when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] + when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] + else fail ArgumentError, 'Authentication token must be in `query` or `header`' + end end + end - # Return Content-Type header based on an array of content types provided. - # @param [Array] content_types array for Content-Type - # @return [String] the Content-Type header (e.g. application/json) - def select_header_content_type(content_types) - # return nil by default - return if content_types.nil? || content_types.empty? + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) + def user_agent=(user_agent) + @user_agent = user_agent + @default_headers['User-Agent'] = @user_agent + end - # use JSON when present, otherwise use the first one - json_content_type = content_types.find { |s| json_mime?(s) } - json_content_type || content_types.first - end + # Return Accept header based on an array of accepts provided. + # @param [Array] accepts array for Accept + # @return [String] the Accept header (e.g. application/json) + def select_header_accept(accepts) + return nil if accepts.nil? || accepts.empty? + # use JSON when present, otherwise use all of the provided + json_accept = accepts.find { |s| json_mime?(s) } + json_accept || accepts.join(',') + end - # Convert object (array, hash, object, etc) to JSON string. - # @param [Object] model object to be converted into JSON string - # @return [String] JSON string representation of the object - def object_to_http_body(model) - return model if model.nil? || model.is_a?(String) - - local_body = if model.is_a?(Array) - model.map { |m| object_to_hash(m) } - else - object_to_hash(model) - end - local_body.to_json + # Return Content-Type header based on an array of content types provided. + # @param [Array] content_types array for Content-Type + # @return [String] the Content-Type header (e.g. application/json) + def select_header_content_type(content_types) + # return nil by default + return if content_types.nil? || content_types.empty? + # use JSON when present, otherwise use the first one + json_content_type = content_types.find { |s| json_mime?(s) } + json_content_type || content_types.first + end + + # Convert object (array, hash, object, etc) to JSON string. + # @param [Object] model object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_http_body(model) + return model if model.nil? || model.is_a?(String) + local_body = nil + if model.is_a?(Array) + local_body = model.map { |m| object_to_hash(m) } + else + local_body = object_to_hash(model) end + local_body.to_json + end - # Convert object(non-array) to hash. - # @param [Object] obj object to be converted into JSON string - # @return [String] JSON string representation of the object - def object_to_hash(obj) - if obj.respond_to?(:to_hash) - obj.to_hash - else - obj - end + # Convert object(non-array) to hash. + # @param [Object] obj object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_hash(obj) + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj end + end - # Build parameter value according to the given collection format. - # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi - def build_collection_param(param, collection_format) - case collection_format - when :csv - param.join(',') - when :ssv - param.join(' ') - when :tsv - param.join("\t") - when :pipes - param.join('|') - when :multi - # return the array directly as typhoeus will handle it as expected - param - else - raise "unknown collection format: #{collection_format.inspect}" - end + # Build parameter value according to the given collection format. + # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi + def build_collection_param(param, collection_format) + case collection_format + when :csv + param.join(',') + when :ssv + param.join(' ') + when :tsv + param.join("\t") + when :pipes + param.join('|') + when :multi + # return the array directly as typhoeus will handle it as expected + param + else + fail "unknown collection format: #{collection_format.inspect}" end end end diff --git a/lib/coinbase/client/api_error.rb b/lib/coinbase/client/api_error.rb index 930c412c..70c6b145 100644 --- a/lib/coinbase/client/api_error.rb +++ b/lib/coinbase/client/api_error.rb @@ -1,57 +1,58 @@ -# frozen_string_literal: true - -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 - -module Coinbase - module Client - class ApiError < StandardError - attr_reader :code, :response_headers, :response_body - - # Usage examples: - # ApiError.new - # ApiError.new("message") - # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") - # ApiError.new(:code => 404, :message => "Not Found") - def initialize(arg = nil) - if arg.is_a? Hash - if arg.key?(:message) || arg.key?('message') - super(arg[:message] || arg['message']) - else - super arg - end - - arg.each do |k, v| - instance_variable_set "@#{k}", v - end +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +module Coinbase::Client + class ApiError < StandardError + attr_reader :code, :response_headers, :response_body + + # Usage examples: + # ApiError.new + # ApiError.new("message") + # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") + # ApiError.new(:code => 404, :message => "Not Found") + def initialize(arg = nil) + if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) else super arg - @message = arg end - end - # Override to_s to display a friendly error message - def to_s - message + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + @message = arg end + end - def message - msg = if @message.nil? - 'Error message: the server returns an error' - else - @message - end - - msg += "\nHTTP status code: #{code}" if code - msg += "\nResponse headers: #{response_headers}" if response_headers - msg += "\nResponse body: #{response_body}" if response_body + # Override to_s to display a friendly error message + def to_s + message + end - msg + def message + if @message.nil? + msg = "Error message: the server returns an error" + else + msg = @message end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg end end end diff --git a/lib/coinbase/client/configuration.rb b/lib/coinbase/client/configuration.rb index c7a01dc8..eeaa0719 100644 --- a/lib/coinbase/client/configuration.rb +++ b/lib/coinbase/client/configuration.rb @@ -3,7 +3,7 @@ #This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -The version of the OpenAPI document: 0.0.alpha +The version of the OpenAPI document: 0.0.1-alpha Contact: yuga.cohler@coinbase.com Generated by: https://openapi-generator.tech Generator version: 7.5.0 diff --git a/lib/coinbase/client/models/address.rb b/lib/coinbase/client/models/address.rb new file mode 100644 index 00000000..7738d50f --- /dev/null +++ b/lib/coinbase/client/models/address.rb @@ -0,0 +1,273 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + class Address + # The ID of the wallet that owns the address + attr_accessor :wallet_id + + # The ID of the blockchain network + attr_accessor :network + + # The public key that the address will be derived for. + attr_accessor :public_key + + # The onchain address derived on the server-side. + attr_accessor :address_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'wallet_id' => :'wallet_id', + :'network' => :'network', + :'public_key' => :'public_key', + :'address_id' => :'address_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'wallet_id' => :'String', + :'network' => :'String', + :'public_key' => :'String', + :'address_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Address` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'wallet_id') + self.wallet_id = attributes[:'wallet_id'] + else + self.wallet_id = nil + end + + if attributes.key?(:'network') + self.network = attributes[:'network'] + else + self.network = nil + end + + if attributes.key?(:'public_key') + self.public_key = attributes[:'public_key'] + else + self.public_key = nil + end + + if attributes.key?(:'address_id') + self.address_id = attributes[:'address_id'] + else + self.address_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @wallet_id.nil? + invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.') + end + + if @network.nil? + invalid_properties.push('invalid value for "network", network cannot be nil.') + end + + if @public_key.nil? + invalid_properties.push('invalid value for "public_key", public_key cannot be nil.') + end + + if @address_id.nil? + invalid_properties.push('invalid value for "address_id", address_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @wallet_id.nil? + return false if @network.nil? + return false if @public_key.nil? + return false if @address_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + wallet_id == o.wallet_id && + network == o.network && + public_key == o.public_key && + address_id == o.address_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [wallet_id, network, public_key, address_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/address_balance_list.rb b/lib/coinbase/client/models/address_balance_list.rb new file mode 100644 index 00000000..559b0f0c --- /dev/null +++ b/lib/coinbase/client/models/address_balance_list.rb @@ -0,0 +1,275 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # + class AddressBalanceList + attr_accessor :data + + # True if this list has another page of items after this one that can be fetched. + attr_accessor :has_more + + # The page token to be used to fetch the next page. + attr_accessor :next_page + + # The total number of balances for the wallet. + attr_accessor :total_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'has_more' => :'has_more', + :'next_page' => :'next_page', + :'total_count' => :'total_count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'has_more' => :'Boolean', + :'next_page' => :'String', + :'total_count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::AddressBalanceList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::AddressBalanceList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + + if attributes.key?(:'next_page') + self.next_page = attributes[:'next_page'] + else + self.next_page = nil + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + else + self.total_count = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + if @next_page.nil? + invalid_properties.push('invalid value for "next_page", next_page cannot be nil.') + end + + if @total_count.nil? + invalid_properties.push('invalid value for "total_count", total_count cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? + return false if @has_more.nil? + return false if @next_page.nil? + return false if @total_count.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + has_more == o.has_more && + next_page == o.next_page && + total_count == o.total_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, has_more, next_page, total_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/address_list.rb b/lib/coinbase/client/models/address_list.rb new file mode 100644 index 00000000..e88f0be3 --- /dev/null +++ b/lib/coinbase/client/models/address_list.rb @@ -0,0 +1,275 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # + class AddressList + attr_accessor :data + + # True if this list has another page of items after this one that can be fetched. + attr_accessor :has_more + + # The page token to be used to fetch the next page. + attr_accessor :next_page + + # The total number of addresses for the wallet. + attr_accessor :total_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'has_more' => :'has_more', + :'next_page' => :'next_page', + :'total_count' => :'total_count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array
', + :'has_more' => :'Boolean', + :'next_page' => :'String', + :'total_count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::AddressList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::AddressList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + + if attributes.key?(:'next_page') + self.next_page = attributes[:'next_page'] + else + self.next_page = nil + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + else + self.total_count = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + if @next_page.nil? + invalid_properties.push('invalid value for "next_page", next_page cannot be nil.') + end + + if @total_count.nil? + invalid_properties.push('invalid value for "total_count", total_count cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? + return false if @has_more.nil? + return false if @next_page.nil? + return false if @total_count.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + has_more == o.has_more && + next_page == o.next_page && + total_count == o.total_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, has_more, next_page, total_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/asset.rb b/lib/coinbase/client/models/asset.rb new file mode 100644 index 00000000..10571d9d --- /dev/null +++ b/lib/coinbase/client/models/asset.rb @@ -0,0 +1,260 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # An asset onchain scoped to a particular network, e.g. ETH on base-sepolia, or the USDC ERC20 Token on ethereum-mainnet. + class Asset + # The ID of the blockchain network + attr_accessor :network + + # The canonical symbol for the asset on the network + attr_accessor :currency + + # The number of decimals the asset supports. This is used to convert from atomic units to base units. + attr_accessor :decimals + + # The optional contract address for the asset. This will be specified for smart contract-based assets, for example ERC20s. + attr_accessor :contract_address + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'network' => :'network', + :'currency' => :'currency', + :'decimals' => :'decimals', + :'contract_address' => :'contract_address' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'network' => :'String', + :'currency' => :'String', + :'decimals' => :'Integer', + :'contract_address' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Asset` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Asset`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'network') + self.network = attributes[:'network'] + else + self.network = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + else + self.currency = nil + end + + if attributes.key?(:'decimals') + self.decimals = attributes[:'decimals'] + end + + if attributes.key?(:'contract_address') + self.contract_address = attributes[:'contract_address'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @network.nil? + invalid_properties.push('invalid value for "network", network cannot be nil.') + end + + if @currency.nil? + invalid_properties.push('invalid value for "currency", currency cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @network.nil? + return false if @currency.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + network == o.network && + currency == o.currency && + decimals == o.decimals && + contract_address == o.contract_address + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [network, currency, decimals, contract_address].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/balance.rb b/lib/coinbase/client/models/balance.rb new file mode 100644 index 00000000..77caf04d --- /dev/null +++ b/lib/coinbase/client/models/balance.rb @@ -0,0 +1,239 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # The balance of an asset onchain + class Balance + # The amount in the atomic units of the asset + attr_accessor :amount + + attr_accessor :asset + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'asset' => :'asset' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'String', + :'asset' => :'Asset' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Balance` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Balance`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'asset') + self.asset = attributes[:'asset'] + else + self.asset = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + if @asset.nil? + invalid_properties.push('invalid value for "asset", asset cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + return false if @asset.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + asset == o.asset + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, asset].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/create_address_request.rb b/lib/coinbase/client/models/create_address_request.rb new file mode 100644 index 00000000..20ce231e --- /dev/null +++ b/lib/coinbase/client/models/create_address_request.rb @@ -0,0 +1,239 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + class CreateAddressRequest + # The public key that the address will be derived from. + attr_accessor :public_key + + # An attestation signed by the private key that is associated with the wallet. + attr_accessor :attestation + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'public_key' => :'public_key', + :'attestation' => :'attestation' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'public_key' => :'String', + :'attestation' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateAddressRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateAddressRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'public_key') + self.public_key = attributes[:'public_key'] + else + self.public_key = nil + end + + if attributes.key?(:'attestation') + self.attestation = attributes[:'attestation'] + else + self.attestation = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @public_key.nil? + invalid_properties.push('invalid value for "public_key", public_key cannot be nil.') + end + + if @attestation.nil? + invalid_properties.push('invalid value for "attestation", attestation cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @public_key.nil? + return false if @attestation.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + public_key == o.public_key && + attestation == o.attestation + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [public_key, attestation].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/create_wallet_request.rb b/lib/coinbase/client/models/create_wallet_request.rb new file mode 100644 index 00000000..06c5f445 --- /dev/null +++ b/lib/coinbase/client/models/create_wallet_request.rb @@ -0,0 +1,221 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + class CreateWalletRequest + attr_accessor :wallet + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'wallet' => :'wallet' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'wallet' => :'Wallet' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateWalletRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateWalletRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'wallet') + self.wallet = attributes[:'wallet'] + else + self.wallet = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @wallet.nil? + invalid_properties.push('invalid value for "wallet", wallet cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @wallet.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + wallet == o.wallet + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [wallet].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/error.rb b/lib/coinbase/client/models/error.rb new file mode 100644 index 00000000..d58f199e --- /dev/null +++ b/lib/coinbase/client/models/error.rb @@ -0,0 +1,278 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # An error response from the Coinbase Developer Platform API + class Error + # A short string representing the reported error. Can be use to handle errors programmatically. + attr_accessor :code + + # A human-readable message providing more details about the error. + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String', + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Error` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @code.to_s.length > 5000 + invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 5000.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + if @message.to_s.length > 5000 + invalid_properties.push('invalid value for "message", the character length must be smaller than or equal to 5000.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + return false if @code.to_s.length > 5000 + return false if @message.nil? + return false if @message.to_s.length > 5000 + true + end + + # Custom attribute writer method with validation + # @param [Object] code Value to be assigned + def code=(code) + if code.nil? + fail ArgumentError, 'code cannot be nil' + end + + if code.to_s.length > 5000 + fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 5000.' + end + + @code = code + end + + # Custom attribute writer method with validation + # @param [Object] message Value to be assigned + def message=(message) + if message.nil? + fail ArgumentError, 'message cannot be nil' + end + + if message.to_s.length > 5000 + fail ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 5000.' + end + + @message = message + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/user.rb b/lib/coinbase/client/models/user.rb index 88be52d3..4bc95a57 100644 --- a/lib/coinbase/client/models/user.rb +++ b/lib/coinbase/client/models/user.rb @@ -1,226 +1,231 @@ -# frozen_string_literal: true +=begin +#Coinbase Platform API -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -require 'date' -require 'time' - -module Coinbase - module Client - class User - attr_accessor :id, :display_name - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - 'id': :id, - 'display_name': :displayName - } - end +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end +=end - # Attribute type mapping. - def self.openapi_types - { - 'id': :String, - 'display_name': :String - } - end +require 'date' +require 'time' - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([]) - end +module Coinbase::Client + class User + # The ID of the user + attr_accessor :id - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - unless attributes.is_a?(Hash) - raise ArgumentError, - 'The input argument (attributes) must be a hash in `Coinbase::Client::User` initialize method' - end + attr_accessor :display_name - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) do |(k, v), h| - unless self.class.attribute_map.key?(k.to_sym) - raise 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 - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'display_name' => :'display_name' + } + end - h[k.to_sym] = v - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - self.id = (attributes[:id] if attributes.key?(:id)) + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'display_name' => :'String' + } + end - return unless attributes.key?(:display_name) + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - self.display_name = attributes[:display_name] + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::User` initialize method" end - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' - invalid_properties = [] - invalid_properties.push('invalid value for "id", id cannot be nil.') if @id.nil? + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + 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 + end + h[k.to_sym] = v + } - invalid_properties + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil end - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - warn '[DEPRECATED] the `valid?` method is obsolete' - return false if @id.nil? + if attributes.key?(:'display_name') + self.display_name = attributes[:'display_name'] + end + end - true + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(other) - return true if equal?(other) + invalid_properties + end - self.class == other.class && - id == other.id && - display_name == other.display_name - end + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(other) - self == other - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + display_name == o.display_name + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, display_name].hash - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash[key.to_s] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash[key.to_s] = attributes[attribute_map[key]].map do |v| - _deserialize(::Regexp.last_match(1), v) - end - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]]) + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, display_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end - new(transformed_hash) end + new(transformed_hash) + end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end - else # model - # models (e.g. Pet) or oneOf - klass = Coinbase::Client.const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end + end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end - hash[param] = _to_hash(value) + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - hash + + hash[param] = _to_hash(value) end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } end + elsif value.respond_to? :to_hash + value.to_hash + else + value end end + end + end diff --git a/lib/coinbase/client/models/wallet.rb b/lib/coinbase/client/models/wallet.rb new file mode 100644 index 00000000..b3dad250 --- /dev/null +++ b/lib/coinbase/client/models/wallet.rb @@ -0,0 +1,232 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + class Wallet + # The server-assigned ID for the wallet. + attr_accessor :id + + # The ID of the blockchain network + attr_accessor :network + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'network' => :'network' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'network' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Wallet` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Wallet`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'network') + self.network = attributes[:'network'] + else + self.network = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @network.nil? + invalid_properties.push('invalid value for "network", network cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @network.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + network == o.network + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, network].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/models/wallet_list.rb b/lib/coinbase/client/models/wallet_list.rb new file mode 100644 index 00000000..71ad7259 --- /dev/null +++ b/lib/coinbase/client/models/wallet_list.rb @@ -0,0 +1,275 @@ +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Coinbase::Client + # Paginated list of wallets + class WalletList + attr_accessor :data + + # True if this list has another page of items after this one that can be fetched. + attr_accessor :has_more + + # The page token to be used to fetch the next page. + attr_accessor :next_page + + # The total number of wallets + attr_accessor :total_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'has_more' => :'has_more', + :'next_page' => :'next_page', + :'total_count' => :'total_count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'has_more' => :'Boolean', + :'next_page' => :'String', + :'total_count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::WalletList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::WalletList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + + if attributes.key?(:'next_page') + self.next_page = attributes[:'next_page'] + else + self.next_page = nil + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + else + self.total_count = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + if @next_page.nil? + invalid_properties.push('invalid value for "next_page", next_page cannot be nil.') + end + + if @total_count.nil? + invalid_properties.push('invalid value for "total_count", total_count cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? + return false if @has_more.nil? + return false if @next_page.nil? + return false if @total_count.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + has_more == o.has_more && + next_page == o.next_page && + total_count == o.total_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, has_more, next_page, total_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Coinbase::Client.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/coinbase/client/version.rb b/lib/coinbase/client/version.rb index 19c2fd59..b9708b21 100644 --- a/lib/coinbase/client/version.rb +++ b/lib/coinbase/client/version.rb @@ -1,14 +1,15 @@ -# frozen_string_literal: true - -# #Coinbase Platform API -# This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. -# The version of the OpenAPI document: 0.0.alpha -# Contact: yuga.cohler@coinbase.com -# Generated by: https://openapi-generator.tech -# Generator version: 7.5.0 - -module Coinbase - module Client - VERSION = '0.0.alpha' - end +=begin +#Coinbase Platform API + +#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + +The version of the OpenAPI document: 0.0.1-alpha +Contact: yuga.cohler@coinbase.com +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +module Coinbase::Client + VERSION = '0.0.1-alpha' end From d90b971c8425a599648891e1e6cacfc732c8585f Mon Sep 17 00:00:00 2001 From: Jayasudha Jayakumaran Date: Tue, 23 Apr 2024 14:55:08 -0700 Subject: [PATCH 2/2] remove files --- .gitignore | 4 +++- lib/coinbase/client/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 lib/coinbase/client/.DS_Store diff --git a/.gitignore b/.gitignore index 087f3b73..61e06fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ Gemfile.lock -.yardoc \ No newline at end of file +.yardoc +lib/**/.DS_Store +.idea \ No newline at end of file diff --git a/lib/coinbase/client/.DS_Store b/lib/coinbase/client/.DS_Store deleted file mode 100644 index d3028a31322d756bf67afdd5012c6da7dceb90ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOG?B*5Up|s35YODH$q=w^a62+J9l#d9V0rBkig*1MUJ93@DAchT)6QDZhX~M z%PG->h%z)mmcf9CdeF3G&SGTAF`b_`bvuya_o`&? zBRZp&mepl{|2KCVOWhR3qG}e;y9Y0iM}2GgjkUe%XT3!jZBtDRm2^QBt&&yw zWcAVBUwi-XX}xxmqi!}k_{t~Q2j9y+T$}-Cz!`7`{wD*tvqiEUMem&fXTTYFXF$$} zfF_t5c8c-nKo?5@;27#C7)vc7F~Kl5>=a>vu!aIPl&!>I4TnCMUvAhbYB;eKA8aeH zix-ZoBY%kQ#JQsP&VVzJGBDEVMDG7%{4#?@ej4I4XTTZwV+`=Pm=`mAl-;eLK2Pr2 vfOd)|B7U6=AQ&f)08Hc@*^5TC2N}aJH|!K8i|AuG&>sSk5bvCUA7J1Ou4+f$