Sha256: 0156dc19c7087c78a96b946ead962c2658d7ce163fb7b3a5d004776cfdf2b91c

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

module Fulfillment
  module Models
    class Voucher < Model
      autoload :Deliverable, "fulfillment/models/deliverable"

      property :id, coerce: Integer
      property :order_id, coerce: Integer
      property :first_name
      property :last_name
      property :offer_name
      property :deliverable_id, coerce: Integer
      property :user_id, coerce: Integer
      property :redeemed
      property :redeemed_at
      property :code
      property :purchase_id, coerce: Integer
      property :procurement_data, coerce: Hash, default: {}
      property :fulfillment_data, coerce: Hash, default: {}
      property :deliverable, coerce: Models::Deliverable

      def code
        self[:code] || deliverable&.code
      end

      def redeemed
        !redeemed_at.nil? && !redeemed_at.empty?
      end
      alias_method :redeemed?, :redeemed
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fulfillment-api-1.1.9 lib/fulfillment/models/voucher.rb
fulfillment-api-1.1.7 lib/fulfillment/models/voucher.rb