Sha256: 8373fe0d4ed50c5e4a23be871dfa36333a87e38946921dae1471cb48cbb20dcf

Contents?: true

Size: 769 Bytes

Versions: 3

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

require 'dry-validation'

module Fawry
  module Contracts
    class PaymentStatusRequestContract < Dry::Validation::Contract
      params do
        required(:merchant_ref_number).value(:string)
        optional(:merchant_code).value(:string)
        optional(:fawry_secure_key).value(:string)
      end

      rule(:fawry_secure_key) do
        if ENV['FAWRY_SECURE_KEY'].nil? && value.nil?
          key(:fawry_secure_key).failure('fawry secure key is required as a param or an env var')
        end
      end

      rule(:merchant_code) do
        if ENV['FAWRY_MERCHANT_CODE'].nil? && value.nil?
          key(:merchant_code).failure('fawry merchant code is required as a param or an env var')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fawry-1.2.1 lib/fawry/contracts/payment_status_request_contract.rb
fawry-1.1.1 lib/fawry/contracts/payment_status_request_contract.rb
fawry-1.0.0 lib/fawry/contracts/payment_status_request_contract.rb