Module: Bobot::GraphFacebook::ClassMethods
- Defined in:
- lib/bobot/graph_facebook.rb
Class Method Summary collapse
- .graph_delete(path, query: {}, body: {}) ⇒ Object
- .graph_get(path, query: {}) ⇒ Object
- .graph_post(path, query: {}, body: {}) ⇒ Object
Class Method Details
.graph_delete(path, query: {}, body: {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bobot/graph_facebook.rb', line 43 def graph_delete(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze response = ::Typhoeus::Request.delete( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: ActiveSupport::JSON.encode(body), headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = ActiveSupport::JSON.decode(response.send(:body) || '{}') Rails.logger.debug "[DELETE] >> #{url}" Rails.logger.debug "[DELETE] << #{json}" Bobot::ErrorParser.raise_errors_from(json) json end |
.graph_get(path, query: {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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) || '{}') Rails.logger.debug "[GET] >> #{url}" Rails.logger.debug "[GET] << #{json}" Bobot::ErrorParser.raise_errors_from(json) json end |
.graph_post(path, query: {}, body: {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bobot/graph_facebook.rb', line 26 def graph_post(path, query: {}, body: {}) url = "#{GRAPH_FB_URL}#{path}".freeze response = ::Typhoeus::Request.post( url, params: URI.encode_www_form(query.reverse_merge(include_headers: false)), body: ActiveSupport::JSON.encode(body), headers: GRAPH_HEADERS, ssl_verifypeer: false, ) json = ActiveSupport::JSON.decode(response.send(:body) || '{}') Rails.logger.debug "[POST] >> #{url}" Rails.logger.debug "[POST] << #{json}" Bobot::ErrorParser.raise_errors_from(json) json end |