class GlobeSSL::Products
Public Instance Methods
fetch()
click to toggle source
# File lib/globessl/products.rb, line 6 def fetch @errors.clear @list.clear response = Client.get('/products/list') case response.code when '200' json = response.body hash = JSON.parse(json) collection = hash["products"].inject([]) { |memo, element| memo << element.last } collection.each do |product| @list << Product.new( :id => product["id"], :name => product["name"], :validation => product["validation"], :wildcard => product["wildcard"], :multi_domain => product["mdc"], :min_domains => product["mdc_min"], :max_domains => product["mdc_max"], :brand => product["brand"] ) end return true when '400', '401', '403' set_errors(response) return false else return false end end
set_errors(response)
click to toggle source
# File lib/globessl/products.rb, line 40 def set_errors(response) json = response.body hash = JSON.parse(json) @errors << hash["message"] end