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