lib/fawry/connection.rb in fawry-1.2.1 vs lib/fawry/connection.rb in fawry-1.3.0

- old
+ new

@@ -8,31 +8,36 @@ FAWRY_BASE_URL = 'https://www.atfawry.com/ECommerceWeb/Fawry/' FAWRY_SANDBOX_BASE_URL = 'https://atfawry.fawrystaging.com//ECommerceWeb/Fawry/' class << self + include Utils + def post(path, params, body, options) - conn = options[:sandbox] ? sandbox_connection : connection + sandbox = Fawry.configuration.sandbox || TRUTH_VALUES.include?(ENV.fetch('FAWRY_SANDBOX', options[:sandbox])) + conn = sandbox ? sandbox_connection : connection conn.post(path) do |request| request.params = params request.body = body.to_json end end def get(path, params, body, options) - conn = options[:sandbox] ? sandbox_connection : connection + sandbox = Fawry.configuration.sandbox || TRUTH_VALUES.include?(ENV.fetch('FAWRY_SANDBOX', options[:sandbox])) + conn = sandbox ? sandbox_connection : connection conn.get(path) do |request| request.params = params request.body = body.to_json # Fawry doesn't understand encoded params request.options = request.options.merge(params_encoder: ParamsSpecialEncoder) end end def delete(path, params, body, options) - conn = options[:sandbox] ? sandbox_connection : connection + sandbox = Fawry.configuration.sandbox || TRUTH_VALUES.include?(ENV.fetch('FAWRY_SANDBOX', options[:sandbox])) + conn = sandbox ? sandbox_connection : connection conn.delete(path) do |request| request.params = params request.body = body.to_json # Fawry doesn't understand encoded params