Class: RefundValidation
- Inherits:
-
Object
- Object
- RefundValidation
- Defined in:
- lib/util/validation/refund.rb
Class Method Summary collapse
Class Method Details
.create(data) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/util/validation/refund.rb', line 8 def self.create(data) # Validate charge format HelperValidation.validate_string_start(data[:charge_id], "chr") # Validate reason allowed_values = ['duplicado', 'fraudulento', 'solicitud_comprador'] HelperValidation.validate_value(data[:reason], allowed_values) # Validate amount amount = data[:amount] if amount.is_a?(String) begin amount = Integer(amount) print amount rescue ArgumentError raise CustomException.new("Invalid 'amount'. It should be an integer or a string representing an integer.") end end unless amount.is_a?(Integer) raise CustomException.new("Invalid 'amount'. It should be an integer or a string representing an integer.") end end |
.list(data) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/util/validation/refund.rb', line 33 def self.list(data) # Validate card_brand if data.key?('reason') allowed_brand_values = ['duplicado', 'fraudulento', 'solicitud_comprador'] Helpers.validate_value(data[:reason], allowed_brand_values) end # Validate date filter if data.key?('creation_date_from') && data.key?('creation_date_to') Helpers.validate_date_filter(data[:creation_date_from], data[:creation_date_to]) end end |