Class: Milo::Main

Inherits:
Object
  • Object
show all
Includes:
Product
Defined in:
lib/milo/main.rb

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Product

#get_product_by_id, #get_product_by_postal_code, #get_product_by_upc

Constructor Details

#initialize(key, options = {}) ⇒ Main

Returns a new instance of Main.



6
7
8
9
# File 'lib/milo/main.rb', line 6

def initialize(key, options = {})
  @key = key
  @options = options
end

Instance Attribute Details

#main_urlObject

Returns the value of attribute main_url.



3
4
5
# File 'lib/milo/main.rb', line 3

def main_url
  @main_url
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/milo/main.rb', line 4

def response
  @response
end

#response_rawObject (readonly)

Returns the value of attribute response_raw.



4
5
6
# File 'lib/milo/main.rb', line 4

def response_raw
  @response_raw
end

Instance Method Details

#make_request(end_url) ⇒ Object



15
16
17
18
19
20
# File 'lib/milo/main.rb', line 15

def make_request(end_url)
  result_key = "&key=#{@key}"
  curl = Curl::Easy.perform(main_url + end_url + result_key)
  response = Response.new(curl)
  JSON.parse(response.body)
end