Sha256: 7a6045357ba3bf9bd53950e015c176d16444f82302f06cae42ba6554d9d11323

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

require 'dry-validation'

module Fawry
  module Contracts
    class DeleteTokenRequestContract < Dry::Validation::Contract
      params do
        required(:merchant_code).value(:string)
        required(:customer_profile_id).value(:string)
        required(:fawry_secure_key).value(:string)
        required(:card_token).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

2 entries across 2 versions & 1 rubygems

Version Path
fawry-1.2.1 lib/fawry/contracts/delete_token_request_contract.rb
fawry-1.1.1 lib/fawry/contracts/delete_token_request_contract.rb