Class: Retailigence::Base
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Retailigence::Base
show all
- Defined in:
- lib/retailigence/base.rb
Class Method Summary
collapse
Class Method Details
.apikey ⇒ Object
12
13
14
|
# File 'lib/retailigence/base.rb', line 12
def self.apikey
@@apikey
end
|
.apikey=(key) ⇒ Object
8
9
10
|
# File 'lib/retailigence/base.rb', line 8
def self.apikey=(key)
@@apikey = key
end
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/retailigence/base.rb', line 16
def self.perform_graph_request(endpoint, params={}, method="get")
require 'net/http'
require 'nori'
@query_string = "?"
@query_string += "apikey=#{apikey}"
if method=="get"
params.each{|key, val| @query_string += "&#{key}=#{val}"}
url = URI.parse("#{self.site}#{endpoint}#{@query_string}")
request = Net::HTTP::Get.new("#{url.path}?#{url.query}",{"Content-Type"=>"text/xml"})
else
url = URI.parse("#{self.site}#{endpoint}#{@query_string}")
request = Net::HTTP::Post.new("#{url.path}?#{url.query}",{"Content-Type"=>"text/xml"})
request.set_form_data(params)
end
http = Net::HTTP.new(url.host, url.port)
response = ::Nori.parse(http.start {|http| http.request(request)}.body)
response
end
|