Sha256: b93d09c2097813d1f809e8c3b5791e8608f3f2d56735ac326cd45afa05767fa5

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

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 Fawry.configuration.fawry_secure_key.nil? && ENV['FAWRY_SECURE_KEY'].nil? && value.nil?
          key(:fawry_secure_key)
            .failure('fawry secure key is required in either Fawry.configuration or'\
                     'as an environment variable (FAWRY_SECURE_KEY), or as an argument to this method')
        end
      end

      rule(:merchant_code) do
        if Fawry.configuration.fawry_merchant_code.nil? && ENV['FAWRY_MERCHANT_CODE'].nil? && value.nil?
          key(:merchant_code)
            .failure('fawry merchant code is required in either Fawry.configuration or'\
                     'as an environment variable (FAWRY_MERCHANT_CODE), or as an argument to this method')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fawry-1.4.1 lib/fawry/contracts/delete_token_request_contract.rb
fawry-1.4.0 lib/fawry/contracts/delete_token_request_contract.rb