module Fulfillment module Models class Order < Model autoload :Voucher, "fulfillment/models/voucher" property :id, coerce: Integer property :email property :first_name property :last_name property :purchase_id, coerce: Integer property :ticket_filename property :voucher_filename property :voucher_url property :confirmation_number property :user_id, coerce: Integer property :procurement_data, coerce: Hash, default: {} property :fulfillment_data, coerce: Hash, default: {} property :status property :note property :estimated_commission property :flagged property :marketing_opt_in property :partner property :releasable? property :vouchers, coerce: Array[Models::Voucher], default: [] def error_message procurement_data['error_message'] end def status return 'Failed' if !error_message.nil? return 'Flagged' if flagged? return 'Pending' if self[:status].nil? self[:status] end end end end