Class: GlobeSSL::AccountBalance

Inherits:
Base
  • Object
show all
Defined in:
lib/globessl/account_balance.rb

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#fetchObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/globessl/account_balance.rb', line 7

def fetch
  @errors.clear
  
  response = Client.get('/account/balance')
  
  case response.code
  when '200'  
    json = response.body
    hash = JSON.parse(json)

    @balance  = hash["balance"]
    @currency = hash["currency"]
    
    return true
  when '400', '401', '403'
    set_errors(response)
    return false
  else
    return false
  end
end

#set_errors(response) ⇒ Object



29
30
31
32
33
# File 'lib/globessl/account_balance.rb', line 29

def set_errors(response)
  json = response.body
  hash = JSON.parse(json)
  @errors << hash["message"]
end