Class: Bloopi::API::Ether

Inherits:
Object
  • Object
show all
Defined in:
lib/bloopi/api/ether.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Ether

Returns a new instance of Ether.



9
10
11
12
13
# File 'lib/bloopi/api/ether.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/bloopi/api/ether.rb', line 7

def balance
  @balance
end

#coin_symbolObject (readonly)

Returns the value of attribute coin_symbol.



7
8
9
# File 'lib/bloopi/api/ether.rb', line 7

def coin_symbol
  @coin_symbol
end

#transaction_hashObject (readonly)

Returns the value of attribute transaction_hash.



7
8
9
# File 'lib/bloopi/api/ether.rb', line 7

def transaction_hash
  @transaction_hash
end

#walletObject (readonly)

Returns the value of attribute wallet.



7
8
9
# File 'lib/bloopi/api/ether.rb', line 7

def wallet
  @wallet
end

Class Method Details

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

:wallet_address=>“”

Raises:



16
17
18
19
20
21
22
# File 'lib/bloopi/api/ether.rb', line 16

def self.balance(args, options = {})
  wallet_address = args[:wallet_address]
  response = Bloopi.make_request("/eth/#{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

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

Raises:



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bloopi/api/ether.rb', line 50

def self.exchange(args, options = {})
  response = Bloopi.make_request("/eth/exchange/omg", 
                                 {}.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

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

Raises:



25
26
27
28
29
30
31
32
33
34
# File 'lib/bloopi/api/ether.rb', line 25

def self.new_wallet(args, options = {})
  response = Bloopi.make_request("/eth/new",
                                 {}.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

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

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

Raises:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bloopi/api/ether.rb', line 37

def self.transfer(args, options = {})
  response = Bloopi.make_request("/eth/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