Class: Fawry::Connection::ParamsSpecialEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/fawry/connection.rb

Overview

Fawry does not understand encoded params so we use this encoder to convert the params hash to a string of query params without encoding { a: 1, b: 2 } => a=1&b=2

Class Method Summary collapse

Class Method Details

.decode(string) ⇒ Object



70
71
72
73
# File 'lib/fawry/connection.rb', line 70

def self.decode(string)
  arr = string.split('&')
  arr.to_h { |str| str.split('=') }
end

.encode(hash) ⇒ Object



66
67
68
# File 'lib/fawry/connection.rb', line 66

def self.encode(hash)
  hash.each_with_object([]) { |(k, v), arr| arr << "#{k}=#{v}" }.join('&')
end