Sha256: 4df608f040c3b4a78677fbb1d4332d152ceabfbf1e4d9471addcab56763967aa

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

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