Class: Blupee::API::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/blupee/api/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Token

Returns a new instance of Token.



9
10
11
12
13
# File 'lib/blupee/api/token.rb', line 9

def initialize(attributes)
  @coin_symbol = attributes["coin_symbol"]
  @balance = attributes["balance"]
  @wallet_address = attributes["wallet_address"]
end

Instance Attribute Details

#balanceObject (readonly)

Returns the value of attribute balance.



7
8
9
# File 'lib/blupee/api/token.rb', line 7

def balance
  @balance
end

#coin_symbolObject (readonly)

Returns the value of attribute coin_symbol.



7
8
9
# File 'lib/blupee/api/token.rb', line 7

def coin_symbol
  @coin_symbol
end

#transaction_hashObject (readonly)

Returns the value of attribute transaction_hash.



7
8
9
# File 'lib/blupee/api/token.rb', line 7

def transaction_hash
  @transaction_hash
end

#walletObject (readonly)

Returns the value of attribute wallet.



7
8
9
# File 'lib/blupee/api/token.rb', line 7

def wallet
  @wallet
end

Class Method Details

.balance(args, options = {}) ⇒ Object

:wallet_address=>“”

Raises:



16
17
18
19
20
21
22
23
# File 'lib/blupee/api/token.rb', line 16

def self.balance(args, options = {})
  contract_id = args[:contract_id]
  wallet_address = args[:wallet_address]
  response = Blupee.make_request("/token/#{contract_id}/#{wallet_address}", {}, "get", {:use_ssl => true}.merge!(options))
  raise ServerError.new(response.status, response.body) if response.status >= 500
  raise OAuthTokenRequestError.new(response.status, response.body) if response.status >= 400
  response
end

.transfer(args, options = {}) ⇒ Object

:from_address=>“”, :password=>“”, :quantity=>0.001, :contract_address=>“”

Raises:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/blupee/api/token.rb', line 26

def self.transfer(args, options = {})
  response = Blupee.make_request("/token/send", 
                                 {}.merge!(args),
                                 "post",
                                 {:use_ssl => true,
                                  format: :json}.merge!(options))

  raise ServerError.new(response.status, response.body) if response.status >= 500
  raise OAuthTokenRequestError.new(response.status, response.body) if response.status >= 400
  response
end