Class: AmazonPay::Sanitize
- Inherits:
-
Object
- Object
- AmazonPay::Sanitize
- Defined in:
- lib/amazon_pay/sanitize.rb
Instance Method Summary collapse
-
#initialize(input_data) ⇒ Sanitize
constructor
A new instance of Sanitize.
- #sanitize_request_data ⇒ Object
- #sanitize_response_data ⇒ Object
Constructor Details
#initialize(input_data) ⇒ Sanitize
Returns a new instance of Sanitize.
3 4 5 |
# File 'lib/amazon_pay/sanitize.rb', line 3 def initialize(input_data) @copy = input_data ? input_data.dup : '' end |
Instance Method Details
#sanitize_request_data ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/amazon_pay/sanitize.rb', line 7 def sanitize_request_data # Array of item to remove patterns = %w[ Buyer PhysicalDestination BillingAddress AuthorizationBillingAddress SellerNote SellerAuthorizationNote SellerCaptureNote SellerRefundNote ] patterns.each do |s| @copy.gsub!(/([?|&]#{s}=)[^\&]+/ms, s + '=*REMOVED*') end @copy end |
#sanitize_response_data ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/amazon_pay/sanitize.rb', line 28 def sanitize_response_data # Array of item to remove patterns = [] patterns.push(/(?<=<Buyer>).*(?=<\/Buyer>)/s) patterns.push(/(?<=<PhysicalDestination>).*(?=<\/PhysicalDestination>)/ms) patterns.push(/(?<=<BillingAddress>).*(?=<\/BillingAddress>)/s) patterns.push(/(?<=<SellerNote>).*(?=<\/SellerNote>)/s) patterns.push(/(?<=<AuthorizationBillingAddress>).*(?=<\/AuthorizationBillingAddress>)/s) patterns.push(/(?<=<SellerAuthorizationNote>).*(?=<\/SellerAuthorizationNote>)/s) patterns.push(/(?<=<SellerCaptureNote>).*(?=<\/SellerCaptureNote>)/s) patterns.push(/(?<=<SellerRefundNote>).*(?=<\/SellerRefundNote>)/s) patterns.each do |s| @copy.gsub!(s, '*REMOVED*') end @copy end |