Sha256: b2c3e30d4f7d0d0791eb5945ffd9af988cdef8334c23a4bd37861f57a63c7951

Contents?: true

Size: 547 Bytes

Versions: 5

Compression:

Stored size: 547 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

5 entries across 5 versions & 1 rubygems

Version Path
voucherify-2.1.1 lib/voucherify/service/validations.rb
voucherify-2.1.0 lib/voucherify/service/validations.rb
voucherify-2.0.0 lib/voucherify/service/validations.rb
voucherify-1.6.1 lib/voucherify/service/validations.rb
voucherify-1.6.0 lib/voucherify/service/validations.rb