Class: Coinbase::Wallet::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/coinbase/wallet/data.rb

Overview

The data required to recreate a Wallet.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wallet_id:, seed:, network_id: nil) ⇒ Data

Returns a new Data object.

Parameters:

  • wallet_id (String)

    The ID of the Wallet

  • seed (String)

    The seed of the Wallet

  • network_id (String, nil) (defaults to: nil)

    The network ID of the Wallet (optional)



13
14
15
16
17
# File 'lib/coinbase/wallet/data.rb', line 13

def initialize(wallet_id:, seed:, network_id: nil)
  @wallet_id = wallet_id
  @seed = seed
  @network_id = network_id
end

Instance Attribute Details

#network_idObject (readonly)

Returns the value of attribute network_id.



7
8
9
# File 'lib/coinbase/wallet/data.rb', line 7

def network_id
  @network_id
end

#seedObject (readonly)

Returns the value of attribute seed.



7
8
9
# File 'lib/coinbase/wallet/data.rb', line 7

def seed
  @seed
end

#wallet_idObject (readonly)

Returns the value of attribute wallet_id.



7
8
9
# File 'lib/coinbase/wallet/data.rb', line 7

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



28
29
30
# File 'lib/coinbase/wallet/data.rb', line 28

def self.from_hash(data)
  Data.new(wallet_id: data['wallet_id'], seed: data['seed'], network_id: data['network_id'])
end

Instance Method Details

#to_hashHash

Converts the Data object to a Hash.

Returns:

  • (Hash)

    The Hash representation of the Data object



21
22
23
# File 'lib/coinbase/wallet/data.rb', line 21

def to_hash
  { wallet_id: wallet_id, seed: seed, network_id: network_id }
end