lib/bobot/graph_facebook.rb in bobot-4.2.0 vs lib/bobot/graph_facebook.rb in bobot-4.3.0

- old
+ new

@@ -1,11 +1,11 @@ require "typhoeus" require "uri" module Bobot module GraphFacebook - GRAPH_FB_URL = 'https://graph.facebook.com/v2.11'.freeze + GRAPH_FB_URL = 'https://graph.facebook.com/v3.1'.freeze GRAPH_HEADERS = { Accept: "application/json", "Content-Type" => "application/json; charset=utf-8" }.freeze module ClassMethods def graph_get(path, query: {}) url = "#{GRAPH_FB_URL}#{path}".freeze @@ -14,12 +14,14 @@ 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}" + unless Rails.env.production? + Rails.logger.debug "[GET] >> #{url}" + Rails.logger.debug "[GET] << #{json}" + end Bobot::ErrorParser.raise_errors_from(json) json end module_function :graph_get @@ -31,12 +33,14 @@ 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}" + unless Rails.env.production? + Rails.logger.debug "[POST] >> #{url}" + Rails.logger.debug "[POST] << #{json}" + end Bobot::ErrorParser.raise_errors_from(json) json end module_function :graph_post @@ -48,11 +52,13 @@ 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}" + unless Rails.env.production? + Rails.logger.debug "[DELETE] >> #{url}" + Rails.logger.debug "[DELETE] << #{json}" + end Bobot::ErrorParser.raise_errors_from(json) json end module_function :graph_delete end