Module: Koala::TyphoeusService

Defined in:
lib/koala/http_services.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

this service uses Typhoeus to send requests to the graph



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/koala/http_services.rb', line 69

def self.included(base)
  base.class_eval do
    require 'typhoeus' unless defined?(Typhoeus)
    include Typhoeus

    def self.make_request(path, args, verb, options = {})
      # if the verb isn't get or post, send it as a post argument
      args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
      server = options[:rest_api] ? Facebook::REST_SERVER : Facebook::GRAPH_SERVER
      response = self.send(verb, "https://#{server}/#{path}", :params => args)
      Koala::Response.new(response.code, response.body, response.headers_hash)
    end
  end # class_eval
end