diff --git a/README.md b/README.md index c65cc05..0aea694 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ SDK Ruby de integração eRede. store = Erede::Models::Store.new store.token = '6069a026cf454706990a801ab5fe8e36' store.filiation = '73854967' +store.logger = Logger.new(STDOUT) store.environment = Erede::Environment.sandbox | Erede::Environment.production # Inicialização da SDK @@ -50,7 +51,7 @@ sdk.capture(capture_transaction) # POST /v1/transactions/{tid}/refunds # https://developer.userede.com.br/e-rede#swagger_operations-Cancelamento-cancelarTransacao callback_url = Erede::Models::Url.new -callback_url.kind = Erede::Models::Url::CALLBACK | Erede::Models::Url::THREE_D_SECURE_FAILURE | Erede::Models::Url::THREE_D_SECURE_SUCCESS +callback_url.kind = 'callback' callback_url.url = 'https://cliente.callback.com.br' cancel_transaction = Erede::Models::Transaction.new cancel_transaction.tid = 123 diff --git a/lib/erede/models/store.rb b/lib/erede/models/store.rb index b26d9e1..494d6b4 100644 --- a/lib/erede/models/store.rb +++ b/lib/erede/models/store.rb @@ -6,7 +6,8 @@ class Store < ::Erede::Models::Base :filiation ] - attr_accessor :environment + attr_accessor :environment, + :logger end end end diff --git a/lib/erede/services/base.rb b/lib/erede/services/base.rb index eb87174..6434467 100644 --- a/lib/erede/services/base.rb +++ b/lib/erede/services/base.rb @@ -25,10 +25,7 @@ def send_request(method, body = '') query_string = uri && uri.query && !uri.query.nil? && !uri.query.empty? ? "?#{uri.query}" : '' response = Net::HTTP.new(uri.host, uri.port) - .tap do |net_http| - net_http.use_ssl = uri.scheme == 'https' - net_http.set_debug_output($stdout) - end + .tap { |net_http| net_http.use_ssl = uri.scheme == 'https' } .request( method.new(uri.path + query_string, { 'Content-Type': 'application/json', 'Transaction-Response': 'brand-return-opened' }) .tap do |request| @@ -37,8 +34,12 @@ def send_request(method, body = '') end ) + if store.logger + store.logger.info("RedeRequest - #{method.to_s.split('::').last.upcase} #{uri} - Response #{response.code} #{response.body}") + end + Erede::Responses::EredeResponse.new.tap do |erede_response| - erede_response.code = response.code + erede_response.code = response.code erede_response.response = JSON.parse(response.body) end end