Class: GlobeSSL::Product

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

Instance Method Summary collapse

Methods inherited from Base

#inspect

Instance Method Details

#fetchObject



13
14
15
16
17
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
# File 'lib/globessl/product.rb', line 13

def fetch
  @errors.clear
  
  unless @id
    @errors << "product id is required"
    return false
  end
  
  response = Client.get('/products/details', { 'product_id' => @id })
  
  case response.code
  when '200'  
    json = response.body
    hash = JSON.parse(json)
    
    @name         = hash["name"]
    @validation   = hash["validation"]
    @wildcard     = hash["wildcard"] == 1 ? true : false
    @multi_domain = hash["mdc"] == 1 ? true : false
    @min_domains  = hash["mdc_min"]
    @max_domains  = hash["mdc_max"]
    @brand        = hash["brand"]
    
    return true
  when '400', '401', '403'
    set_errors(response)
    return false
  else
    return false
  end      
end

#set_errors(response) ⇒ Object



45
46
47
48
49
# File 'lib/globessl/product.rb', line 45

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