Class: WackyGraph::GraphRequest
- Inherits:
-
Object
- Object
- WackyGraph::GraphRequest
- Defined in:
- lib/wacky_graph/request.rb
Instance Attribute Summary collapse
-
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
Instance Method Summary collapse
- #get(path, options = {}) ⇒ Object
-
#initialize(oauth_token) ⇒ GraphRequest
constructor
A new instance of GraphRequest.
- #post(path, params) ⇒ Object
Constructor Details
#initialize(oauth_token) ⇒ GraphRequest
Returns a new instance of GraphRequest.
10 11 12 |
# File 'lib/wacky_graph/request.rb', line 10 def initialize(oauth_token) @oauth_token = oauth_token end |
Instance Attribute Details
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
8 9 10 |
# File 'lib/wacky_graph/request.rb', line 8 def oauth_token @oauth_token end |
Instance Method Details
#get(path, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wacky_graph/request.rb', line 14 def get(path, = {}) uri = build_uri(path, ) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) data = JSON.parse(response.body) case response when Net::HTTPOK return data when Net::HTTPBadRequest exception = GraphError.new(data["error"]["message"], data["error"]["type"], data["error"]["code"], data["error"]["error_subcode"]) raise exception else raise "Unhandled response from Facebook Graph API" end end |
#post(path, params) ⇒ Object
32 33 34 |
# File 'lib/wacky_graph/request.rb', line 32 def post(path, params) end |