module Bobot::GraphFacebook::ClassMethods
Public Class Methods
graph_delete(path, query: {}, body: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 50 def graph_delete(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze graph_body = ActiveSupport::JSON.encode(body) response = ::Typhoeus::Request.delete( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: graph_body, headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[DELETE] >> #{url}" Rails.logger.debug "[DELETE] << #{json}" end Bobot::ErrorParser.raise_errors_from(json, graph_body) json end
graph_get(path, query: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 10 def graph_get(path, query: {}) url = "#{GRAPH_FB_URL}#{path}".freeze response = ::Typhoeus::Request.get( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[GET] >> #{url}" Rails.logger.debug "[GET] << #{json}" end Bobot::ErrorParser.raise_errors_from(json) json end
graph_post(path, query: {}, body: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 29 def graph_post(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze graph_body = ActiveSupport::JSON.encode(body) response = ::Typhoeus::Request.post( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: graph_body, headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[POST] >> #{url}" Rails.logger.debug "[POST] << #{json}" end Bobot::ErrorParser.raise_errors_from(json, graph_body) json end
Private Instance Methods
graph_delete(path, query: {}, body: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 50 def graph_delete(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze graph_body = ActiveSupport::JSON.encode(body) response = ::Typhoeus::Request.delete( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: graph_body, headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[DELETE] >> #{url}" Rails.logger.debug "[DELETE] << #{json}" end Bobot::ErrorParser.raise_errors_from(json, graph_body) json end
graph_get(path, query: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 10 def graph_get(path, query: {}) url = "#{GRAPH_FB_URL}#{path}".freeze response = ::Typhoeus::Request.get( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[GET] >> #{url}" Rails.logger.debug "[GET] << #{json}" end Bobot::ErrorParser.raise_errors_from(json) json end
graph_post(path, query: {}, body: {})
click to toggle source
# File lib/bobot/graph_facebook.rb, line 29 def graph_post(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze graph_body = ActiveSupport::JSON.encode(body) response = ::Typhoeus::Request.post( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: graph_body, headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = (ActiveSupport::JSON.decode(response.send(:body) || '{}') rescue nil) Bobot::ErrorParser.raise_errors_from_html(response, graph_body) if json.nil? unless Rails.env.production? Rails.logger.debug "[POST] >> #{url}" Rails.logger.debug "[POST] << #{json}" end Bobot::ErrorParser.raise_errors_from(json, graph_body) json end