Class: GlobeSSL::DomainEmails

Inherits:
Base
  • Object
show all
Defined in:
lib/globessl/domain_emails.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
28
29
30
# File 'lib/globessl/domain_emails.rb', line 7

def fetch
  @errors.clear
  @list.clear
  
  unless @domain
    @errors << "domain is required"
    return false
  end
  
  response = Client.get('/tools/domainemails', { 'domain' => @domain })
  
  case response.code
  when '200'  
    json = response.body
    hash = JSON.parse(json)
    hash.each { |email| @list << email }
    return true
  when '400', '401', '403'
    set_errors(response)
    return false
  else
    return false
  end
end

#set_errors(response) ⇒ Object



32
33
34
35
36
# File 'lib/globessl/domain_emails.rb', line 32

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