Sha256: 1d4c40d6147c9d87aa4f3cea5ed1993255d76ffc2ed48d2abb4b7cda40380405

Contents?: true

Size: 548 Bytes

Versions: 4

Compression:

Stored size: 548 Bytes

Contents

require 'uri'

module Voucherify
  module Service
    class Validations
      attr_reader :client

      def initialize(client)
        @client = client
      end

      def validate_voucher(code, context = {})
        @client.post("/vouchers/#{URI.encode(code)}/validate", context.to_json)
      end

      def validate(code, context = {})
        if code.is_a? Hash
          context = code
          return @client.promotions.validate(context)
        end
        @client.validations.validate_voucher(code, context)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voucherify-3.0.0 lib/voucherify/service/validations.rb
voucherify-2.4.0 lib/voucherify/service/validations.rb
voucherify-2.3.0 lib/voucherify/service/validations.rb
voucherify-2.2.0 lib/voucherify/service/validations.rb