Class: SocialNet::Facebook::Api::Request
- Inherits:
-
Object
- Object
- SocialNet::Facebook::Api::Request
- Defined in:
- lib/social_net/facebook/api/request.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Request
constructor
A new instance of Request.
- #run ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 15 |
# File 'lib/social_net/facebook/api/request.rb', line 9 def initialize(attrs = {}) @host = 'graph.facebook.com' @query = attrs[:username] if attrs[:username] @access_token = attrs[:access_token] if attrs[:access_token] @path = attrs.fetch :path, "/v2.3/#{@query}" @method = attrs.fetch :method, :get end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/social_net/facebook/api/request.rb', line 17 def run #print "#{as_curl}\n" case response = run_http_request when Net::HTTPOK JSON.parse(response.body) else raise Errors::ResponseError, response end end |