diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 787cce81..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml new file mode 100644 index 00000000..6f9e49bd --- /dev/null +++ b/.github/workflows/e2e_test.yml @@ -0,0 +1,27 @@ +name: Run End-To-End Tests + +on: [pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + + - name: Install dependencies + run: | + gem install bundler -v 2.4.22 + bundle install --jobs 4 --retry 3 + + - name: Run e2e tests + env: + API_KEY_NAME: ${{ secrets.API_KEY_NAME }} + API_KEY_PRIVATE_KEY: ${{ secrets.API_KEY_PRIVATE_KEY }} + WALLET_DATA: ${{ secrets.WALLET_DATA }} + run: bundle exec rspec spec/e2e/production.rb \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/unit_tests.yml similarity index 88% rename from .github/workflows/tests.yml rename to .github/workflows/unit_tests.yml index 03a3f40f..0dbf4435 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/unit_tests.yml @@ -1,4 +1,4 @@ -name: Run Tests +name: Run Unit Tests on: [pull_request] @@ -19,5 +19,5 @@ jobs: gem install bundler -v 2.4.22 bundle install --jobs 4 --retry 3 - - name: Run tests + - name: Run unit tests run: bundle exec rake test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 283c9376..24212ac3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ Gemfile.lock -coinbase_cloud_api_key.json -.yardoc \ No newline at end of file +.yardoc +lib/**/.DS_Store +.idea +.DS_Store \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index ddf66f9b..38c86f91 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,9 +2,16 @@ AllCops: NewCops: disable SuggestExtensions: false TargetRubyVersion: 2.7 + Exclude: + # Exclude autogenerated files. + - 'lib/coinbase/client.rb' + - 'lib/coinbase/client/**/*' # Tests can be long. Metrics/BlockLength: Enabled: false +# Classes can be long. +Metrics/ClassLength: + Max: 1000 Metrics/MethodLength: Max: 50 # Methods can have many parameters. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0678c644..b963c33a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Faucet +- Trade +- Individual private key export +- Allow disabling debug tracing +- Error specifications + +## [0.0.2] - 2024-05-01 + +### Added + +- Configuration via Config object +- API Key-based authentication +- API clients to use server-side architecture +- User object and default_user +- Send and receive ERC-20s + ## [0.0.1] - 2024-04-19 Initial release of the Coinbase Ruby SDK. Purely client-side implementation. ### Added + - Wallet creation and export - Address creation - Send and receive ETH -- Supported networks: Base Sepolia \ No newline at end of file +- Supported networks: Base Sepolia diff --git a/Makefile b/Makefile index e249a8bd..c2a8fa16 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: format format: - bundle exec rubocop -a + bundle exec rubocop -A .PHONY: lint lint: diff --git a/README.md b/README.md index 5e5651b1..81aadc29 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,17 @@ one asset into another. The SDK currently supports Customer-custodied Wallets on the Base Sepolia test network. **NOTE: The Coinbase SDK is currently in Alpha. The SDK:** + - **may make backwards-incompatible changes between releases** - **should not be used on Mainnet (i.e. with real funds)** - Currently, the SDK is intended for use on testnet for quick bootstrapping of crypto wallets at hackathons, code academies, and other development settings. - ## Documentation -[Click here for full SDK documentation](https://coinbase.github.io/coinbase-sdk-ruby/) + +- [Platform API Documentation](https://docs.cdp.coinbase.com/platform-apis/docs/welcome) +- [Ruby SDK Documentation](https://coinbase.github.io/coinbase-sdk-ruby/) ## Installation @@ -65,61 +66,75 @@ require 'coinbase' ### Initialization -The SDK requires a Base Sepolia RPC node, and uses the public instance (https://sepolia.base.org) by default. -This instance is rate-limited, but you can also provision your own on the -[Coinbase Developer Platform](https://portal.cloud.coinbase.com/products/base). +To start, [create a CDP API Key](https://portal.cdp.coinbase.com/access/api). Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the `configure` method: +```ruby +api_key_name = 'Copy your API Key name here.' +api_key_private_key = 'Copy your API Key\'s private key here.' -You can configure the SDK with your Base Sepolia RPC node by copying your node URL from the CDP portal -and setting the following: +Coinbase.configure do |config| + config.api_key_name = api_key_name + config.api_key_private_key = api_key_private_key +end +``` + +This will allow you to authenticate with the Platform APIs and get access to the `default_user`. ```ruby -Coinbase.base_sepolia_rpc_url = 'https://api.developer.coinbase.com/rpc/v1/base/your-node-id' +u = Coinbase.default_user ``` -### Wallets and Addresses - -A Wallet is a collection of Addresses on the Base Sepolia Network, which can be used to send and receive crypto. +### Wallets, Addresses, and Transfers -The SDK provides customer-custodied wallets, which means that you are responsible for securely storing the data required -to re-create wallets. The following code snippet demonstrates this: +Now, create a Wallet from the User. Wallets are created with a single default Address. ```ruby # Create a Wallet with one Address by default. -w1 = Coinbase::Wallet.new +w1 = u.create_wallet +``` -# Export the data required to re-create the wallet. -data = w1.export +Next, view the default Address of your Wallet. You will need this default Address in order to fund the Wallet for your first Transfer. -# At this point, you should implement your own "store" method to securely persist -# the data required to re-create the wallet at a later time. -store(data) +```ruby +# A Wallet has a default Address. +a = w1.default_address +a.to_s +``` -# The wallet can be re-created using the exported data. -# w2 will be equivalent to w1. -w2 = Wallet.new(seed: data.seed, address_count: data.address_count) +Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don't have testnet funds, get funds from a [faucet](https://docs.base.org/docs/tools/network-faucets/). + +```ruby +# Create a new Wallet to transfer funds to. +# Then, we can transfer 0.00001 ETH out of the Wallet to another Wallet. +w2 = u.create_wallet +w1.transfer(0.00001, :eth, w2).wait! ``` -### Transfers +### Re-Instantiating Wallets -The following creates an in-memory wallet. After the wallet is funded with ETH, it transfers 0.00001 ETH to a different wallet. +The SDK creates Wallets with developer managed keys, which means you are responsible for securely storing the keys required to re-instantiate Wallets. The below code walks you through how to export a Wallets and store it in a secure location. ```ruby -# Wallets are self-custodial with in-memory key management on Base Sepolia. -# This should NOT be used in mainnet with real funds. -w1 = Coinbase::Wallet.new +# Optional: Create a new Wallet if you do not already have one. +# Export the data required to re-instantiate the Wallet. +w3 = u.create_wallet +data = w3.export +``` -# A wallet has a default address. -a = w1.default_address -a.to_s +In order to persist the data for the Wallet, you will need to implement a store method to store the data export in a secure location. If you do not store the Wallet in a secure location you will lose access to the Wallet and all of the funds on it. -# At this point, fund the wallet out-of-band. -# Then, we can transfer 0.00001 ETH out of the wallet to another wallet. -w2 = Coinbase::Wallet.new +```ruby +# At this point, you should implement your own "store" method to securely persist +# the data required to re-instantiate the Wallet at a later time. +store(data) +``` -# We wait for the transfer to complete. -# Base Sepolia is fast, so it should take only a few seconds. -w1.transfer(0.00001, :eth, w2).wait! +The below code demonstrates how to re-instantiate a Wallet from the data export. + +```ruby +# The Wallet can be re-instantiated using the exported data. +# w2 will be equivalent to w1. +w4 = u.import_wallet(data) ``` ## Development @@ -134,6 +149,7 @@ RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.7.0 ``` ### Set-up + Clone the repo by running: ```bash @@ -174,6 +190,7 @@ make lint ``` ### Testing + To run all tests, run: ```bash @@ -201,4 +218,4 @@ To generate documentation from the Ruby comments, run: ```bash make docs -``` \ No newline at end of file +``` diff --git a/coinbase.gemspec b/coinbase.gemspec index 05508d4e..5df26baa 100644 --- a/coinbase.gemspec +++ b/coinbase.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = 'coinbase-sdk' - spec.version = '0.0.1' + spec.version = '0.0.2' spec.authors = ['Yuga Cohler'] spec.files = Dir['lib/**/*.rb'] spec.summary = 'Coinbase Ruby SDK' @@ -15,12 +15,15 @@ Gem::Specification.new do |spec| spec.metadata['rubygems_mfa_required'] = 'true' - spec.add_runtime_dependency 'bigdecimal' spec.add_runtime_dependency 'eth' + spec.add_runtime_dependency 'faraday' + spec.add_runtime_dependency 'faraday-multipart' spec.add_runtime_dependency 'jimson' + spec.add_runtime_dependency 'jwt' + spec.add_runtime_dependency 'marcel' spec.add_runtime_dependency 'money-tree' - spec.add_runtime_dependency 'securerandom' + spec.add_development_dependency 'dotenv' spec.add_development_dependency 'pry' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec' diff --git a/docs/Coinbase.html b/docs/Coinbase.html index 8fb623a6..0e81add8 100644 --- a/docs/Coinbase.html +++ b/docs/Coinbase.html @@ -79,7 +79,7 @@
Defined in:
lib/coinbase.rb,
- lib/coinbase/asset.rb,
lib/coinbase/wallet.rb,
lib/coinbase/address.rb,
lib/coinbase/network.rb,
lib/coinbase/transfer.rb,
lib/coinbase/constants.rb,
lib/coinbase/balance_map.rb
+ lib/coinbase/user.rb,
lib/coinbase/asset.rb,
lib/coinbase/wallet.rb,
lib/coinbase/address.rb,
lib/coinbase/network.rb,
lib/coinbase/transfer.rb,
lib/coinbase/constants.rb,
lib/coinbase/middleware.rb,
lib/coinbase/balance_map.rb,
lib/coinbase/authenticator.rb
@@ -100,9 +100,11 @@

Overview

+ Modules: Client, Middleware + - Classes: Address, Asset, BalanceMap, Network, Transfer, Wallet + Classes: Address, Asset, Authenticator, BalanceMap, Configuration, InvalidConfiguration, Network, Transfer, User, Wallet

@@ -226,7 +228,8 @@

{
   eth: true, # Ether, the native asset of most EVM networks.
   gwei: true, # A medium denomination of Ether, typically used in gas prices.
-  wei: true # The smallest denomination of Ether.
+  wei: true, # The smallest denomination of Ether.
+  usdc: true # USD Coin, a stablecoin pegged to the US Dollar.
 }.freeze
@@ -249,7 +252,97 @@

  • - .base_sepolia_rpc_url ⇒ String + .configuration ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + .configure {|configuration| ... } ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + .default_user ⇒ Coinbase::User + + + + + + + + + + + + + +
    +

    Returns the default user.

    +
    + +
  • + + +
  • + + + .load_default_user ⇒ Object + + + + + + + + + + + + + +
    + +
  • + + +
  • + + + .to_balance_map(address_balance_list) ⇒ BalanceMap @@ -264,7 +357,7 @@

    -

    Returns the Base Sepolia RPC URL.

    +

    Converts a Coinbase::Client::AddressBalanceList to a BalanceMap.

  • @@ -273,7 +366,7 @@

  • - .base_sepolia_rpc_url=(value) ⇒ Object + .to_sym(value) ⇒ Symbol @@ -288,7 +381,7 @@

    -

    Sets the Base Sepolia RPC URL.

    +

    Converts a string to a symbol, replacing hyphens with underscores.

  • @@ -304,9 +397,110 @@

    Class Method Details

    -

    +

    + + .configurationObject + + + + + +

    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase.rb', line 19
    +
    +def self.configuration
    +  @configuration ||= Configuration.new
    +end
    +
    +
    + +
    +

    + + .configure {|configuration| ... } ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + +

    Yields:

    + +

    Raises:

    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +26
    +27
    +28
    +
    +
    # File 'lib/coinbase.rb', line 23
    +
    +def self.configure
    +  yield(configuration)
    +
    +  raise InvalidConfiguration, 'API key private key is not set' unless configuration.api_key_private_key
    +  raise InvalidConfiguration, 'API key name is not set' unless configuration.api_key_name
    +end
    +
    +
    + +
    +

    + + .default_userCoinbase::User @@ -315,7 +509,7 @@

    -

    Returns the Base Sepolia RPC URL.

    +

    Returns the default user.

    @@ -328,13 +522,13 @@

  • - (String) + (Coinbase::User)
    -

    the Base Sepolia RPC URL

    +

    the default user

  • @@ -347,15 +541,152 @@

     
     
    -17
    -18
    -19
    +53 +54 +55 + + +
    # File 'lib/coinbase.rb', line 53
    +
    +def self.default_user
    +  @default_user ||= load_default_user
    +end
    + + + +

    + +
    +

    + + .load_default_userObject + + + + + +

    + + + +
    +
    +
    +
    +83
    +84
    +85
    +86
    +87
    -
    # File 'lib/coinbase.rb', line 17
    +      
    # File 'lib/coinbase.rb', line 83
    +
    +def self.load_default_user
    +  users_api = Coinbase::Client::UsersApi.new(configuration.api_client)
    +  user_model = users_api.get_current_user
    +  Coinbase::User.new(user_model)
    +end
    +
    +
    + +
    +

    + + .to_balance_map(address_balance_list) ⇒ BalanceMap + + + + + +

    +
    + +

    Converts a Coinbase::Client::AddressBalanceList to a BalanceMap.

    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    +
      + +
    • + + + (BalanceMap) + + + + — +
      +

      The converted BalanceMap

      +
      + +
    • + +
    + +
    + + + @@ -363,9 +694,9 @@

    -

    +

    - .base_sepolia_rpc_url=(value) ⇒ Object + .to_sym(value) ⇒ Symbol @@ -374,7 +705,7 @@

    -

    Sets the Base Sepolia RPC URL.

    +

    Converts a string to a symbol, replacing hyphens with underscores.

    @@ -385,7 +716,7 @@

  • - value + string (String) @@ -394,13 +725,31 @@

    -

    the Base Sepolia RPC URL

    +

    the string to convert

  • +

    Returns:

    +
      + +
    • + + + (Symbol) + + + + — +
      +

      the converted symbol

      +
      + +
    • + +

    +
     
    -def self.base_sepolia_rpc_url
    -  @base_sepolia_rpc_url
    +
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +
    +
    # File 'lib/coinbase.rb', line 67
    +
    +def self.to_balance_map(address_balance_list)
    +  balances = {}
    +
    +  address_balance_list.data.each do |balance|
    +    asset_id = Coinbase.to_sym(balance.asset.asset_id.downcase)
    +    amount = if asset_id == :eth
    +               BigDecimal(balance.amount) / BigDecimal(Coinbase::WEI_PER_ETHER)
    +             else
    +               BigDecimal(balance.amount)
    +             end
    +    balances[asset_id] = amount
    +  end
    +
    +  BalanceMap.new(balances)
     end
    @@ -408,15 +757,15 @@

     
     
    -23
    -24
    -25
    +60 +61 +62

    @@ -428,7 +777,7 @@

    diff --git a/docs/Coinbase/Address.html b/docs/Coinbase/Address.html index d371c811..f7a981dd 100644 --- a/docs/Coinbase/Address.html +++ b/docs/Coinbase/Address.html @@ -102,7 +102,7 @@

    Overview

    -

    A representation of a blockchain Address, which is a user-controlled account on a Network. Addresses are used to send and receive Assets, and should be created using Wallet#create_address. Addresses require a Eth::Key to sign transaction data.

    +

    A representation of a blockchain Address, which is a user-controlled account on a Network. Addresses are used to send and receive Assets, and should be created using Wallet#create_address. Addresses require an Eth::Key to sign transaction data.

    @@ -114,13 +114,21 @@

    Overview

    -

    Instance Attribute Summary collapse

    -
    @@ -486,15 +406,15 @@

    -
    -

    Instance Attribute Details

    + +
    +

    Instance Method Details

    + - -

    - #address_idObject (readonly) + #address_idString @@ -503,99 +423,31 @@

    -

    Returns the value of attribute address_id.

    +

    Returns the Address ID.

    - -

    -
    # File 'lib/coinbase.rb', line 23
    +      
    # File 'lib/coinbase.rb', line 60
     
    -def self.base_sepolia_rpc_url=(value)
    -  @base_sepolia_rpc_url = value
    +def self.to_sym(value)
    +  value.to_s.gsub('-', '_').to_sym
     end
    -
    # File 'lib/coinbase/address.rb', line 22
    -
    -def initialize(network_id, address_id, wallet_id, key,
    -               client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url))
    -  # TODO: Don't require key.
    -  @network_id = network_id
    -  @address_id = address_id
    -  @wallet_id = wallet_id
    +      
    # File 'lib/coinbase/address.rb', line 19
    +
    +def initialize(model, key)
    +  @model = model
       @key = key
    -  @client = client
     end
    - - - - -
    -
    -
    -
    -14
    -15
    -16
    -
    -
    # File 'lib/coinbase/address.rb', line 14
    -
    -def address_id
    -  @address_id
    -end
    -
    -
    - - - -
    -

    - - #network_idObject (readonly) - - - - - -

    -
    - -

    Returns the value of attribute network_id.

    - - -
    -
    -
    +

    Returns:

    +
      - -
    - - - - -
    -
    -
    -
    -14
    -15
    -16
    -
    -
    # File 'lib/coinbase/address.rb', line 14
    -
    -def network_id
    -  @network_id
    -end
    -
    -
    - +
  • - -
    -

    - - #wallet_idObject (readonly) - - - - - -

    -
    - -

    Returns the value of attribute wallet_id.

    - - -
    + + (String) + + + + — +
    +

    The Address ID

    -
    + +
  • +
    @@ -603,30 +455,23 @@

     
     
    -14
    -15
    -16
    +38 +39 +40

    -
    # File 'lib/coinbase/address.rb', line 14
    +      
    # File 'lib/coinbase/address.rb', line 38
     
    -def wallet_id
    -  @wallet_id
    +def address_id
    +  @model.address_id
     end
    - - - -
    -

    Instance Method Details

    - - -
    -

    +
    +

    #get_balance(asset_id) ⇒ BigDecimal @@ -637,7 +482,7 @@

    -

    Returns the balance of the provided Asset. Currently only ETH is supported.

    +

    Returns the balance of the provided Asset.

    @@ -689,13 +534,6 @@

     
     
    -46
    -47
    -48
    -49
    -50
    -51
    -52
     53
     54
     55
    @@ -708,29 +546,32 @@ 

    62 63 64 -65

    +65 +66 +67 +68 +69 +70 -
    # File 'lib/coinbase/address.rb', line 46
    +      
    # File 'lib/coinbase/address.rb', line 53
     
     def get_balance(asset_id)
    -  normalized_asset_id = if %i[wei gwei].include?(asset_id)
    -                          :eth
    -                        else
    -                          asset_id
    -                        end
    +  normalized_asset_id = normalize_asset_id(asset_id)
    +
    +  response = addresses_api.get_address_balance(wallet_id, address_id, normalized_asset_id.to_s)
     
    -  eth_balance = list_balances[normalized_asset_id] || BigDecimal(0)
    +  return BigDecimal('0') if response.nil?
    +
    +  amount = BigDecimal(response.amount)
     
       case asset_id
       when :eth
    -    eth_balance
    +    amount / BigDecimal(Coinbase::WEI_PER_ETHER.to_s)
       when :gwei
    -    eth_balance * Coinbase::GWEI_PER_ETHER
    -  when :wei
    -    eth_balance * Coinbase::WEI_PER_ETHER
    +    amount / BigDecimal(Coinbase::GWEI_PER_ETHER.to_s)
       else
    -    BigDecimal(0)
    +    amount
       end
     end
    @@ -750,7 +591,7 @@

    -

    Returns the balances of the Address. Currently only ETH balances are supported.

    +

    Returns the balances of the Address.

    @@ -782,23 +623,76 @@

     
     
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    +45 +46 +47 +48

    -
    # File 'lib/coinbase/address.rb', line 35
    +      
    # File 'lib/coinbase/address.rb', line 45
     
     def list_balances
    -  # TODO: Handle multiple currencies.
    -  eth_balance_in_wei = BigDecimal(@client.eth_getBalance(@address_id, 'latest').to_i(16).to_s)
    -  eth_balance = BigDecimal(eth_balance_in_wei / BigDecimal(Coinbase::WEI_PER_ETHER.to_s))
    +  response = addresses_api.list_address_balances(wallet_id, address_id)
    +  Coinbase.to_balance_map(response)
    +end
    + + + +

    + +
    +

    + + #network_idSymbol + + + + + +

    +
    + +

    Returns the Network ID of the Address.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Symbol) + + + + — +
      +

      The Network ID

      +
      + +
    • + +
    - BalanceMap.new({ eth: eth_balance }) +
    + + + @@ -849,15 +743,15 @@

     
     
    -104
    -105
    -106
    +120 +121 +122

    @@ -973,11 +867,6 @@

     
     
    -73
    -74
    -75
    -76
    -77
     78
     79
     80
    @@ -1000,21 +889,36 @@ 

    97 98 99 -100

    +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116

    +
    +
    +
    +26
    +27
    +28
    +
    +
    # File 'lib/coinbase/address.rb', line 26
    +
    +def network_id
    +  Coinbase.to_sym(@model.network_id)
     end
    -
    # File 'lib/coinbase/address.rb', line 104
    +      
    # File 'lib/coinbase/address.rb', line 120
     
     def to_s
    -  @address_id
    +  address_id
     end
    -
    # File 'lib/coinbase/address.rb', line 73
    +      
    # File 'lib/coinbase/address.rb', line 78
     
     def transfer(amount, asset_id, destination)
    -  # TODO: Handle multiple currencies.
    -  raise ArgumentError, "Unsupported asset: #{asset_id}" unless Coinbase::SUPPORTED_ASSET_IDS[asset_id]
    +  raise ArgumentError, "Unsupported asset: #{asset_id}" unless Coinbase::SUPPORTED_ASSET_IDS[asset_id]
     
       if destination.is_a?(Wallet)
    -    raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != @network_id
    +    raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != network_id
     
         destination = destination.default_address.address_id
       elsif destination.is_a?(Address)
    -    raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != @network_id
    +    raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != network_id
     
         destination = destination.address_id
       end
    @@ -1024,18 +928,89 @@ 

    raise ArgumentError, "Insufficient funds: #{amount} requested, but only #{current_balance} available" end - transfer = Coinbase::Transfer.new(@network_id, @wallet_id, @address_id, amount, asset_id, destination, - client: @client) + normalized_amount = normalize_wei_amount(amount, asset_id) + + normalized_asset_id = normalize_asset_id(asset_id) + + create_transfer_request = { + amount: normalized_amount.to_i.to_s, + network_id: network_id, + asset_id: normalized_asset_id.to_s, + destination: destination + } + + transfer_model = transfers_api.create_transfer(wallet_id, address_id, create_transfer_request) + + transfer = Coinbase::Transfer.new(transfer_model) transaction = transfer.transaction transaction.sign(@key) - @client.eth_sendRawTransaction("0x#{transaction.hex}") + Coinbase.configuration.base_sepolia_client.eth_sendRawTransaction("0x#{transaction.hex}") transfer end

    +
    + +
    +

    + + #wallet_idString + + + + + +

    +
    + +

    Returns the Wallet ID of the Address.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The Wallet ID

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/coinbase/address.rb', line 32
    +
    +def wallet_id
    +  @model.wallet_id
    +end
    +
    @@ -1043,7 +1018,7 @@

    diff --git a/docs/Coinbase/Asset.html b/docs/Coinbase/Asset.html index 8e30afe9..2372392f 100644 --- a/docs/Coinbase/Asset.html +++ b/docs/Coinbase/Asset.html @@ -290,7 +290,7 @@

    -

    Returns a new Asset object.

    +

    Returns a new Asset object. Do not use this method. Instead, use the Asset constants defined in the Coinbase module.

    @@ -374,15 +374,15 @@

     
     
    -13
     14
     15
     16
     17
    -18
    +18 +19 -
    # File 'lib/coinbase/asset.rb', line 13
    +      
    # File 'lib/coinbase/asset.rb', line 14
     
     def initialize(network_id:, asset_id:, display_name:, address_id: nil)
       @network_id = network_id
    @@ -578,7 +578,7 @@ 

    diff --git a/docs/Coinbase/Authenticator.html b/docs/Coinbase/Authenticator.html new file mode 100644 index 00000000..7c10ddce --- /dev/null +++ b/docs/Coinbase/Authenticator.html @@ -0,0 +1,475 @@ + + + + + + + Class: Coinbase::Authenticator + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Authenticator + + + +

    +
    + +
    +
    Inherits:
    +
    + Faraday::Middleware + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/authenticator.rb
    +
    + +
    + +

    Overview

    +
    + +

    A class that builds JWTs for authenticating with the Coinbase Platform APIs.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(app) ⇒ Authenticator + + + + + +

    +
    + +

    Initializes the Authenticator.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + app + + + (Faraday::Connection) + + + + — +
      +

      The Faraday connection

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +13
    +14
    +15
    +16
    +
    +
    # File 'lib/coinbase/authenticator.rb', line 13
    +
    +def initialize(app)
    +  super(app)
    +  @app = app
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #build_jwt(uri) ⇒ String + + + + + +

    +
    + +

    Builds the JWT for the given API endpoint URI. The JWT is signed with the API key's private key.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + uri + + + (String) + + + + — +
      +

      The API endpoint URI

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The JWT

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +
    +
    # File 'lib/coinbase/authenticator.rb', line 32
    +
    +def build_jwt(uri)
    +  header = {
    +    typ: 'JWT',
    +    kid: Coinbase.configuration.api_key_name,
    +    nonce: SecureRandom.hex(16)
    +  }
    +
    +  claims = {
    +    sub: Coinbase.configuration.api_key_name,
    +    iss: 'coinbase-cloud',
    +    aud: ['cdp_service'],
    +    nbf: Time.now.to_i,
    +    exp: Time.now.to_i + 60, # Expiration time: 1 minute from now.
    +    uris: [uri]
    +  }
    +
    +  private_key = OpenSSL::PKey.read(Coinbase.configuration.api_key_private_key)
    +  JWT.encode(claims, private_key, 'ES256', header)
    +end
    +
    +
    + +
    +

    + + #call(env) ⇒ Object + + + + + +

    +
    + +

    Processes the request by adding the JWT to the Authorization header.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + env + + + (Faraday::Env) + + + + — +
      +

      The Faraday request environment

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/authenticator.rb', line 20
    +
    +def call(env)
    +  method = env.method.downcase.to_sym
    +  uri = env.url.to_s
    +  uri_without_protocol = URI(uri).host
    +  token = build_jwt("#{method.upcase} #{uri_without_protocol}#{env.url.path}")
    +  env.request_headers['Authorization'] = "Bearer #{token}"
    +  @app.call(env)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/BalanceMap.html b/docs/Coinbase/BalanceMap.html index 7f459e2d..07583dc4 100644 --- a/docs/Coinbase/BalanceMap.html +++ b/docs/Coinbase/BalanceMap.html @@ -104,7 +104,7 @@

    Overview

    -

    A convenience class for printing out crypto asset balances in a human-readable format.

    +

    A convenience class for printing out Asset balances in a human-readable format.

    @@ -407,7 +407,7 @@

    diff --git a/docs/Coinbase/Client.html b/docs/Coinbase/Client.html new file mode 100644 index 00000000..d652b6a5 --- /dev/null +++ b/docs/Coinbase/Client.html @@ -0,0 +1,246 @@ + + + + + + + Module: Coinbase::Client + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Coinbase::Client + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/version.rb,
    + lib/coinbase/client.rb,
    lib/coinbase/client/api_error.rb,
    lib/coinbase/client/api_client.rb,
    lib/coinbase/client/models/user.rb,
    lib/coinbase/client/models/asset.rb,
    lib/coinbase/client/models/error.rb,
    lib/coinbase/client/api/users_api.rb,
    lib/coinbase/client/configuration.rb,
    lib/coinbase/client/models/wallet.rb,
    lib/coinbase/client/models/address.rb,
    lib/coinbase/client/models/balance.rb,
    lib/coinbase/client/api/wallets_api.rb,
    lib/coinbase/client/models/transfer.rb,
    lib/coinbase/client/api/addresses_api.rb,
    lib/coinbase/client/api/transfers_api.rb,
    lib/coinbase/client/models/wallet_list.rb,
    lib/coinbase/client/models/address_list.rb,
    lib/coinbase/client/models/transfer_list.rb,
    lib/coinbase/client/models/address_balance_list.rb,
    lib/coinbase/client/models/create_wallet_request.rb,
    lib/coinbase/client/models/create_address_request.rb,
    lib/coinbase/client/models/create_transfer_request.rb
    +
    +
    + +
    + +

    Overview

    +
    + +

    #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: openapi-generator.tech Generator version: 7.5.0

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + + + Classes: Address, AddressBalanceList, AddressList, AddressesApi, ApiClient, ApiError, Asset, Balance, Configuration, CreateAddressRequest, CreateTransferRequest, CreateWalletRequest, Error, Transfer, TransferList, TransfersApi, User, UsersApi, Wallet, WalletList, WalletsApi + + +

    + + +

    + Constant Summary + collapse +

    + +
    + +
    VERSION = + +
    +
    '0.0.1-alpha'
    + +
    + + + + + + + + + +

    + Class Method Summary + collapse +

    + +
      + +
    • + + + .configure ⇒ Object + + + + + + + + + + + + + +
      +

      Customize default settings for the SDK using block.

      +
      + +
    • + + +
    + + + + +
    +

    Class Method Details

    + + +
    +

    + + .configureObject + + + + + +

    +
    + +

    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.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +
    +
    # File 'lib/coinbase/client.rb', line 49
    +
    +def configure
    +  if block_given?
    +    yield(Configuration.default)
    +  else
    +    Configuration.default
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Address.html b/docs/Coinbase/Client/Address.html new file mode 100644 index 00000000..a032f26a --- /dev/null +++ b/docs/Coinbase/Client/Address.html @@ -0,0 +1,2093 @@ + + + + + + + Class: Coinbase::Client::Address + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Address + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/address.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #address_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The onchain address derived on the server-side.

      +
      + +
    • + + +
    • + + + #network_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID of the blockchain network.

      +
      + +
    • + + +
    • + + + #public_key ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The public key from which the address is derived.

      +
      + +
    • + + +
    • + + + #wallet_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID of the wallet that owns the address.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Address + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 63
    +
    +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_id')
    +    self.network_id = attributes[:'network_id']
    +  else
    +    self.network_id = 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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #address_idObject + + + + + +

    +
    + +

    The onchain address derived on the server-side.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 28
    +
    +def address_id
    +  @address_id
    +end
    +
    +
    + + + +
    +

    + + #network_idObject + + + + + +

    +
    + +

    The ID of the blockchain network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 22
    +
    +def network_id
    +  @network_id
    +end
    +
    +
    + + + +
    +

    + + #public_keyObject + + + + + +

    +
    + +

    The public key from which the address is derived.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 25
    +
    +def public_key
    +  @public_key
    +end
    +
    +
    + + + +
    +

    + + #wallet_idObject + + + + + +

    +
    + +

    The ID of the wallet that owns the address

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 19
    +
    +def wallet_id
    +  @wallet_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 186
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'wallet_id' => :'wallet_id',
    +    :'network_id' => :'network_id',
    +    :'public_key' => :'public_key',
    +    :'address_id' => :'address_id'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 162
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'wallet_id' => :'String',
    +    :'network_id' => :'String',
    +    :'public_key' => :'String',
    +    :'address_id' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 138
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      wallet_id == o.wallet_id &&
    +      network_id == o.network_id &&
    +      public_key == o.public_key &&
    +      address_id == o.address_id
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 257
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +149
    +150
    +151
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 149
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 155
    +
    +def hash
    +  [wallet_id, network_id, public_key, address_id].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 103
    +
    +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_id.nil?
    +    invalid_properties.push('invalid value for "network_id", network_id 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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +233
    +234
    +235
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 233
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +239
    +240
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 239
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +227
    +228
    +229
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 227
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +
    +
    # File 'lib/coinbase/client/models/address.rb', line 127
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @wallet_id.nil?
    +  return false if @network_id.nil?
    +  return false if @public_key.nil?
    +  return false if @address_id.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/AddressBalanceList.html b/docs/Coinbase/Client/AddressBalanceList.html new file mode 100644 index 00000000..c5f642e6 --- /dev/null +++ b/docs/Coinbase/Client/AddressBalanceList.html @@ -0,0 +1,2097 @@ + + + + + + + Class: Coinbase::Client::AddressBalanceList + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::AddressBalanceList + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/address_balance_list.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #data ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute data.

      +
      + +
    • + + +
    • + + + #has_more ⇒ Object + + + + + + + + + + + + + + + + +
      +

      True if this list has another page of items after this one that can be fetched.

      +
      + +
    • + + +
    • + + + #next_page ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The page token to be used to fetch the next page.

      +
      + +
    • + + +
    • + + + #total_count ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The total number of balances for the wallet.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ AddressBalanceList + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 63
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #dataObject + + + + + +

    +
    + +

    Returns the value of attribute data.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 19
    +
    +def data
    +  @data
    +end
    +
    +
    + + + +
    +

    + + #has_moreObject + + + + + +

    +
    + +

    True if this list has another page of items after this one that can be fetched.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 22
    +
    +def has_more
    +  @has_more
    +end
    +
    +
    + + + +
    +

    + + #next_pageObject + + + + + +

    +
    + +

    The page token to be used to fetch the next page.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 25
    +
    +def next_page
    +  @next_page
    +end
    +
    +
    + + + +
    +

    + + #total_countObject + + + + + +

    +
    + +

    The total number of balances for the wallet.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 28
    +
    +def total_count
    +  @total_count
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 188
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'data' => :'data',
    +    :'has_more' => :'has_more',
    +    :'next_page' => :'next_page',
    +    :'total_count' => :'total_count'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 164
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'data' => :'Array<Balance>',
    +    :'has_more' => :'Boolean',
    +    :'next_page' => :'String',
    +    :'total_count' => :'Integer'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 140
    +
    +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
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 259
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 151
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 157
    +
    +def hash
    +  [data, has_more, next_page, total_count].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 105
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +235
    +236
    +237
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 235
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 241
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 229
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +
    +
    # File 'lib/coinbase/client/models/address_balance_list.rb', line 129
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/AddressList.html b/docs/Coinbase/Client/AddressList.html new file mode 100644 index 00000000..6fb99878 --- /dev/null +++ b/docs/Coinbase/Client/AddressList.html @@ -0,0 +1,2097 @@ + + + + + + + Class: Coinbase::Client::AddressList + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::AddressList + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/address_list.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #data ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute data.

      +
      + +
    • + + +
    • + + + #has_more ⇒ Object + + + + + + + + + + + + + + + + +
      +

      True if this list has another page of items after this one that can be fetched.

      +
      + +
    • + + +
    • + + + #next_page ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The page token to be used to fetch the next page.

      +
      + +
    • + + +
    • + + + #total_count ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The total number of addresses for the wallet.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ AddressList + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 63
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #dataObject + + + + + +

    +
    + +

    Returns the value of attribute data.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 19
    +
    +def data
    +  @data
    +end
    +
    +
    + + + +
    +

    + + #has_moreObject + + + + + +

    +
    + +

    True if this list has another page of items after this one that can be fetched.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 22
    +
    +def has_more
    +  @has_more
    +end
    +
    +
    + + + +
    +

    + + #next_pageObject + + + + + +

    +
    + +

    The page token to be used to fetch the next page.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 25
    +
    +def next_page
    +  @next_page
    +end
    +
    +
    + + + +
    +

    + + #total_countObject + + + + + +

    +
    + +

    The total number of addresses for the wallet.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 28
    +
    +def total_count
    +  @total_count
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 188
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'data' => :'data',
    +    :'has_more' => :'has_more',
    +    :'next_page' => :'next_page',
    +    :'total_count' => :'total_count'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 164
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'data' => :'Array<Address>',
    +    :'has_more' => :'Boolean',
    +    :'next_page' => :'String',
    +    :'total_count' => :'Integer'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 140
    +
    +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
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 259
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 151
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 157
    +
    +def hash
    +  [data, has_more, next_page, total_count].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 105
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +235
    +236
    +237
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 235
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 241
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 229
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +
    +
    # File 'lib/coinbase/client/models/address_list.rb', line 129
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/AddressesApi.html b/docs/Coinbase/Client/AddressesApi.html new file mode 100644 index 00000000..d57a0253 --- /dev/null +++ b/docs/Coinbase/Client/AddressesApi.html @@ -0,0 +1,2282 @@ + + + + + + + Class: Coinbase::Client::AddressesApi + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::AddressesApi + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api/addresses_api.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #api_client ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute api_client.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(api_client = ApiClient.default) ⇒ AddressesApi + + + + + +

    +
    + +

    Returns a new instance of AddressesApi.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 19
    +
    +def initialize(api_client = ApiClient.default)
    +  @api_client = api_client
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #api_clientObject + + + + + +

    +
    + +

    Returns the value of attribute api_client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 17
    +
    +def api_client
    +  @api_client
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #create_address(wallet_id, opts = {}) ⇒ Address + + + + + +

    +
    + +

    Create a new address Create a new address scoped to the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to create the address in.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + +

    Options Hash (opts):

    + + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +31
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 28
    +
    +def create_address(wallet_id, opts = {})
    +  data, _status_code, _headers = create_address_with_http_info(wallet_id, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #create_address_with_http_info(wallet_id, opts = {}) ⇒ Array<(Address, Integer, Hash)> + + + + + +

    +
    + +

    Create a new address Create a new address scoped to the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to create the address in.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + +

    Options Hash (opts):

    + + + +

    Returns:

    +
      + +
    • + + + (Array<(Address, Integer, Hash)>) + + + + — +
      +

      Address data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 39
    +
    +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(wallet_id, address_id, opts = {}) ⇒ Address + + + + + +

    +
    + +

    Get address by onchain address Get address

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to.

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 98
    +
    +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_balance(wallet_id, address_id, asset_id, opts = {}) ⇒ Balance + + + + + +

    +
    + +

    Get address balance for asset Get address balance

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balance for

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + asset_id + + + (String) + + + + — +
      +

      The symbol of the asset to fetch the balance for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +168
    +169
    +170
    +171
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 168
    +
    +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_with_http_info(wallet_id, address_id, asset_id, opts = {}) ⇒ Array<(Balance, Integer, Hash)> + + + + + +

    +
    + +

    Get address balance for asset Get address balance

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balance for

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + asset_id + + + (String) + + + + — +
      +

      The symbol of the asset to fetch the balance for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Balance, Integer, Hash)>) + + + + — +
      +

      Balance data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 180
    +
    +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_address_with_http_info(wallet_id, address_id, opts = {}) ⇒ Array<(Address, Integer, Hash)> + + + + + +

    +
    + +

    Get address by onchain address Get address

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to.

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Address, Integer, Hash)>) + + + + — +
      +

      Address data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 109
    +
    +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
    +
    +
    + +
    +

    + + #list_address_balances(wallet_id, address_id, opts = {}) ⇒ AddressBalanceList + + + + + +

    +
    + +

    Get all balances for address Get address balances

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balances for

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +243
    +244
    +245
    +246
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 243
    +
    +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
    +
    +
    + +
    +

    + + #list_address_balances_with_http_info(wallet_id, address_id, opts = {}) ⇒ Array<(AddressBalanceList, Integer, Hash)> + + + + + +

    +
    + +

    Get all balances for address Get address balances

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balances for

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The onchain address of the address that is being fetched.

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    +
      + +
    • + + + (Array<(AddressBalanceList, Integer, Hash)>) + + + + — +
      +

      AddressBalanceList data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +255
    +256
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
    +276
    +277
    +278
    +279
    +280
    +281
    +282
    +283
    +284
    +285
    +286
    +287
    +288
    +289
    +290
    +291
    +292
    +293
    +294
    +295
    +296
    +297
    +298
    +299
    +300
    +301
    +302
    +303
    +304
    +305
    +306
    +307
    +308
    +309
    +310
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 255
    +
    +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
    +  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_address_balances, the character length must be smaller than or equal to 5000.'
    +  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] || {}
    +  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] || '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(wallet_id, opts = {}) ⇒ AddressList + + + + + +

    +
    + +

    List addresses in a wallet. List addresses in the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet whose addresses to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +319
    +320
    +321
    +322
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 319
    +
    +def list_addresses(wallet_id, opts = {})
    +  data, _status_code, _headers = list_addresses_with_http_info(wallet_id, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #list_addresses_with_http_info(wallet_id, opts = {}) ⇒ Array<(AddressList, Integer, Hash)> + + + + + +

    +
    + +

    List addresses in a wallet. List addresses in the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet whose addresses to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    +
      + +
    • + + + (Array<(AddressList, Integer, Hash)>) + + + + — +
      +

      AddressList data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +331
    +332
    +333
    +334
    +335
    +336
    +337
    +338
    +339
    +340
    +341
    +342
    +343
    +344
    +345
    +346
    +347
    +348
    +349
    +350
    +351
    +352
    +353
    +354
    +355
    +356
    +357
    +358
    +359
    +360
    +361
    +362
    +363
    +364
    +365
    +366
    +367
    +368
    +369
    +370
    +371
    +372
    +373
    +374
    +375
    +376
    +377
    +378
    +379
    +380
    +381
    +382
    +383
    +
    +
    # File 'lib/coinbase/client/api/addresses_api.rb', line 331
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/ApiClient.html b/docs/Coinbase/Client/ApiClient.html new file mode 100644 index 00000000..03402da9 --- /dev/null +++ b/docs/Coinbase/Client/ApiClient.html @@ -0,0 +1,2972 @@ + + + + + + + Class: Coinbase::Client::ApiClient + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::ApiClient + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api_client.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #config ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The Configuration object holding settings to be used in the API client.

      +
      + +
    • + + +
    • + + + #default_headers ⇒ Hash + + + + + + + + + + + + + + + + +
      +

      Defines the headers to be used in HTTP requests of all API calls by default.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(config = Configuration.default) ⇒ ApiClient + + + + + +

    +
    + +

    Initializes the ApiClient

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + config + + + (Hash) + + + (defaults to: Configuration.default) + + + — +
      +

      a customizable set of options

      +
      + +
    • + +
    + + + + +

    Options Hash (config):

    +
      + +
    • + Configuration + (Configuration) + + + + + —
      +

      for initializing the object, default to Configuration.default

      +
      + +
    • + +
    + + + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 35
    +
    +def initialize(config = Configuration.default)
    +  @config = config
    +  @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
    +  @default_headers = {
    +    'Content-Type' => 'application/json',
    +    'User-Agent' => @user_agent
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #configObject + + + + + +

    +
    + +

    The Configuration object holding settings to be used in the API client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 26
    +
    +def config
    +  @config
    +end
    +
    +
    + + + +
    +

    + + #default_headersHash + + + + + +

    +
    + +

    Defines the headers to be used in HTTP requests of all API calls by default.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 31
    +
    +def default_headers
    +  @default_headers
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .defaultObject + + + + + +

    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 44
    +
    +def self.default
    +  @@default ||= ApiClient.new
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #basic_auth(conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +233
    +234
    +235
    +236
    +237
    +238
    +239
    +240
    +241
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 233
    +
    +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
    +
    +
    + +
    +

    + + #build_collection_param(param, collection_format) ⇒ Object + + + + + +

    +
    + +

    Build parameter value according to the given collection format.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + collection_format + + + (String) + + + + — +
      +

      one of :csv, :ssv, :tsv, :pipes and :multi

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +413
    +414
    +415
    +416
    +417
    +418
    +419
    +420
    +421
    +422
    +423
    +424
    +425
    +426
    +427
    +428
    +429
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 413
    +
    +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
    +
    +
    + +
    +

    + + #build_connectionObject + + + + + +

    + + + + +
    +
    +
    +
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 213
    +
    +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
    +
    +
    + +
    +

    + + #build_request(http_method, path, request, opts = {}) ⇒ Faraday::Request + + + + + +

    +
    + +

    Builds the HTTP request

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + http_method + + + (String) + + + + — +
      +

      HTTP method/verb (e.g. POST)

      +
      + +
    • + +
    • + + path + + + (String) + + + + — +
      +

      URL path (e.g. /account/new)

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      a customizable set of options

      +
      + +
    • + +
    + + + + + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :header_params + (Hash) + + + + + —
      +

      Header parameters

      +
      + +
    • + +
    • + :query_params + (Hash) + + + + + —
      +

      Query parameters

      +
      + +
    • + +
    • + :form_params + (Hash) + + + + + —
      +

      Query parameters

      +
      + +
    • + +
    • + :body + (Object) + + + + + —
      +

      HTTP body (JSON/XML)

      +
      + +
    • + +
    + + +

    Returns:

    +
      + +
    • + + + (Faraday::Request) + + + + — +
      +

      A Faraday Request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 101
    +
    +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
    +  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
    +
    +
    + +
    +

    + + #build_request_body(header_params, form_params, body) ⇒ String + + + + + +

    +
    + +

    Builds the HTTP request body

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + header_params + + + (Hash) + + + + — +
      +

      Header parameters

      +
      + +
    • + +
    • + + form_params + + + (Hash) + + + + — +
      +

      Query parameters

      +
      + +
    • + +
    • + + body + + + (Object) + + + + — +
      +

      HTTP body (JSON/XML)

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      HTTP body data in the form of string

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 135
    +
    +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
    +        data[key] = value.to_s
    +      end
    +    end
    +  elsif body
    +    data = body.is_a?(String) ? body : body.to_json
    +  else
    +    data = nil
    +  end
    +  data
    +end
    +
    +
    + +
    +

    + + #build_request_url(path, opts = {}) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +334
    +335
    +336
    +337
    +338
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 334
    +
    +def build_request_url(path, opts = {})
    +  # Add leading and trailing slashes to path
    +  path = "/#{path}".gsub(/\/+/, '/')
    +  @config.base_url(opts[:operation]) + path
    +end
    +
    +
    + +
    +

    + + #call_api(http_method, path, opts = {}) ⇒ Array<(Object, Integer, Hash)> + + + + + +

    +
    + +

    Call an API with given options.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Object, Integer, Hash)>) + + + + — +
      +

      an array of 3 elements: the data deserialized from response body (could be nil), response status code and response headers.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 52
    +
    +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
    +
    +    if config.debugging
    +      config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
    +    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
    +    end
    +  rescue Faraday::TimeoutError
    +    fail ApiError.new('Connection timed out')
    +  rescue Faraday::ConnectionFailed
    +    fail ApiError.new('Connection failed')
    +  end
    +
    +  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
    +
    +
    + +
    +

    + + #connection(opts) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +198
    +199
    +200
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 198
    +
    +def connection(opts)
    +  opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
    +end
    +
    +
    + +
    +

    + + #connection_multipartObject + + + + + +

    + + + + +
    +
    +
    +
    +202
    +203
    +204
    +205
    +206
    +207
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 202
    +
    +def connection_multipart
    +  @connection_multipart ||= build_connection do |conn|
    +    conn.request :multipart
    +    conn.request :url_encoded
    +  end
    +end
    +
    +
    + +
    +

    + + #connection_regularObject + + + + + +

    + + + + +
    +
    +
    +
    +209
    +210
    +211
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 209
    +
    +def connection_regular
    +  @connection_regular ||= build_connection
    +end
    +
    +
    + +
    +

    + + #convert_to_type(data, return_type) ⇒ Mixed + + + + + +

    +
    + +

    Convert data to the given return type.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + data + + + (Object) + + + + — +
      +

      Data to be converted

      +
      + +
    • + +
    • + + return_type + + + (String) + + + + — +
      +

      Return type

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Mixed) + + + + — +
      +

      Data in a particular type

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +288
    +289
    +290
    +291
    +292
    +293
    +294
    +295
    +296
    +297
    +298
    +299
    +300
    +301
    +302
    +303
    +304
    +305
    +306
    +307
    +308
    +309
    +310
    +311
    +312
    +313
    +314
    +315
    +316
    +317
    +318
    +319
    +320
    +321
    +322
    +323
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 288
    +
    +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<Pet>
    +    sub_type = $1
    +    data.map { |item| convert_to_type(item, sub_type) }
    +  when /\AHash\<String, (.+)\>\z/
    +    # e.g. Hash<String, Integer>
    +    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
    +
    +
    + +
    +

    + + #deserialize(response, return_type) ⇒ Object + + + + + +

    +
    + +

    Deserialize the response to the given return type.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + response + + + (Response) + + + + — +
      +

      HTTP response

      +
      + +
    • + +
    • + + return_type + + + (String) + + + + — +
      +

      some examples: “User”, “Array<User>”, “Hash<String, Integer>”

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
    +276
    +277
    +278
    +279
    +280
    +281
    +282
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 259
    +
    +def deserialize(response, return_type)
    +  body = response.body
    +  return nil if body.nil? || body.empty?
    +
    +  # return response body directly for String return type
    +  return body.to_s if return_type == 'String'
    +
    +  # ensuring a default content type
    +  content_type = response.headers['Content-Type'] || 'application/json'
    +
    +  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
    +    else
    +      raise e
    +    end
    +  end
    +
    +  convert_to_type data, return_type
    +end
    +
    +
    + +
    +

    + + #deserialize_file(response, stream) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 170
    +
    +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
    +
    +
    + +
    +

    + + #download_file(request) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 160
    +
    +def download_file(request)
    +  stream = []
    +
    +  # handle streaming Responses
    +  request.options.on_data = Proc.new do |chunk, overall_received_bytes|
    +    stream << chunk
    +  end
    +  stream
    +end
    +
    +
    + +
    +

    + + #json_mime?(mime) ⇒ Boolean + + + + + +

    +
    + +

    Check if the given MIME is a JSON MIME. JSON MIME examples:

    + +
    application/json
    +application/json; charset=UTF8
    +APPLICATION/JSON
    +*/*
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mime + + + (String) + + + + — +
      +

      MIME

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      True if the MIME is application/json

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +251
    +252
    +253
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 251
    +
    +def json_mime?(mime)
    +  (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
    +end
    +
    +
    + +
    +

    + + #object_to_hash(obj) ⇒ String + + + + + +

    +
    + +

    Convert object(non-array) to hash.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + obj + + + (Object) + + + + — +
      +

      object to be converted into JSON string

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      JSON string representation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +403
    +404
    +405
    +406
    +407
    +408
    +409
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 403
    +
    +def object_to_hash(obj)
    +  if obj.respond_to?(:to_hash)
    +    obj.to_hash
    +  else
    +    obj
    +  end
    +end
    +
    +
    + +
    +

    + + #object_to_http_body(model) ⇒ String + + + + + +

    +
    + +

    Convert object (array, hash, object, etc) to JSON string.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + model + + + (Object) + + + + — +
      +

      object to be converted into JSON string

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      JSON string representation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +389
    +390
    +391
    +392
    +393
    +394
    +395
    +396
    +397
    +398
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 389
    +
    +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
    +
    +
    + +
    +

    + + #sanitize_filename(filename) ⇒ String + + + + + +

    +
    + +

    Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + filename + + + (String) + + + + — +
      +

      the filename to be sanitized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      the sanitized filename

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +330
    +331
    +332
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 330
    +
    +def sanitize_filename(filename)
    +  filename.gsub(/.*[\/\\]/, '')
    +end
    +
    +
    + +
    +

    + + #select_header_accept(accepts) ⇒ String + + + + + +

    +
    + +

    Return Accept header based on an array of accepts provided.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + accepts + + + (Array) + + + + — +
      +

      array for Accept

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      the Accept header (e.g. application/json)

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +368
    +369
    +370
    +371
    +372
    +373
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 368
    +
    +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
    +
    +
    + +
    +

    + + #select_header_content_type(content_types) ⇒ String + + + + + +

    +
    + +

    Return Content-Type header based on an array of content types provided.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + content_types + + + (Array) + + + + — +
      +

      array for Content-Type

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      the Content-Type header (e.g. application/json)

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +378
    +379
    +380
    +381
    +382
    +383
    +384
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 378
    +
    +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
    +
    +
    + +
    +

    + + #ssl_optionsObject + + + + + +

    + + + + +
    +
    +
    +
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 223
    +
    +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
    +
    +
    + +
    +

    + + #update_params_for_auth!(header_params, query_params, auth_names) ⇒ Object + + + + + +

    +
    + +

    Update header and query params based on authentication settings.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + header_params + + + (Hash) + + + + — +
      +

      Header parameters

      +
      + +
    • + +
    • + + query_params + + + (Hash) + + + + — +
      +

      Query parameters

      +
      + +
    • + +
    • + + auth_names + + + (String) + + + + — +
      +

      Authentication scheme name

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +345
    +346
    +347
    +348
    +349
    +350
    +351
    +352
    +353
    +354
    +355
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 345
    +
    +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
    +
    +
    + +
    +

    + + #user_agent=(user_agent) ⇒ Object + + + + + +

    +
    + +

    Sets user agent in HTTP header

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + user_agent + + + (String) + + + + — +
      +

      User agent (e.g. openapi-generator/ruby/1.0.0)

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +360
    +361
    +362
    +363
    +
    +
    # File 'lib/coinbase/client/api_client.rb', line 360
    +
    +def user_agent=(user_agent)
    +  @user_agent = user_agent
    +  @default_headers['User-Agent'] = @user_agent
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/ApiError.html b/docs/Coinbase/Client/ApiError.html new file mode 100644 index 00000000..b790d8be --- /dev/null +++ b/docs/Coinbase/Client/ApiError.html @@ -0,0 +1,607 @@ + + + + + + + Exception: Coinbase::Client::ApiError + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Coinbase::Client::ApiError + + + +

    +
    + +
    +
    Inherits:
    +
    + StandardError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api_error.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #code ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute code.

      +
      + +
    • + + +
    • + + + #response_body ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute response_body.

      +
      + +
    • + + +
    • + + + #response_headers ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute response_headers.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #initialize(arg = nil) ⇒ ApiError + + + + + + + constructor + + + + + + + + +
      +

      Usage examples: ApiError.new ApiError.new(“message”) ApiError.new(:code => 500, :response_headers => {}, :response_body => “”) ApiError.new(:code => 404, :message => “Not Found”).

      +
      + +
    • + + +
    • + + + #message ⇒ Object + + + + + + + + + + + + + +
      + +
    • + + +
    • + + + #to_s ⇒ Object + + + + + + + + + + + + + +
      +

      Override to_s to display a friendly error message.

      +
      + +
    • + + +
    + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(arg = nil) ⇒ ApiError + + + + + +

    +
    + +

    Usage examples:

    + +
    ApiError.new
    +ApiError.new("message")
    +ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
    +ApiError.new(:code => 404, :message => "Not Found")
    +
    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 22
    +
    +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
    +  else
    +    super arg
    +    @message = arg
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #codeObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute code.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 15
    +
    +def code
    +  @code
    +end
    +
    +
    + + + +
    +

    + + #response_bodyObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute response_body.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 15
    +
    +def response_body
    +  @response_body
    +end
    +
    +
    + + + +
    +

    + + #response_headersObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute response_headers.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 15
    +
    +def response_headers
    +  @response_headers
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #messageObject + + + + + +

    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 44
    +
    +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
    +
    +
    + +
    +

    + + #to_sObject + + + + + +

    +
    + +

    Override to_s to display a friendly error message

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +40
    +41
    +42
    +
    +
    # File 'lib/coinbase/client/api_error.rb', line 40
    +
    +def to_s
    +  message
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Asset.html b/docs/Coinbase/Client/Asset.html new file mode 100644 index 00000000..75ff8fca --- /dev/null +++ b/docs/Coinbase/Client/Asset.html @@ -0,0 +1,2076 @@ + + + + + + + Class: Coinbase::Client::Asset + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Asset + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/asset.rb
    +
    + +
    + +

    Overview

    +
    + +

    An asset onchain scoped to a particular network, e.g. ETH on base-sepolia, or the USDC ERC20 Token on ethereum-mainnet.

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #asset_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID for the asset on the network.

      +
      + +
    • + + +
    • + + + #contract_address ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The optional contract address for the asset.

      +
      + +
    • + + +
    • + + + #decimals ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The number of decimals the asset supports.

      +
      + +
    • + + +
    • + + + #network_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID of the blockchain network.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #==(o) ⇒ Object + + + + + + + + + + + + + +
      +

      Checks equality by comparing each attribute.

      +
      + +
    • + + +
    • + + + #_to_hash(value) ⇒ Hash + + + + + + + + + + + + + +
      +

      Outputs non-array value in the form of hash For object, use to_hash.

      +
      + +
    • + + +
    • + + + #eql?(o) ⇒ Boolean + + + + + + + + + + + + + +
      + +
    • + + +
    • + + + #hash ⇒ Integer + + + + + + + + + + + + + +
      +

      Calculates hash code according to all attributes.

      +
      + +
    • + + +
    • + + + #initialize(attributes = {}) ⇒ Asset + + + + + + + constructor + + + + + + + + +
      +

      Initializes the object.

      +
      + +
    • + + +
    • + + + #list_invalid_properties ⇒ Object + + + + + + + + + + + + + +
      +

      Show invalid properties with the reasons.

      +
      + +
    • + + +
    • + + + #to_body ⇒ Hash + + + + + + + + + + + + + +
      +

      to_body is an alias to to_hash (backward compatibility).

      +
      + +
    • + + +
    • + + + #to_hash ⇒ Hash + + + + + + + + + + + + + +
      +

      Returns the object in the form of hash.

      +
      + +
    • + + +
    • + + + #to_s ⇒ String + + + + + + + + + + + + + +
      +

      Returns the string representation of the object.

      +
      + +
    • + + +
    • + + + #valid? ⇒ Boolean + + + + + + + + + + + + + +
      +

      Check to see if the all the properties in the model are valid.

      +
      + +
    • + + +
    + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Asset + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 64
    +
    +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_id')
    +    self.network_id = attributes[:'network_id']
    +  else
    +    self.network_id = nil
    +  end
    +
    +  if attributes.key?(:'asset_id')
    +    self.asset_id = attributes[:'asset_id']
    +  else
    +    self.asset_id = nil
    +  end
    +
    +  if attributes.key?(:'decimals')
    +    self.decimals = attributes[:'decimals']
    +  end
    +
    +  if attributes.key?(:'contract_address')
    +    self.contract_address = attributes[:'contract_address']
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #asset_idObject + + + + + +

    +
    + +

    The ID for the asset on the network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 23
    +
    +def asset_id
    +  @asset_id
    +end
    +
    +
    + + + +
    +

    + + #contract_addressObject + + + + + +

    +
    + +

    The optional contract address for the asset. This will be specified for smart contract-based assets, for example ERC20s.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 29
    +
    +def contract_address
    +  @contract_address
    +end
    +
    +
    + + + +
    +

    + + #decimalsObject + + + + + +

    +
    + +

    The number of decimals the asset supports. This is used to convert from atomic units to base units.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 26
    +
    +def decimals
    +  @decimals
    +end
    +
    +
    + + + +
    +

    + + #network_idObject + + + + + +

    +
    + +

    The ID of the blockchain network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 20
    +
    +def network_id
    +  @network_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 173
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +42
    +43
    +44
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 42
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 32
    +
    +def self.attribute_map
    +  {
    +    :'network_id' => :'network_id',
    +    :'asset_id' => :'asset_id',
    +    :'decimals' => :'decimals',
    +    :'contract_address' => :'contract_address'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 149
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +57
    +58
    +59
    +60
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 57
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 47
    +
    +def self.openapi_types
    +  {
    +    :'network_id' => :'String',
    +    :'asset_id' => :'String',
    +    :'decimals' => :'Integer',
    +    :'contract_address' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 125
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      network_id == o.network_id &&
    +      asset_id == o.asset_id &&
    +      decimals == o.decimals &&
    +      contract_address == o.contract_address
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +254
    +255
    +256
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 244
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +136
    +137
    +138
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 136
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +142
    +143
    +144
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 142
    +
    +def hash
    +  [network_id, asset_id, decimals, contract_address].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +100
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 100
    +
    +def list_invalid_properties
    +  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
    +  invalid_properties = Array.new
    +  if @network_id.nil?
    +    invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
    +  end
    +
    +  if @asset_id.nil?
    +    invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
    +  end
    +
    +  invalid_properties
    +end
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +220
    +221
    +222
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 220
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +236
    +237
    +238
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 226
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +214
    +215
    +216
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 214
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +116
    +117
    +118
    +119
    +120
    +121
    +
    +
    # File 'lib/coinbase/client/models/asset.rb', line 116
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @network_id.nil?
    +  return false if @asset_id.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Balance.html b/docs/Coinbase/Client/Balance.html new file mode 100644 index 00000000..7fb9d805 --- /dev/null +++ b/docs/Coinbase/Client/Balance.html @@ -0,0 +1,1908 @@ + + + + + + + Class: Coinbase::Client::Balance + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Balance + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/balance.rb
    +
    + +
    + +

    Overview

    +
    + +

    The balance of an asset onchain

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #amount ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The amount in the atomic units of the asset.

      +
      + +
    • + + +
    • + + + #asset ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute asset.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Balance + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 53
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #amountObject + + + + + +

    +
    + +

    The amount in the atomic units of the asset

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 20
    +
    +def amount
    +  @amount
    +end
    +
    +
    + + + +
    +

    + + #assetObject + + + + + +

    +
    + +

    Returns the value of attribute asset.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 22
    +
    +def asset
    +  @asset
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 152
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 33
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 25
    +
    +def self.attribute_map
    +  {
    +    :'amount' => :'amount',
    +    :'asset' => :'asset'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 128
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 46
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +38
    +39
    +40
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 38
    +
    +def self.openapi_types
    +  {
    +    :'amount' => :'String',
    +    :'asset' => :'Asset'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +106
    +107
    +108
    +109
    +110
    +111
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 106
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      amount == o.amount &&
    +      asset == o.asset
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 223
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +115
    +116
    +117
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 115
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +121
    +122
    +123
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 121
    +
    +def hash
    +  [amount, asset].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 81
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +199
    +200
    +201
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 199
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 205
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +193
    +194
    +195
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 193
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +97
    +98
    +99
    +100
    +101
    +102
    +
    +
    # File 'lib/coinbase/client/models/balance.rb', line 97
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @amount.nil?
    +  return false if @asset.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Configuration.html b/docs/Coinbase/Client/Configuration.html new file mode 100644 index 00000000..3838ffa2 --- /dev/null +++ b/docs/Coinbase/Client/Configuration.html @@ -0,0 +1,3845 @@ + + + + + + + Class: Coinbase::Client::Configuration + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Configuration + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/configuration.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Class Method Summary + collapse +

    + +
      + +
    • + + + .default ⇒ Object + + + + + + + + + + + + + +
      +

      The default Configuration object.

      +
      + +
    • + + +
    + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize {|_self| ... } ⇒ Configuration + + + + + +

    +
    + +

    Returns a new instance of Configuration.

    + + +
    +
    +
    + +

    Yields:

    +
      + +
    • + + + (_self) + + + +
    • + +
    +

    Yield Parameters:

    + + +
    + + + + +
    +
    +
    +
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 150
    +
    +def initialize
    +  @scheme = 'https'
    +  @host = 'api.cdp.coinbase.com'
    +  @base_path = '/platform'
    +  @server_index = nil
    +  @server_operation_index = {}
    +  @server_variables = {}
    +  @server_operation_variables = {}
    +  @api_key = {}
    +  @api_key_prefix = {}
    +  @client_side_validation = true
    +  @ssl_verify = true
    +  @ssl_verify_mode = nil
    +  @ssl_ca_file = nil
    +  @ssl_client_cert = nil
    +  @ssl_client_key = nil
    +  @middlewares = Hash.new { |h, k| h[k] = [] }
    +  @configure_connection_blocks = []
    +  @timeout = 60
    +  # return data as binary instead of file
    +  @return_binary_data = false
    +  @params_encoder = nil
    +  @debugging = false
    +  @inject_format = false
    +  @force_ending_format = false
    +  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
    +
    +  yield(self) if block_given?
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #access_tokenObject + + + + + +

    +
    + +

    Defines the access token (Bearer) used with OAuth2.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 63
    +
    +def access_token
    +  @access_token
    +end
    +
    +
    + + + +
    +

    + + #access_token_getterProc + + + + + +

    +
    + +

    Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2. Overrides the access_token if set

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Proc) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +68
    +69
    +70
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 68
    +
    +def access_token_getter
    +  @access_token_getter
    +end
    +
    +
    + + + +
    +

    + + #api_keyHash + + + + + +

    +
    + +

    Defines API keys used with API Key authentications.

    + + +
    +
    +
    + +
    +

    Examples:

    + + +

    +

    parameter name is “api_key”, API key is “xxx” (e.g. “api_key=xxx” in query string)

    +

    + +
    config.api_key['api_key'] = 'xxx'
    + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      key: parameter name, value: parameter value (API key)

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +42
    +43
    +44
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 42
    +
    +def api_key
    +  @api_key
    +end
    +
    +
    + + + +
    +

    + + #api_key_prefixHash + + + + + +

    +
    + +

    Defines API key prefixes used with API Key authentications.

    + + +
    +
    +
    + +
    +

    Examples:

    + + +

    +

    parameter name is “Authorization”, API key prefix is “Token” (e.g. “Authorization: Token xxx” in headers)

    +

    + +
    config.api_key_prefix['api_key'] = 'Token'
    + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      key: parameter name, value: API key prefix

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +50
    +51
    +52
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 50
    +
    +def api_key_prefix
    +  @api_key_prefix
    +end
    +
    +
    + + + +
    +

    + + #base_pathObject + + + + + +

    +
    + +

    Defines url base path

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 22
    +
    +def base_path
    +  @base_path
    +end
    +
    +
    + + + +
    +

    + + #client_side_validationtrue, false + + + + + +

    +
    + +

    Set this to false to skip client side validation in the operation. Default to true.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +102
    +103
    +104
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 102
    +
    +def client_side_validation
    +  @client_side_validation
    +end
    +
    +
    + + + +
    +

    + + #debuggingtrue, false + + + + + +

    +
    + +

    Set this to enable/disable debugging. When enabled (set to true), HTTP request/response details will be logged with `logger.debug` (see the `logger` attribute). Default to false.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +80
    +81
    +82
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 80
    +
    +def debugging
    +  @debugging
    +end
    +
    +
    + + + +
    +

    + + #force_ending_formatObject + + + + + +

    +
    + +

    Returns the value of attribute force_ending_format.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +148
    +149
    +150
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 148
    +
    +def force_ending_format
    +  @force_ending_format
    +end
    +
    +
    + + + +
    +

    + + #hostObject + + + + + +

    +
    + +

    Defines url host

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 19
    +
    +def host
    +  @host
    +end
    +
    +
    + + + +
    +

    + + #inject_formatObject + + + + + +

    +
    + +

    Returns the value of attribute inject_format.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +146
    +147
    +148
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 146
    +
    +def inject_format
    +  @inject_format
    +end
    +
    +
    + + + +
    +

    + + #logger#debug + + + + + +

    +
    + +

    Defines the logger used for debugging. Default to `Rails.logger` (when in Rails) or logging to STDOUT.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (#debug) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +86
    +87
    +88
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 86
    +
    +def logger
    +  @logger
    +end
    +
    +
    + + + +
    +

    + + #params_encoderObject + + + + + +

    +
    + +

    Set this to customize parameters encoder of array parameter. Default to nil. Faraday uses NestedParamsEncoder when nil.

    + +

    github.com/lostisland/faraday/tree/main/lib/faraday/encoders

    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • params_encoder option of Faraday. Related source code:
    • + +
    + +
    + + + + +
    +
    +
    +
    +143
    +144
    +145
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 143
    +
    +def params_encoder
    +  @params_encoder
    +end
    +
    +
    + + + +
    +

    + + #passwordString + + + + + +

    +
    + +

    Defines the password used with HTTP basic authentication.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +60
    +61
    +62
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 60
    +
    +def password
    +  @password
    +end
    +
    +
    + + + +
    +

    + + #proxyObject + + + + + +

    +
    + +

    Proxy setting HTTP Proxy settings

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +136
    +137
    +138
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 136
    +
    +def proxy
    +  @proxy
    +end
    +
    +
    + + + +
    +

    + + #return_binary_dataObject + + + + + +

    +
    + +

    Set this to return data as binary instead of downloading a temp file. When enabled (set to true) HTTP responses with return type `File` will be returned as a stream of binary data. Default to false.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +73
    +74
    +75
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 73
    +
    +def return_binary_data
    +  @return_binary_data
    +end
    +
    +
    + + + +
    +

    + + #schemeObject + + + + + +

    +
    + +

    Defines url scheme

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +16
    +17
    +18
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 16
    +
    +def scheme
    +  @scheme
    +end
    +
    +
    + + + +
    +

    + + #server_indexObject + + + + + +

    +
    + +

    Define server configuration index

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 25
    +
    +def server_index
    +  @server_index
    +end
    +
    +
    + + + +
    +

    + + #server_operation_indexObject + + + + + +

    +
    + +

    Define server operation configuration index

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 28
    +
    +def server_operation_index
    +  @server_operation_index
    +end
    +
    +
    + + + +
    +

    + + #server_operation_variablesObject + + + + + +

    +
    + +

    Default server operation variables

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 34
    +
    +def server_operation_variables
    +  @server_operation_variables
    +end
    +
    +
    + + + +
    +

    + + #server_variablesObject + + + + + +

    +
    + +

    Default server variables

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 31
    +
    +def server_variables
    +  @server_variables
    +end
    +
    +
    + + + +
    +

    + + #ssl_ca_fileString + + + + + +

    +
    + +

    TLS/SSL setting Set this to customize the certificate file to verify the peer.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      the path to the certificate file

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +124
    +125
    +126
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 124
    +
    +def ssl_ca_file
    +  @ssl_ca_file
    +end
    +
    +
    + + + +
    +

    + + #ssl_client_certObject + + + + + +

    +
    + +

    TLS/SSL setting Client certificate file (for client certificate)

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 128
    +
    +def ssl_client_cert
    +  @ssl_client_cert
    +end
    +
    +
    + + + +
    +

    + + #ssl_client_keyObject + + + + + +

    +
    + +

    TLS/SSL setting Client private key file (for client certificate)

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +132
    +133
    +134
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 132
    +
    +def ssl_client_key
    +  @ssl_client_key
    +end
    +
    +
    + + + +
    +

    + + #ssl_verifytrue, false + + + + + +

    +
    + +
    + Note: +
    +

    Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.

    +
    +
    + + +

    TLS/SSL setting Set this to false to skip verifying SSL certificate when calling API from https server. Default to true.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +111
    +112
    +113
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 111
    +
    +def ssl_verify
    +  @ssl_verify
    +end
    +
    +
    + + + +
    +

    + + #ssl_verify_modeObject + + + + + +

    +
    + +
    + Note: +
    +

    Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.

    +
    +
    + + +

    TLS/SSL setting Any `OpenSSL::SSL::` constant (see ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +118
    +119
    +120
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 118
    +
    +def ssl_verify_mode
    +  @ssl_verify_mode
    +end
    +
    +
    + + + +
    +

    + + #temp_folder_pathString + + + + + +

    +
    + +

    Defines the temporary folder to store downloaded files (for API endpoints that have file response). Default to use `Tempfile`.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +93
    +94
    +95
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 93
    +
    +def temp_folder_path
    +  @temp_folder_path
    +end
    +
    +
    + + + +
    +

    + + #timeoutObject + + + + + +

    +
    + +

    The time limit for HTTP request in seconds. Default to 0 (never times out).

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +97
    +98
    +99
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 97
    +
    +def timeout
    +  @timeout
    +end
    +
    +
    + + + +
    +

    + + #usernameString + + + + + +

    +
    + +

    Defines the username used with HTTP basic authentication.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +55
    +56
    +57
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 55
    +
    +def username
    +  @username
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .defaultObject + + + + + +

    +
    + +

    The default Configuration object.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +181
    +182
    +183
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 181
    +
    +def self.default
    +  @@default ||= Configuration.new
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #access_token_with_refreshObject + + + + + +

    +
    + +

    Gets access_token using access_token_getter or uses the static access_token

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +228
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 228
    +
    +def access_token_with_refresh
    +  return access_token if access_token_getter.nil?
    +  access_token_getter.call
    +end
    +
    +
    + +
    +

    + + #api_key_with_prefix(param_name, param_alias = nil) ⇒ Object + + + + + +

    +
    + +

    Gets API key (with prefix if set).

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + param_name + + + (String) + + + + — +
      +

      the parameter name of API key auth

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 217
    +
    +def api_key_with_prefix(param_name, param_alias = nil)
    +  key = @api_key[param_name]
    +  key = @api_key.fetch(param_alias, key) unless param_alias.nil?
    +  if @api_key_prefix[param_name]
    +    "#{@api_key_prefix[param_name]} #{key}"
    +  else
    +    key
    +  end
    +end
    +
    +
    + +
    +

    + + #auth_settingsObject + + + + + +

    +
    + +

    Returns Auth Settings hash for api client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +239
    +240
    +241
    +242
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 239
    +
    +def auth_settings
    +  {
    +  }
    +end
    +
    +
    + +
    +

    + + #base_url(operation = nil) ⇒ Object + + + + + +

    +
    + +

    Returns base URL for specified operation based on server settings

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 206
    +
    +def base_url(operation = nil)
    +  if operation_server_settings.key?(operation) then
    +    index = server_operation_index.fetch(operation, server_index)
    +    server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
    +  else
    +    server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
    +  end
    +end
    +
    +
    + +
    +

    + + #basic_auth_tokenObject + + + + + +

    +
    + +

    Gets Basic Auth token string

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +234
    +235
    +236
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 234
    +
    +def basic_auth_token
    +  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
    +end
    +
    +
    + +
    +

    + + #configure {|_self| ... } ⇒ Object + + + + + +

    +
    + + +
    +
    +
    + +

    Yields:

    +
      + +
    • + + + (_self) + + + +
    • + +
    +

    Yield Parameters:

    + + +
    + + + + +
    +
    +
    +
    +185
    +186
    +187
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 185
    +
    +def configure
    +  yield(self) if block_given?
    +end
    +
    +
    + +
    +

    + + #configure_connection(conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +313
    +314
    +315
    +316
    +317
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 313
    +
    +def configure_connection(conn)
    +  @configure_connection_blocks.each do |block|
    +    block.call(conn)
    +  end
    +end
    +
    +
    + +
    +

    + + #configure_faraday_connection(&block) ⇒ Object + + + + + +

    +
    + +

    Configure Faraday connection directly.

    + +

    “` c.configure_faraday_connection do |conn|

    + +
    conn.use Faraday::HttpCache, shared_cache: false, logger: logger
    +conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
    +  logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
    +end
    +
    + +

    end

    + +

    c.configure_faraday_connection do |conn|

    + +
    conn.adapter :typhoeus
    +
    + +

    end “`

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + block + + + (Proc) + + + + — +
      +

      `#call`able object that takes one arg, the connection

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +309
    +310
    +311
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 309
    +
    +def configure_faraday_connection(&block)
    +  @configure_connection_blocks << block
    +end
    +
    +
    + +
    +

    + + #configure_middleware(connection) ⇒ Object + + + + + +

    +
    + +

    Set up middleware on the connection

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +356
    +357
    +358
    +359
    +360
    +361
    +362
    +363
    +364
    +365
    +366
    +367
    +368
    +369
    +370
    +371
    +372
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 356
    +
    +def configure_middleware(connection)
    +  return if @middlewares.empty?
    +
    +  [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
    +    next unless @middlewares.key?(operation)
    +
    +    @middlewares[operation].each do |key, args, block|
    +      connection.builder.send(operation, key, *args, &block)
    +    end
    +  end
    +
    +  if @middlewares.key?(:delete)
    +    @middlewares[:delete].each do |key, _args, _block|
    +      connection.builder.delete(key)
    +    end
    +  end
    +end
    +
    +
    + +
    +

    + + #operation_server_settingsObject + + + + + +

    + + + + +
    +
    +
    +
    +254
    +255
    +256
    +257
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 254
    +
    +def operation_server_settings
    +  {
    +  }
    +end
    +
    +
    + +
    +

    + + #request(*middleware) ⇒ Object + + + + + +

    +
    + +

    Adds request middleware to the stack

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +325
    +326
    +327
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 325
    +
    +def request(*middleware)
    +  set_faraday_middleware(:request, *middleware)
    +end
    +
    +
    + +
    +

    + + #response(*middleware) ⇒ Object + + + + + +

    +
    + +

    Adds response middleware to the stack

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +330
    +331
    +332
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 330
    +
    +def response(*middleware)
    +  set_faraday_middleware(:response, *middleware)
    +end
    +
    +
    + +
    +

    + + #server_settingsObject + + + + + +

    +
    + +

    Returns an array of Server setting

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 245
    +
    +def server_settings
    +  [
    +    {
    +      url: "https://api.cdp.coinbase.com/platform",
    +      description: "No description provided",
    +    }
    +  ]
    +end
    +
    +
    + +
    +

    + + #server_url(index, variables = {}, servers = nil) ⇒ Object + + + + + +

    +
    + +

    Returns URL based on server settings

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + index + + + + + + + — +
      +

      array index of the server settings

      +
      + +
    • + +
    • + + variables + + + + + + (defaults to: {}) + + + — +
      +

      hash of variable and the corresponding value

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
    +276
    +277
    +278
    +279
    +280
    +281
    +282
    +283
    +284
    +285
    +286
    +287
    +288
    +289
    +290
    +291
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 263
    +
    +def server_url(index, variables = {}, servers = nil)
    +  servers = server_settings if servers == nil
    +
    +  # check array index out of bound
    +  if (index.nil? || index < 0 || index >= servers.size)
    +    fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
    +  end
    +
    +  server = servers[index]
    +  url = server[:url]
    +
    +  return url unless server.key? :variables
    +
    +  # go through variable and assign a value
    +  server[:variables].each do |name, variable|
    +    if variables.key?(name)
    +      if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
    +        url.gsub! "{" + name.to_s + "}", variables[name]
    +      else
    +        fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
    +      end
    +    else
    +      # use default value
    +      url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
    +    end
    +  end
    +
    +  url
    +end
    +
    +
    + +
    +

    + + #set_faraday_middleware(operation, key, *args, &block) ⇒ Object + + + + + +

    +
    + +

    Adds Faraday middleware setting information to the stack

    + + +
    +
    +
    + +
    +

    Examples:

    + + +

    +

    Use the `set_faraday_middleware` method to set middleware information

    +

    + +
    config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
    +config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
    +config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
    +config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
    +config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
    +config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
    + +
    + + +

    See Also:

    + + +
    + + + + +
    +
    +
    +
    +345
    +346
    +347
    +348
    +349
    +350
    +351
    +352
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 345
    +
    +def set_faraday_middleware(operation, key, *args, &block)
    +  unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
    +    fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
    +                        " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
    +  end
    +
    +  @middlewares[operation] << [key, args, block]
    +end
    +
    +
    + +
    +

    + + #use(*middleware) ⇒ Object + + + + + +

    +
    + +

    Adds middleware to the stack

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +320
    +321
    +322
    +
    +
    # File 'lib/coinbase/client/configuration.rb', line 320
    +
    +def use(*middleware)
    +  set_faraday_middleware(:use, *middleware)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/CreateAddressRequest.html b/docs/Coinbase/Client/CreateAddressRequest.html new file mode 100644 index 00000000..623ecbe6 --- /dev/null +++ b/docs/Coinbase/Client/CreateAddressRequest.html @@ -0,0 +1,1897 @@ + + + + + + + Class: Coinbase::Client::CreateAddressRequest + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::CreateAddressRequest + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/create_address_request.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #attestation ⇒ Object + + + + + + + + + + + + + + + + +
      +

      An attestation signed by the private key that is associated with the wallet.

      +
      + +
    • + + +
    • + + + #public_key ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The public key from which the address will be derived.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ CreateAddressRequest + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 53
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #attestationObject + + + + + +

    +
    + +

    An attestation signed by the private key that is associated with the wallet. The attestation will be a hex-encoded signature of a json payload with fields `wallet_id` and `public_key`, signed by the private key associated with the public_key set in the request.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 22
    +
    +def attestation
    +  @attestation
    +end
    +
    +
    + + + +
    +

    + + #public_keyObject + + + + + +

    +
    + +

    The public key from which the address will be derived.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 19
    +
    +def public_key
    +  @public_key
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 152
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 33
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 25
    +
    +def self.attribute_map
    +  {
    +    :'public_key' => :'public_key',
    +    :'attestation' => :'attestation'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 128
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 46
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +38
    +39
    +40
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 38
    +
    +def self.openapi_types
    +  {
    +    :'public_key' => :'String',
    +    :'attestation' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +106
    +107
    +108
    +109
    +110
    +111
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 106
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      public_key == o.public_key &&
    +      attestation == o.attestation
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 223
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +115
    +116
    +117
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 115
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +121
    +122
    +123
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 121
    +
    +def hash
    +  [public_key, attestation].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 81
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +199
    +200
    +201
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 199
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 205
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +193
    +194
    +195
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 193
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +97
    +98
    +99
    +100
    +101
    +102
    +
    +
    # File 'lib/coinbase/client/models/create_address_request.rb', line 97
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @public_key.nil?
    +  return false if @attestation.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/CreateTransferRequest.html b/docs/Coinbase/Client/CreateTransferRequest.html new file mode 100644 index 00000000..9627d8bf --- /dev/null +++ b/docs/Coinbase/Client/CreateTransferRequest.html @@ -0,0 +1,2093 @@ + + + + + + + Class: Coinbase::Client::CreateTransferRequest + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::CreateTransferRequest + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/create_transfer_request.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ CreateTransferRequest + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 63
    +
    +def initialize(attributes = {})
    +  if (!attributes.is_a?(Hash))
    +    fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateTransferRequest` 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::CreateTransferRequest`. 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?(:'network_id')
    +    self.network_id = attributes[:'network_id']
    +  else
    +    self.network_id = nil
    +  end
    +
    +  if attributes.key?(:'asset_id')
    +    self.asset_id = attributes[:'asset_id']
    +  else
    +    self.asset_id = nil
    +  end
    +
    +  if attributes.key?(:'destination')
    +    self.destination = attributes[:'destination']
    +  else
    +    self.destination = nil
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #amountObject + + + + + +

    +
    + +

    The amount to transfer

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 19
    +
    +def amount
    +  @amount
    +end
    +
    +
    + + + +
    +

    + + #asset_idObject + + + + + +

    +
    + +

    The ID of the asset to transfer

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 25
    +
    +def asset_id
    +  @asset_id
    +end
    +
    +
    + + + +
    +

    + + #destinationObject + + + + + +

    +
    + +

    The destination address

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 28
    +
    +def destination
    +  @destination
    +end
    +
    +
    + + + +
    +

    + + #network_idObject + + + + + +

    +
    + +

    The ID of the blockchain network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 22
    +
    +def network_id
    +  @network_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 186
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'amount' => :'amount',
    +    :'network_id' => :'network_id',
    +    :'asset_id' => :'asset_id',
    +    :'destination' => :'destination'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 162
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'amount' => :'String',
    +    :'network_id' => :'String',
    +    :'asset_id' => :'String',
    +    :'destination' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 138
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      amount == o.amount &&
    +      network_id == o.network_id &&
    +      asset_id == o.asset_id &&
    +      destination == o.destination
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 257
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +149
    +150
    +151
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 149
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 155
    +
    +def hash
    +  [amount, network_id, asset_id, destination].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 103
    +
    +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 @network_id.nil?
    +    invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
    +  end
    +
    +  if @asset_id.nil?
    +    invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
    +  end
    +
    +  if @destination.nil?
    +    invalid_properties.push('invalid value for "destination", destination cannot be nil.')
    +  end
    +
    +  invalid_properties
    +end
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +233
    +234
    +235
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 233
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +239
    +240
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 239
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +227
    +228
    +229
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 227
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +
    +
    # File 'lib/coinbase/client/models/create_transfer_request.rb', line 127
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @amount.nil?
    +  return false if @network_id.nil?
    +  return false if @asset_id.nil?
    +  return false if @destination.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/CreateWalletRequest.html b/docs/Coinbase/Client/CreateWalletRequest.html new file mode 100644 index 00000000..110b63f4 --- /dev/null +++ b/docs/Coinbase/Client/CreateWalletRequest.html @@ -0,0 +1,1799 @@ + + + + + + + Class: Coinbase::Client::CreateWalletRequest + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::CreateWalletRequest + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/create_wallet_request.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #wallet ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute wallet.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ CreateWalletRequest + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 47
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #walletObject + + + + + +

    +
    + +

    Returns the value of attribute wallet.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 18
    +
    +def wallet
    +  @wallet
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 134
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 28
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +24
    +25
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 21
    +
    +def self.attribute_map
    +  {
    +    :'wallet' => :'wallet'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 110
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +40
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 40
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +36
    +37
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 33
    +
    +def self.openapi_types
    +  {
    +    :'wallet' => :'Wallet'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +89
    +90
    +91
    +92
    +93
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 89
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      wallet == o.wallet
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 205
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +97
    +98
    +99
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 97
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +103
    +104
    +105
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 103
    +
    +def hash
    +  [wallet].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 69
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +181
    +182
    +183
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 181
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 187
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +175
    +176
    +177
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 175
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +81
    +82
    +83
    +84
    +85
    +
    +
    # File 'lib/coinbase/client/models/create_wallet_request.rb', line 81
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @wallet.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Error.html b/docs/Coinbase/Client/Error.html new file mode 100644 index 00000000..086e8d7c --- /dev/null +++ b/docs/Coinbase/Client/Error.html @@ -0,0 +1,1928 @@ + + + + + + + Class: Coinbase::Client::Error + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Error + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/error.rb
    +
    + +
    + +

    Overview

    +
    + +

    An error response from the Coinbase Developer Platform API

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #code ⇒ Object + + + + + + + + + + + + + + + + +
      +

      A short string representing the reported error.

      +
      + +
    • + + +
    • + + + #message ⇒ Object + + + + + + + + + + + + + + + + +
      +

      A human-readable message providing more details about the error.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #==(o) ⇒ Object + + + + + + + + + + + + + +
      +

      Checks equality by comparing each attribute.

      +
      + +
    • + + +
    • + + + #_to_hash(value) ⇒ Hash + + + + + + + + + + + + + +
      +

      Outputs non-array value in the form of hash For object, use to_hash.

      +
      + +
    • + + +
    • + + + #eql?(o) ⇒ Boolean + + + + + + + + + + + + + +
      + +
    • + + +
    • + + + #hash ⇒ Integer + + + + + + + + + + + + + +
      +

      Calculates hash code according to all attributes.

      +
      + +
    • + + +
    • + + + #initialize(attributes = {}) ⇒ Error + + + + + + + constructor + + + + + + + + +
      +

      Initializes the object.

      +
      + +
    • + + +
    • + + + #list_invalid_properties ⇒ Object + + + + + + + + + + + + + +
      +

      Show invalid properties with the reasons.

      +
      + +
    • + + +
    • + + + #to_body ⇒ Hash + + + + + + + + + + + + + +
      +

      to_body is an alias to to_hash (backward compatibility).

      +
      + +
    • + + +
    • + + + #to_hash ⇒ Hash + + + + + + + + + + + + + +
      +

      Returns the object in the form of hash.

      +
      + +
    • + + +
    • + + + #to_s ⇒ String + + + + + + + + + + + + + +
      +

      Returns the string representation of the object.

      +
      + +
    • + + +
    • + + + #valid? ⇒ Boolean + + + + + + + + + + + + + +
      +

      Check to see if the all the properties in the model are valid.

      +
      + +
    • + + +
    + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Error + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 54
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #codeObject + + + + + +

    +
    + +

    A short string representing the reported error. Can be use to handle errors programmatically.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 20
    +
    +def code
    +  @code
    +end
    +
    +
    + + + +
    +

    + + #messageObject + + + + + +

    +
    + +

    A human-readable message providing more details about the error.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 23
    +
    +def message
    +  @message
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +228
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 191
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 34
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +29
    +30
    +31
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 26
    +
    +def self.attribute_map
    +  {
    +    :'code' => :'code',
    +    :'message' => :'message'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 167
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +50
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 47
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +42
    +43
    +44
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 39
    +
    +def self.openapi_types
    +  {
    +    :'code' => :'String',
    +    :'message' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +145
    +146
    +147
    +148
    +149
    +150
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 145
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      code == o.code &&
    +      message == o.message
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 262
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +154
    +155
    +156
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 154
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +160
    +161
    +162
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 160
    +
    +def hash
    +  [code, message].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +102
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 82
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +238
    +239
    +240
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 238
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +254
    +255
    +256
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 244
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +232
    +233
    +234
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 232
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +
    +
    # File 'lib/coinbase/client/models/error.rb', line 106
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Transfer.html b/docs/Coinbase/Client/Transfer.html new file mode 100644 index 00000000..4bee19e4 --- /dev/null +++ b/docs/Coinbase/Client/Transfer.html @@ -0,0 +1,2608 @@ + + + + + + + Class: Coinbase::Client::Transfer + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Transfer + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/transfer.rb
    +
    + +
    + +

    Overview

    +
    + +

    A transfer of an asset from one address to another

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + + + Classes: EnumAttributeValidator + + +

    + + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Transfer + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 111
    +
    +def initialize(attributes = {})
    +  if (!attributes.is_a?(Hash))
    +    fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Transfer` 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::Transfer`. 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_id')
    +    self.network_id = attributes[:'network_id']
    +  else
    +    self.network_id = nil
    +  end
    +
    +  if attributes.key?(:'wallet_id')
    +    self.wallet_id = attributes[:'wallet_id']
    +  else
    +    self.wallet_id = nil
    +  end
    +
    +  if attributes.key?(:'address_id')
    +    self.address_id = attributes[:'address_id']
    +  else
    +    self.address_id = nil
    +  end
    +
    +  if attributes.key?(:'destination')
    +    self.destination = attributes[:'destination']
    +  else
    +    self.destination = nil
    +  end
    +
    +  if attributes.key?(:'amount')
    +    self.amount = attributes[:'amount']
    +  else
    +    self.amount = nil
    +  end
    +
    +  if attributes.key?(:'asset_id')
    +    self.asset_id = attributes[:'asset_id']
    +  else
    +    self.asset_id = nil
    +  end
    +
    +  if attributes.key?(:'transfer_id')
    +    self.transfer_id = attributes[:'transfer_id']
    +  else
    +    self.transfer_id = nil
    +  end
    +
    +  if attributes.key?(:'unsigned_payload')
    +    self.unsigned_payload = attributes[:'unsigned_payload']
    +  else
    +    self.unsigned_payload = nil
    +  end
    +
    +  if attributes.key?(:'status')
    +    self.status = attributes[:'status']
    +  else
    +    self.status = nil
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #address_idObject + + + + + +

    +
    + +

    The onchain address of the sender

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 26
    +
    +def address_id
    +  @address_id
    +end
    +
    +
    + + + +
    +

    + + #amountObject + + + + + +

    +
    + +

    The amount in the atomic units of the asset

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 32
    +
    +def amount
    +  @amount
    +end
    +
    +
    + + + +
    +

    + + #asset_idObject + + + + + +

    +
    + +

    The ID of the asset being transferred

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 35
    +
    +def asset_id
    +  @asset_id
    +end
    +
    +
    + + + +
    +

    + + #destinationObject + + + + + +

    +
    + +

    The onchain address of the recipient

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 29
    +
    +def destination
    +  @destination
    +end
    +
    +
    + + + +
    +

    + + #network_idObject + + + + + +

    +
    + +

    The ID of the blockchain network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 20
    +
    +def network_id
    +  @network_id
    +end
    +
    +
    + + + +
    +

    + + #statusObject + + + + + +

    +
    + +

    The status of the transfer

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 44
    +
    +def status
    +  @status
    +end
    +
    +
    + + + +
    +

    + + #transfer_idObject + + + + + +

    +
    + +

    The ID of the transfer

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +38
    +39
    +40
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 38
    +
    +def transfer_id
    +  @transfer_id
    +end
    +
    +
    + + + +
    +

    + + #unsigned_payloadObject + + + + + +

    +
    + +

    The unsigned payload of the transfer. This is the payload that needs to be signed by the sender.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 41
    +
    +def unsigned_payload
    +  @unsigned_payload
    +end
    +
    +
    + + + +
    +

    + + #wallet_idObject + + + + + +

    +
    + +

    The ID of the wallet that owns the from address

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 23
    +
    +def wallet_id
    +  @wallet_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +306
    +307
    +308
    +309
    +310
    +311
    +312
    +313
    +314
    +315
    +316
    +317
    +318
    +319
    +320
    +321
    +322
    +323
    +324
    +325
    +326
    +327
    +328
    +329
    +330
    +331
    +332
    +333
    +334
    +335
    +336
    +337
    +338
    +339
    +340
    +341
    +342
    +343
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 306
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +84
    +85
    +86
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 84
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 69
    +
    +def self.attribute_map
    +  {
    +    :'network_id' => :'network_id',
    +    :'wallet_id' => :'wallet_id',
    +    :'address_id' => :'address_id',
    +    :'destination' => :'destination',
    +    :'amount' => :'amount',
    +    :'asset_id' => :'asset_id',
    +    :'transfer_id' => :'transfer_id',
    +    :'unsigned_payload' => :'unsigned_payload',
    +    :'status' => :'status'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +282
    +283
    +284
    +285
    +286
    +287
    +288
    +289
    +290
    +291
    +292
    +293
    +294
    +295
    +296
    +297
    +298
    +299
    +300
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 282
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +104
    +105
    +106
    +107
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 104
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 89
    +
    +def self.openapi_types
    +  {
    +    :'network_id' => :'String',
    +    :'wallet_id' => :'String',
    +    :'address_id' => :'String',
    +    :'destination' => :'String',
    +    :'amount' => :'String',
    +    :'asset_id' => :'String',
    +    :'transfer_id' => :'String',
    +    :'unsigned_payload' => :'String',
    +    :'status' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +253
    +254
    +255
    +256
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 253
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      network_id == o.network_id &&
    +      wallet_id == o.wallet_id &&
    +      address_id == o.address_id &&
    +      destination == o.destination &&
    +      amount == o.amount &&
    +      asset_id == o.asset_id &&
    +      transfer_id == o.transfer_id &&
    +      unsigned_payload == o.unsigned_payload &&
    +      status == o.status
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +377
    +378
    +379
    +380
    +381
    +382
    +383
    +384
    +385
    +386
    +387
    +388
    +389
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 377
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +269
    +270
    +271
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 269
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +275
    +276
    +277
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 275
    +
    +def hash
    +  [network_id, wallet_id, address_id, destination, amount, asset_id, transfer_id, unsigned_payload, status].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 181
    +
    +def list_invalid_properties
    +  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
    +  invalid_properties = Array.new
    +  if @network_id.nil?
    +    invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
    +  end
    +
    +  if @wallet_id.nil?
    +    invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
    +  end
    +
    +  if @address_id.nil?
    +    invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
    +  end
    +
    +  if @destination.nil?
    +    invalid_properties.push('invalid value for "destination", destination cannot be nil.')
    +  end
    +
    +  if @amount.nil?
    +    invalid_properties.push('invalid value for "amount", amount cannot be nil.')
    +  end
    +
    +  if @asset_id.nil?
    +    invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
    +  end
    +
    +  if @transfer_id.nil?
    +    invalid_properties.push('invalid value for "transfer_id", transfer_id cannot be nil.')
    +  end
    +
    +  if @unsigned_payload.nil?
    +    invalid_properties.push('invalid value for "unsigned_payload", unsigned_payload cannot be nil.')
    +  end
    +
    +  if @status.nil?
    +    invalid_properties.push('invalid value for "status", status cannot be nil.')
    +  end
    +
    +  invalid_properties
    +end
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +353
    +354
    +355
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 353
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +359
    +360
    +361
    +362
    +363
    +364
    +365
    +366
    +367
    +368
    +369
    +370
    +371
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 359
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +347
    +348
    +349
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 347
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +236
    +237
    +238
    +239
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 225
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @network_id.nil?
    +  return false if @wallet_id.nil?
    +  return false if @address_id.nil?
    +  return false if @destination.nil?
    +  return false if @amount.nil?
    +  return false if @asset_id.nil?
    +  return false if @transfer_id.nil?
    +  return false if @unsigned_payload.nil?
    +  return false if @status.nil?
    +  status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
    +  return false unless status_validator.valid?(@status)
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Transfer/EnumAttributeValidator.html b/docs/Coinbase/Client/Transfer/EnumAttributeValidator.html new file mode 100644 index 00000000..387f99e9 --- /dev/null +++ b/docs/Coinbase/Client/Transfer/EnumAttributeValidator.html @@ -0,0 +1,455 @@ + + + + + + + Class: Coinbase::Client::Transfer::EnumAttributeValidator + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Transfer::EnumAttributeValidator + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/transfer.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #allowable_values ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute allowable_values.

      +
      + +
    • + + +
    • + + + #datatype ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute datatype.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(datatype, allowable_values) ⇒ EnumAttributeValidator + + + + + +

    +
    + +

    Returns a new instance of EnumAttributeValidator.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 50
    +
    +def initialize(datatype, allowable_values)
    +  @allowable_values = allowable_values.map do |value|
    +    case datatype.to_s
    +    when /Integer/i
    +      value.to_i
    +    when /Float/i
    +      value.to_f
    +    else
    +      value
    +    end
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #allowable_valuesObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute allowable_values.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 48
    +
    +def allowable_values
    +  @allowable_values
    +end
    +
    +
    + + + +
    +

    + + #datatypeObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute datatype.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 47
    +
    +def datatype
    +  @datatype
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #valid?(value) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +
    +
    # File 'lib/coinbase/client/models/transfer.rb', line 63
    +
    +def valid?(value)
    +  !value || allowable_values.include?(value)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/TransferList.html b/docs/Coinbase/Client/TransferList.html new file mode 100644 index 00000000..db67e399 --- /dev/null +++ b/docs/Coinbase/Client/TransferList.html @@ -0,0 +1,2097 @@ + + + + + + + Class: Coinbase::Client::TransferList + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::TransferList + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/transfer_list.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #data ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute data.

      +
      + +
    • + + +
    • + + + #has_more ⇒ Object + + + + + + + + + + + + + + + + +
      +

      True if this list has another page of items after this one that can be fetched.

      +
      + +
    • + + +
    • + + + #next_page ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The page token to be used to fetch the next page.

      +
      + +
    • + + +
    • + + + #total_count ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The total number of transfers for the address in the wallet.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ TransferList + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 63
    +
    +def initialize(attributes = {})
    +  if (!attributes.is_a?(Hash))
    +    fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::TransferList` 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::TransferList`. 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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #dataObject + + + + + +

    +
    + +

    Returns the value of attribute data.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 19
    +
    +def data
    +  @data
    +end
    +
    +
    + + + +
    +

    + + #has_moreObject + + + + + +

    +
    + +

    True if this list has another page of items after this one that can be fetched.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 22
    +
    +def has_more
    +  @has_more
    +end
    +
    +
    + + + +
    +

    + + #next_pageObject + + + + + +

    +
    + +

    The page token to be used to fetch the next page.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 25
    +
    +def next_page
    +  @next_page
    +end
    +
    +
    + + + +
    +

    + + #total_countObject + + + + + +

    +
    + +

    The total number of transfers for the address in the wallet.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 28
    +
    +def total_count
    +  @total_count
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 188
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'data' => :'data',
    +    :'has_more' => :'has_more',
    +    :'next_page' => :'next_page',
    +    :'total_count' => :'total_count'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 164
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'data' => :'Array<Transfer>',
    +    :'has_more' => :'Boolean',
    +    :'next_page' => :'String',
    +    :'total_count' => :'Integer'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 140
    +
    +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
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 259
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 151
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 157
    +
    +def hash
    +  [data, has_more, next_page, total_count].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 105
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +235
    +236
    +237
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 235
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 241
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 229
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +
    +
    # File 'lib/coinbase/client/models/transfer_list.rb', line 129
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/TransfersApi.html b/docs/Coinbase/Client/TransfersApi.html new file mode 100644 index 00000000..3b679eb7 --- /dev/null +++ b/docs/Coinbase/Client/TransfersApi.html @@ -0,0 +1,1560 @@ + + + + + + + Class: Coinbase::Client::TransfersApi + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::TransfersApi + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api/transfers_api.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #api_client ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute api_client.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(api_client = ApiClient.default) ⇒ TransfersApi + + + + + +

    +
    + +

    Returns a new instance of TransfersApi.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 19
    +
    +def initialize(api_client = ApiClient.default)
    +  @api_client = api_client
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #api_clientObject + + + + + +

    +
    + +

    Returns the value of attribute api_client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 17
    +
    +def api_client
    +  @api_client
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #create_transfer(wallet_id, address_id, create_transfer_request, opts = {}) ⇒ Transfer + + + + + +

    +
    + +

    Create a new transfer for an address Create a new transfer

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the source address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address to transfer from

      +
      + +
    • + +
    • + + create_transfer_request + + + (CreateTransferRequest) + + + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +32
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 29
    +
    +def create_transfer(wallet_id, address_id, create_transfer_request, opts = {})
    +  data, _status_code, _headers = create_transfer_with_http_info(wallet_id, address_id, create_transfer_request, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #create_transfer_with_http_info(wallet_id, address_id, create_transfer_request, opts = {}) ⇒ Array<(Transfer, Integer, Hash)> + + + + + +

    +
    + +

    Create a new transfer for an address Create a new transfer

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the source address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address to transfer from

      +
      + +
    • + +
    • + + create_transfer_request + + + (CreateTransferRequest) + + + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Transfer, Integer, Hash)>) + + + + — +
      +

      Transfer data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 41
    +
    +def create_transfer_with_http_info(wallet_id, address_id, create_transfer_request, opts = {})
    +  if @api_client.config.debugging
    +    @api_client.config.logger.debug 'Calling API: TransfersApi.create_transfer ...'
    +  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 TransfersApi.create_transfer"
    +  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 TransfersApi.create_transfer"
    +  end
    +  # verify the required parameter 'create_transfer_request' is set
    +  if @api_client.config.client_side_validation && create_transfer_request.nil?
    +    fail ArgumentError, "Missing the required parameter 'create_transfer_request' when calling TransfersApi.create_transfer"
    +  end
    +  # resource path
    +  local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers'.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'])
    +  # 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(create_transfer_request)
    +
    +  # return_type
    +  return_type = opts[:debug_return_type] || 'Transfer'
    +
    +  # auth_names
    +  auth_names = opts[:debug_auth_names] || []
    +
    +  new_options = opts.merge(
    +    :operation => :"TransfersApi.create_transfer",
    +    :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: TransfersApi#create_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
    +  end
    +  return data, status_code, headers
    +end
    +
    +
    + +
    +

    + + #get_transfer(wallet_id, address_id, transfer_id, opts = {}) ⇒ Transfer + + + + + +

    +
    + +

    Get a transfer by ID Get a transfer by ID

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address the transfer belongs to

      +
      + +
    • + +
    • + + transfer_id + + + (String) + + + + — +
      +

      The ID of the transfer to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +109
    +110
    +111
    +112
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 109
    +
    +def get_transfer(wallet_id, address_id, transfer_id, opts = {})
    +  data, _status_code, _headers = get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts = {}) ⇒ Array<(Transfer, Integer, Hash)> + + + + + +

    +
    + +

    Get a transfer by ID Get a transfer by ID

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address the transfer belongs to

      +
      + +
    • + +
    • + + transfer_id + + + (String) + + + + — +
      +

      The ID of the transfer to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Transfer, Integer, Hash)>) + + + + — +
      +

      Transfer data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 121
    +
    +def get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts = {})
    +  if @api_client.config.debugging
    +    @api_client.config.logger.debug 'Calling API: TransfersApi.get_transfer ...'
    +  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 TransfersApi.get_transfer"
    +  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 TransfersApi.get_transfer"
    +  end
    +  # verify the required parameter 'transfer_id' is set
    +  if @api_client.config.client_side_validation && transfer_id.nil?
    +    fail ArgumentError, "Missing the required parameter 'transfer_id' when calling TransfersApi.get_transfer"
    +  end
    +  # resource path
    +  local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers/{transfer_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'transfer_id' + '}', CGI.escape(transfer_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] || 'Transfer'
    +
    +  # auth_names
    +  auth_names = opts[:debug_auth_names] || []
    +
    +  new_options = opts.merge(
    +    :operation => :"TransfersApi.get_transfer",
    +    :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: TransfersApi#get_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
    +  end
    +  return data, status_code, headers
    +end
    +
    +
    + +
    +

    + + #list_transfers(wallet_id, address_id, opts = {}) ⇒ TransferList + + + + + +

    +
    + +

    List transfers for an address. List transfers for an address.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address to list transfers for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +185
    +186
    +187
    +188
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 185
    +
    +def list_transfers(wallet_id, address_id, opts = {})
    +  data, _status_code, _headers = list_transfers_with_http_info(wallet_id, address_id, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #list_transfers_with_http_info(wallet_id, address_id, opts = {}) ⇒ Array<(TransferList, Integer, Hash)> + + + + + +

    +
    + +

    List transfers for an address. List transfers for an address.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet the address belongs to

      +
      + +
    • + +
    • + + address_id + + + (String) + + + + — +
      +

      The ID of the address to list transfers for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    +
      + +
    • + + + (Array<(TransferList, Integer, Hash)>) + + + + — +
      +

      TransferList data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +236
    +237
    +238
    +239
    +240
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +254
    +
    +
    # File 'lib/coinbase/client/api/transfers_api.rb', line 198
    +
    +def list_transfers_with_http_info(wallet_id, address_id, opts = {})
    +  if @api_client.config.debugging
    +    @api_client.config.logger.debug 'Calling API: TransfersApi.list_transfers ...'
    +  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 TransfersApi.list_transfers"
    +  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 TransfersApi.list_transfers"
    +  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 TransfersApi.list_transfers, the character length must be smaller than or equal to 5000.'
    +  end
    +
    +  # resource path
    +  local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers'.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] || {}
    +  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] || 'TransferList'
    +
    +  # auth_names
    +  auth_names = opts[:debug_auth_names] || []
    +
    +  new_options = opts.merge(
    +    :operation => :"TransfersApi.list_transfers",
    +    :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: TransfersApi#list_transfers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
    +  end
    +  return data, status_code, headers
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/User.html b/docs/Coinbase/Client/User.html new file mode 100644 index 00000000..d8f14c7d --- /dev/null +++ b/docs/Coinbase/Client/User.html @@ -0,0 +1,1883 @@ + + + + + + + Class: Coinbase::Client::User + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::User + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/user.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #display_name ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute display_name.

      +
      + +
    • + + +
    • + + + #id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID of the user.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #==(o) ⇒ Object + + + + + + + + + + + + + +
      +

      Checks equality by comparing each attribute.

      +
      + +
    • + + +
    • + + + #_to_hash(value) ⇒ Hash + + + + + + + + + + + + + +
      +

      Outputs non-array value in the form of hash For object, use to_hash.

      +
      + +
    • + + +
    • + + + #eql?(o) ⇒ Boolean + + + + + + + + + + + + + +
      + +
    • + + +
    • + + + #hash ⇒ Integer + + + + + + + + + + + + + +
      +

      Calculates hash code according to all attributes.

      +
      + +
    • + + +
    • + + + #initialize(attributes = {}) ⇒ User + + + + + + + constructor + + + + + + + + +
      +

      Initializes the object.

      +
      + +
    • + + +
    • + + + #list_invalid_properties ⇒ Object + + + + + + + + + + + + + +
      +

      Show invalid properties with the reasons.

      +
      + +
    • + + +
    • + + + #to_body ⇒ Hash + + + + + + + + + + + + + +
      +

      to_body is an alias to to_hash (backward compatibility).

      +
      + +
    • + + +
    • + + + #to_hash ⇒ Hash + + + + + + + + + + + + + +
      +

      Returns the object in the form of hash.

      +
      + +
    • + + +
    • + + + #to_s ⇒ String + + + + + + + + + + + + + +
      +

      Returns the string representation of the object.

      +
      + +
    • + + +
    • + + + #valid? ⇒ Boolean + + + + + + + + + + + + + +
      +

      Check to see if the all the properties in the model are valid.

      +
      + +
    • + + +
    + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ User + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 52
    +
    +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
    +
    +  # 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
    +  }
    +
    +  if attributes.key?(:'id')
    +    self.id = attributes[:'id']
    +  else
    +    self.id = nil
    +  end
    +
    +  if attributes.key?(:'display_name')
    +    self.display_name = attributes[:'display_name']
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #display_nameObject + + + + + +

    +
    + +

    Returns the value of attribute display_name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 21
    +
    +def display_name
    +  @display_name
    +end
    +
    +
    + + + +
    +

    + + #idObject + + + + + +

    +
    + +

    The ID of the user

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 19
    +
    +def id
    +  @id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +144
    +145
    +146
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 144
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 32
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +24
    +25
    +26
    +27
    +28
    +29
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 24
    +
    +def self.attribute_map
    +  {
    +    :'id' => :'id',
    +    :'display_name' => :'display_name'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 120
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +45
    +46
    +47
    +48
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 45
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +37
    +38
    +39
    +40
    +41
    +42
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 37
    +
    +def self.openapi_types
    +  {
    +    :'id' => :'String',
    +    :'display_name' => :'String'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +98
    +99
    +100
    +101
    +102
    +103
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 98
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      id == o.id &&
    +      display_name == o.display_name
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +226
    +227
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 215
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +107
    +108
    +109
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 107
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +113
    +114
    +115
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 113
    +
    +def hash
    +  [id, display_name].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 78
    +
    +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
    +
    +  invalid_properties
    +end
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +191
    +192
    +193
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 191
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 197
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +185
    +186
    +187
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 185
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +90
    +91
    +92
    +93
    +94
    +
    +
    # File 'lib/coinbase/client/models/user.rb', line 90
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @id.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/UsersApi.html b/docs/Coinbase/Client/UsersApi.html new file mode 100644 index 00000000..0582bd24 --- /dev/null +++ b/docs/Coinbase/Client/UsersApi.html @@ -0,0 +1,576 @@ + + + + + + + Class: Coinbase::Client::UsersApi + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::UsersApi + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api/users_api.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #api_client ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute api_client.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(api_client = ApiClient.default) ⇒ UsersApi + + + + + +

    +
    + +

    Returns a new instance of UsersApi.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/api/users_api.rb', line 19
    +
    +def initialize(api_client = ApiClient.default)
    +  @api_client = api_client
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #api_clientObject + + + + + +

    +
    + +

    Returns the value of attribute api_client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/coinbase/client/api/users_api.rb', line 17
    +
    +def api_client
    +  @api_client
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #get_current_user(opts = {}) ⇒ User + + + + + +

    +
    + +

    Get current user Get current user

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (User) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +29
    +
    +
    # File 'lib/coinbase/client/api/users_api.rb', line 26
    +
    +def get_current_user(opts = {})
    +  data, _status_code, _headers = get_current_user_with_http_info(opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #get_current_user_with_http_info(opts = {}) ⇒ Array<(User, Integer, Hash)> + + + + + +

    +
    + +

    Get current user Get current user

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(User, Integer, Hash)>) + + + + — +
      +

      User data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +
    +
    # File 'lib/coinbase/client/api/users_api.rb', line 35
    +
    +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'
    +
    +  # 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] || 'User'
    +
    +  # 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
    +  )
    +
    +  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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/Wallet.html b/docs/Coinbase/Client/Wallet.html new file mode 100644 index 00000000..44d26ccf --- /dev/null +++ b/docs/Coinbase/Client/Wallet.html @@ -0,0 +1,1967 @@ + + + + + + + Class: Coinbase::Client::Wallet + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::Wallet + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/wallet.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #default_address ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute default_address.

      +
      + +
    • + + +
    • + + + #id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The server-assigned ID for the wallet.

      +
      + +
    • + + +
    • + + + #network_id ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The ID of the blockchain network.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ Wallet + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 57
    +
    +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_id')
    +    self.network_id = attributes[:'network_id']
    +  else
    +    self.network_id = nil
    +  end
    +
    +  if attributes.key?(:'default_address')
    +    self.default_address = attributes[:'default_address']
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #default_addressObject + + + + + +

    +
    + +

    Returns the value of attribute default_address.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +24
    +25
    +26
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 24
    +
    +def default_address
    +  @default_address
    +end
    +
    +
    + + + +
    +

    + + #idObject + + + + + +

    +
    + +

    The server-assigned ID for the wallet.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 19
    +
    +def id
    +  @id
    +end
    +
    +
    + + + +
    +

    + + #network_idObject + + + + + +

    +
    + +

    The ID of the blockchain network

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 22
    +
    +def network_id
    +  @network_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +154
    +155
    +156
    +157
    +158
    +159
    +160
    +161
    +162
    +163
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 154
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 36
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 27
    +
    +def self.attribute_map
    +  {
    +    :'id' => :'id',
    +    :'network_id' => :'network_id',
    +    :'default_address' => :'default_address'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +148
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 130
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 50
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 41
    +
    +def self.openapi_types
    +  {
    +    :'id' => :'String',
    +    :'network_id' => :'String',
    +    :'default_address' => :'Address'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 107
    +
    +def ==(o)
    +  return true if self.equal?(o)
    +  self.class == o.class &&
    +      id == o.id &&
    +      network_id == o.network_id &&
    +      default_address == o.default_address
    +end
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +225
    +226
    +227
    +228
    +229
    +230
    +231
    +232
    +233
    +234
    +235
    +236
    +237
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 225
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +117
    +118
    +119
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 117
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +123
    +124
    +125
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 123
    +
    +def hash
    +  [id, network_id, default_address].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 87
    +
    +def list_invalid_properties
    +  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
    +  invalid_properties = Array.new
    +  if @network_id.nil?
    +    invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
    +  end
    +
    +  invalid_properties
    +end
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +201
    +202
    +203
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 201
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 207
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +195
    +196
    +197
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 195
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +99
    +100
    +101
    +102
    +103
    +
    +
    # File 'lib/coinbase/client/models/wallet.rb', line 99
    +
    +def valid?
    +  warn '[DEPRECATED] the `valid?` method is obsolete'
    +  return false if @network_id.nil?
    +  true
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/WalletList.html b/docs/Coinbase/Client/WalletList.html new file mode 100644 index 00000000..b075ecd5 --- /dev/null +++ b/docs/Coinbase/Client/WalletList.html @@ -0,0 +1,2108 @@ + + + + + + + Class: Coinbase::Client::WalletList + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::WalletList + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/models/wallet_list.rb
    +
    + +
    + +

    Overview

    +
    + +

    Paginated list of wallets

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #data ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute data.

      +
      + +
    • + + +
    • + + + #has_more ⇒ Object + + + + + + + + + + + + + + + + +
      +

      True if this list has another page of items after this one that can be fetched.

      +
      + +
    • + + +
    • + + + #next_page ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The page token to be used to fetch the next page.

      +
      + +
    • + + +
    • + + + #total_count ⇒ Object + + + + + + + + + + + + + + + + +
      +

      The total number of wallets.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(attributes = {}) ⇒ WalletList + + + + + +

    +
    + +

    Initializes the object

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +101
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 63
    +
    +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
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #dataObject + + + + + +

    +
    + +

    Returns the value of attribute data.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 19
    +
    +def data
    +  @data
    +end
    +
    +
    + + + +
    +

    + + #has_moreObject + + + + + +

    +
    + +

    True if this list has another page of items after this one that can be fetched.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 22
    +
    +def has_more
    +  @has_more
    +end
    +
    +
    + + + +
    +

    + + #next_pageObject + + + + + +

    +
    + +

    The page token to be used to fetch the next page.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 25
    +
    +def next_page
    +  @next_page
    +end
    +
    +
    + + + +
    +

    + + #total_countObject + + + + + +

    +
    + +

    The total number of wallets

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 28
    +
    +def total_count
    +  @total_count
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + ._deserialize(type, value) ⇒ Object + + + + + +

    +
    + +

    Deserializes the data based on type

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + string + + + + + + + — +
      +

      type Data type

      +
      + +
    • + +
    • + + string + + + + + + + — +
      +

      value Value to be deserialized

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Deserialized data

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +217
    +218
    +219
    +220
    +221
    +222
    +223
    +224
    +225
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 188
    +
    +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<(?<inner_type>.+)>\z/
    +    inner_type = Regexp.last_match[:inner_type]
    +    value.map { |v| _deserialize(inner_type, v) }
    +  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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
    +
    +
    + +
    +

    + + .acceptable_attributesObject + + + + + +

    +
    + +

    Returns all the JSON keys this model knows about

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 41
    +
    +def self.acceptable_attributes
    +  attribute_map.values
    +end
    +
    +
    + +
    +

    + + .attribute_mapObject + + + + + +

    +
    + +

    Attribute mapping from ruby-style variable name to JSON key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 31
    +
    +def self.attribute_map
    +  {
    +    :'data' => :'data',
    +    :'has_more' => :'has_more',
    +    :'next_page' => :'next_page',
    +    :'total_count' => :'total_count'
    +  }
    +end
    +
    +
    + +
    +

    + + .build_from_hash(attributes) ⇒ Object + + + + + +

    +
    + +

    Builds the object from hash

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + attributes + + + (Hash) + + + + — +
      +

      Model attributes in the form of hash

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + + — +
      +

      Returns the model itself

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +164
    +165
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 164
    +
    +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
    +
    +
    + +
    +

    + + .openapi_nullableObject + + + + + +

    +
    + +

    List of attributes with nullable: true

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +59
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 56
    +
    +def self.openapi_nullable
    +  Set.new([
    +  ])
    +end
    +
    +
    + +
    +

    + + .openapi_typesObject + + + + + +

    +
    + +

    Attribute type mapping.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 46
    +
    +def self.openapi_types
    +  {
    +    :'data' => :'Array<Wallet>',
    +    :'has_more' => :'Boolean',
    +    :'next_page' => :'String',
    +    :'total_count' => :'Integer'
    +  }
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(o) ⇒ Object + + + + + +

    +
    + +

    Checks equality by comparing each attribute.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 140
    +
    +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
    +
    +
    + +
    +

    + + #_to_hash(value) ⇒ Hash + + + + + +

    +
    + +

    Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + value + + + (Object) + + + + — +
      +

      Any valid value

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the value in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 259
    +
    +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
    +
    +
    + +
    +

    + + #eql?(o) ⇒ Boolean + + + + + +

    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + Object + + + (Object) + + + + — +
      +

      to be compared

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • `==` method
    • + +
    + +
    + + + + +
    +
    +
    +
    +151
    +152
    +153
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 151
    +
    +def eql?(o)
    +  self == o
    +end
    +
    +
    + +
    +

    + + #hashInteger + + + + + +

    +
    + +

    Calculates hash code according to all attributes.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +
      +

      Hash code

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 157
    +
    +def hash
    +  [data, has_more, next_page, total_count].hash
    +end
    +
    +
    + +
    +

    + + #list_invalid_propertiesObject + + + + + +

    +
    + +

    Show invalid properties with the reasons. Usually used together with valid?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + + + + + +
      +

      Array for valid properties with the reasons

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 105
    +
    +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
    +
    +
    + +
    +

    + + #to_bodyHash + + + + + +

    +
    + +

    to_body is an alias to to_hash (backward compatibility)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +235
    +236
    +237
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 235
    +
    +def to_body
    +  to_hash
    +end
    +
    +
    + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Returns the object in the form of hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      Returns the object in the form of hash

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 241
    +
    +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
    +
    +
    + +
    +

    + + #to_sString + + + + + +

    +
    + +

    Returns the string representation of the object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      String presentation of the object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +229
    +230
    +231
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 229
    +
    +def to_s
    +  to_hash.to_s
    +end
    +
    +
    + +
    +

    + + #valid?Boolean + + + + + +

    +
    + +

    Check to see if the all the properties in the model are valid

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +
      +

      true if the model is valid

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +
    +
    # File 'lib/coinbase/client/models/wallet_list.rb', line 129
    +
    +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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Client/WalletsApi.html b/docs/Coinbase/Client/WalletsApi.html new file mode 100644 index 00000000..ec3c1d1a --- /dev/null +++ b/docs/Coinbase/Client/WalletsApi.html @@ -0,0 +1,2012 @@ + + + + + + + Class: Coinbase::Client::WalletsApi + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Client::WalletsApi + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/client/api/wallets_api.rb
    +
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #api_client ⇒ Object + + + + + + + + + + + + + + + + +
      +

      Returns the value of attribute api_client.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(api_client = ApiClient.default) ⇒ WalletsApi + + + + + +

    +
    + +

    Returns a new instance of WalletsApi.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 19
    +
    +def initialize(api_client = ApiClient.default)
    +  @api_client = api_client
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #api_clientObject + + + + + +

    +
    + +

    Returns the value of attribute api_client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 17
    +
    +def api_client
    +  @api_client
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #create_wallet(opts = {}) ⇒ Wallet + + + + + +

    +
    + +

    Create a new wallet Create a new wallet scoped to the user.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + +

    Options Hash (opts):

    + + + +

    Returns:

    +
      + +
    • + + + (Wallet) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 27
    +
    +def create_wallet(opts = {})
    +  data, _status_code, _headers = create_wallet_with_http_info(opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #create_wallet_with_http_info(opts = {}) ⇒ Array<(Wallet, Integer, Hash)> + + + + + +

    +
    + +

    Create a new wallet Create a new wallet scoped to the user.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + +

    Options Hash (opts):

    + + + +

    Returns:

    +
      + +
    • + + + (Array<(Wallet, Integer, Hash)>) + + + + — +
      +

      Wallet data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 37
    +
    +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(wallet_id, opts = {}) ⇒ Wallet + + + + + +

    +
    + +

    Get wallet by ID Get wallet

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Wallet) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +91
    +92
    +93
    +94
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 91
    +
    +def get_wallet(wallet_id, opts = {})
    +  data, _status_code, _headers = get_wallet_with_http_info(wallet_id, opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #get_wallet_balance(wallet_id, asset_id, opts = {}) ⇒ Balance + + + + + +

    +
    + +

    Get the balance of an asset in the wallet Get the aggregated balance of an asset across all of the addresses in the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balance for

      +
      + +
    • + +
    • + + asset_id + + + (String) + + + + — +
      +

      The symbol of the asset to fetch the balance for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +155
    +156
    +157
    +158
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 155
    +
    +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_wallet_balance_with_http_info(wallet_id, asset_id, opts = {}) ⇒ Array<(Balance, Integer, Hash)> + + + + + +

    +
    + +

    Get the balance of an asset in the wallet Get the aggregated balance of an asset across all of the addresses in the wallet.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balance for

      +
      + +
    • + +
    • + + asset_id + + + (String) + + + + — +
      +

      The symbol of the asset to fetch the balance for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Balance, Integer, Hash)>) + + + + — +
      +

      Balance data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +166
    +167
    +168
    +169
    +170
    +171
    +172
    +173
    +174
    +175
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +196
    +197
    +198
    +199
    +200
    +201
    +202
    +203
    +204
    +205
    +206
    +207
    +208
    +209
    +210
    +211
    +212
    +213
    +214
    +215
    +216
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 166
    +
    +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
    +
    +
    + +
    +

    + + #get_wallet_with_http_info(wallet_id, opts = {}) ⇒ Array<(Wallet, Integer, Hash)> + + + + + +

    +
    + +

    Get wallet by ID Get wallet

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(Wallet, Integer, Hash)>) + + + + — +
      +

      Wallet data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +101
    +102
    +103
    +104
    +105
    +106
    +107
    +108
    +109
    +110
    +111
    +112
    +113
    +114
    +115
    +116
    +117
    +118
    +119
    +120
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +131
    +132
    +133
    +134
    +135
    +136
    +137
    +138
    +139
    +140
    +141
    +142
    +143
    +144
    +145
    +146
    +147
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 101
    +
    +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
    +
    +
    + +
    +

    + + #list_wallet_balances(wallet_id, opts = {}) ⇒ AddressBalanceList + + + + + +

    +
    + +

    List wallet balances List the balances of all of the addresses in the wallet aggregated by asset.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balances for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +223
    +224
    +225
    +226
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 223
    +
    +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_with_http_info(wallet_id, opts = {}) ⇒ Array<(AddressBalanceList, Integer, Hash)> + + + + + +

    +
    + +

    List wallet balances List the balances of all of the addresses in the wallet aggregated by asset.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the wallet to fetch the balances for

      +
      + +
    • + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<(AddressBalanceList, Integer, Hash)>) + + + + — +
      +

      AddressBalanceList data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +233
    +234
    +235
    +236
    +237
    +238
    +239
    +240
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +254
    +255
    +256
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
    +276
    +277
    +278
    +279
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 233
    +
    +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(opts = {}) ⇒ WalletList + + + + + +

    +
    + +

    List wallets List wallets belonging to the user.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +287
    +288
    +289
    +290
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 287
    +
    +def list_wallets(opts = {})
    +  data, _status_code, _headers = list_wallets_with_http_info(opts)
    +  data
    +end
    +
    +
    + +
    +

    + + #list_wallets_with_http_info(opts = {}) ⇒ Array<(WalletList, Integer, Hash)> + + + + + +

    +
    + +

    List wallets List wallets belonging to the user.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
      +

      the optional parameters

      +
      + +
    • + +
    + + + + +

    Options Hash (opts):

    +
      + +
    • + :limit + (Integer) + + + + + —
      +

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

      +
      + +
    • + +
    • + :page + (String) + + + + + —
      +

      A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.

      +
      + +
    • + +
    + + +

    Returns:

    +
      + +
    • + + + (Array<(WalletList, Integer, Hash)>) + + + + — +
      +

      WalletList data, response status code and response headers

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +298
    +299
    +300
    +301
    +302
    +303
    +304
    +305
    +306
    +307
    +308
    +309
    +310
    +311
    +312
    +313
    +314
    +315
    +316
    +317
    +318
    +319
    +320
    +321
    +322
    +323
    +324
    +325
    +326
    +327
    +328
    +329
    +330
    +331
    +332
    +333
    +334
    +335
    +336
    +337
    +338
    +339
    +340
    +341
    +342
    +343
    +344
    +345
    +346
    +
    +
    # File 'lib/coinbase/client/api/wallets_api.rb', line 298
    +
    +def list_wallets_with_http_info(opts = {})
    +  if @api_client.config.debugging
    +    @api_client.config.logger.debug 'Calling API: WalletsApi.list_wallets ...'
    +  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 WalletsApi.list_wallets, the character length must be smaller than or equal to 5000.'
    +  end
    +
    +  # resource path
    +  local_var_path = '/v1/wallets'
    +
    +  # 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] || '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
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Configuration.html b/docs/Coinbase/Configuration.html new file mode 100644 index 00000000..80a07e85 --- /dev/null +++ b/docs/Coinbase/Configuration.html @@ -0,0 +1,638 @@ + + + + + + + Class: Coinbase::Configuration + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Configuration + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase.rb
    +
    + +
    + +

    Overview

    +
    + +

    Configuration object for the Coinbase SDK

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initializeConfiguration + + + + + +

    +
    + +

    Returns a new instance of Configuration.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +38
    +39
    +
    +
    # File 'lib/coinbase.rb', line 35
    +
    +def initialize
    +  @base_sepolia_rpc_url = 'https://sepolia.base.org'
    +  @base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url)
    +  @api_url = 'https://api.cdp.coinbase.com'
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #api_key_nameObject + + + + + +

    +
    + +

    Returns the value of attribute api_key_name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/coinbase.rb', line 33
    +
    +def api_key_name
    +  @api_key_name
    +end
    +
    +
    + + + +
    +

    + + #api_key_private_keyObject + + + + + +

    +
    + +

    Returns the value of attribute api_key_private_key.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/coinbase.rb', line 33
    +
    +def api_key_private_key
    +  @api_key_private_key
    +end
    +
    +
    + + + +
    +

    + + #api_urlObject + + + + + +

    +
    + +

    Returns the value of attribute api_url.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/coinbase.rb', line 33
    +
    +def api_url
    +  @api_url
    +end
    +
    +
    + + + +
    +

    + + #base_sepolia_clientObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute base_sepolia_client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/coinbase.rb', line 32
    +
    +def base_sepolia_client
    +  @base_sepolia_client
    +end
    +
    +
    + + + +
    +

    + + #base_sepolia_rpc_urlObject + + + + + +

    +
    + +

    Returns the value of attribute base_sepolia_rpc_url.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/coinbase.rb', line 32
    +
    +def base_sepolia_rpc_url
    +  @base_sepolia_rpc_url
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #api_clientObject + + + + + +

    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +
    +
    # File 'lib/coinbase.rb', line 46
    +
    +def api_client
    +  @api_client ||= Coinbase::Client::ApiClient.new(Middleware.config)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/InvalidConfiguration.html b/docs/Coinbase/InvalidConfiguration.html new file mode 100644 index 00000000..58f9d7c3 --- /dev/null +++ b/docs/Coinbase/InvalidConfiguration.html @@ -0,0 +1,124 @@ + + + + + + + Exception: Coinbase::InvalidConfiguration + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: Coinbase::InvalidConfiguration + + + +

    +
    + +
    +
    Inherits:
    +
    + StandardError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase.rb
    +
    + +
    + + + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Middleware.html b/docs/Coinbase/Middleware.html new file mode 100644 index 00000000..df451014 --- /dev/null +++ b/docs/Coinbase/Middleware.html @@ -0,0 +1,206 @@ + + + + + + + Module: Coinbase::Middleware + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Coinbase::Middleware + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/middleware.rb
    +
    + +
    + +

    Overview

    +
    + +

    A module for middleware that can be used with Faraday.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Class Method Summary + collapse +

    + +
      + +
    • + + + .config ⇒ Object + + + + + + + + + + + + + +
      +

      Returns the default middleware configuration for the Coinbase SDK.

      +
      + +
    • + + +
    + + + + +
    +

    Class Method Details

    + + +
    +

    + + .configObject + + + + + +

    +
    + +

    Returns the default middleware configuration for the Coinbase SDK.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +
    +
    # File 'lib/coinbase/middleware.rb', line 13
    +
    +def self.config
    +  Coinbase::Client::Configuration.default.tap do |config|
    +    config.debugging = true
    +    config.host = Coinbase.configuration.api_url
    +    config.request(:authenticator)
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Network.html b/docs/Coinbase/Network.html index 46a03359..31652729 100644 --- a/docs/Coinbase/Network.html +++ b/docs/Coinbase/Network.html @@ -280,7 +280,7 @@

    -

    Returns a new Network object.

    +

    Returns a new Network object. Do not use this method directly. Instead, use the Network constants defined in the Coinbase module.

    @@ -723,7 +723,7 @@

    diff --git a/docs/Coinbase/Transfer.html b/docs/Coinbase/Transfer.html index fe5089bf..0d3e224f 100644 --- a/docs/Coinbase/Transfer.html +++ b/docs/Coinbase/Transfer.html @@ -102,7 +102,7 @@

    Overview

    -

    A representation of a Transfer, which moves an amount of an Asset from a user-controlled Wallet to another address. The fee is assumed to be paid in the native Asset of the Network. Currently only ETH transfers are supported. Transfers should be created through Wallet#transfer or Address#transfer.

    +

    A representation of a Transfer, which moves an amount of an Asset from a user-controlled Wallet to another address. The fee is assumed to be paid in the native Asset of the Network. Transfers should be created through Wallet#transfer or Address#transfer.

    @@ -124,13 +124,21 @@

    Overview

    -

    Instance Attribute Summary collapse

    -
    @@ -599,35 +501,15 @@

     
     
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    +34 +35 +36

    @@ -636,15 +518,15 @@

    -
    -

    Instance Attribute Details

    + +
    +

    Instance Method Details

    + - -

    - #amountObject (readonly) + #amountBigDecimal @@ -653,13 +535,31 @@

    -

    Returns the value of attribute amount.

    +

    Returns the amount of the asset for the Transfer.

    +

    Returns:

    +
      + +
    • + + + (BigDecimal) + + + + — +
      +

      The amount in units of ETH

      +
      + +
    • + +

    -
    # File 'lib/coinbase/transfer.rb', line 42
    -
    -def initialize(network_id, wallet_id, from_address_id, amount, asset_id, to_address_id,
    -               client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url))
    -
    -  raise ArgumentError, "Unsupported asset: #{asset_id}" if asset_id != :eth
    +      
    # File 'lib/coinbase/transfer.rb', line 34
     
    -  @network_id = network_id
    -  @wallet_id = wallet_id
    -  @from_address_id = from_address_id
    -  @amount = normalize_eth_amount(amount)
    -  @asset_id = asset_id
    -  @to_address_id = to_address_id
    -  @client = client
    +def initialize(model)
    +  @model = model
     end
    @@ -667,27 +567,25 @@

     
     
    -13
    -14
    -15
    +76 +77 +78

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 76
     
     def amount
    -  @amount
    +  BigDecimal(@model.amount) / BigDecimal(Coinbase::WEI_PER_ETHER.to_s)
     end
    - -

    - #asset_idObject (readonly) + #asset_idSymbol @@ -696,13 +594,31 @@

    -

    Returns the value of attribute asset_id.

    +

    Returns the Asset ID of the Transfer.

    +

    Returns:

    +
      + +
    • + + + (Symbol) + + + + — +
      +

      The Asset ID

      +
      + +
    • + +
    @@ -710,27 +626,25 @@

     
     
    -13
    -14
    -15
    +70 +71 +72

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 70
     
     def asset_id
    -  @asset_id
    +  @model.asset_id.to_sym
     end
    - -
    -

    +

    - #from_address_idObject (readonly) + #destination_address_idString @@ -739,13 +653,31 @@

    -

    Returns the value of attribute from_address_id.

    +

    Returns the Destination Address ID of the Transfer.

    +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The Destination Address ID

      +
      + +
    • + +
    @@ -753,27 +685,25 @@

     
     
    -13
    -14
    -15
    +64 +65 +66

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 64
     
    -def from_address_id
    -  @from_address_id
    +def destination_address_id
    +  @model.destination
     end
    - -
    -

    +

    - #network_idObject (readonly) + #from_address_idString @@ -782,13 +712,31 @@

    -

    Returns the value of attribute network_id.

    +

    Returns the From Address ID of the Transfer.

    +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The From Address ID

      +
      + +
    • + +
    @@ -796,27 +744,25 @@

     
     
    -13
    -14
    -15
    +58 +59 +60

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 58
     
    -def network_id
    -  @network_id
    +def from_address_id
    +  @model.address_id
     end
    - -
    -

    +

    - #to_address_idObject (readonly) + #network_idString @@ -825,13 +771,31 @@

    -

    Returns the value of attribute to_address_id.

    +

    Returns the Network ID of the Transfer.

    +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The Network ID

      +
      + +
    • + +
    @@ -839,27 +803,25 @@

     
     
    -13
    -14
    -15
    +46 +47 +48

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 46
     
    -def to_address_id
    -  @to_address_id
    +def network_id
    +  @model.network_id
     end
    - -
    -

    +

    - #wallet_idObject (readonly) + #statusSymbol @@ -868,13 +830,31 @@

    -

    Returns the value of attribute wallet_id.

    +

    Returns the status of the Transfer.

    +

    Returns:

    +
      + +
    • + + + (Symbol) + + + + — +
      +

      The status

      +
      + +
    • + +
    @@ -882,32 +862,75 @@

     
     
    -13
    -14
    -15
    +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139

    -
    # File 'lib/coinbase/transfer.rb', line 13
    +      
    # File 'lib/coinbase/transfer.rb', line 112
     
    -def wallet_id
    -  @wallet_id
    +def status
    +  begin
    +    # Create the transaction, and attempt to get the hash to see if it has been signed.
    +    transaction.hash
    +  rescue Eth::Signature::SignatureError
    +    # If the transaction has not been signed, it is still pending.
    +    return Status::PENDING
    +  end
    +
    +  onchain_transaction = Coinbase.configuration.base_sepolia_client.eth_getTransactionByHash(transaction_hash)
    +
    +  if onchain_transaction.nil?
    +    # If the transaction has not been broadcast, it is still pending.
    +    Status::PENDING
    +  elsif onchain_transaction['blockHash'].nil?
    +    # If the transaction has been broadcast but hasn't been included in a block, it is
    +    # broadcast.
    +    Status::BROADCAST
    +  else
    +    transaction_receipt = Coinbase.configuration.base_sepolia_client.eth_getTransactionReceipt(transaction_hash)
    +
    +    if transaction_receipt['status'].to_i(16) == 1
    +      Status::COMPLETE
    +    else
    +      Status::FAILED
    +    end
    +  end
     end
    -
    - - -
    -

    Instance Method Details

    - - -
    -

    +
    +

    - #statusSymbol + #transactionEth::Tx::Eip1559 @@ -916,7 +939,7 @@

    -

    Returns the status of the Transfer.

    +

    Returns the underlying Transfer transaction, creating it if it has not been yet.

    @@ -929,13 +952,13 @@

  • - (Symbol) + (Eth::Tx::Eip1559)
    -

    The status

    +

    The Transfer transaction

  • @@ -948,13 +971,6 @@

     
     
    -81
    -82
    -83
    -84
    -85
    -86
    -87
     88
     89
     90
    @@ -978,35 +994,28 @@ 

    108

    -
    # File 'lib/coinbase/transfer.rb', line 81
    +      
    # File 'lib/coinbase/transfer.rb', line 88
     
    -def status
    -  begin
    -    # Create the transaction, and attempt to get the hash to see if it has been signed.
    -    transaction.hash
    -  rescue Eth::Signature::SignatureError
    -    # If the transaction has not been signed, it is still pending.
    -    return Status::PENDING
    -  end
    +def transaction
    +  return @transaction unless @transaction.nil?
     
    -  onchain_transaction = @client.eth_getTransactionByHash(transaction_hash)
    +  raw_payload = [unsigned_payload].pack('H*')
    +  parsed_payload = JSON.parse(raw_payload)
     
    -  if onchain_transaction.nil?
    -    # If the transaction has not been broadcast, it is still pending.
    -    Status::PENDING
    -  elsif onchain_transaction['blockHash'].nil?
    -    # If the transaction has been broadcast but hasn't been included in a block, it is
    -    # broadcast.
    -    Status::BROADCAST
    -  else
    -    transaction_receipt = @client.eth_getTransactionReceipt(transaction_hash)
    +  params = {
    +    chain_id: parsed_payload['chainId'].to_i(16),
    +    nonce: parsed_payload['nonce'].to_i(16),
    +    priority_fee: parsed_payload['maxPriorityFeePerGas'].to_i(16),
    +    max_gas_fee: parsed_payload['maxFeePerGas'].to_i(16),
    +    gas_limit: parsed_payload['gas'].to_i(16), # TODO: Handle multiple currencies.
    +    from: Eth::Address.new(from_address_id),
    +    to: Eth::Address.new(destination_address_id),
    +    value: parsed_payload['value'].to_i(16),
    +    data: parsed_payload['data'] || ''
    +  }
     
    -    if transaction_receipt['status'].to_i(16) == 1
    -      Status::COMPLETE
    -    else
    -      Status::FAILED
    -    end
    -  end
    +  @transaction = Eth::Tx::Eip1559.new(Eth::Tx.validate_eip1559_params(params))
    +  @transaction
     end
    @@ -1014,9 +1023,9 @@

    -

    +

    - #transactionEth::Tx::Eip1559 + #transaction_hashString @@ -1025,7 +1034,7 @@

    -

    Returns the underlying Transfer transaction, creating it if it has not been yet.

    +

    Returns the transaction hash of the Transfer, or nil if not yet available.

    @@ -1038,13 +1047,13 @@

  • - (Eth::Tx::Eip1559) + (String)
    -

    The Transfer transaction

    +

    The transaction hash

  • @@ -1057,49 +1066,78 @@

     
     
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    +162 +163 +164 +165 +166 -
    # File 'lib/coinbase/transfer.rb', line 58
    +      
    # File 'lib/coinbase/transfer.rb', line 162
     
    -def transaction
    -  return @transaction unless @transaction.nil?
    +def transaction_hash
    +  "0x#{transaction.hash}"
    +rescue Eth::Signature::SignatureError
    +  nil
    +end
    + + + +

    + +
    +

    + + #transfer_idString + - nonce = @client.eth_getTransactionCount(@from_address_id.to_s, 'latest').to_i(16) - gas_price = @client.eth_gasPrice.to_i(16) + - params = { - chain_id: BASE_SEPOLIA.chain_id, # TODO: Don't hardcode Base Sepolia. - nonce: nonce, - priority_fee: gas_price, # TODO: Optimize this. - max_gas_fee: gas_price, - gas_limit: 21_000, # TODO: Handle multiple currencies. - from: Eth::Address.new(@from_address_id), - to: Eth::Address.new(@to_address_id), - value: (@amount * Coinbase::WEI_PER_ETHER).to_i - } + +

    +
    + +

    Returns the Transfer ID.

    - @transaction = Eth::Tx::Eip1559.new(Eth::Tx.validate_eip1559_params(params)) - @transaction + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The Transfer ID

      +
      + +
    • + +
    + +
    + + + @@ -1107,9 +1145,9 @@

    -

    +

    - #transaction_hashString + #unsigned_payloadString @@ -1118,7 +1156,7 @@

    -

    Returns the transaction hash of the Transfer, or nil if not yet available.

    +

    Returns the Unsigned Payload of the Transfer.

    @@ -1137,7 +1175,7 @@

    -

    The transaction hash

    +

    The Unsigned Payload

    @@ -1150,19 +1188,15 @@

     
     
    -131
    -132
    -133
    -134
    -135
    +82 +83 +84

    @@ -1253,22 +1287,22 @@

     
     
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    -127
    +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158

    +
    +
    +
    +40
    +41
    +42
    +
    +
    # File 'lib/coinbase/transfer.rb', line 40
    +
    +def transfer_id
    +  @model.transfer_id
     end
    -
    # File 'lib/coinbase/transfer.rb', line 131
    +      
    # File 'lib/coinbase/transfer.rb', line 82
     
    -def transaction_hash
    -  "0x#{transaction.hash}"
    -rescue Eth::Signature::SignatureError
    -  nil
    +def unsigned_payload
    +  @model.unsigned_payload
     end
    -
    # File 'lib/coinbase/transfer.rb', line 115
    +      
    # File 'lib/coinbase/transfer.rb', line 146
     
     def wait!(interval_seconds = 0.2, timeout_seconds = 10)
       start_time = Time.now
    @@ -1286,6 +1320,65 @@ 

    +
    + +
    +

    + + #wallet_idString + + + + + +

    +
    + +

    Returns the Wallet ID of the Transfer.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      The Wallet ID

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +52
    +53
    +54
    +
    +
    # File 'lib/coinbase/transfer.rb', line 52
    +
    +def wallet_id
    +  @model.wallet_id
    +end
    +
    @@ -1293,7 +1386,7 @@

    diff --git a/docs/Coinbase/Transfer/Status.html b/docs/Coinbase/Transfer/Status.html index 7818222b..0e77f7ba 100644 --- a/docs/Coinbase/Transfer/Status.html +++ b/docs/Coinbase/Transfer/Status.html @@ -181,7 +181,7 @@

    diff --git a/docs/Coinbase/User.html b/docs/Coinbase/User.html new file mode 100644 index 00000000..7cc8ac77 --- /dev/null +++ b/docs/Coinbase/User.html @@ -0,0 +1,618 @@ + + + + + + + Class: Coinbase::User + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::User + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/user.rb
    +
    + +
    + +

    Overview

    +
    + +

    A representation of a User. Users have Wallets, which can hold balances of Assets. Access the default User through Coinbase#default_user.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(model) ⇒ User + + + + + +

    +
    + +

    Returns a new User object. Do not use this method directly. Instead, use Coinbase#default_user.

    + + +
    +
    +
    +

    Parameters:

    + + + +
    + + + + +
    +
    +
    +
    +12
    +13
    +14
    +
    +
    # File 'lib/coinbase/user.rb', line 12
    +
    +def initialize(model)
    +  @model = model
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #create_walletCoinbase::Wallet + + + + + +

    +
    + +

    Creates a new Wallet belonging to the User.

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +
    +
    # File 'lib/coinbase/user.rb', line 24
    +
    +def create_wallet
    +  create_wallet_request = {
    +    wallet: {
    +      # TODO: Don't hardcode this.
    +      network_id: 'base-sepolia'
    +    }
    +  }
    +  opts = { create_wallet_request: create_wallet_request }
    +
    +  model = wallets_api.create_wallet(opts)
    +
    +  Wallet.new(model)
    +end
    +
    +
    + +
    +

    + + #import_wallet(data) ⇒ Coinbase::Wallet + + + + + +

    +
    + +

    Imports a Wallet belonging to the User.

    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +41
    +42
    +43
    +44
    +45
    +
    +
    # File 'lib/coinbase/user.rb', line 41
    +
    +def import_wallet(data)
    +  model = @wallets_api.get_wallet(data.wallet_id)
    +  address_count = addresses_api.list_addresses(model.id).total_count
    +  Wallet.new(model, seed: data.seed, address_count: address_count)
    +end
    +
    +
    + +
    +

    + + #list_wallet_idsArray<String> + + + + + +

    +
    + +

    Lists the IDs of the Wallets belonging to the User.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<String>) + + + + — +
      +

      the IDs of the Wallets belonging to the User

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +49
    +50
    +51
    +52
    +
    +
    # File 'lib/coinbase/user.rb', line 49
    +
    +def list_wallet_ids
    +  wallets = wallets_api.list_wallets
    +  wallets.data.map(&:id)
    +end
    +
    +
    + +
    +

    + + #user_idString + + + + + +

    +
    + +

    Returns the User ID.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +
      +

      the User ID

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +
    +
    # File 'lib/coinbase/user.rb', line 18
    +
    +def user_id
    +  @model.id
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/Coinbase/Wallet.html b/docs/Coinbase/Wallet.html index 00ffaf2c..fd21039a 100644 --- a/docs/Coinbase/Wallet.html +++ b/docs/Coinbase/Wallet.html @@ -102,7 +102,7 @@

    Overview

    -

    A representation of a Wallet. Wallets come with a single default Address, but can expand to have a set of Addresses, each of which can hold a balance of one or more Assets. Wallets can create new Addresses, list their addresses, list their balances, and transfer Assets to other Addresses.

    +

    A representation of a Wallet. Wallets come with a single default Address, but can expand to have a set of Addresses, each of which can hold a balance of one or more Assets. Wallets can create new Addresses, list their addresses, list their balances, and transfer Assets to other Addresses. Wallets should be created through User#create_wallet or User#import_wallet.

    @@ -116,7 +116,7 @@

    Overview

    - Classes: WalletData + Classes: Data

    @@ -124,69 +124,6 @@

    Overview

    -

    Instance Attribute Summary collapse

    -
      - -
    • - - - #network_id ⇒ Object - - - - - - - - - readonly - - - - - - - - - -
      -

      Returns the value of attribute network_id.

      -
      - -
    • - - -
    • - - - #wallet_id ⇒ Object - - - - - - - - - readonly - - - - - - - - - -
      -

      Returns the value of attribute wallet_id.

      -
      - -
    • - - -
    - @@ -249,7 +186,7 @@

  • - #export ⇒ WalletData + #export ⇒ Data @@ -264,7 +201,7 @@

    -

    Exports the Wallet's data to a WalletData object.

    +

    Exports the Wallet's data to a Data object.

  • @@ -321,7 +258,7 @@

  • - #initialize(seed: nil, address_count: 1, client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) ⇒ Wallet + #initialize(model, seed: nil, address_count: 0) ⇒ Wallet @@ -395,7 +332,7 @@

  • - #to_data ⇒ WalletData + #network_id ⇒ Symbol @@ -410,7 +347,7 @@

    -

    Returns the data required to recreate the Wallet.

    +

    Returns the Network ID of the Wallet.

  • @@ -437,6 +374,30 @@

    Transfers the given amount of the given Asset to the given address.

  • + + + +
  • + + + #wallet_id ⇒ String + + + + + + + + + + + + + +
    +

    Returns the Wallet ID.

    +
    +
  • @@ -449,7 +410,7 @@

    Constructor Details

    - #initialize(seed: nil, address_count: 1, client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) ⇒ Wallet + #initialize(model, seed: nil, address_count: 0) ⇒ Wallet @@ -458,7 +419,7 @@

    -

    Returns a new Wallet object.

    +

    Returns a new Wallet object. Do not use this method directly. Instead, use User#create_wallet or User#import_wallet.

    @@ -467,12 +428,28 @@

    Parameters:

      +
    • + + model + + + (Coinbase::Client::Wallet) + + + + — +
      +

      The underlying Wallet object

      +
      + +
    • +
    • seed - (Integer) + (String) (defaults to: nil) @@ -480,7 +457,7 @@

      -

      (Optional) The seed to use for the Wallet. Expects a 32-byte hexadecimal. If not provided, a new seed will be generated.

      +

      (Optional) The seed to use for the Wallet. Expects a 32-byte hexadecimal with no 0x prefix. If not provided, a new seed will be generated.

    • @@ -493,12 +470,12 @@

      (Integer) - (defaults to: 1) + (defaults to: 0)
      -

      (Optional) The number of addresses to generate for the Wallet. If not provided, a single address will be generated.

      +

      (Optional) The number of addresses already registered for the Wallet.

      @@ -511,8 +488,6 @@

      (Jimson::Client) - (defaults to: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) - —
      @@ -543,8 +518,6 @@

       
       
      -20
      -21
       22
       23
       24
      @@ -561,18 +534,24 @@ 

      35 36 37 -38

      +38 +39 +40 +41 +42 +43 +44 -
      # File 'lib/coinbase/wallet.rb', line 20
      +      
      # File 'lib/coinbase/wallet.rb', line 22
       
      -def initialize(seed: nil, address_count: 1, client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url))
      +def initialize(model, seed: nil, address_count: 0)
         raise ArgumentError, 'Seed must be 32 bytes' if !seed.nil? && seed.length != 64
      -  raise ArgumentError, 'Address count must be positive' if address_count < 1
      +
      +  @model = model
       
         @master = seed.nil? ? MoneyTree::Master.new : MoneyTree::Master.new(seed_hex: seed)
       
      -  @wallet_id = SecureRandom.uuid
         # TODO: Make Network an argument to the constructor.
         @network_id = :base_sepolia
         @addresses = []
      @@ -581,9 +560,13 @@ 

      @address_path_prefix = "m/44'/60'/0'/0" @address_index = 0 - @client = client - - address_count.times { create_address } + if address_count.positive? + address_count.times { derive_address } + else + create_address + # Update the model to reflect the new default address. + update_model + end end

      @@ -592,97 +575,6 @@

      -
      -

      Instance Attribute Details

      - - - -
      -

      - - #network_idObject (readonly) - - - - - -

      -
      - -

      Returns the value of attribute network_id.

      - - -
      -
      -
      - - -
      - - - - -
      -
      -
      -
      -12
      -13
      -14
      -
      -
      # File 'lib/coinbase/wallet.rb', line 12
      -
      -def network_id
      -  @network_id
      -end
      -
      -
      - - - -
      -

      - - #wallet_idObject (readonly) - - - - - -

      -
      - -

      Returns the value of attribute wallet_id.

      - - -
      -
      -
      - - -
      - - - - -
      -
      -
      -
      -12
      -13
      -14
      -
      -
      # File 'lib/coinbase/wallet.rb', line 12
      -
      -def wallet_id
      -  @wallet_id
      -end
      -
      -
      - -
      -

      Instance Method Details

      @@ -732,29 +624,39 @@

       
       
      -42
      -43
      -44
      -45
      -46
      -47
      -48
      -49
      -50
      -51
      +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 -
      # File 'lib/coinbase/wallet.rb', line 42
      +      
      # File 'lib/coinbase/wallet.rb', line 60
       
       def create_address
      -  # TODO: Register with server.
      -  path = "#{@address_path_prefix}/#{@address_index}"
      -  private_key = @master.node_for_path(path).private_key.to_hex
      -  key = Eth::Key.new(priv: private_key)
      -  address = Address.new(@network_id, key.address.address, @wallet_id, key, client: @client)
      -  @addresses << address
      -  @address_index += 1
      -  address
      +  key = derive_key
      +  attestation = create_attestation(key)
      +  public_key = key.public_key.compressed.unpack1('H*')
      +
      +  opts = {
      +    create_address_request: {
      +      public_key: public_key,
      +      attestation: attestation
      +    }
      +  }
      +  address_model = addresses_api.create_address(wallet_id, opts)
      +
      +  cache_address(address_model, key)
       end
      @@ -805,15 +707,15 @@

       
       
      -55
      -56
      -57
      +78 +79 +80

      -
      # File 'lib/coinbase/wallet.rb', line 55
      +      
      # File 'lib/coinbase/wallet.rb', line 78
       
       def default_address
      -  @addresses.first
      +  @addresses.find { |address| address.address_id == @model.default_address.address_id }
       end
      @@ -823,7 +725,7 @@

      - #exportWalletData + #exportData @@ -832,7 +734,7 @@

      -

      Exports the Wallet's data to a WalletData object.

      +

      Exports the Wallet's data to a Data object.

      @@ -845,7 +747,7 @@

    • - (WalletData) + (Data) @@ -864,15 +766,15 @@

       
       
      -137
      -138
      -139
      +151 +152 +153

    • -
      # File 'lib/coinbase/wallet.rb', line 137
      +      
      # File 'lib/coinbase/wallet.rb', line 151
       
       def export
      -  WalletData.new(@master.seed_hex, @addresses.length)
      +  Data.new(wallet_id, @master.seed_hex)
       end
      @@ -943,12 +845,12 @@

       
       
      -62
      -63
      -64
      +85 +86 +87

      -
      # File 'lib/coinbase/wallet.rb', line 62
      +      
      # File 'lib/coinbase/wallet.rb', line 85
       
       def get_address(address_id)
         @addresses.find { |address| address.address_id == address_id }
      @@ -1022,18 +924,6 @@ 

       
       
      -93
      -94
      -95
      -96
      -97
      -98
      -99
      -100
      -101
      -102
      -103
      -104
       105
       106
       107
      @@ -1041,10 +931,24 @@ 

      109 110 111 -112

      +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126

      -
      # File 'lib/coinbase/wallet.rb', line 93
      +      
      # File 'lib/coinbase/wallet.rb', line 105
       
       def get_balance(asset_id)
         normalized_asset_id = if %i[wei gwei].include?(asset_id)
      @@ -1053,17 +957,19 @@ 

      asset_id end - eth_balance = list_balances[normalized_asset_id] || BigDecimal(0) + response = wallets_api.get_wallet_balance(wallet_id, normalized_asset_id.to_s) + + return BigDecimal('0') if response.nil? + + amount = BigDecimal(response.amount) case asset_id when :eth - eth_balance + amount / BigDecimal(Coinbase::WEI_PER_ETHER.to_s) when :gwei - eth_balance * Coinbase::GWEI_PER_ETHER - when :wei - eth_balance * Coinbase::WEI_PER_ETHER + amount / BigDecimal(Coinbase::GWEI_PER_ETHER.to_s) else - BigDecimal(0) + amount end end

      @@ -1115,17 +1021,15 @@

       
       
      -68
      -69
      -70
      -71
      +91 +92 +93

      -
      # File 'lib/coinbase/wallet.rb', line 68
      +      
      # File 'lib/coinbase/wallet.rb', line 91
       
       def list_addresses
      -  # TODO: Register with server.
      -  @addresses
      +  @addresses
       end
      @@ -1176,37 +1080,17 @@

       
       
      -75
      -76
      -77
      -78
      -79
      -80
      -81
      -82
      -83
      -84
      -85
      -86
      -87
      -88
      +97 +98 +99 +100

      -
      # File 'lib/coinbase/wallet.rb', line 75
      +      
      # File 'lib/coinbase/wallet.rb', line 97
       
       def list_balances
      -  balance_map = BalanceMap.new
      -
      -  @addresses.each do |address|
      -    address.list_balances.each do |asset_id, balance|
      -      balance_map[asset_id] ||= BigDecimal(0)
      -      current_balance = balance_map[asset_id]
      -      new_balance = balance + current_balance
      -      balance_map[asset_id] = new_balance
      -    end
      -  end
      -
      -  balance_map
      +  response = wallets_api.list_wallet_balances(wallet_id)
      +  Coinbase.to_balance_map(response)
       end
      @@ -1214,9 +1098,9 @@

      -

      +

      - #to_dataWalletData + #network_idSymbol @@ -1225,7 +1109,7 @@

      -

      Returns the data required to recreate the Wallet.

      +

      Returns the Network ID of the Wallet.

      @@ -1238,13 +1122,13 @@

    • - (WalletData) + (Symbol)
      -

      The Wallet data

      +

      The Network ID

    • @@ -1257,15 +1141,15 @@

       
       
      -156
      -157
      -158
      +54 +55 +56 -
      # File 'lib/coinbase/wallet.rb', line 156
      +      
      # File 'lib/coinbase/wallet.rb', line 54
       
      -def to_data
      -  WalletData.new(@master.seed_hex, @addresses.length)
      +def network_id
      +  Coinbase.to_sym(@model.network_id)
       end
      @@ -1368,22 +1252,22 @@

       
       
      -121
      -122
      -123
      -124
      -125
      -126
      -127
      -128
      -129
      -130
      -131
      -132
      -133
      +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147

      -
      # File 'lib/coinbase/wallet.rb', line 121
      +      
      # File 'lib/coinbase/wallet.rb', line 135
       
       def transfer(amount, asset_id, destination)
         if destination.is_a?(Wallet)
      @@ -1401,6 +1285,65 @@ 

      +

      + +
      +

      + + #wallet_idString + + + + + +

      +
      + +

      Returns the Wallet ID.

      + + +
      +
      +
      + +

      Returns:

      +
        + +
      • + + + (String) + + + + — +
        +

        The Wallet ID

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +48
      +49
      +50
      +
      +
      # File 'lib/coinbase/wallet.rb', line 48
      +
      +def wallet_id
      +  @model.id
      +end
      +
      @@ -1408,7 +1351,7 @@

    diff --git a/docs/Coinbase/Wallet/Data.html b/docs/Coinbase/Wallet/Data.html new file mode 100644 index 00000000..4b07e9c8 --- /dev/null +++ b/docs/Coinbase/Wallet/Data.html @@ -0,0 +1,613 @@ + + + + + + + Class: Coinbase::Wallet::Data + + — Documentation by YARD 0.9.36 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Coinbase::Wallet::Data + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/coinbase/wallet.rb
    +
    + +
    + +

    Overview

    +
    + +

    The data required to recreate a Wallet.

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #seed ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute seed.

      +
      + +
    • + + +
    • + + + #wallet_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +
      +

      Returns the value of attribute wallet_id.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(wallet_id, seed) ⇒ Data + + + + + +

    +
    + +

    Returns a new Data object.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + wallet_id + + + (String) + + + + — +
      +

      The ID of the Wallet

      +
      + +
    • + +
    • + + seed + + + (String) + + + + — +
      +

      The seed of the Wallet

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +162
    +163
    +164
    +165
    +
    +
    # File 'lib/coinbase/wallet.rb', line 162
    +
    +def initialize(wallet_id, seed)
    +  @wallet_id = wallet_id
    +  @seed = seed
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #seedObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute seed.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/wallet.rb', line 157
    +
    +def seed
    +  @seed
    +end
    +
    +
    + + + +
    +

    + + #wallet_idObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute wallet_id.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +157
    +158
    +159
    +
    +
    # File 'lib/coinbase/wallet.rb', line 157
    +
    +def wallet_id
    +  @wallet_id
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .from_hash(data) ⇒ Data + + + + + +

    +
    + +

    Creates a Data object from the given Hash.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + data + + + (Hash) + + + + — +
      +

      The Hash to create the Data object from

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Data) + + + + — +
      +

      The new Data object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +176
    +177
    +178
    +
    +
    # File 'lib/coinbase/wallet.rb', line 176
    +
    +def self.from_hash(data)
    +  Data.new(data['wallet_id'], data['seed'])
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #to_hashHash + + + + + +

    +
    + +

    Converts the Data object to a Hash.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +
      +

      The Hash representation of the Data object

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +169
    +170
    +171
    +
    +
    # File 'lib/coinbase/wallet.rb', line 169
    +
    +def to_hash
    +  { wallet_id: wallet_id, seed: seed }
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/_index.html b/docs/_index.html index 8718ee0c..3b394e76 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -87,6 +87,55 @@

    Namespace Listing A-Z

    +
  • + Address + + (Coinbase::Client) + +
  • + +
  • + AddressBalanceList + + (Coinbase::Client) + +
  • + +
  • + AddressList + + (Coinbase::Client) + +
  • + +
  • + AddressesApi + + (Coinbase::Client) + +
  • + +
  • + ApiClient + + (Coinbase::Client) + +
  • + +
  • + ApiError + + (Coinbase::Client) + +
  • + +
  • + Asset + + (Coinbase::Client) + +
  • +
  • Asset @@ -94,6 +143,13 @@

    Namespace Listing A-Z

  • +
  • + Authenticator + + (Coinbase) + +
  • + @@ -102,6 +158,13 @@

    Namespace Listing A-Z

  • B
  • + + +
      +
    • D
    • +
        + +
      • + Data + + (Coinbase::Wallet) + +
      • +
    + + + + + + + + + + + +
    • N
      • @@ -167,6 +342,56 @@

        Namespace Listing A-Z

        +
      • + Transfer + + (Coinbase::Client) + +
      • + +
      • + TransferList + + (Coinbase::Client) + +
      • + +
      • + TransfersApi + + (Coinbase::Client) + +
      • + +
      +
    + + +
      +
    • U
    • +
        + +
      • + User + + (Coinbase) + +
      • + +
      • + User + + (Coinbase::Client) + +
      • + +
      • + UsersApi + + (Coinbase::Client) + +
      • +
    @@ -175,6 +400,13 @@

    Namespace Listing A-Z

  • W
    • +
    • + Wallet + + (Coinbase::Client) + +
    • +
    • Wallet @@ -183,9 +415,16 @@

      Namespace Listing A-Z

    • - WalletData + WalletList - (Coinbase::Wallet) + (Coinbase::Client) + +
    • + +
    • + WalletsApi + + (Coinbase::Client)
    • @@ -201,7 +440,7 @@

      Namespace Listing A-Z

    diff --git a/docs/class_list.html b/docs/class_list.html index 8b75c266..fd448a85 100644 --- a/docs/class_list.html +++ b/docs/class_list.html @@ -43,7 +43,7 @@

    Class List

    diff --git a/docs/file.README.html b/docs/file.README.html index ad02ab1c..0ffabc9f 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -64,13 +64,21 @@

    Coinbase Ruby SDK

    The SDK currently supports Customer-custodied Wallets on the Base Sepolia test network.

    -

    NOTE: The Coinbase SDK is currently in Alpha. The SDK: - may make backwards-incompatible changes between releases - should not be used on Mainnet (i.e. with real funds)

    +

    NOTE: The Coinbase SDK is currently in Alpha. The SDK:

    +
    • +

      may make backwards-incompatible changes between releases

      +
    • +

      should not be used on Mainnet (i.e. with real funds)

      +

    Currently, the SDK is intended for use on testnet for quick bootstrapping of crypto wallets at hackathons, code academies, and other development settings.

    Documentation

    - -

    Click here for full SDK documentation

    +

    Installation

    @@ -102,7 +110,7 @@

    In the Interactive Ruby S

    After running irb, require the Gem:

    -
    require 'coinbase-sdk'
    +
    require 'coinbase'
     

    Requirements

    @@ -114,53 +122,67 @@

    Usage

    Initialization

    -

    The SDK requires a Base Sepolia RPC node, and uses the public instance (sepolia.base.org) by default. This instance is rate-limited, but you can also provision your own on the Coinbase Developer Platform.

    +

    To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the configure method:

    -

    You can configure the SDK with your Base Sepolia RPC node by copying your node URL from the CDP portal and setting the following:

    +
    api_key_name = 'Copy your API Key name here.'
    +api_key_private_key = 'Copy your API Key\'s private key here.'
     
    -
    Coinbase.base_sepolia_rpc_url = 'https://api.developer.coinbase.com/rpc/v1/base/your-node-id'
    +Coinbase.configure do |config|
    +  config.api_key_name = api_key_name
    +  config.api_key_private_key = api_key_private_key
    +end
     
    -

    Wallets and Addresses

    +

    This will allow you to authenticate with the Platform APIs and get access to the default_user.

    -

    A Wallet is a collection of Addresses on the Base Sepolia Network, which can be used to send and receive crypto.

    +
    u = Coinbase.default_user
    +
    + +

    Wallets, Addresses, and Transfers

    -

    The SDK provides customer-custodied wallets, which means that you are responsible for securely storing the data required to re-create wallets. The following code snippet demonstrates this:

    +

    Now, create a Wallet from the User. Wallets are created with a single default Address.

    # Create a Wallet with one Address by default.
    -w1 = Coinbase::Wallet.new
    +w1 = u.create_wallet
    +
    -# Export the data required to re-create the wallet. -data = w1.export +

    Next, view the default Address of your Wallet. You will need this default Address in order to fund the Wallet for your first Transfer.

    -# At this point, you should implement your own "store" method to securely persist -# the data required to re-create the wallet at a later time. -store(data) +
    # A Wallet has a default Address.
    +a = w1.default_address
    +a.to_s
    +
    -# The wallet can be re-created using the exported data. -# w2 will be equivalent to w1. -w2 = Wallet.new(seed: data.seed, address_count: data.address_count) +

    Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don't have testnet funds, get funds from a faucet.

    + +
    # Create a new Wallet to transfer funds to.
    +# Then, we can transfer 0.00001 ETH out of the Wallet to another Wallet.
    +w2 = u.create_wallet
    +w1.transfer(0.00001, :eth, w2).wait!
     
    -

    Transfers

    +

    Re-Instantiating Wallets

    -

    The following creates an in-memory wallet. After the wallet is funded with ETH, it transfers 0.00001 ETH to a different wallet.

    +

    The SDK creates Wallets with developer managed keys, which means you are responsible for securely storing the keys required to re-instantiate Wallets. The below code walks you through how to export a Wallets and store it in a secure location.

    -
    # Wallets are self-custodial with in-memory key management on Base Sepolia.
    -# This should NOT be used in mainnet with real funds. 
    -w1 = Coinbase::Wallet.new
    +
    # Optional: Create a new Wallet if you do not already have one.
    +# Export the data required to re-instantiate the Wallet.
    +w3 = u.create_wallet
    +data = w3.export
    +
    -# A wallet has a default address. -a = w1.default_address -a.to_s +

    In order to persist the data for the Wallet, you will need to implement a store method to store the data export in a secure location. If you do not store the Wallet in a secure location you will lose access to the Wallet and all of the funds on it.

    -# At this point, fund the wallet out-of-band. -# Then, we can transfer 0.00001 ETH out of the wallet to another wallet. -w2 = Coinbase::Wallet.new +
    # At this point, you should implement your own "store" method to securely persist
    +# the data required to re-instantiate the Wallet at a later time.
    +store(data)
    +
    -# We wait for the transfer to complete. -# Base Sepolia is fast, so it should take only a few seconds. -w1.transfer(0.00001, :eth, w2).wait! +

    The below code demonstrates how to re-instantiate a Wallet from the data export.

    + +
    # The Wallet can be re-instantiated using the exported data.
    +# w2 will be equivalent to w1.
    +w4 = u.import_wallet(data)
     

    Development

    @@ -231,7 +253,7 @@

    Generating Documentation

    diff --git a/docs/index.html b/docs/index.html index 21876faa..1e27e83b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -64,13 +64,21 @@

    Coinbase Ruby SDK

    The SDK currently supports Customer-custodied Wallets on the Base Sepolia test network.

    -

    NOTE: The Coinbase SDK is currently in Alpha. The SDK: - may make backwards-incompatible changes between releases - should not be used on Mainnet (i.e. with real funds)

    +

    NOTE: The Coinbase SDK is currently in Alpha. The SDK:

    +
    • +

      may make backwards-incompatible changes between releases

      +
    • +

      should not be used on Mainnet (i.e. with real funds)

      +

    Currently, the SDK is intended for use on testnet for quick bootstrapping of crypto wallets at hackathons, code academies, and other development settings.

    Documentation

    - -

    Click here for full SDK documentation

    +

    Installation

    @@ -102,7 +110,7 @@

    In the Interactive Ruby S

    After running irb, require the Gem:

    -
    require 'coinbase-sdk'
    +
    require 'coinbase'
     

    Requirements

    @@ -114,53 +122,67 @@

    Usage

    Initialization

    -

    The SDK requires a Base Sepolia RPC node, and uses the public instance (sepolia.base.org) by default. This instance is rate-limited, but you can also provision your own on the Coinbase Developer Platform.

    +

    To start, create a CDP API Key. Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the configure method:

    -

    You can configure the SDK with your Base Sepolia RPC node by copying your node URL from the CDP portal and setting the following:

    +
    api_key_name = 'Copy your API Key name here.'
    +api_key_private_key = 'Copy your API Key\'s private key here.'
     
    -
    Coinbase.base_sepolia_rpc_url = 'https://api.developer.coinbase.com/rpc/v1/base/your-node-id'
    +Coinbase.configure do |config|
    +  config.api_key_name = api_key_name
    +  config.api_key_private_key = api_key_private_key
    +end
     
    -

    Wallets and Addresses

    +

    This will allow you to authenticate with the Platform APIs and get access to the default_user.

    -

    A Wallet is a collection of Addresses on the Base Sepolia Network, which can be used to send and receive crypto.

    +
    u = Coinbase.default_user
    +
    + +

    Wallets, Addresses, and Transfers

    -

    The SDK provides customer-custodied wallets, which means that you are responsible for securely storing the data required to re-create wallets. The following code snippet demonstrates this:

    +

    Now, create a Wallet from the User. Wallets are created with a single default Address.

    # Create a Wallet with one Address by default.
    -w1 = Coinbase::Wallet.new
    +w1 = u.create_wallet
    +
    -# Export the data required to re-create the wallet. -data = w1.export +

    Next, view the default Address of your Wallet. You will need this default Address in order to fund the Wallet for your first Transfer.

    -# At this point, you should implement your own "store" method to securely persist -# the data required to re-create the wallet at a later time. -store(data) +
    # A Wallet has a default Address.
    +a = w1.default_address
    +a.to_s
    +
    -# The wallet can be re-created using the exported data. -# w2 will be equivalent to w1. -w2 = Wallet.new(seed: data.seed, address_count: data.address_count) +

    Wallets do not have funds on them to start. In order to fund the Address, you will need to send funds to the Wallet you generated above. If you don't have testnet funds, get funds from a faucet.

    + +
    # Create a new Wallet to transfer funds to.
    +# Then, we can transfer 0.00001 ETH out of the Wallet to another Wallet.
    +w2 = u.create_wallet
    +w1.transfer(0.00001, :eth, w2).wait!
     
    -

    Transfers

    +

    Re-Instantiating Wallets

    -

    The following creates an in-memory wallet. After the wallet is funded with ETH, it transfers 0.00001 ETH to a different wallet.

    +

    The SDK creates Wallets with developer managed keys, which means you are responsible for securely storing the keys required to re-instantiate Wallets. The below code walks you through how to export a Wallets and store it in a secure location.

    -
    # Wallets are self-custodial with in-memory key management on Base Sepolia.
    -# This should NOT be used in mainnet with real funds. 
    -w1 = Coinbase::Wallet.new
    +
    # Optional: Create a new Wallet if you do not already have one.
    +# Export the data required to re-instantiate the Wallet.
    +w3 = u.create_wallet
    +data = w3.export
    +
    -# A wallet has a default address. -a = w1.default_address -a.to_s +

    In order to persist the data for the Wallet, you will need to implement a store method to store the data export in a secure location. If you do not store the Wallet in a secure location you will lose access to the Wallet and all of the funds on it.

    -# At this point, fund the wallet out-of-band. -# Then, we can transfer 0.00001 ETH out of the wallet to another wallet. -w2 = Coinbase::Wallet.new +
    # At this point, you should implement your own "store" method to securely persist
    +# the data required to re-instantiate the Wallet at a later time.
    +store(data)
    +
    -# We wait for the transfer to complete. -# Base Sepolia is fast, so it should take only a few seconds. -w1.transfer(0.00001, :eth, w2).wait! +

    The below code demonstrates how to re-instantiate a Wallet from the data export.

    + +
    # The Wallet can be re-instantiated using the exported data.
    +# w2 will be equivalent to w1.
    +w4 = u.import_wallet(data)
     

    Development

    @@ -231,7 +253,7 @@

    Generating Documentation

    diff --git a/docs/method_list.html b/docs/method_list.html index e66b8cb5..4e898c49 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -46,8 +46,488 @@

    Method List

  • - #address_count - Coinbase::Wallet::WalletData + #== + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #== + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #== + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #== + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #== + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #== + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #== + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #== + Coinbase::Client::User +
    +
  • + + +
  • +
    + #== + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #== + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #== + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #== + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #== + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #== + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Address +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Error +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::User +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + _deserialize + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::User +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #_to_hash + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Error +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::User +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::Address +
    +
  • + + +
  • +
    + acceptable_attributes + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #access_token + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #access_token_getter + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #access_token_with_refresh + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #address_id + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #address_id + Coinbase::Asset
  • @@ -62,312 +542,2936 @@

    Method List

  • - #address_id - Coinbase::Asset + #address_id + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #allowable_values + Coinbase::Client::Transfer::EnumAttributeValidator +
    +
  • + + +
  • +
    + #amount + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #amount + Coinbase::Transfer +
    +
  • + + +
  • +
    + #amount + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #amount + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #api_client + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #api_client + Coinbase::Client::UsersApi +
    +
  • + + +
  • +
    + #api_client + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #api_client + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #api_client + Coinbase::Configuration +
    +
  • + + +
  • +
    + #api_key + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #api_key_name + Coinbase::Configuration +
    +
  • + + +
  • +
    + #api_key_prefix + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #api_key_private_key + Coinbase::Configuration +
    +
  • + + +
  • +
    + #api_key_with_prefix + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #api_url + Coinbase::Configuration +
    +
  • + + +
  • +
    + #asset + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #asset_id + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #asset_id + Coinbase::Asset +
    +
  • + + +
  • +
    + #asset_id + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #asset_id + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #asset_id + Coinbase::Transfer +
    +
  • + + +
  • +
    + #attestation + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::User +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Address +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Error +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + attribute_map + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #auth_settings + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #base_path + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #base_sepolia_client + Coinbase::Configuration +
    +
  • + + +
  • +
    + #base_sepolia_rpc_url + Coinbase::Configuration +
    +
  • + + +
  • +
    + #base_url + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #basic_auth + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #basic_auth_token + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #build_collection_param + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #build_connection + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Error +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Address +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::User +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + build_from_hash + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #build_jwt + Coinbase::Authenticator +
    +
  • + + +
  • +
    + #build_request + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #build_request_body + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #build_request_url + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #call + Coinbase::Authenticator +
    +
  • + + +
  • +
    + #call_api + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #chain_id + Coinbase::Network +
    +
  • + + +
  • +
    + #client_side_validation + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #code + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #code + Coinbase::Client::ApiError +
    +
  • + + +
  • +
    + #config + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + config + Coinbase::Middleware +
    +
  • + + +
  • +
    + configuration + Coinbase +
    +
  • + + +
  • +
    + configure + Coinbase +
    +
  • + + +
  • +
    + #configure + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + configure + Coinbase::Client +
    +
  • + + +
  • +
    + #configure_connection + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #configure_faraday_connection + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #configure_middleware + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #connection + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #connection_multipart + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #connection_regular + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #contract_address + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #convert_to_type + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #create_address + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #create_address + Coinbase::Wallet +
    +
  • + + +
  • +
    + #create_address_with_http_info + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #create_transfer + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #create_transfer_with_http_info + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #create_wallet + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #create_wallet + Coinbase::User +
    +
  • + + +
  • +
    + #create_wallet_with_http_info + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #data + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #data + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #data + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #data + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #datatype + Coinbase::Client::Transfer::EnumAttributeValidator +
    +
  • + + +
  • +
    + #debugging + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #decimals + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + default + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + default + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #default_address + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #default_address + Coinbase::Wallet +
    +
  • + + +
  • +
    + #default_headers + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + default_user + Coinbase +
    +
  • + + +
  • +
    + #deserialize + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #deserialize_file + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #destination + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #destination + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #destination_address_id + Coinbase::Transfer +
    +
  • + + +
  • +
    + #display_name + Coinbase::Client::User +
    +
  • + + +
  • +
    + #display_name + Coinbase::Asset +
    +
  • + + +
  • +
    + #download_file + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::User +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #eql? + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #export + Coinbase::Wallet +
    +
  • + + +
  • +
    + #force_ending_format + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #from_address_id + Coinbase::Transfer +
    +
  • + + +
  • +
    + from_hash + Coinbase::Wallet::Data +
    +
  • + + +
  • +
    + #get_address + Coinbase::Wallet +
    +
  • + + +
  • +
    + #get_address + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #get_address_balance + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #get_address_balance_with_http_info + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #get_address_with_http_info + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #get_asset + Coinbase::Network +
    +
  • + + +
  • +
    + #get_balance + Coinbase::Wallet +
    +
  • + + +
  • +
    + #get_balance + Coinbase::Address +
    +
  • + + +
  • +
    + #get_current_user + Coinbase::Client::UsersApi +
    +
  • + + +
  • +
    + #get_current_user_with_http_info + Coinbase::Client::UsersApi +
    +
  • + + +
  • +
    + #get_transfer + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #get_transfer_with_http_info + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #get_wallet + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #get_wallet_balance + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #get_wallet_balance_with_http_info + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #get_wallet_with_http_info + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #has_more + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #has_more + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #has_more + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #has_more + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::User +
    +
  • + + +
  • +
    + #hash + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #host + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #id + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #id + Coinbase::Client::User +
    +
  • + + +
  • +
    + #import_wallet + Coinbase::User +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #initialize + Coinbase::Configuration +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #initialize + Coinbase::User +
    +
  • + + +
  • +
    + #initialize + Coinbase::Asset +
    +
  • + + +
  • +
    + #initialize + Coinbase::Wallet +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::UsersApi +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #initialize + Coinbase::Wallet::Data +
    +
  • + + +
  • +
    + #initialize + Coinbase::Address +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #initialize + Coinbase::Network +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #initialize + Coinbase::Transfer +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #initialize + Coinbase::BalanceMap +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #initialize + Coinbase::Authenticator +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::ApiError +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Transfer::EnumAttributeValidator +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #initialize + Coinbase::Client::User +
    +
  • + + +
  • +
    + #inject_format + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #inspect + Coinbase::BalanceMap +
    +
  • + + +
  • +
    + #json_mime? + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #list_address_balances + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #list_address_balances_with_http_info + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #list_addresses + Coinbase::Wallet +
    +
  • + + +
  • +
    + #list_addresses + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #list_addresses_with_http_info + Coinbase::Client::AddressesApi +
    +
  • + + +
  • +
    + #list_assets + Coinbase::Network +
    +
  • + + +
  • +
    + #list_balances + Coinbase::Address +
    +
  • + + +
  • +
    + #list_balances + Coinbase::Wallet +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::User +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #list_invalid_properties + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #list_transfers + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #list_transfers_with_http_info + Coinbase::Client::TransfersApi +
    +
  • + + +
  • +
    + #list_wallet_balances + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #list_wallet_balances_with_http_info + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #list_wallet_ids + Coinbase::User +
    +
  • + + +
  • +
    + #list_wallets + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + #list_wallets_with_http_info + Coinbase::Client::WalletsApi +
    +
  • + + +
  • +
    + load_default_user + Coinbase +
    +
  • + + +
  • +
    + #logger + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #message + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #message + Coinbase::Client::ApiError +
    +
  • + + +
  • +
    + #native_asset + Coinbase::Network +
    +
  • + + +
  • +
    + #network_id + Coinbase::Address +
    +
  • + + +
  • +
    + #network_id + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #network_id + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #network_id + Coinbase::Asset +
    +
  • + + +
  • +
    + #network_id + Coinbase::Wallet +
    +
  • + + +
  • +
    + #network_id + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #network_id + Coinbase::Transfer +
    +
  • + + +
  • +
    + #network_id + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #network_id + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #next_page + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #next_page + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #next_page + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #next_page + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #object_to_hash + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #object_to_http_body + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::User +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Address +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::Error +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + openapi_nullable + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Address +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Error +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::User +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + openapi_types + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #operation_server_settings + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #params_encoder + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #password + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #proxy + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #public_key + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #public_key + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #request + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #response + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #response_body + Coinbase::Client::ApiError +
    +
  • + + +
  • +
    + #response_headers + Coinbase::Client::ApiError +
    +
  • + + +
  • +
    + #return_binary_data + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #sanitize_filename + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #scheme + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #seed + Coinbase::Wallet::Data +
    +
  • + + +
  • +
    + #select_header_accept + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #select_header_content_type + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #server_index + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #server_operation_index + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #server_operation_variables + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #server_settings + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #server_url + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #server_variables + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #set_faraday_middleware + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #ssl_ca_file + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #ssl_client_cert + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #ssl_client_key + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #ssl_options + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #ssl_verify + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #ssl_verify_mode + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #status + Coinbase::Transfer +
    +
  • + + +
  • +
    + #status + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #temp_folder_path + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #timeout + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + to_balance_map + Coinbase +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::WalletList +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::User +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #to_body + Coinbase::Client::CreateAddressRequest
  • - #amount - Coinbase::Transfer + #to_body + Coinbase::Client::Balance
  • - #asset_id - Coinbase::Asset + #to_hash + Coinbase::Client::TransferList
  • - #asset_id - Coinbase::Transfer + #to_hash + Coinbase::Client::AddressBalanceList
  • - base_sepolia_rpc_url - Coinbase + #to_hash + Coinbase::Client::Address
  • - base_sepolia_rpc_url= - Coinbase + #to_hash + Coinbase::Client::Transfer
  • - #chain_id - Coinbase::Network + #to_hash + Coinbase::Client::AddressList
  • - #create_address - Coinbase::Wallet + #to_hash + Coinbase::Client::WalletList
  • - #default_address - Coinbase::Wallet + #to_hash + Coinbase::Client::CreateWalletRequest
  • - #display_name - Coinbase::Asset + #to_hash + Coinbase::Client::Balance
  • - #export - Coinbase::Wallet + #to_hash + Coinbase::Client::Error
  • - #from_address_id - Coinbase::Transfer + #to_hash + Coinbase::Client::User
  • - #get_address - Coinbase::Wallet + #to_hash + Coinbase::Client::Wallet
  • - #get_asset - Coinbase::Network + #to_hash + Coinbase::Client::CreateTransferRequest
  • - #get_balance - Coinbase::Wallet + #to_hash + Coinbase::Client::Asset
  • - #get_balance - Coinbase::Address + #to_hash + Coinbase::Wallet::Data
  • - #initialize - Coinbase::Transfer + #to_hash + Coinbase::Client::CreateAddressRequest
  • - #initialize - Coinbase::Network + #to_s + Coinbase::Client::Address
  • - #initialize - Coinbase::BalanceMap + #to_s + Coinbase::Address
  • - #initialize - Coinbase::Wallet + #to_s + Coinbase::Client::CreateTransferRequest
  • - #initialize - Coinbase::Wallet::WalletData + #to_s + Coinbase::Client::Asset
  • - #initialize - Coinbase::Address + #to_s + Coinbase::Client::TransferList
  • - #initialize - Coinbase::Asset + #to_s + Coinbase::Client::User
  • - #inspect - Coinbase::BalanceMap + #to_s + Coinbase::Client::Error
  • - #list_addresses - Coinbase::Wallet + #to_s + Coinbase::Client::AddressBalanceList
  • - #list_assets - Coinbase::Network + #to_s + Coinbase::BalanceMap
  • - #list_balances - Coinbase::Address + #to_s + Coinbase::Client::ApiError
  • - #list_balances - Coinbase::Wallet + #to_s + Coinbase::Client::AddressList
  • - #native_asset - Coinbase::Network + #to_s + Coinbase::Client::Wallet
  • - #network_id - Coinbase::Address + #to_s + Coinbase::Client::Balance
  • - #network_id - Coinbase::Wallet + #to_s + Coinbase::Client::CreateWalletRequest
  • - #network_id - Coinbase::Asset + #to_s + Coinbase::Client::Transfer
  • - #network_id - Coinbase::Transfer + #to_s + Coinbase::Client::CreateAddressRequest
  • - #seed - Coinbase::Wallet::WalletData + #to_s + Coinbase::Client::WalletList
  • - #status - Coinbase::Transfer + to_sym + Coinbase
  • - #to_address_id - Coinbase::Transfer + #total_count + Coinbase::Client::WalletList
  • - #to_data - Coinbase::Wallet + #total_count + Coinbase::Client::TransferList
  • - #to_s - Coinbase::BalanceMap + #total_count + Coinbase::Client::AddressBalanceList
  • - #to_s - Coinbase::Address + #total_count + Coinbase::Client::AddressList
  • @@ -404,6 +3508,198 @@

    Method List

    +
  • +
    + #transfer_id + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #transfer_id + Coinbase::Transfer +
    +
  • + + +
  • +
    + #unsigned_payload + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #unsigned_payload + Coinbase::Transfer +
    +
  • + + +
  • +
    + #update_params_for_auth! + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #use + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #user_agent= + Coinbase::Client::ApiClient +
    +
  • + + +
  • +
    + #user_id + Coinbase::User +
    +
  • + + +
  • +
    + #username + Coinbase::Client::Configuration +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Balance +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::User +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::AddressList +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::CreateWalletRequest +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::CreateAddressRequest +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Wallet +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Asset +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Address +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::CreateTransferRequest +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::AddressBalanceList +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Transfer +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Error +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::TransferList +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::Transfer::EnumAttributeValidator +
    +
  • + + +
  • +
    + #valid? + Coinbase::Client::WalletList +
    +
  • + +
  • #wait! @@ -414,16 +3710,16 @@

    Method List

  • - #wallet_id - Coinbase::Wallet + #wallet + Coinbase::Client::CreateWalletRequest
  • - #wallet_id - Coinbase::Address + #wallet_id + Coinbase::Client::Address
  • @@ -436,6 +3732,38 @@

    Method List

    +
  • +
    + #wallet_id + Coinbase::Address +
    +
  • + + +
  • +
    + #wallet_id + Coinbase::Wallet::Data +
    +
  • + + +
  • +
    + #wallet_id + Coinbase::Wallet +
    +
  • + + +
  • +
    + #wallet_id + Coinbase::Client::Transfer +
    +
  • + + diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index ce81d589..d339bb6f 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -100,7 +100,7 @@

    Defined Under Namespace

    diff --git a/lib/coinbase.rb b/lib/coinbase.rb index e0021d68..aaf8e78d 100644 --- a/lib/coinbase.rb +++ b/lib/coinbase.rb @@ -2,25 +2,89 @@ require_relative 'coinbase/address' require_relative 'coinbase/asset' +require_relative 'coinbase/authenticator' require_relative 'coinbase/balance_map' +require_relative 'coinbase/client' require_relative 'coinbase/constants' +require_relative 'coinbase/middleware' require_relative 'coinbase/network' require_relative 'coinbase/transfer' +require_relative 'coinbase/user' require_relative 'coinbase/wallet' # The Coinbase SDK. module Coinbase - @base_sepolia_rpc_url = 'https://sepolia.base.org' + class InvalidConfiguration < StandardError; end - # Returns the Base Sepolia RPC URL. - # @return [String] the Base Sepolia RPC URL - def self.base_sepolia_rpc_url - @base_sepolia_rpc_url + def self.configuration + @configuration ||= Configuration.new end - # Sets the Base Sepolia RPC URL. - # @param value [String] the Base Sepolia RPC URL - def self.base_sepolia_rpc_url=(value) - @base_sepolia_rpc_url = value + def self.configure + yield(configuration) + + raise InvalidConfiguration, 'API key private key is not set' unless configuration.api_key_private_key + raise InvalidConfiguration, 'API key name is not set' unless configuration.api_key_name + end + + # Configuration object for the Coinbase SDK + class Configuration + attr_reader :base_sepolia_rpc_url, :base_sepolia_client + attr_accessor :api_url, :api_key_name, :api_key_private_key + + def initialize + @base_sepolia_rpc_url = 'https://sepolia.base.org' + @base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url) + @api_url = 'https://api.cdp.coinbase.com' + end + + def base_sepolia_rpc_url=(new_base_sepolia_rpc_url) + @base_sepolia_rpc_url = new_base_sepolia_rpc_url + @base_sepolia_client = Jimson::Client.new(@base_sepolia_rpc_url) + end + + def api_client + @api_client ||= Coinbase::Client::ApiClient.new(Middleware.config) + end + end + + # Returns the default user. + # @return [Coinbase::User] the default user + def self.default_user + @default_user ||= load_default_user + end + + # Converts a string to a symbol, replacing hyphens with underscores. + # @param string [String] the string to convert + # @return [Symbol] the converted symbol + def self.to_sym(value) + value.to_s.gsub('-', '_').to_sym + end + + # Converts a Coinbase::Client::AddressBalanceList to a BalanceMap. + # @param address_balance_list [Coinbase::Client::AddressBalanceList] The AddressBalanceList to convert + # @return [BalanceMap] The converted BalanceMap + def self.to_balance_map(address_balance_list) + balances = {} + + address_balance_list.data.each do |balance| + asset_id = Coinbase.to_sym(balance.asset.asset_id.downcase) + amount = if asset_id == :eth + BigDecimal(balance.amount) / BigDecimal(Coinbase::WEI_PER_ETHER) + elsif asset_id == :usdc + BigDecimal(balance.amount) / BigDecimal(Coinbase::ATOMIC_UNITS_PER_USDC) + else + BigDecimal(balance.amount) + end + balances[asset_id] = amount + end + + BalanceMap.new(balances) + end + + def self.load_default_user + users_api = Coinbase::Client::UsersApi.new(configuration.api_client) + user_model = users_api.get_current_user + Coinbase::User.new(user_model) end end diff --git a/lib/coinbase/address.rb b/lib/coinbase/address.rb index d2dafb70..cecbf62b 100644 --- a/lib/coinbase/address.rb +++ b/lib/coinbase/address.rb @@ -2,65 +2,72 @@ require_relative 'balance_map' require_relative 'constants' +require_relative 'wallet' require 'bigdecimal' require 'eth' require 'jimson' module Coinbase # A representation of a blockchain Address, which is a user-controlled account on a Network. Addresses are used to - # send and receive Assets, and should be created using {link:Wallet#create_address}. Addresses require a - # {link:Eth::Key} to sign transaction data. + # send and receive Assets, and should be created using Wallet#create_address. Addresses require an + # Eth::Key to sign transaction data. class Address - attr_reader :network_id, :address_id, :wallet_id - - # Returns a new Address object. - # @param network_id [Symbol] The ID of the Network on which the Address exists - # @param address_id [String] The ID of the Address. On EVM Networks, for example, this is a hash of the public key. - # @param wallet_id [String] The ID of the Wallet to which the Address belongs + # Returns a new Address object. Do not use this method directly. Instead, use Wallet#create_address, or use + # the Wallet's default_address. + # @param model [Coinbase::Client::Address] The underlying Address object # @param key [Eth::Key] The key backing the Address - # @param client [Jimson::Client] (Optional) The JSON RPC client to use for interacting with the Network - def initialize(network_id, address_id, wallet_id, key, - client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) - # TODO: Don't require key. - @network_id = network_id - @address_id = address_id - @wallet_id = wallet_id + def initialize(model, key) + @model = model @key = key - @client = client end - # Returns the balances of the Address. Currently only ETH balances are supported. + # Returns the Network ID of the Address. + # @return [Symbol] The Network ID + def network_id + Coinbase.to_sym(@model.network_id) + end + + # Returns the Wallet ID of the Address. + # @return [String] The Wallet ID + def wallet_id + @model.wallet_id + end + + # Returns the Address ID. + # @return [String] The Address ID + def address_id + @model.address_id + end + + # Returns the balances of the Address. # @return [BalanceMap] The balances of the Address, keyed by asset ID. Ether balances are denominated # in ETH. def list_balances - # TODO: Handle multiple currencies. - eth_balance_in_wei = BigDecimal(@client.eth_getBalance(@address_id, 'latest').to_i(16).to_s) - eth_balance = BigDecimal(eth_balance_in_wei / BigDecimal(Coinbase::WEI_PER_ETHER.to_s)) - - BalanceMap.new({ eth: eth_balance }) + response = addresses_api.list_address_balances(wallet_id, address_id) + Coinbase.to_balance_map(response) end - # Returns the balance of the provided Asset. Currently only ETH is supported. + # Returns the balance of the provided Asset. # @param asset_id [Symbol] The Asset to retrieve the balance for # @return [BigDecimal] The balance of the Asset def get_balance(asset_id) - normalized_asset_id = if %i[wei gwei].include?(asset_id) - :eth - else - asset_id - end + normalized_asset_id = normalize_asset_id(asset_id) + + response = addresses_api.get_address_balance(wallet_id, address_id, normalized_asset_id.to_s) - eth_balance = list_balances[normalized_asset_id] || BigDecimal(0) + return BigDecimal('0') if response.nil? + + amount = BigDecimal(response.amount) case asset_id when :eth - eth_balance + amount / BigDecimal(Coinbase::WEI_PER_ETHER.to_s) when :gwei - eth_balance * Coinbase::GWEI_PER_ETHER - when :wei - eth_balance * Coinbase::WEI_PER_ETHER + amount / BigDecimal(Coinbase::GWEI_PER_ETHER.to_s) + when :usdc + amount / BigDecimal(Coinbase::ATOMIC_UNITS_PER_USDC.to_s) else - BigDecimal(0) + amount end end @@ -71,15 +78,14 @@ def get_balance(asset_id) # default address. If a String, interprets it as the address ID. # @return [String] The hash of the Transfer transaction. def transfer(amount, asset_id, destination) - # TODO: Handle multiple currencies. raise ArgumentError, "Unsupported asset: #{asset_id}" unless Coinbase::SUPPORTED_ASSET_IDS[asset_id] if destination.is_a?(Wallet) - raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != @network_id + raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != network_id destination = destination.default_address.address_id elsif destination.is_a?(Address) - raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != @network_id + raise ArgumentError, 'Transfer must be on the same Network' if destination.network_id != network_id destination = destination.address_id end @@ -89,12 +95,24 @@ def transfer(amount, asset_id, destination) raise ArgumentError, "Insufficient funds: #{amount} requested, but only #{current_balance} available" end - transfer = Coinbase::Transfer.new(@network_id, @wallet_id, @address_id, amount, asset_id, destination, - client: @client) + normalized_amount = normalize_asset_amount(amount, asset_id) + + normalized_asset_id = normalize_asset_id(asset_id) + + create_transfer_request = { + amount: normalized_amount.to_i.to_s, + network_id: network_id, + asset_id: normalized_asset_id.to_s, + destination: destination + } + + transfer_model = transfers_api.create_transfer(wallet_id, address_id, create_transfer_request) + + transfer = Coinbase::Transfer.new(transfer_model) transaction = transfer.transaction transaction.sign(@key) - @client.eth_sendRawTransaction("0x#{transaction.hex}") + Coinbase.configuration.base_sepolia_client.eth_sendRawTransaction("0x#{transaction.hex}") transfer end @@ -102,26 +120,47 @@ def transfer(amount, asset_id, destination) # Returns the address as a string. # @return [String] The address def to_s - @address_id + address_id end private - # Normalizes the amount of ETH to send based on the asset ID. + # Normalizes the amount of the Asset to send to the atomic unit. # @param amount [Integer, Float, BigDecimal] The amount to normalize # @param asset_id [Symbol] The ID of the Asset being transferred - # @return [BigDecimal] The normalized amount in units of ETH - def normalize_eth_amount(amount, asset_id) + # @return [BigDecimal] The normalized amount in atomic units + def normalize_asset_amount(amount, asset_id) + big_amount = BigDecimal(amount.to_s) + case asset_id when :eth - amount.is_a?(BigDecimal) ? amount : BigDecimal(amount.to_s) + big_amount * Coinbase::WEI_PER_ETHER when :gwei - BigDecimal(amount / Coinbase::GWEI_PER_ETHER) - when :wei - BigDecimal(amount / Coinbase::WEI_PER_ETHER) + big_amount * Coinbase::WEI_PER_GWEI + when :usdc + big_amount * Coinbase::ATOMIC_UNITS_PER_USDC else - raise ArgumentError, "Unsupported asset: #{asset_id}" + big_amount end end + + # Normalizes the asset ID to use during requests. + # @param asset_id [Symbol] The asset ID to normalize + # @return [Symbol] The normalized asset ID + def normalize_asset_id(asset_id) + if %i[wei gwei].include?(asset_id) + :eth + else + asset_id + end + end + + def addresses_api + @addresses_api ||= Coinbase::Client::AddressesApi.new(Coinbase.configuration.api_client) + end + + def transfers_api + @transfers_api ||= Coinbase::Client::TransfersApi.new(Coinbase.configuration.api_client) + end end end diff --git a/lib/coinbase/asset.rb b/lib/coinbase/asset.rb index 595e1b6d..d310338c 100644 --- a/lib/coinbase/asset.rb +++ b/lib/coinbase/asset.rb @@ -5,7 +5,8 @@ module Coinbase class Asset attr_reader :network_id, :asset_id, :display_name, :address_id - # Returns a new Asset object. + # Returns a new Asset object. Do not use this method. Instead, use the Asset constants defined in + # the Coinbase module. # @param network_id [Symbol] The ID of the Network to which the Asset belongs # @param asset_id [Symbol] The Asset ID # @param display_name [String] The Asset's display name diff --git a/lib/coinbase/authenticator.rb b/lib/coinbase/authenticator.rb new file mode 100644 index 00000000..1eb90a6a --- /dev/null +++ b/lib/coinbase/authenticator.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'faraday' +require 'jwt' +require 'openssl' +require 'securerandom' + +module Coinbase + # A class that builds JWTs for authenticating with the Coinbase Platform APIs. + class Authenticator < Faraday::Middleware + # Initializes the Authenticator. + # @param app [Faraday::Connection] The Faraday connection + def initialize(app) + super(app) + @app = app + end + + # Processes the request by adding the JWT to the Authorization header. + # @param env [Faraday::Env] The Faraday request environment + def call(env) + method = env.method.downcase.to_sym + uri = env.url.to_s + uri_without_protocol = URI(uri).host + token = build_jwt("#{method.upcase} #{uri_without_protocol}#{env.url.path}") + env.request_headers['Authorization'] = "Bearer #{token}" + @app.call(env) + end + + # Builds the JWT for the given API endpoint URI. The JWT is signed with the API key's private key. + # @param uri [String] The API endpoint URI + # @return [String] The JWT + def build_jwt(uri) + header = { + typ: 'JWT', + kid: Coinbase.configuration.api_key_name, + nonce: SecureRandom.hex(16) + } + + claims = { + sub: Coinbase.configuration.api_key_name, + iss: 'coinbase-cloud', + aud: ['cdp_service'], + nbf: Time.now.to_i, + exp: Time.now.to_i + 60, # Expiration time: 1 minute from now. + uris: [uri] + } + + private_key = OpenSSL::PKey.read(Coinbase.configuration.api_key_private_key) + JWT.encode(claims, private_key, 'ES256', header) + end + end +end diff --git a/lib/coinbase/balance_map.rb b/lib/coinbase/balance_map.rb index 7ce3b9bd..0ece340b 100644 --- a/lib/coinbase/balance_map.rb +++ b/lib/coinbase/balance_map.rb @@ -3,7 +3,7 @@ require 'bigdecimal' module Coinbase - # A convenience class for printing out crypto asset balances in a human-readable format. + # A convenience class for printing out Asset balances in a human-readable format. class BalanceMap < Hash # Returns a new BalanceMap object. # @param hash [Map] The hash to initialize with diff --git a/lib/coinbase/client.rb b/lib/coinbase/client.rb new file mode 100644 index 00000000..f5d56974 --- /dev/null +++ b/lib/coinbase/client.rb @@ -0,0 +1,57 @@ +=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 + +# Common files +require 'coinbase/client/api_client' +require 'coinbase/client/api_error' +require 'coinbase/client/version' +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 :CreateTransferRequest, 'coinbase/client/models/create_transfer_request' +Coinbase::Client.autoload :CreateWalletRequest, 'coinbase/client/models/create_wallet_request' +Coinbase::Client.autoload :Error, 'coinbase/client/models/error' +Coinbase::Client.autoload :Transfer, 'coinbase/client/models/transfer' +Coinbase::Client.autoload :TransferList, 'coinbase/client/models/transfer_list' +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 :TransfersApi, 'coinbase/client/api/transfers_api' +Coinbase::Client.autoload :UsersApi, 'coinbase/client/api/users_api' +Coinbase::Client.autoload :WalletsApi, 'coinbase/client/api/wallets_api' + +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 +end diff --git a/lib/coinbase/client/api/addresses_api.rb b/lib/coinbase/client/api/addresses_api.rb new file mode 100644 index 00000000..26c59da1 --- /dev/null +++ b/lib/coinbase/client/api/addresses_api.rb @@ -0,0 +1,385 @@ +=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 + # @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 [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 + # @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<(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 + 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_address_balances, the character length must be smaller than or equal to 5000.' + 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] || {} + 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] || '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 addresses 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 addresses 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/transfers_api.rb b/lib/coinbase/client/api/transfers_api.rb new file mode 100644 index 00000000..04031cfd --- /dev/null +++ b/lib/coinbase/client/api/transfers_api.rb @@ -0,0 +1,256 @@ +=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 TransfersApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create a new transfer for an address + # Create a new transfer + # @param wallet_id [String] The ID of the wallet the source address belongs to + # @param address_id [String] The ID of the address to transfer from + # @param create_transfer_request [CreateTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Transfer] + def create_transfer(wallet_id, address_id, create_transfer_request, opts = {}) + data, _status_code, _headers = create_transfer_with_http_info(wallet_id, address_id, create_transfer_request, opts) + data + end + + # Create a new transfer for an address + # Create a new transfer + # @param wallet_id [String] The ID of the wallet the source address belongs to + # @param address_id [String] The ID of the address to transfer from + # @param create_transfer_request [CreateTransferRequest] + # @param [Hash] opts the optional parameters + # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers + def create_transfer_with_http_info(wallet_id, address_id, create_transfer_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TransfersApi.create_transfer ...' + 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 TransfersApi.create_transfer" + 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 TransfersApi.create_transfer" + end + # verify the required parameter 'create_transfer_request' is set + if @api_client.config.client_side_validation && create_transfer_request.nil? + fail ArgumentError, "Missing the required parameter 'create_transfer_request' when calling TransfersApi.create_transfer" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers'.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']) + # 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(create_transfer_request) + + # return_type + return_type = opts[:debug_return_type] || 'Transfer' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"TransfersApi.create_transfer", + :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: TransfersApi#create_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get a transfer by ID + # Get a transfer by ID + # @param wallet_id [String] The ID of the wallet the address belongs to + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to fetch + # @param [Hash] opts the optional parameters + # @return [Transfer] + def get_transfer(wallet_id, address_id, transfer_id, opts = {}) + data, _status_code, _headers = get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts) + data + end + + # Get a transfer by ID + # Get a transfer by ID + # @param wallet_id [String] The ID of the wallet the address belongs to + # @param address_id [String] The ID of the address the transfer belongs to + # @param transfer_id [String] The ID of the transfer to fetch + # @param [Hash] opts the optional parameters + # @return [Array<(Transfer, Integer, Hash)>] Transfer data, response status code and response headers + def get_transfer_with_http_info(wallet_id, address_id, transfer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TransfersApi.get_transfer ...' + 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 TransfersApi.get_transfer" + 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 TransfersApi.get_transfer" + end + # verify the required parameter 'transfer_id' is set + if @api_client.config.client_side_validation && transfer_id.nil? + fail ArgumentError, "Missing the required parameter 'transfer_id' when calling TransfersApi.get_transfer" + end + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers/{transfer_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'transfer_id' + '}', CGI.escape(transfer_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] || 'Transfer' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"TransfersApi.get_transfer", + :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: TransfersApi#get_transfer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List transfers for an address. + # List transfers for an address. + # @param wallet_id [String] The ID of the wallet the address belongs to + # @param address_id [String] The ID of the address to list transfers for + # @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 [TransferList] + def list_transfers(wallet_id, address_id, opts = {}) + data, _status_code, _headers = list_transfers_with_http_info(wallet_id, address_id, opts) + data + end + + # List transfers for an address. + # List transfers for an address. + # @param wallet_id [String] The ID of the wallet the address belongs to + # @param address_id [String] The ID of the address to list transfers for + # @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<(TransferList, Integer, Hash)>] TransferList data, response status code and response headers + def list_transfers_with_http_info(wallet_id, address_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TransfersApi.list_transfers ...' + 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 TransfersApi.list_transfers" + 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 TransfersApi.list_transfers" + 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 TransfersApi.list_transfers, the character length must be smaller than or equal to 5000.' + end + + # resource path + local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/transfers'.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] || {} + 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] || 'TransferList' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"TransfersApi.list_transfers", + :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: TransfersApi#list_transfers\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 new file mode 100644 index 00000000..73080e3a --- /dev/null +++ b/lib/coinbase/client/api/users_api.rb @@ -0,0 +1,79 @@ +=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 UsersApi + attr_accessor :api_client + + 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 [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' + + # 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] || 'User' + + # 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 + ) + + 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..21c7e8bc --- /dev/null +++ b/lib/coinbase/client/api/wallets_api.rb @@ -0,0 +1,348 @@ +=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 + # @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 [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 + # @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<(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 + 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 WalletsApi.list_wallets, the character length must be smaller than or equal to 5000.' + end + + # resource path + local_var_path = '/v1/wallets' + + # 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] || '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 new file mode 100644 index 00000000..c1aafb61 --- /dev/null +++ b/lib/coinbase/client/api_client.rb @@ -0,0 +1,431 @@ +=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 'json' +require 'logger' +require 'tempfile' +require 'time' +require 'faraday' +require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0') +require 'marcel' + + +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 + + def self.default + @@default ||= ApiClient.new + 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 + + if config.debugging + config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" + 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 + end + rescue Faraday::TimeoutError + fail ApiError.new('Connection timed out') + rescue Faraday::ConnectionFailed + fail ApiError.new('Connection failed') + end + + 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 + + # 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 + 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| + 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 + data[key] = value.to_s + end + end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil + end + data + end + + def download_file(request) + stream = [] + + # handle streaming Responses + request.options.on_data = Proc.new do |chunk, overall_received_bytes| + stream << chunk + end + stream + end + + 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(opts) + opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + 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 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 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 =~ /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? + + # return response body directly for String return type + return body.to_s if return_type == 'String' + + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' + + 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 + else + raise e + end + 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 = $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 + + # 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 + + def build_request_url(path, opts = {}) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(/\/+/, '/') + @config.base_url(opts[:operation]) + path + 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 fail ArgumentError, 'Authentication token must be in `query` or `header`' + end + 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 + + # 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 + + # 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 + 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 +end diff --git a/lib/coinbase/client/api_error.rb b/lib/coinbase/client/api_error.rb new file mode 100644 index 00000000..70c6b145 --- /dev/null +++ b/lib/coinbase/client/api_error.rb @@ -0,0 +1,58 @@ +=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 + end + + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + @message = arg + end + end + + # Override to_s to display a friendly error message + def to_s + message + end + + 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 new file mode 100644 index 00000000..eeaa0719 --- /dev/null +++ b/lib/coinbase/client/configuration.rb @@ -0,0 +1,375 @@ +=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 Configuration + # Defines url scheme + attr_accessor :scheme + + # Defines url host + attr_accessor :host + + # Defines url base path + attr_accessor :base_path + + # Define server configuration index + attr_accessor :server_index + + # Define server operation configuration index + attr_accessor :server_operation_index + + # Default server variables + attr_accessor :server_variables + + # Default server operation variables + attr_accessor :server_operation_variables + + # Defines API keys used with API Key authentications. + # + # @return [Hash] key: parameter name, value: parameter value (API key) + # + # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string) + # config.api_key['api_key'] = 'xxx' + attr_accessor :api_key + + # Defines API key prefixes used with API Key authentications. + # + # @return [Hash] key: parameter name, value: API key prefix + # + # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers) + # config.api_key_prefix['api_key'] = 'Token' + attr_accessor :api_key_prefix + + # Defines the username used with HTTP basic authentication. + # + # @return [String] + attr_accessor :username + + # Defines the password used with HTTP basic authentication. + # + # @return [String] + attr_accessor :password + + # Defines the access token (Bearer) used with OAuth2. + attr_accessor :access_token + + # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2. + # Overrides the access_token if set + # @return [Proc] + attr_accessor :access_token_getter + + # Set this to return data as binary instead of downloading a temp file. When enabled (set to true) + # HTTP responses with return type `File` will be returned as a stream of binary data. + # Default to false. + attr_accessor :return_binary_data + + # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response + # details will be logged with `logger.debug` (see the `logger` attribute). + # Default to false. + # + # @return [true, false] + attr_accessor :debugging + + # Defines the logger used for debugging. + # Default to `Rails.logger` (when in Rails) or logging to STDOUT. + # + # @return [#debug] + attr_accessor :logger + + # Defines the temporary folder to store downloaded files + # (for API endpoints that have file response). + # Default to use `Tempfile`. + # + # @return [String] + attr_accessor :temp_folder_path + + # The time limit for HTTP request in seconds. + # Default to 0 (never times out). + attr_accessor :timeout + + # Set this to false to skip client side validation in the operation. + # Default to true. + # @return [true, false] + attr_accessor :client_side_validation + + ### TLS/SSL setting + # Set this to false to skip verifying SSL certificate when calling API from https server. + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :ssl_verify + + ### TLS/SSL setting + # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html) + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + attr_accessor :ssl_verify_mode + + ### TLS/SSL setting + # Set this to customize the certificate file to verify the peer. + # + # @return [String] the path to the certificate file + attr_accessor :ssl_ca_file + + ### TLS/SSL setting + # Client certificate file (for client certificate) + attr_accessor :ssl_client_cert + + ### TLS/SSL setting + # Client private key file (for client certificate) + attr_accessor :ssl_client_key + + ### Proxy setting + # HTTP Proxy settings + attr_accessor :proxy + + # Set this to customize parameters encoder of array parameter. + # Default to nil. Faraday uses NestedParamsEncoder when nil. + # + # @see The params_encoder option of Faraday. Related source code: + # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders + attr_accessor :params_encoder + + + attr_accessor :inject_format + + attr_accessor :force_ending_format + + def initialize + @scheme = 'https' + @host = 'api.cdp.coinbase.com' + @base_path = '/platform' + @server_index = nil + @server_operation_index = {} + @server_variables = {} + @server_operation_variables = {} + @api_key = {} + @api_key_prefix = {} + @client_side_validation = true + @ssl_verify = true + @ssl_verify_mode = nil + @ssl_ca_file = nil + @ssl_client_cert = nil + @ssl_client_key = nil + @middlewares = Hash.new { |h, k| h[k] = [] } + @configure_connection_blocks = [] + @timeout = 60 + # return data as binary instead of file + @return_binary_data = false + @params_encoder = nil + @debugging = false + @inject_format = false + @force_ending_format = false + @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) + + yield(self) if block_given? + end + + # The default Configuration object. + def self.default + @@default ||= Configuration.new + end + + def configure + yield(self) if block_given? + end + + def scheme=(scheme) + # remove :// from scheme + @scheme = scheme.sub(/:\/\//, '') + end + + def host=(host) + # remove http(s):// and anything after a slash + @host = host.sub(/https?:\/\//, '').split('/').first + end + + def base_path=(base_path) + # Add leading and trailing slashes to base_path + @base_path = "/#{base_path}".gsub(/\/+/, '/') + @base_path = '' if @base_path == '/' + end + + # Returns base URL for specified operation based on server settings + def base_url(operation = nil) + if operation_server_settings.key?(operation) then + index = server_operation_index.fetch(operation, server_index) + server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) + else + server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil) + end + end + + # Gets API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def api_key_with_prefix(param_name, param_alias = nil) + key = @api_key[param_name] + key = @api_key.fetch(param_alias, key) unless param_alias.nil? + if @api_key_prefix[param_name] + "#{@api_key_prefix[param_name]} #{key}" + else + key + end + end + + # Gets access_token using access_token_getter or uses the static access_token + def access_token_with_refresh + return access_token if access_token_getter.nil? + access_token_getter.call + end + + # Gets Basic Auth token string + def basic_auth_token + 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") + end + + # Returns Auth Settings hash for api client. + def auth_settings + { + } + end + + # Returns an array of Server setting + def server_settings + [ + { + url: "https://api.cdp.coinbase.com/platform", + description: "No description provided", + } + ] + end + + def operation_server_settings + { + } + end + + # Returns URL based on server settings + # + # @param index array index of the server settings + # @param variables hash of variable and the corresponding value + def server_url(index, variables = {}, servers = nil) + servers = server_settings if servers == nil + + # check array index out of bound + if (index.nil? || index < 0 || index >= servers.size) + fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}" + end + + server = servers[index] + url = server[:url] + + return url unless server.key? :variables + + # go through variable and assign a value + server[:variables].each do |name, variable| + if variables.key?(name) + if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) + url.gsub! "{" + name.to_s + "}", variables[name] + else + fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." + end + else + # use default value + url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value] + end + end + + url + end + + # Configure Faraday connection directly. + # + # ``` + # c.configure_faraday_connection do |conn| + # conn.use Faraday::HttpCache, shared_cache: false, logger: logger + # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger| + # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]') + # end + # end + # + # c.configure_faraday_connection do |conn| + # conn.adapter :typhoeus + # end + # ``` + # + # @param block [Proc] `#call`able object that takes one arg, the connection + def configure_faraday_connection(&block) + @configure_connection_blocks << block + end + + def configure_connection(conn) + @configure_connection_blocks.each do |block| + block.call(conn) + end + end + + # Adds middleware to the stack + def use(*middleware) + set_faraday_middleware(:use, *middleware) + end + + # Adds request middleware to the stack + def request(*middleware) + set_faraday_middleware(:request, *middleware) + end + + # Adds response middleware to the stack + def response(*middleware) + set_faraday_middleware(:response, *middleware) + end + + # Adds Faraday middleware setting information to the stack + # + # @example Use the `set_faraday_middleware` method to set middleware information + # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503]) + # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug }) + # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false) + # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 }) + # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger) + # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware) + # + # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143 + def set_faraday_middleware(operation, key, *args, &block) + unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation) + fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \ + " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete." + end + + @middlewares[operation] << [key, args, block] + end + ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true) + + # Set up middleware on the connection + def configure_middleware(connection) + return if @middlewares.empty? + + [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation| + next unless @middlewares.key?(operation) + + @middlewares[operation].each do |key, args, block| + connection.builder.send(operation, key, *args, &block) + end + end + + if @middlewares.key?(:delete) + @middlewares[:delete].each do |key, _args, _block| + connection.builder.delete(key) + end + end + end + + end +end diff --git a/lib/coinbase/client/models/address.rb b/lib/coinbase/client/models/address.rb new file mode 100644 index 00000000..a93c1c14 --- /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_id + + # The public key from which the address is derived. + 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_id' => :'network_id', + :'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_id' => :'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_id') + self.network_id = attributes[:'network_id'] + else + self.network_id = 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_id.nil? + invalid_properties.push('invalid value for "network_id", network_id 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_id.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_id == o.network_id && + 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_id, 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..de3397c4 --- /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_id + + # The ID for the asset on the network + attr_accessor :asset_id + + # 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_id' => :'network_id', + :'asset_id' => :'asset_id', + :'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_id' => :'String', + :'asset_id' => :'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_id') + self.network_id = attributes[:'network_id'] + else + self.network_id = nil + end + + if attributes.key?(:'asset_id') + self.asset_id = attributes[:'asset_id'] + else + self.asset_id = 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_id.nil? + invalid_properties.push('invalid value for "network_id", network_id cannot be nil.') + end + + if @asset_id.nil? + invalid_properties.push('invalid value for "asset_id", asset_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 @network_id.nil? + return false if @asset_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 && + network_id == o.network_id && + asset_id == o.asset_id && + 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_id, asset_id, 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..97f67a83 --- /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 from which the address will be derived. + attr_accessor :public_key + + # An attestation signed by the private key that is associated with the wallet. The attestation will be a hex-encoded signature of a json payload with fields `wallet_id` and `public_key`, signed by the private key associated with the public_key set in the request. + 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_transfer_request.rb b/lib/coinbase/client/models/create_transfer_request.rb new file mode 100644 index 00000000..40abf7a5 --- /dev/null +++ b/lib/coinbase/client/models/create_transfer_request.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 CreateTransferRequest + # The amount to transfer + attr_accessor :amount + + # The ID of the blockchain network + attr_accessor :network_id + + # The ID of the asset to transfer + attr_accessor :asset_id + + # The destination address + attr_accessor :destination + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'network_id' => :'network_id', + :'asset_id' => :'asset_id', + :'destination' => :'destination' + } + 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', + :'network_id' => :'String', + :'asset_id' => :'String', + :'destination' => :'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::CreateTransferRequest` 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::CreateTransferRequest`. 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?(:'network_id') + self.network_id = attributes[:'network_id'] + else + self.network_id = nil + end + + if attributes.key?(:'asset_id') + self.asset_id = attributes[:'asset_id'] + else + self.asset_id = nil + end + + if attributes.key?(:'destination') + self.destination = attributes[:'destination'] + else + self.destination = 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 @network_id.nil? + invalid_properties.push('invalid value for "network_id", network_id cannot be nil.') + end + + if @asset_id.nil? + invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.') + end + + if @destination.nil? + invalid_properties.push('invalid value for "destination", destination 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 @network_id.nil? + return false if @asset_id.nil? + return false if @destination.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 && + network_id == o.network_id && + asset_id == o.asset_id && + destination == o.destination + 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, network_id, asset_id, destination].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/transfer.rb b/lib/coinbase/client/models/transfer.rb new file mode 100644 index 00000000..aee6306e --- /dev/null +++ b/lib/coinbase/client/models/transfer.rb @@ -0,0 +1,393 @@ +=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 + # A transfer of an asset from one address to another + class Transfer + # The ID of the blockchain network + attr_accessor :network_id + + # The ID of the wallet that owns the from address + attr_accessor :wallet_id + + # The onchain address of the sender + attr_accessor :address_id + + # The onchain address of the recipient + attr_accessor :destination + + # The amount in the atomic units of the asset + attr_accessor :amount + + # The ID of the asset being transferred + attr_accessor :asset_id + + # The ID of the transfer + attr_accessor :transfer_id + + # The unsigned payload of the transfer. This is the payload that needs to be signed by the sender. + attr_accessor :unsigned_payload + + # The status of the transfer + attr_accessor :status + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'network_id' => :'network_id', + :'wallet_id' => :'wallet_id', + :'address_id' => :'address_id', + :'destination' => :'destination', + :'amount' => :'amount', + :'asset_id' => :'asset_id', + :'transfer_id' => :'transfer_id', + :'unsigned_payload' => :'unsigned_payload', + :'status' => :'status' + } + 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_id' => :'String', + :'wallet_id' => :'String', + :'address_id' => :'String', + :'destination' => :'String', + :'amount' => :'String', + :'asset_id' => :'String', + :'transfer_id' => :'String', + :'unsigned_payload' => :'String', + :'status' => :'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::Transfer` 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::Transfer`. 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_id') + self.network_id = attributes[:'network_id'] + else + self.network_id = nil + end + + if attributes.key?(:'wallet_id') + self.wallet_id = attributes[:'wallet_id'] + else + self.wallet_id = nil + end + + if attributes.key?(:'address_id') + self.address_id = attributes[:'address_id'] + else + self.address_id = nil + end + + if attributes.key?(:'destination') + self.destination = attributes[:'destination'] + else + self.destination = nil + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'asset_id') + self.asset_id = attributes[:'asset_id'] + else + self.asset_id = nil + end + + if attributes.key?(:'transfer_id') + self.transfer_id = attributes[:'transfer_id'] + else + self.transfer_id = nil + end + + if attributes.key?(:'unsigned_payload') + self.unsigned_payload = attributes[:'unsigned_payload'] + else + self.unsigned_payload = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 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_id.nil? + invalid_properties.push('invalid value for "network_id", network_id cannot be nil.') + end + + if @wallet_id.nil? + invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.') + end + + if @address_id.nil? + invalid_properties.push('invalid value for "address_id", address_id cannot be nil.') + end + + if @destination.nil? + invalid_properties.push('invalid value for "destination", destination cannot be nil.') + end + + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + if @asset_id.nil? + invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.') + end + + if @transfer_id.nil? + invalid_properties.push('invalid value for "transfer_id", transfer_id cannot be nil.') + end + + if @unsigned_payload.nil? + invalid_properties.push('invalid value for "unsigned_payload", unsigned_payload cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status 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_id.nil? + return false if @wallet_id.nil? + return false if @address_id.nil? + return false if @destination.nil? + return false if @amount.nil? + return false if @asset_id.nil? + return false if @transfer_id.nil? + return false if @unsigned_payload.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + 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_id == o.network_id && + wallet_id == o.wallet_id && + address_id == o.address_id && + destination == o.destination && + amount == o.amount && + asset_id == o.asset_id && + transfer_id == o.transfer_id && + unsigned_payload == o.unsigned_payload && + status == o.status + 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_id, wallet_id, address_id, destination, amount, asset_id, transfer_id, unsigned_payload, status].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/transfer_list.rb b/lib/coinbase/client/models/transfer_list.rb new file mode 100644 index 00000000..2ee3c3cb --- /dev/null +++ b/lib/coinbase/client/models/transfer_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 TransferList + 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 transfers for the address in 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::TransferList` 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::TransferList`. 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/user.rb b/lib/coinbase/client/models/user.rb new file mode 100644 index 00000000..4bc95a57 --- /dev/null +++ b/lib/coinbase/client/models/user.rb @@ -0,0 +1,231 @@ +=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 User + # The ID of the user + attr_accessor :id + + attr_accessor :display_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'display_name' => :'display_name' + } + 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', + :'display_name' => :'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::User` 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::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 + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'display_name') + self.display_name = attributes[:'display_name'] + 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 @id.nil? + invalid_properties.push('invalid value for "id", 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 @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 && + id == o.id && + display_name == o.display_name + 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, 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 + 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.rb b/lib/coinbase/client/models/wallet.rb new file mode 100644 index 00000000..49221f07 --- /dev/null +++ b/lib/coinbase/client/models/wallet.rb @@ -0,0 +1,241 @@ +=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_id + + attr_accessor :default_address + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'network_id' => :'network_id', + :'default_address' => :'default_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 + { + :'id' => :'String', + :'network_id' => :'String', + :'default_address' => :'Address' + } + 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_id') + self.network_id = attributes[:'network_id'] + else + self.network_id = nil + end + + if attributes.key?(:'default_address') + self.default_address = attributes[:'default_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_id.nil? + invalid_properties.push('invalid value for "network_id", network_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 @network_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 && + id == o.id && + network_id == o.network_id && + default_address == o.default_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 + [id, network_id, default_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/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 new file mode 100644 index 00000000..b9708b21 --- /dev/null +++ b/lib/coinbase/client/version.rb @@ -0,0 +1,15 @@ +=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 diff --git a/lib/coinbase/constants.rb b/lib/coinbase/constants.rb index c38fc998..06195142 100644 --- a/lib/coinbase/constants.rb +++ b/lib/coinbase/constants.rb @@ -29,10 +29,14 @@ module Coinbase # The amount of Gwei per Ether. GWEI_PER_ETHER = 1_000_000_000 + # The amount of atomic units of USDC per USDC. + ATOMIC_UNITS_PER_USDC = 1_000_000 + # A map of supported Asset IDs. SUPPORTED_ASSET_IDS = { eth: true, # Ether, the native asset of most EVM networks. gwei: true, # A medium denomination of Ether, typically used in gas prices. - wei: true # The smallest denomination of Ether. + wei: true, # The smallest denomination of Ether. + usdc: true # USD Coin, a stablecoin pegged to the US Dollar. }.freeze end diff --git a/lib/coinbase/middleware.rb b/lib/coinbase/middleware.rb new file mode 100644 index 00000000..dd0d59c3 --- /dev/null +++ b/lib/coinbase/middleware.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require_relative 'authenticator' +require_relative 'client/configuration' +require 'faraday' + +module Coinbase + # A module for middleware that can be used with Faraday. + module Middleware + Faraday::Request.register_middleware authenticator: -> { Coinbase::Authenticator } + + # Returns the default middleware configuration for the Coinbase SDK. + def self.config + Coinbase::Client::Configuration.default.tap do |config| + config.debugging = true + config.host = Coinbase.configuration.api_url + config.request(:authenticator) + end + end + end +end diff --git a/lib/coinbase/network.rb b/lib/coinbase/network.rb index 7175786c..4bc7cca6 100644 --- a/lib/coinbase/network.rb +++ b/lib/coinbase/network.rb @@ -5,8 +5,8 @@ module Coinbase class Network attr_reader :chain_id - # Returns a new Network object. - # + # Returns a new Network object. Do not use this method directly. Instead, use the Network constants defined in + # the Coinbase module. # @param network_id [Symbol] The Network ID # @param display_name [String] The Network's display name # @param protocol_family [String] The protocol family to which the Network belongs diff --git a/lib/coinbase/transfer.rb b/lib/coinbase/transfer.rb index dfbe69d6..8930e000 100644 --- a/lib/coinbase/transfer.rb +++ b/lib/coinbase/transfer.rb @@ -3,15 +3,14 @@ require_relative 'constants' require 'bigdecimal' require 'eth' +require 'json' module Coinbase # A representation of a Transfer, which moves an amount of an Asset from # a user-controlled Wallet to another address. The fee is assumed to be paid - # in the native Asset of the Network. Currently only ETH transfers are supported. Transfers - # should be created through {link:Wallet#transfer} or {link:Address#transfer}. + # in the native Asset of the Network. Transfers should be created through Wallet#transfer or + # Address#transfer. class Transfer - attr_reader :network_id, :wallet_id, :from_address_id, :amount, :asset_id, :to_address_id - # A representation of a Transfer status. module Status # The Transfer is awaiting being broadcast to the Network. At this point, transaction @@ -29,28 +28,59 @@ module Status FAILED = :failed end - # Returns a new Transfer object. - # @param network_id [Symbol] The ID of the Network on which the Transfer originated - # @param wallet_id [String] The ID of the Wallet from which the Transfer originated - # @param from_address_id [String] The ID of the address from which the Transfer originated - # @param amount [Integer, Float, BigDecimal] The amount of the Asset to send. Integers are interpreted as - # the smallest denomination of the Asset (e.g. Wei for Ether). Floats and BigDecimals are interpreted as the Asset - # itself (e.g. Ether). - # @param asset_id [Symbol] The ID of the Asset being transferred. Currently only ETH is supported. - # @param to_address_id [String] The address to which the Transfer is being sent - # @param client [Jimson::Client] (Optional) The JSON RPC client to use for interacting with the Network - def initialize(network_id, wallet_id, from_address_id, amount, asset_id, to_address_id, - client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) - - raise ArgumentError, "Unsupported asset: #{asset_id}" if asset_id != :eth - - @network_id = network_id - @wallet_id = wallet_id - @from_address_id = from_address_id - @amount = normalize_eth_amount(amount) - @asset_id = asset_id - @to_address_id = to_address_id - @client = client + # Returns a new Transfer object. Do not use this method directly. Instead, use Wallet#transfer or + # Address#transfer. + # @param model [Coinbase::Client::Transfer] The underlying Transfer object + def initialize(model) + @model = model + end + + # Returns the Transfer ID. + # @return [String] The Transfer ID + def transfer_id + @model.transfer_id + end + + # Returns the Network ID of the Transfer. + # @return [String] The Network ID + def network_id + @model.network_id + end + + # Returns the Wallet ID of the Transfer. + # @return [String] The Wallet ID + def wallet_id + @model.wallet_id + end + + # Returns the From Address ID of the Transfer. + # @return [String] The From Address ID + def from_address_id + @model.address_id + end + + # Returns the Destination Address ID of the Transfer. + # @return [String] The Destination Address ID + def destination_address_id + @model.destination + end + + # Returns the Asset ID of the Transfer. + # @return [Symbol] The Asset ID + def asset_id + @model.asset_id.to_sym + end + + # Returns the amount of the asset for the Transfer. + # @return [BigDecimal] The amount in units of ETH + def amount + BigDecimal(@model.amount) / BigDecimal(Coinbase::WEI_PER_ETHER.to_s) + end + + # Returns the Unsigned Payload of the Transfer. + # @return [String] The Unsigned Payload + def unsigned_payload + @model.unsigned_payload end # Returns the underlying Transfer transaction, creating it if it has not been yet. @@ -58,18 +88,19 @@ def initialize(network_id, wallet_id, from_address_id, amount, asset_id, to_addr def transaction return @transaction unless @transaction.nil? - nonce = @client.eth_getTransactionCount(@from_address_id.to_s, 'latest').to_i(16) - gas_price = @client.eth_gasPrice.to_i(16) + raw_payload = [unsigned_payload].pack('H*') + parsed_payload = JSON.parse(raw_payload) params = { - chain_id: BASE_SEPOLIA.chain_id, # TODO: Don't hardcode Base Sepolia. - nonce: nonce, - priority_fee: gas_price, # TODO: Optimize this. - max_gas_fee: gas_price, - gas_limit: 21_000, # TODO: Handle multiple currencies. - from: Eth::Address.new(@from_address_id), - to: Eth::Address.new(@to_address_id), - value: (@amount * Coinbase::WEI_PER_ETHER).to_i + chain_id: parsed_payload['chainId'].to_i(16), + nonce: parsed_payload['nonce'].to_i(16), + priority_fee: parsed_payload['maxPriorityFeePerGas'].to_i(16), + max_gas_fee: parsed_payload['maxFeePerGas'].to_i(16), + gas_limit: parsed_payload['gas'].to_i(16), # TODO: Handle multiple currencies. + from: Eth::Address.new(from_address_id), + to: Eth::Address.new(parsed_payload['to']), + value: parsed_payload['value'].to_i(16), + data: parsed_payload['input'] || '' } @transaction = Eth::Tx::Eip1559.new(Eth::Tx.validate_eip1559_params(params)) @@ -87,7 +118,7 @@ def status return Status::PENDING end - onchain_transaction = @client.eth_getTransactionByHash(transaction_hash) + onchain_transaction = Coinbase.configuration.base_sepolia_client.eth_getTransactionByHash(transaction_hash) if onchain_transaction.nil? # If the transaction has not been broadcast, it is still pending. @@ -97,7 +128,7 @@ def status # broadcast. Status::BROADCAST else - transaction_receipt = @client.eth_getTransactionReceipt(transaction_hash) + transaction_receipt = Coinbase.configuration.base_sepolia_client.eth_getTransactionReceipt(transaction_hash) if transaction_receipt['status'].to_i(16) == 1 Status::COMPLETE @@ -133,21 +164,5 @@ def transaction_hash rescue Eth::Signature::SignatureError nil end - - private - - # Normalizes the given Ether amount into a BigDecimal. - # @param amount [Integer, Float, BigDecimal] The amount to normalize - # @return [BigDecimal] The normalized amount - def normalize_eth_amount(amount) - case amount - when BigDecimal - amount - when Integer, Float - BigDecimal(amount.to_s) - else - raise ArgumentError, "Invalid amount: #{amount}" - end - end end end diff --git a/lib/coinbase/user.rb b/lib/coinbase/user.rb new file mode 100644 index 00000000..b7148716 --- /dev/null +++ b/lib/coinbase/user.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require_relative 'client' +require_relative 'wallet' + +module Coinbase + # A representation of a User. Users have Wallets, which can hold balances of Assets. Access the default User through + # Coinbase#default_user. + class User + # Returns a new User object. Do not use this method directly. Instead, use Coinbase#default_user. + # @param model [Coinbase::Client::User] the underlying User object + def initialize(model) + @model = model + end + + # Returns the User ID. + # @return [String] the User ID + def user_id + @model.id + end + + # Creates a new Wallet belonging to the User. + # @return [Coinbase::Wallet] the new Wallet + def create_wallet + create_wallet_request = { + wallet: { + # TODO: Don't hardcode this. + network_id: 'base-sepolia' + } + } + opts = { create_wallet_request: create_wallet_request } + + model = wallets_api.create_wallet(opts) + + Wallet.new(model) + end + + # Imports a Wallet belonging to the User. + # @param data [Coinbase::Wallet::Data] the Wallet data to import + # @return [Coinbase::Wallet] the imported Wallet + def import_wallet(data) + model = wallets_api.get_wallet(data.wallet_id) + address_count = addresses_api.list_addresses(model.id).total_count + Wallet.new(model, seed: data.seed, address_count: address_count) + end + + # Lists the IDs of the Wallets belonging to the User. + # @return [Array] the IDs of the Wallets belonging to the User + def list_wallet_ids + wallets = wallets_api.list_wallets + wallets.data.map(&:id) + end + + private + + def addresses_api + @addresses_api ||= Coinbase::Client::AddressesApi.new(Coinbase.configuration.api_client) + end + + def wallets_api + @wallets_api ||= Coinbase::Client::WalletsApi.new(Coinbase.configuration.api_client) + end + end +end diff --git a/lib/coinbase/wallet.rb b/lib/coinbase/wallet.rb index 1bea9be5..01e27a10 100644 --- a/lib/coinbase/wallet.rb +++ b/lib/coinbase/wallet.rb @@ -1,29 +1,31 @@ # frozen_string_literal: true +require 'digest' require 'jimson' +require 'json' require 'money-tree' require 'securerandom' module Coinbase # A representation of a Wallet. Wallets come with a single default Address, but can expand to have a set of Addresses, # each of which can hold a balance of one or more Assets. Wallets can create new Addresses, list their addresses, - # list their balances, and transfer Assets to other Addresses. + # list their balances, and transfer Assets to other Addresses. Wallets should be created through User#create_wallet or + # User#import_wallet. class Wallet - attr_reader :wallet_id, :network_id - - # Returns a new Wallet object. - # @param seed [Integer] (Optional) The seed to use for the Wallet. Expects a 32-byte hexadecimal. If not provided, - # a new seed will be generated. - # @param address_count [Integer] (Optional) The number of addresses to generate for the Wallet. If not provided, - # a single address will be generated. + # Returns a new Wallet object. Do not use this method directly. Instead, use User#create_wallet or + # User#import_wallet. + # @param model [Coinbase::Client::Wallet] The underlying Wallet object + # @param seed [String] (Optional) The seed to use for the Wallet. Expects a 32-byte hexadecimal with no 0x prefix. + # If not provided, a new seed will be generated. + # @param address_count [Integer] (Optional) The number of addresses already registered for the Wallet. # @param client [Jimson::Client] (Optional) The JSON RPC client to use for interacting with the Network - def initialize(seed: nil, address_count: 1, client: Jimson::Client.new(Coinbase.base_sepolia_rpc_url)) + def initialize(model, seed: nil, address_count: 0) raise ArgumentError, 'Seed must be 32 bytes' if !seed.nil? && seed.length != 64 - raise ArgumentError, 'Address count must be positive' if address_count < 1 + + @model = model @master = seed.nil? ? MoneyTree::Master.new : MoneyTree::Master.new(seed_hex: seed) - @wallet_id = SecureRandom.uuid # TODO: Make Network an argument to the constructor. @network_id = :base_sepolia @addresses = [] @@ -32,28 +34,49 @@ def initialize(seed: nil, address_count: 1, client: Jimson::Client.new(Coinbase. @address_path_prefix = "m/44'/60'/0'/0" @address_index = 0 - @client = client + if address_count.positive? + address_count.times { derive_address } + else + create_address + # Update the model to reflect the new default address. + update_model + end + end - address_count.times { create_address } + # Returns the Wallet ID. + # @return [String] The Wallet ID + def wallet_id + @model.id + end + + # Returns the Network ID of the Wallet. + # @return [Symbol] The Network ID + def network_id + Coinbase.to_sym(@model.network_id) end # Creates a new Address in the Wallet. # @return [Address] The new Address def create_address - # TODO: Register with server. - path = "#{@address_path_prefix}/#{@address_index}" - private_key = @master.node_for_path(path).private_key.to_hex - key = Eth::Key.new(priv: private_key) - address = Address.new(@network_id, key.address.address, @wallet_id, key, client: @client) - @addresses << address - @address_index += 1 - address + key = derive_key + attestation = create_attestation(key) + public_key = key.public_key.compressed.unpack1('H*') + + opts = { + create_address_request: { + public_key: public_key, + attestation: attestation + } + } + address_model = addresses_api.create_address(wallet_id, opts) + + cache_address(address_model, key) end # Returns the default address of the Wallet. # @return [Address] The default address def default_address - @addresses.first + @addresses.find { |address| address.address_id == @model.default_address.address_id } end # Returns the Address with the given ID. @@ -66,25 +89,14 @@ def get_address(address_id) # Returns the list of Addresses in the Wallet. # @return [Array
    ] The list of Addresses def list_addresses - # TODO: Register with server. @addresses end # Returns the list of balances of this Wallet. Balances are aggregated across all Addresses in the Wallet. # @return [BalanceMap] The list of balances. The key is the Asset ID, and the value is the balance. def list_balances - balance_map = BalanceMap.new - - @addresses.each do |address| - address.list_balances.each do |asset_id, balance| - balance_map[asset_id] ||= BigDecimal(0) - current_balance = balance_map[asset_id] - new_balance = balance + current_balance - balance_map[asset_id] = new_balance - end - end - - balance_map + response = wallets_api.list_wallet_balances(wallet_id) + Coinbase.to_balance_map(response) end # Returns the balance of the provided Asset. Balances are aggregated across all Addresses in the Wallet. @@ -97,17 +109,21 @@ def get_balance(asset_id) asset_id end - eth_balance = list_balances[normalized_asset_id] || BigDecimal(0) + response = wallets_api.get_wallet_balance(wallet_id, normalized_asset_id.to_s) + + return BigDecimal('0') if response.nil? + + amount = BigDecimal(response.amount) case asset_id when :eth - eth_balance + amount / BigDecimal(Coinbase::WEI_PER_ETHER.to_s) when :gwei - eth_balance * Coinbase::GWEI_PER_ETHER - when :wei - eth_balance * Coinbase::WEI_PER_ETHER + amount / BigDecimal(Coinbase::GWEI_PER_ETHER.to_s) + when :usdc + amount / BigDecimal(Coinbase::ATOMIC_UNITS_PER_USDC.to_s) else - BigDecimal(0) + amount end end @@ -132,29 +148,105 @@ def transfer(amount, asset_id, destination) default_address.transfer(amount, asset_id, destination) end - # Exports the Wallet's data to a WalletData object. - # @return [WalletData] The Wallet data + # Exports the Wallet's data to a Data object. + # @return [Data] The Wallet data def export - WalletData.new(@master.seed_hex, @addresses.length) + Data.new(wallet_id: wallet_id, seed: @master.seed_hex) end # The data required to recreate a Wallet. - class WalletData - attr_reader :seed, :address_count + class Data + attr_reader :wallet_id, :seed - # Returns a new WalletData object. + # Returns a new Data object. + # @param wallet_id [String] The ID of the Wallet # @param seed [String] The seed of the Wallet - # @param address_count [Integer] The number of addresses in the Wallet - def initialize(seed, address_count) + def initialize(wallet_id:, seed:) + @wallet_id = wallet_id @seed = seed - @address_count = address_count end + + # Converts the Data object to a Hash. + # @return [Hash] The Hash representation of the Data object + def to_hash + { wallet_id: wallet_id, seed: seed } + end + + # Creates a Data object from the given Hash. + # @param data [Hash] The Hash to create the Data object from + # @return [Data] The new Data object + def self.from_hash(data) + Data.new(wallet_id: data['wallet_id'], seed: data['seed']) + end + end + + private + + # Derives an already registered Address in the Wallet. + # @return [Address] The new Address + def derive_address + key = derive_key + + address_id = key.address.to_s + address_model = addresses_api.get_address(wallet_id, address_id) + + cache_address(address_model, key) + end + + # Derives a key for an already registered Address in the Wallet. + # @return [Eth::Key] The new key + def derive_key + path = "#{@address_path_prefix}/#{@address_index}" + private_key = @master.node_for_path(path).private_key.to_hex + Eth::Key.new(priv: private_key) + end + + # Caches an Address on the client-side and increments the address index. + # @param address_model [Coinbase::Client::Address] The Address model + # @param key [Eth::Key] The private key of the Address + # @return [Address] The new Address + def cache_address(address_model, key) + address = Address.new(address_model, key) + @addresses << address + @address_index += 1 + address + end + + # Creates an attestation for the Address currently being created. + # @param key [Eth::Key] The private key of the Address + # @return [String] The attestation + def create_attestation(key) + public_key = key.public_key.compressed.unpack1('H*') + payload = { + wallet_id: wallet_id, + public_key: public_key + }.to_json + hashed_payload = Digest::SHA256.digest(payload) + signature = key.sign(hashed_payload) + + # The secp256k1 library serializes the signature as R, S, V. + # The server expects the signature as V, R, S in the format: + # <(byte of 27+public key solution)+4 if compressed >< padded bytes for signature R> + # Ruby gem does not add 4 to the recovery byte, so we need to add it here. + # Take the last byte (V) and add 4 to it to show signature is compressed. + signature_bytes = [signature].pack('H*').unpack('C*') + last_byte = signature_bytes.last + compressed_last_byte = last_byte + 4 + new_signature_bytes = [compressed_last_byte] + signature_bytes[0..-2] + new_signature_bytes.pack('C*').unpack1('H*') + end + + # Updates the Wallet model with the latest data. + def update_model + @model = wallets_api.get_wallet(wallet_id) + end + + def addresses_api + @addresses_api ||= Coinbase::Client::AddressesApi.new(Coinbase.configuration.api_client) end - # Returns the data required to recreate the Wallet. - # @return [WalletData] The Wallet data - def to_data - WalletData.new(@master.seed_hex, @addresses.length) + def wallets_api + @wallets_api ||= Coinbase::Client::WalletsApi.new(Coinbase.configuration.api_client) end end end diff --git a/spec/coinbase/address_spec.rb b/spec/coinbase/address_spec.rb deleted file mode 100644 index b027e213..00000000 --- a/spec/coinbase/address_spec.rb +++ /dev/null @@ -1,141 +0,0 @@ -# frozen_string_literal: true - -describe Coinbase::Address do - let(:key) { Eth::Key.new } - let(:network_id) { :base_sepolia } - let(:address_id) { key.address.to_s } - let(:wallet_id) { SecureRandom.uuid } - let(:client) { double('Jimson::Client') } - - subject(:address) do - described_class.new(network_id, address_id, wallet_id, key, client: client) - end - - describe '#initialize' do - it 'initializes a new Address' do - expect(address).to be_a(Coinbase::Address) - end - end - - describe '#network_id' do - it 'returns the network ID' do - expect(address.network_id).to eq(network_id) - end - end - - describe '#address_id' do - it 'returns the address ID' do - expect(address.address_id).to eq(address_id) - end - end - - describe '#wallet_id' do - it 'returns the wallet ID' do - expect(address.wallet_id).to eq(wallet_id) - end - end - - describe '#list_balances' do - before do - allow(client).to receive(:eth_getBalance).with(address_id, 'latest').and_return('0xde0b6b3a7640000') - end - - it 'returns a hash with an ETH balance' do - expect(address.list_balances).to eq(eth: BigDecimal('1')) - end - end - - describe '#get_balance' do - before do - allow(client).to receive(:eth_getBalance).with(address_id, 'latest').and_return('0xde0b6b3a7640000') - end - - it 'returns the correct ETH balance' do - expect(address.get_balance(:eth)).to eq BigDecimal('1') - end - - it 'returns the correct Gwei balance' do - expect(address.get_balance(:gwei)).to eq BigDecimal('1_000_000_000') - end - - it 'returns the correct Wei balance' do - expect(address.get_balance(:wei)).to eq BigDecimal('1_000_000_000_000_000_000') - end - - it 'returns 0 for an unsupported asset' do - expect(address.get_balance(:uni)).to eq BigDecimal('0') - end - end - - describe '#transfer' do - let(:amount) { 500_000_000_000_000_000 } - let(:asset_id) { :wei } - let(:to_key) { Eth::Key.new } - let(:to_address_id) { to_key.address.to_s } - let(:transaction_hash) { '0xdeadbeef' } - let(:raw_signed_transaction) { '0123456789abcdef' } - let(:transaction) { double('Transaction', sign: transaction_hash, hex: raw_signed_transaction) } - let(:transfer) do - double('Transfer', transaction: transaction) - end - - before do - allow(client).to receive(:eth_getBalance).with(address_id, 'latest').and_return('0xde0b6b3a7640000') - allow(Coinbase::Transfer).to receive(:new).and_return(transfer) - allow(client).to receive(:eth_sendRawTransaction).with("0x#{raw_signed_transaction}").and_return(transaction_hash) - end - - # TODO: Add test case for when the destination is a Wallet. - - context 'when the destination is a valid Address' do - let(:destination) { described_class.new(network_id, to_address_id, wallet_id, to_key, client: client) } - - it 'creates a Transfer' do - expect(address.transfer(amount, asset_id, destination)).to eq(transfer) - end - end - - context 'when the destination is a valid Address ID' do - let(:destination) { to_address_id } - - it 'creates a Transfer' do - expect(address.transfer(amount, asset_id, destination)).to eq(transfer) - end - end - - context 'when the asset is unsupported' do - it 'raises an ArgumentError' do - expect { address.transfer(amount, :uni, to_address_id) }.to raise_error(ArgumentError, 'Unsupported asset: uni') - end - end - - # TODO: Add test case for when the destination is a Wallet. - - context 'when the destination Address is on a different network' do - it 'raises an ArgumentError' do - expect do - address.transfer(amount, asset_id, Coinbase::Address.new(:different_network, to_address_id, wallet_id, - to_key, client: client)) - end.to raise_error(ArgumentError, 'Transfer must be on the same Network') - end - end - - context 'when the balance is insufficient' do - before do - allow(client).to receive(:eth_getBalance).with(address_id, 'latest').and_return('0x0') - end - - it 'raises an ArgumentError' do - expect do - address.transfer(amount, asset_id, to_address_id) - end.to raise_error(ArgumentError, "Insufficient funds: #{amount} requested, but only 0.0 available") - end - end - end - - describe '#to_s' do - it 'returns the address as a string' do - expect(address.to_s).to eq(address_id) - end - end -end diff --git a/spec/coinbase/wallet_spec.rb b/spec/coinbase/wallet_spec.rb deleted file mode 100644 index 54f61223..00000000 --- a/spec/coinbase/wallet_spec.rb +++ /dev/null @@ -1,164 +0,0 @@ -# frozen_string_literal: true - -describe Coinbase::Wallet do - let(:client) { double('Jimson::Client') } - subject(:wallet) { described_class.new(client: client) } - - describe '#initialize' do - it 'initializes a new Wallet' do - expect(wallet).to be_a(Coinbase::Wallet) - end - - context 'when a seed is provided' do - let(:seed) { '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f' } - let(:seed_wallet) { described_class.new(seed: seed, client: client) } - - it 'initializes a new Wallet with the provided seed' do - expect(seed_wallet).to be_a(Coinbase::Wallet) - end - - it 'raises an error for an invalid seed' do - expect do - described_class.new(seed: 'invalid', client: client) - end.to raise_error(ArgumentError, 'Seed must be 32 bytes') - end - end - - context 'when the address count is provided' do - let(:address_count) { 5 } - let(:address_wallet) { described_class.new(address_count: address_count, client: client) } - - it 'initializes a new Wallet with the provided address count' do - expect(address_wallet.list_addresses.length).to eq(address_count) - end - - it 'raises an error for a negative address count' do - expect do - described_class.new(address_count: -1, client: client) - end.to raise_error(ArgumentError, 'Address count must be positive') - end - end - end - - describe '#create_address' do - it 'creates a new address' do - address = wallet.create_address - expect(address).to be_a(Coinbase::Address) - expect(wallet.list_addresses.length).to eq(2) - expect(address).not_to eq(wallet.default_address) - end - end - - describe '#default_address' do - it 'returns the first address' do - expect(wallet.default_address).to eq(wallet.list_addresses.first) - end - end - - describe '#get_address' do - it 'returns the correct address' do - default_address = wallet.default_address - expect(wallet.get_address(default_address.address_id)).to eq(default_address) - end - end - - describe '#list_addresses' do - it 'contains one address' do - expect(wallet.list_addresses.length).to eq(1) - end - end - - describe '#list_balances' do - before do - expect(wallet.default_address).to receive(:list_balances).and_return({ eth: BigDecimal(1) }) - end - - it 'returns a hash with an ETH balance' do - expect(wallet.list_balances).to eq({ eth: BigDecimal(1) }) - end - end - - describe '#get_balance' do - before do - expect(wallet.default_address).to receive(:list_balances).and_return({ eth: BigDecimal(5) }) - end - - it 'returns the correct ETH balance' do - expect(wallet.get_balance(:eth)).to eq(BigDecimal(5)) - end - - it 'returns the correct Gwei balance' do - expect(wallet.get_balance(:gwei)).to eq(BigDecimal(5 * Coinbase::GWEI_PER_ETHER)) - end - - it 'returns the correct Wei balance' do - expect(wallet.get_balance(:wei)).to eq(BigDecimal(5 * Coinbase::WEI_PER_ETHER)) - end - end - - describe '#transfer' do - let(:transfer) { double('Coinbase::Transfer') } - let(:amount) { 5 } - let(:asset_id) { :eth } - - context 'when the destination is a Wallet' do - let(:destination) { described_class.new(client: client) } - let(:to_address_id) { destination.default_address.address_id } - - before do - expect(wallet.default_address).to receive(:transfer).with(amount, asset_id, to_address_id).and_return(transfer) - end - - it 'creates a transfer to the default address ID' do - expect(wallet.transfer(amount, asset_id, destination)).to eq(transfer) - end - end - - context 'when the desination is an Address' do - let(:destination) { wallet.create_address } - let(:to_address_id) { destination.address_id } - - before do - expect(wallet.default_address).to receive(:transfer).with(amount, asset_id, to_address_id).and_return(transfer) - end - - it 'creates a transfer to the address ID' do - expect(wallet.transfer(amount, asset_id, destination)).to eq(transfer) - end - end - - context 'when the destination is a String' do - let(:destination) { '0x1234567890' } - - before do - expect(wallet.default_address).to receive(:transfer).with(amount, asset_id, destination).and_return(transfer) - end - - it 'creates a transfer to the address ID' do - expect(wallet.transfer(amount, asset_id, destination)).to eq(transfer) - end - end - end - - describe '#export' do - let(:seed) { '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f' } - let(:address_count) { 5 } - let(:seed_wallet) { described_class.new(seed: seed, address_count: address_count, client: client) } - - it 'exports the Wallet data' do - wallet_data = seed_wallet.export - expect(wallet_data).to be_a(Coinbase::Wallet::WalletData) - expect(wallet_data.seed).to eq(seed) - expect(wallet_data.address_count).to eq(address_count) - end - - it 'allows for re-creation of a Wallet' do - wallet_data = seed_wallet.export - new_wallet = described_class.new(seed: wallet_data.seed, address_count: wallet_data.address_count, client: client) - expect(new_wallet.list_addresses.length).to eq(address_count) - new_wallet.list_addresses.each_with_index do |address, i| - expect(address.address_id).to eq(seed_wallet.list_addresses[i].address_id) - end - end - end -end diff --git a/spec/coinbase_spec.rb b/spec/coinbase_spec.rb deleted file mode 100644 index 0e1d33ac..00000000 --- a/spec/coinbase_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -describe Coinbase do - describe '#base_sepolia_rpc_url' do - it 'returns the Base Sepolia RPC URL' do - expect(Coinbase.base_sepolia_rpc_url).to eq('https://sepolia.base.org') - end - end - - describe '#base_sepolia_rpc_url=' do - it 'sets the Base Sepolia RPC URL' do - Coinbase.base_sepolia_rpc_url = 'https://not-sepolia.base.org' - expect(Coinbase.base_sepolia_rpc_url).to eq('https://not-sepolia.base.org') - end - end -end diff --git a/spec/e2e/production.rb b/spec/e2e/production.rb new file mode 100644 index 00000000..0e7fee33 --- /dev/null +++ b/spec/e2e/production.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'dotenv' +Dotenv.load + +describe Coinbase do + describe 'v0.0.2 SDK' do + it 'behaves as expected' do + # GitHub secrets truncate newlines as whitespace, so we need to replace them. + # See https://github.com/github/docs/issues/14207 + api_key_name = ENV['API_KEY_NAME'].gsub('\n', "\n") + api_key_private_key = ENV['API_KEY_PRIVATE_KEY'].gsub('\n', "\n") + Coinbase.configure do |config| + config.api_key_name = api_key_name + config.api_key_private_key = api_key_private_key + end + + puts 'Fetching default user...' + u = Coinbase.default_user + expect(u).not_to be_nil + puts "Fetched default user with ID: #{u.user_id}" + + puts 'Creating new wallet...' + w1 = u.create_wallet + expect(w1).not_to be_nil + puts "Created new wallet with ID: #{w1.wallet_id}, default address: #{w1.default_address}" + + puts 'Importing wallet with balance...' + data_string = ENV['WALLET_DATA'] + data_hash = JSON.parse(data_string) + data = Coinbase::Wallet::Data.from_hash(data_hash) + w2 = u.import_wallet(data) + expect(w2).not_to be_nil + puts "Imported wallet with ID: #{w2.wallet_id}, default address: #{w2.default_address}" + + puts 'Listing addresses...' + addresses = w2.list_addresses + expect(addresses.length).to be > 1 + puts "Listed addresses: #{addresses.map(&:to_s).join(', ')}" + + puts 'Fetching balances...' + balances = w2.list_balances + expect(balances.length).to be >= 1 + puts "Fetched balances: #{balances}" + + puts 'Transfering 1 Gwei from default address to second address...' + a1 = addresses[0] + a2 = addresses[1] + t = a1.transfer(1, :gwei, a2).wait! + expect(t.status).to eq(:complete) + puts "Transferred 1 Gwei from #{a1} to #{a2}" + + puts 'Fetching updated balances...' + first_balance = a1.list_balances + second_balance = a2.list_balances + expect(first_balance[:eth]).to be > BigDecimal('0') + expect(second_balance[:eth]).to be > BigDecimal('0') + puts "First address balances: #{first_balance}" + puts "Second address balances: #{second_balance}" + end + end +end diff --git a/spec/fixtures/cdp_api_key.json b/spec/fixtures/cdp_api_key.json new file mode 100644 index 00000000..77787117 --- /dev/null +++ b/spec/fixtures/cdp_api_key.json @@ -0,0 +1,4 @@ +{ + "name": "organizations/e0716da6-47ce-4c68-b3da-d551b5a8671b/apiKeys/3688b1ac-d453-42db-814e-c425746dc967", + "privateKey": "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIFxG95q+feSkhWSnAKze+rWB3eo7oDNYKXpkiX45h3QcoAoGCCqGSM49\nAwEHoUQDQgAEyVDroLdmHJEpDAzJX6YJYQjMiWGYzEdDzu2TNyVUAP6w4ayA8qGe\nuJROGr7n7QT7MGg/IaA+MkhqO7lhgWLw2A==\n-----END EC PRIVATE KEY-----\n" +} \ No newline at end of file diff --git a/spec/unit/coinbase/address_spec.rb b/spec/unit/coinbase/address_spec.rb new file mode 100644 index 00000000..14cd026e --- /dev/null +++ b/spec/unit/coinbase/address_spec.rb @@ -0,0 +1,311 @@ +# frozen_string_literal: true + +describe Coinbase::Address do + let(:key) { Eth::Key.new } + let(:network_id) { :base_sepolia } + let(:address_id) { key.address.to_s } + let(:wallet_id) { SecureRandom.uuid } + let(:model) do + Coinbase::Client::Address.new({ + 'network_id' => 'base-sepolia', + 'address_id' => address_id, + 'wallet_id' => wallet_id, + 'public_key' => key.public_key.compressed.unpack1('H*') + }) + end + let(:addresses_api) { double('Coinbase::Client::AddressesApi') } + let(:transfers_api) { double('Coinbase::Client::TransfersApi') } + let(:client) { double('Jimson::Client') } + + before(:each) do + allow(Coinbase.configuration).to receive(:base_sepolia_client).and_return(client) + allow(Coinbase::Client::AddressesApi).to receive(:new).and_return(addresses_api) + allow(Coinbase::Client::TransfersApi).to receive(:new).and_return(transfers_api) + end + + subject(:address) do + described_class.new(model, key) + end + + describe '#initialize' do + it 'initializes a new Address' do + expect(address).to be_a(Coinbase::Address) + end + end + + describe '#network_id' do + it 'returns the network ID' do + expect(address.network_id).to eq(network_id) + end + end + + describe '#address_id' do + it 'returns the address ID' do + expect(address.address_id).to eq(address_id) + end + end + + describe '#wallet_id' do + it 'returns the wallet ID' do + expect(address.wallet_id).to eq(wallet_id) + end + end + + describe '#list_balances' do + let(:response) do + Coinbase::Client::AddressBalanceList.new( + 'data' => [ + Coinbase::Client::Balance.new( + { + 'amount' => '1000000000000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'eth', + 'decimals': 18 + }) + } + ), + Coinbase::Client::Balance.new( + { + 'amount' => '5000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'usdc', + 'decimals': 6 + }) + } + ) + ] + ) + end + + it 'returns a hash with balances' do + expect(addresses_api) + .to receive(:list_address_balances) + .with(wallet_id, address_id) + .and_return(response) + expect(address.list_balances).to eq(eth: BigDecimal('1'), usdc: BigDecimal('5000')) + end + end + + describe '#get_balance' do + let(:response) do + Coinbase::Client::Balance.new( + { + 'amount' => '1000000000000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'eth', + 'decimals': 18 + }) + } + ) + end + + it 'returns the correct ETH balance' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(response) + expect(address.get_balance(:eth)).to eq BigDecimal('1') + end + + it 'returns the correct Gwei balance' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(response) + expect(address.get_balance(:gwei)).to eq BigDecimal('1_000_000_000') + end + + it 'returns the correct Wei balance' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(response) + expect(address.get_balance(:wei)).to eq BigDecimal('1_000_000_000_000_000_000') + end + + it 'returns 0 for an unsupported asset' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'uni') + .and_return(nil) + expect(address.get_balance(:uni)).to eq BigDecimal('0') + end + end + + describe '#transfer' do + let(:eth_balance_response) do + Coinbase::Client::Balance.new( + { + 'amount' => '1000000000000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'eth', + 'decimals': 18 + }) + } + ) + end + let(:usdc_balance_response) do + Coinbase::Client::Balance.new( + { + 'amount' => '10000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'usdc', + 'decimals': 6 + }) + } + ) + end + let(:to_key) { Eth::Key.new } + let(:to_address_id) { to_key.address.to_s } + let(:transaction_hash) { '0xdeadbeef' } + let(:raw_signed_transaction) { '0123456789abcdef' } + let(:transaction) { double('Transaction', sign: transaction_hash, hex: raw_signed_transaction) } + let(:transfer) do + double('Transfer', transaction: transaction) + end + + before do + allow(Coinbase::Transfer).to receive(:new).and_return(transfer) + allow(client).to receive(:eth_sendRawTransaction).with("0x#{raw_signed_transaction}").and_return(transaction_hash) + end + + # TODO: Add test case for when the destination is a Wallet. + + context 'when the destination is a valid Address' do + let(:asset_id) { :wei } + let(:amount) { 500_000_000_000_000_000 } + let(:destination) { described_class.new(model, to_key) } + let(:create_transfer_request) do + { amount: amount.to_s, network_id: network_id, asset_id: 'eth', destination: destination.address_id } + end + + it 'creates a Transfer' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(eth_balance_response) + expect(transfers_api) + .to receive(:create_transfer) + .with(wallet_id, address_id, create_transfer_request) + expect(address.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the destination is a valid Address and asset is USDC' do + let(:asset_id) { :usdc } + let(:usdc_amount) { 5 } + let(:usdc_atomic_amount) { 5_000_000 } + let(:destination) { described_class.new(model, to_key) } + let(:create_transfer_request) do + { amount: usdc_atomic_amount.to_s, network_id: network_id, asset_id: 'usdc', + destination: destination.address_id } + end + + it 'creates a Transfer' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'usdc') + .and_return(usdc_balance_response) + expect(transfers_api) + .to receive(:create_transfer) + .with(wallet_id, address_id, create_transfer_request) + expect(address.transfer(usdc_amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the destination is a valid Address ID' do + let(:asset_id) { :wei } + let(:amount) { 500_000_000_000_000_000 } + let(:destination) { to_address_id } + let(:create_transfer_request) do + { amount: amount.to_s, network_id: network_id, asset_id: 'eth', destination: to_address_id } + end + it 'creates a Transfer' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(eth_balance_response) + expect(transfers_api) + .to receive(:create_transfer) + .with(wallet_id, address_id, create_transfer_request) + expect(address.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the destination is a valid Address ID and asset is Gwei' do + let(:asset_id) { :gwei } + let(:amount) { 500_000_000 } + let(:wei_amount) { 500_000_000_000_000_000 } + let(:destination) { to_address_id } + let(:create_transfer_request) do + { amount: wei_amount.to_s, network_id: network_id, asset_id: 'eth', destination: to_address_id } + end + it 'creates a Transfer' do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(eth_balance_response) + expect(transfers_api) + .to receive(:create_transfer) + .with(wallet_id, address_id, create_transfer_request) + expect(address.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the asset is unsupported' do + let(:amount) { 500_000_000_000_000_000 } + it 'raises an ArgumentError' do + expect { address.transfer(amount, :uni, to_address_id) }.to raise_error(ArgumentError, 'Unsupported asset: uni') + end + end + + # TODO: Add test case for when the destination is a Wallet. + + context 'when the destination Address is on a different network' do + let(:asset_id) { :wei } + let(:amount) { 500_000_000_000_000_000 } + let(:new_model) do + Coinbase::Client::Address.new({ + 'network_id' => 'base-mainnet', + 'address_id' => address_id, + 'wallet_id' => wallet_id, + 'public_key' => key.public_key.compressed.unpack1('H*') + }) + end + + it 'raises an ArgumentError' do + expect do + address.transfer(amount, asset_id, Coinbase::Address.new(new_model, to_key)) + end.to raise_error(ArgumentError, 'Transfer must be on the same Network') + end + end + + context 'when the balance is insufficient' do + let(:asset_id) { :wei } + let(:excessive_amount) { 9_000_000_000_000_000_000_000 } + before do + expect(addresses_api) + .to receive(:get_address_balance) + .with(wallet_id, address_id, 'eth') + .and_return(eth_balance_response) + end + + it 'raises an ArgumentError' do + expect do + address.transfer(excessive_amount, asset_id, to_address_id) + end.to raise_error(ArgumentError) + end + end + end + + describe '#to_s' do + it 'returns the address as a string' do + expect(address.to_s).to eq(address_id) + end + end +end diff --git a/spec/unit/coinbase/authenticator_spec.rb b/spec/unit/coinbase/authenticator_spec.rb new file mode 100644 index 00000000..f6e119ad --- /dev/null +++ b/spec/unit/coinbase/authenticator_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +describe Coinbase::Authenticator do + let(:app) { double('Faraday::Connection') } + let(:authenticator) { described_class.new(app) } + let(:data) { JSON.parse(File.read('spec/fixtures/cdp_api_key.json')) } + let(:api_key_name) { data['name'] } + let(:api_key_private_key) { data['privateKey'] } + + before do + allow(Coinbase.configuration).to receive(:api_key_name).and_return(api_key_name) + allow(Coinbase.configuration).to receive(:api_key_private_key).and_return(api_key_private_key) + end + + describe '#call' do + let(:env) { double('Faraday::Env') } + + it 'adds the JWT to the Authorization header' do + allow(env).to receive(:method).and_return('GET') + allow(env).to receive(:url).and_return(URI('https://cdp.api.coinbase.com/v1/users/me')) + allow(env).to receive(:request_headers).and_return({}) + expect(app).to receive(:call) do |env| + expect(env.request_headers['Authorization']).to start_with('Bearer ') + end + + authenticator.call(env) + end + end + + describe '#build_jwt' do + let(:uri) { 'https://cdp.api.coinbase.com/v1/users/me' } + + it 'builds a JWT for the given endpoint URI' do + jwt = authenticator.build_jwt(uri) + + expect(jwt).to be_a(String) + end + end +end diff --git a/spec/coinbase/network_spec.rb b/spec/unit/coinbase/network_spec.rb similarity index 100% rename from spec/coinbase/network_spec.rb rename to spec/unit/coinbase/network_spec.rb diff --git a/spec/coinbase/transfer_spec.rb b/spec/unit/coinbase/transfer_spec.rb similarity index 60% rename from spec/coinbase/transfer_spec.rb rename to spec/unit/coinbase/transfer_spec.rb index 33ddc9e5..e4c6673f 100644 --- a/spec/coinbase/transfer_spec.rb +++ b/spec/unit/coinbase/transfer_spec.rb @@ -6,23 +6,63 @@ let(:network_id) { :base_sepolia } let(:wallet_id) { SecureRandom.uuid } let(:from_address_id) { from_key.address.to_s } - let(:amount) { 5 } + let(:amount) { BigDecimal(100) } + let(:eth_amount) { amount / BigDecimal(Coinbase::WEI_PER_ETHER.to_s) } let(:to_address_id) { to_key.address.to_s } + let(:transfer_id) { SecureRandom.uuid } + let(:unsigned_payload) do \ + '7b2274797065223a22307832222c22636861696e4964223a2230783134613334222c226e6f6e63' \ +'65223a22307830222c22746f223a22307834643965346633663464316138623566346637623166' \ +'356235633762386436623262336231623062222c22676173223a22307835323038222c22676173' \ +'5072696365223a6e756c6c2c226d61785072696f72697479466565506572476173223a223078' \ +'3539363832663030222c226d6178466565506572476173223a2230783539363832663030222c22' \ +'76616c7565223a2230783536626337356532643633313030303030222c22696e707574223a22' \ +'3078222c226163636573734c697374223a5b5d2c2276223a22307830222c2272223a2230783022' \ +'2c2273223a22307830222c2279506172697479223a22307830222c2268617368223a2230783664' \ +'633334306534643663323633653363396561396135656438646561346332383966613861363966' \ +'3031653635393462333732386230386138323335333433227d' + end + let(:model) do + Coinbase::Client::Transfer.new({ + 'network_id' => network_id, + 'wallet_id' => wallet_id, + 'address_id' => from_address_id, + 'destination' => to_address_id, + 'asset_id' => 'eth', + 'amount' => amount.to_s, + 'transfer_id' => transfer_id, + 'status' => 'pending', + 'unsigned_payload' => unsigned_payload + }) + end + let(:transfers_api) { double('Coinbase::Client::TransfersApi') } let(:client) { double('Jimson::Client') } + before(:each) do + configuration = double(Coinbase::Configuration) + allow(Coinbase).to receive(:configuration).and_return(configuration) + allow(configuration).to receive(:base_sepolia_client).and_return(client) + end + subject(:transfer) do - described_class.new(network_id, wallet_id, from_address_id, amount, :eth, to_address_id, client: client) + described_class.new(model) end describe '#initialize' do it 'initializes a new Transfer' do expect(transfer).to be_a(Coinbase::Transfer) end + end + + describe '#transfer_id' do + it 'returns the transfer ID' do + expect(transfer.transfer_id).to eq(transfer_id) + end + end - it 'does not initialize a new transfer for an invalid asset' do - expect do - Coinbase::Transfer.new(network_id, wallet_id, from_address_id, amount, :uni, to_address_id, client: client) - end.to raise_error(ArgumentError, 'Unsupported asset: uni') + describe '#unsigned_payload' do + it 'returns the unsigned payload' do + expect(transfer.unsigned_payload).to eq(unsigned_payload) end end @@ -46,41 +86,7 @@ describe '#amount' do it 'returns the amount' do - expect(transfer.amount).to eq(amount) - end - - context 'when the amount is a Float' do - let(:float_amount) { 0.5 } - let(:float_transfer) do - described_class.new(network_id, wallet_id, from_address_id, float_amount, :eth, to_address_id, client: client) - end - - it 'normalizes the amount' do - expect(float_transfer.amount).to eq(BigDecimal('0.5')) - end - end - - context 'when the amount is an Integer' do - let(:integer_amount) { 5 } - let(:integer_transfer) do - described_class.new(network_id, wallet_id, from_address_id, integer_amount, :eth, to_address_id, client: client) - end - - it 'normalizes the amount' do - expect(integer_transfer.amount).to eq(BigDecimal('5')) - end - end - - context 'when the amount is a BigDecimal' do - let(:big_decimal_amount) { BigDecimal('0.5') } - let(:big_decimal_transfer) do - described_class.new(network_id, wallet_id, from_address_id, big_decimal_amount, :eth, to_address_id, - client: client) - end - - it 'normalizes the amount' do - expect(big_decimal_transfer.amount).to eq(big_decimal_amount) - end + expect(transfer.amount).to eq(eth_amount) end end @@ -90,30 +96,54 @@ end end - describe '#to_address_id' do + describe '#destination_address_id' do it 'returns the destination address ID' do - expect(transfer.to_address_id).to eq(to_address_id) + expect(transfer.destination_address_id).to eq(to_address_id) end end describe '#transaction' do - before do - allow(client).to receive(:eth_getTransactionCount).with(from_address_id, 'latest').and_return('0x7') - allow(client).to receive(:eth_gasPrice).and_return('0x7b') - end - it 'returns the Transfer transaction' do expect(transfer.transaction).to be_a(Eth::Tx::Eip1559) expect(transfer.transaction.amount).to eq(amount * Coinbase::WEI_PER_ETHER) end - end - describe '#transaction_hash' do - before do - allow(client).to receive(:eth_getTransactionCount).with(from_address_id, 'latest').and_return('0x7') - allow(client).to receive(:eth_gasPrice).and_return('0x7b') + context 'when the transaction is for an ERC-20' do + let(:usdc_unsigned_payload) do + '7b2274797065223a22307832222c22636861696e4964223a2230783134613334222c226e6f6e6365223a22307830222c22746f223a22' \ + '307830333663626435333834326335343236363334653739323935343165633233313866336463663765222c22676173223a22307831' \ + '38366130222c226761735072696365223a6e756c6c2c226d61785072696f72697479466565506572476173223a223078353936383266' \ + '3030222c226d6178466565506572476173223a2230783539363832663030222c2276616c7565223a22307830222c22696e707574223a' \ + '223078613930353963626230303030303030303030303030303030303030303030303034643965346633663464316138623566346637' \ + '623166356235633762386436623262336231623062303030303030303030303030303030303030303030303030303030303030303030' \ + '30303030303030303030303030303030303030303030303030303030303031222c226163636573734c697374223a5b5d2c2276223a22' \ + '307830222c2272223a22307830222c2273223a22307830222c2279506172697479223a22307830222c2268617368223a223078316365' \ + '386164393935306539323437316461666665616664653562353836373938323430663630303138336136363365393661643738383039' \ + '66643965303666227d' + end + + let(:usdc_model) do + Coinbase::Client::Transfer.new({ + 'address_id' => from_address_id, + 'destination' => to_address_id, + 'unsigned_payload' => usdc_unsigned_payload + }) + end + let(:usdc_transfer) do + described_class.new(usdc_model) + end + + it 'returns the Transfer transaction' do + expect(usdc_transfer.transaction).to be_a(Eth::Tx::Eip1559) + expect(usdc_transfer.transaction.amount).to eq(BigDecimal('0')) + expect(usdc_transfer.transaction.chain_id).to eq(84_532) + expect(usdc_transfer.transaction.max_fee_per_gas).to eq(1_500_000_000) + expect(usdc_transfer.transaction.max_priority_fee_per_gas).to eq(1_500_000_000) + end end + end + describe '#transaction_hash' do context 'when the transaction has been signed' do it 'returns the transaction hash' do transfer.transaction.sign(from_key) @@ -136,11 +166,6 @@ end describe '#status' do - before do - allow(client).to receive(:eth_getTransactionCount).with(from_address_id, 'latest').and_return('0x7') - allow(client).to receive(:eth_gasPrice).and_return('0x7b') - end - context 'when the transaction has not been created' do it 'returns PENDING' do expect(transfer.status).to eq(Coinbase::Transfer::Status::PENDING) @@ -226,8 +251,6 @@ describe '#wait!' do before do - allow(client).to receive(:eth_getTransactionCount).with(from_address_id, 'latest').and_return('0x7') - allow(client).to receive(:eth_gasPrice).and_return('0x7b') # TODO: This isn't working for some reason. allow(transfer).to receive(:sleep) end diff --git a/spec/unit/coinbase/user_spec.rb b/spec/unit/coinbase/user_spec.rb new file mode 100644 index 00000000..54d3f52d --- /dev/null +++ b/spec/unit/coinbase/user_spec.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +describe Coinbase::User do + let(:user_id) { SecureRandom.uuid } + let(:model) { Coinbase::Client::User.new({ 'id': user_id }) } + let(:wallets_api) { instance_double(Coinbase::Client::WalletsApi) } + let(:addresses_api) { instance_double(Coinbase::Client::AddressesApi) } + let(:user) { described_class.new(model) } + let(:transfers_api) { instance_double(Coinbase::Client::TransfersApi) } + + describe '#user_id' do + it 'returns the user ID' do + expect(user.user_id).to eq(user_id) + end + end + + describe '#create_wallet' do + let(:wallet_id) { SecureRandom.uuid } + let(:network_id) { 'base-sepolia' } + let(:create_wallet_request) { { wallet: { network_id: network_id } } } + let(:opts) { { create_wallet_request: create_wallet_request } } + let(:wallet_model) { Coinbase::Client::Wallet.new({ 'id': wallet_id, 'network_id': network_id }) } + let(:wallet_model_with_default_address) do + Coinbase::Client::Wallet.new( + { + 'id': wallet_id, + 'network_id': 'base-sepolia', + 'default_address': Coinbase::Client::Address.new({ + 'address_id': '0xdeadbeef', + 'wallet_id': wallet_id, + 'public_key': '0x1234567890', + 'network_id': 'base-sepolia' + }) + } + ) + end + + before do + allow(Coinbase::Client::AddressesApi).to receive(:new).and_return(addresses_api) + allow(Coinbase::Client::WalletsApi).to receive(:new).and_return(wallets_api) + expect(wallets_api).to receive(:create_wallet).with(opts).and_return(wallet_model) + expect(addresses_api) + .to receive(:create_address) + .with(wallet_id, satisfy do |opts| + public_key_present = opts[:create_address_request][:public_key].is_a?(String) + attestation_present = opts[:create_address_request][:attestation].is_a?(String) + public_key_present && attestation_present + end) + expect(wallets_api).to receive(:get_wallet).with(wallet_id).and_return(wallet_model_with_default_address) + end + + it 'creates a new wallet' do + wallet = user.create_wallet + expect(wallet).to be_a(Coinbase::Wallet) + expect(wallet.wallet_id).to eq(wallet_id) + expect(wallet.network_id).to eq(:base_sepolia) + end + end + + describe '#import_wallet' do + let(:client) { double('Jimson::Client') } + let(:wallet_id) { SecureRandom.uuid } + let(:wallet_model) { Coinbase::Client::Wallet.new({ 'id': wallet_id, 'network_id': 'base-sepolia' }) } + let(:wallets_api) { double('Coinbase::Client::WalletsApi') } + let(:network_id) { 'base-sepolia' } + let(:create_wallet_request) { { wallet: { network_id: network_id } } } + let(:opts) { { create_wallet_request: create_wallet_request } } + let(:addresses_api) { double('Coinbase::Client::AddressesApi') } + let(:address_model) do + Coinbase::Client::Address.new({ + 'address_id': '0xdeadbeef', + 'wallet_id': wallet_id, + 'public_key': '0x1234567890', + 'network_id': 'base-sepolia' + }) + end + let(:wallet_model_with_default_address) do + Coinbase::Client::Wallet.new( + { + 'id': wallet_id, + 'network_id': 'base-sepolia', + 'default_address': address_model + } + ) + end + let(:address_list_model) do + Coinbase::Client::AddressList.new({ 'data' => [address_model], 'total_count' => 1 }) + end + let(:wallet_export_data) do + Coinbase::Wallet::Data.new( + wallet_id: wallet_id, + seed: MoneyTree::Master.new.seed_hex + ) + end + subject(:imported_wallet) { user.import_wallet(wallet_export_data) } + + before do + allow(Coinbase::Client::AddressesApi).to receive(:new).and_return(addresses_api) + allow(Coinbase::Client::WalletsApi).to receive(:new).and_return(wallets_api) + expect(wallets_api).to receive(:get_wallet).with(wallet_id).and_return(wallet_model_with_default_address) + expect(addresses_api).to receive(:list_addresses).with(wallet_id).and_return(address_list_model) + expect(addresses_api).to receive(:get_address).and_return(address_model) + end + + it 'imports an exported wallet' do + expect(imported_wallet.wallet_id).to eq(wallet_id) + end + + it 'loads the wallet addresses' do + expect(imported_wallet.list_addresses.length).to eq(address_list_model.total_count) + end + + it 'contains the same seed when re-exported' do + expect(imported_wallet.export.seed).to eq(wallet_export_data.seed) + end + end + + describe '#list_wallet_ids' do + let(:wallet_ids) { [SecureRandom.uuid, SecureRandom.uuid] } + let(:data) do + wallet_ids.map { |id| Coinbase::Client::Wallet.new({ 'id': id, 'network_id': 'base-sepolia' }) } + end + let(:wallet_list) { Coinbase::Client::WalletList.new({ 'data' => data }) } + it 'lists the wallet IDs' do + allow(Coinbase::Client::WalletsApi).to receive(:new).and_return(wallets_api) + expect(wallets_api).to receive(:list_wallets).and_return(wallet_list) + expect(user.list_wallet_ids).to eq(wallet_ids) + end + end +end diff --git a/spec/unit/coinbase/wallet_spec.rb b/spec/unit/coinbase/wallet_spec.rb new file mode 100644 index 00000000..047874ce --- /dev/null +++ b/spec/unit/coinbase/wallet_spec.rb @@ -0,0 +1,275 @@ +# frozen_string_literal: true + +describe Coinbase::Wallet do + let(:client) { double('Jimson::Client') } + let(:wallet_id) { SecureRandom.uuid } + let(:model) { Coinbase::Client::Wallet.new({ 'id': wallet_id, 'network_id': 'base-sepolia' }) } + let(:address_model) do + Coinbase::Client::Address.new({ + 'address_id': '0xdeadbeef', + 'wallet_id': wallet_id, + 'public_key': '0x1234567890', + 'network_id': 'base-sepolia' + }) + end + let(:model_with_default_address) do + Coinbase::Client::Wallet.new( + { + 'id': wallet_id, + 'network_id': 'base-sepolia', + 'default_address': address_model + } + ) + end + let(:wallets_api) { double('Coinbase::Client::WalletsApi') } + let(:addresses_api) { double('Coinbase::Client::AddressesApi') } + let(:transfers_api) { double('Coinbase::Client::TransfersApi') } + + before do + allow(Coinbase::Client::AddressesApi).to receive(:new).and_return(addresses_api) + allow(Coinbase::Client::WalletsApi).to receive(:new).and_return(wallets_api) + allow(addresses_api).to receive(:create_address).and_return(address_model) + allow(addresses_api).to receive(:get_address).and_return(address_model) + allow(wallets_api).to receive(:get_wallet).with(wallet_id).and_return(model_with_default_address) + @wallet = described_class.new(model) + end + + describe '#initialize' do + context 'when no seed or address count is provided' do + it 'initializes a new Wallet' do + expect(addresses_api) + .to receive(:create_address) + .with(wallet_id, satisfy do |opts| + public_key_present = opts[:create_address_request][:public_key].is_a?(String) + attestation_present = opts[:create_address_request][:attestation].is_a?(String) + public_key_present && attestation_present + end) + @wallet = described_class.new(model) + expect(@wallet).to be_a(Coinbase::Wallet) + end + end + + context 'when a seed is provided' do + let(:seed) { '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f' } + let(:seed_wallet) { described_class.new(model, seed: seed) } + + it 'initializes a new Wallet with the provided seed' do + expect(addresses_api) + .to receive(:create_address) + .with(wallet_id, satisfy do |opts| + public_key_present = opts[:create_address_request][:public_key].is_a?(String) + attestation_present = opts[:create_address_request][:attestation].is_a?(String) + public_key_present && attestation_present + end) + .and_return(address_model) + expect(seed_wallet).to be_a(Coinbase::Wallet) + end + + it 'raises an error for an invalid seed' do + expect do + described_class.new(model, seed: 'invalid') + end.to raise_error(ArgumentError, 'Seed must be 32 bytes') + end + end + + context 'when the address count is provided' do + let(:address_count) { 5 } + let(:address_wallet) do + described_class.new(model, address_count: address_count) + end + + it 'initializes a new Wallet with the provided address count' do + expect(addresses_api).to receive(:get_address).exactly(address_count).times + expect(address_wallet.list_addresses.length).to eq(address_count) + end + end + end + + describe '#wallet_id' do + it 'returns the Wallet ID' do + expect(@wallet.wallet_id).to eq(wallet_id) + end + end + + describe '#network_id' do + it 'returns the Network ID' do + expect(@wallet.network_id).to eq(:base_sepolia) + end + end + + describe '#create_address' do + it 'creates a new address' do + expect(addresses_api) + .to receive(:create_address) + .with(wallet_id, satisfy do |opts| + public_key_present = opts[:create_address_request][:public_key].is_a?(String) + attestation_present = opts[:create_address_request][:attestation].is_a?(String) + public_key_present && attestation_present + end) + .and_return(address_model) + .exactly(1).times + address = @wallet.create_address + expect(address).to be_a(Coinbase::Address) + expect(@wallet.list_addresses.length).to eq(2) + expect(address).not_to eq(@wallet.default_address) + end + end + + describe '#default_address' do + it 'returns the first address' do + expect(@wallet.default_address).to eq(@wallet.list_addresses.first) + end + end + + describe '#get_address' do + before do + allow(addresses_api).to receive(:create_address).and_return(address_model) + end + + it 'returns the correct address' do + default_address = @wallet.default_address + expect(@wallet.get_address(default_address.address_id)).to eq(default_address) + end + end + + describe '#list_addresses' do + it 'contains one address' do + expect(@wallet.list_addresses.length).to eq(1) + end + end + + describe '#list_balances' do + let(:response) do + Coinbase::Client::AddressBalanceList.new( + 'data' => [ + Coinbase::Client::Balance.new( + { + 'amount' => '1000000000000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'eth', + 'decimals': 18 + }) + } + ), + Coinbase::Client::Balance.new( + { + 'amount' => '5000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'usdc', + 'decimals': 6 + }) + } + ) + ] + ) + end + before do + expect(wallets_api).to receive(:list_wallet_balances).and_return(response) + end + + it 'returns a hash with an ETH and USDC balance' do + expect(@wallet.list_balances).to eq({ eth: BigDecimal(1), usdc: BigDecimal(5) }) + end + end + + describe '#get_balance' do + let(:response) do + Coinbase::Client::Balance.new( + { + 'amount' => '5000000000000000000', + 'asset' => Coinbase::Client::Asset.new({ + 'network_id': 'base-sepolia', + 'asset_id': 'eth', + 'decimals': 18 + }) + } + ) + end + + before do + expect(wallets_api).to receive(:get_wallet_balance).with(wallet_id, 'eth').and_return(response) + end + + it 'returns the correct ETH balance' do + expect(@wallet.get_balance(:eth)).to eq(BigDecimal(5)) + end + + it 'returns the correct Gwei balance' do + expect(@wallet.get_balance(:gwei)).to eq(BigDecimal(5 * Coinbase::GWEI_PER_ETHER)) + end + + it 'returns the correct Wei balance' do + expect(@wallet.get_balance(:wei)).to eq(BigDecimal(5 * Coinbase::WEI_PER_ETHER)) + end + end + + describe '#transfer' do + let(:transfer) { double('Coinbase::Transfer') } + let(:amount) { 5 } + let(:asset_id) { :eth } + + context 'when the destination is a Wallet' do + let(:destination) { described_class.new(model) } + let(:to_address_id) { destination.default_address.address_id } + + before do + expect(@wallet.default_address).to receive(:transfer).with(amount, asset_id, to_address_id).and_return(transfer) + end + + it 'creates a transfer to the default address ID' do + expect(@wallet.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the desination is an Address' do + let(:destination) { @wallet.create_address } + let(:to_address_id) { destination.address_id } + + before do + expect(@wallet.default_address).to receive(:transfer).with(amount, asset_id, to_address_id).and_return(transfer) + end + + it 'creates a transfer to the address ID' do + expect(@wallet.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + + context 'when the destination is a String' do + let(:destination) { '0x1234567890' } + + before do + expect(@wallet.default_address).to receive(:transfer).with(amount, asset_id, destination).and_return(transfer) + end + + it 'creates a transfer to the address ID' do + expect(@wallet.transfer(amount, asset_id, destination)).to eq(transfer) + end + end + end + + describe '#export' do + let(:seed) { '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f' } + let(:address_count) { 5 } + let(:seed_wallet) do + described_class.new(model, seed: seed, address_count: address_count) + end + + it 'exports the Wallet data' do + wallet_data = seed_wallet.export + expect(wallet_data).to be_a(Coinbase::Wallet::Data) + expect(wallet_data.wallet_id).to eq(seed_wallet.wallet_id) + expect(wallet_data.seed).to eq(seed) + end + + it 'allows for re-creation of a Wallet' do + wallet_data = seed_wallet.export + new_wallet = described_class.new(model, seed: wallet_data.seed, address_count: address_count) + expect(new_wallet.list_addresses.length).to eq(address_count) + new_wallet.list_addresses.each_with_index do |address, i| + expect(address.address_id).to eq(seed_wallet.list_addresses[i].address_id) + end + end + end +end diff --git a/spec/unit/coinbase_spec.rb b/spec/unit/coinbase_spec.rb new file mode 100644 index 00000000..ca78c9b1 --- /dev/null +++ b/spec/unit/coinbase_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +describe Coinbase do + describe '#configure' do + let(:api_key_private_key) { 'some-key' } + let(:api_key_name) { 'some-key-name' } + + subject do + Coinbase.configure do |config| + config.api_key_private_key = api_key_private_key + config.api_key_name = api_key_name + end + end + + context 'when api_key_private_key is nil' do + let(:api_key_private_key) { nil } + it 'raises an exception' do + expect { subject }.to raise_error(Coinbase::InvalidConfiguration, /API key private key/) + end + end + + context 'when api_key_name is nil' do + let(:api_key_name) { nil } + it 'raises an exception' do + expect { subject }.to raise_error(Coinbase::InvalidConfiguration, /API key name/) + end + end + end + + describe '#default_user' do + let(:users_api) { double Coinbase::Client::UsersApi } + let(:user_model) { double 'User Model' } + + before(:each) do + allow(Coinbase::Client::UsersApi).to receive(:new).and_return(users_api) + allow(users_api).to receive(:get_current_user).and_return(user_model) + allow(Coinbase::User).to receive(:new) + end + + it 'creates a new users api client' do + Coinbase.default_user + expect(Coinbase::Client::UsersApi).to have_received(:new).with(Coinbase.configuration.api_client) + end + + it 'gets the current user from the api' do + Coinbase.default_user + expect(users_api).to have_received(:get_current_user) + end + + it 'creates a new user object from the response' do + Coinbase.default_user + expect(Coinbase::User).to have_received(:new).with(user_model) + end + end + + describe Coinbase::Configuration do + describe '#api_url' do + it 'returns the default api url' do + expect(Coinbase.configuration.api_url).to eq 'https://api.cdp.coinbase.com' + end + end + + describe '#base_sepolia_rpc_url' do + it 'returns the default base sepolia rpc url' do + expect(Coinbase.configuration.base_sepolia_rpc_url).to eq 'https://sepolia.base.org' + end + end + end +end