Method: ZipMoney::Checkout#validate
- Defined in:
- lib/zipMoney/api/checkout.rb
#validate ⇒ Object
Performs the parameters validation
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zipMoney/api/checkout.rb', line 34 def validate raise ArgumentError, "Params emtpy" if @params.nil? @errors = [] @errors << 'charge must be provided' if @params.charge.nil? @errors << 'currency_code must be provided' if @params.currency_code.nil? @errors << 'order_id must be provided' if @params.order_id.nil? @errors << 'order must be provided' if @params.order.nil? @errors << 'order.id must be provided' if @params.order.id.nil? @errors << 'order.total must be provided' if @params.order.total.nil? @errors << 'order.shipping_value must be provided' if @params.order.shipping_value.nil? @errors << 'order.tax must be provided' if @params.order.tax.nil? @errors << 'order detail must be provided' if @params.order.detail.nil? validate_item_details @params.order.detail raise ZipMoney::RequestError.new("Following error(s) occurred while making request, please resolve them to make the request: #{@errors}") if @errors.any? end |