Class: GlobeSSL::AccountDetails

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

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#fetchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/globessl/account_details.rb', line 18

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

    @status        = hash["status"]
    @account_id    = hash["account_id"]
    @balance       = hash["balance"]
    @total_balance = hash["total_balance"]
    @account_type  = hash["account_type"]
    @email_address = hash["email"]
    @name          = hash["name"]
    @company       = hash["company"]
    @address       = hash["address"]
    @city          = hash["city"]
    @state         = hash["state"]
    @country       = hash["country"]
    @postal_code   = hash["postal_code"]
    
    return true
  when '400', '401', '403' 
    set_errors(response)
    return false
  else
    return false
  end
end

#set_errors(response) ⇒ Object



51
52
53
54
55
# File 'lib/globessl/account_details.rb', line 51

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