module MangoPay::FilterParameters

Public Class Methods

request(body) click to toggle source
# File lib/mangopay/filter_parameters.rb, line 4
def self.request(body)
  begin
    body = JSON.load(body)
  rescue MultiJson::LoadError => e
    return body
  end
  filter_hash(body, req_confidential_params)
  JSON.dump(body)
end
response(body) click to toggle source
# File lib/mangopay/filter_parameters.rb, line 14
def self.response(body)
  return '' if body.to_s.empty?

  begin
    body = JSON.load(body)
  rescue MultiJson::LoadError => e
    return body
  end
  filter_hash(body, res_confidential_params)
  JSON.dump(body)
end

Private Class Methods

filter_hash(hash, to_filter) click to toggle source
# File lib/mangopay/filter_parameters.rb, line 28
def self.filter_hash(hash, to_filter)
  hash.each do |k,v|
    if v.is_a?(Hash)
      filter_hash(v, to_filter)
    else
      hash[k] = '[FILTERED]' if to_filter.include?(k)
    end
  end
end
req_confidential_params() click to toggle source
# File lib/mangopay/filter_parameters.rb, line 48
def self.req_confidential_params
  @@req_confidential_params ||= [
    'File', 'IBAN', 'OwnerName', 'OwnerAddress', 'BIC', 'FirstName',
    'LastName', 'Email', 'AddressLine1', 'AddressLine2',
  ].freeze
end
res_confidential_params() click to toggle source
# File lib/mangopay/filter_parameters.rb, line 38
def self.res_confidential_params
  @@res_confidential_params ||= [
    'access_token', 'AccessKey', 'IBAN', 'CardRegistrationURL',
    'PreregistrationData', 'RedirectURL', 'RegistrationData',
    'SecureModeRedirectUrl', 'OwnerName', 'OwnerAddress', 'BIC',
    'FirstName', 'LastName', 'Email', 'AddressLine1',
    'AddressLine2',
  ].freeze
end