Class: Sdp::Balance

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdp/resources/wallets.rb

Overview

Token balance row from GET /v1/payments/wallets/:id/balances. amount is base units (string); ui_amount is the decimal string. usd_value is passed through when SDP includes it and is nil otherwise (varies across SDP versions) — nil means “no price”, never zero.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#amountObject

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def amount
  @amount
end

#decimalsObject

Returns the value of attribute decimals

Returns:

  • (Object)

    the current value of decimals



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def decimals
  @decimals
end

#mintObject

Returns the value of attribute mint

Returns:

  • (Object)

    the current value of mint



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def mint
  @mint
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def token
  @token
end

#ui_amountObject

Returns the value of attribute ui_amount

Returns:

  • (Object)

    the current value of ui_amount



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def ui_amount
  @ui_amount
end

#usd_valueObject

Returns the value of attribute usd_value

Returns:

  • (Object)

    the current value of usd_value



10
11
12
# File 'lib/sdp/resources/wallets.rb', line 10

def usd_value
  @usd_value
end

Class Method Details

.from_hash(hash) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sdp/resources/wallets.rb', line 11

def self.from_hash(hash)
  hash ||= {}
  new(
    token: hash[:token],
    mint: hash[:mint],
    amount: hash[:amount],
    ui_amount: hash[:ui_amount],
    decimals: hash[:decimals],
    usd_value: hash[:usd_value]
  )
end