Add payments data, reformat dates

This commit is contained in:
stveep
2016-01-01 09:37:21 -05:00
parent f9435a3c34
commit 6992d66202
2 changed files with 18 additions and 2 deletions

View File

@@ -1,8 +1,10 @@
class Api::OrderSerializer < ActiveModel::Serializer
attributes :id, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money
attributes :id, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money, :payments
has_many :payments, serializer: Api::PaymentSerializer
def completed_at
object.completed_at.blank? ? "" : object.completed_at.strftime("%F %T")
object.completed_at.blank? ? "" : object.completed_at.to_formatted_s(:long_ordinal)
end
def total_money

View File

@@ -0,0 +1,14 @@
class Api::PaymentSerializer < ActiveModel::Serializer
attributes :identifier, :amount, :updated_at, :payment_method
def payment_method
object.payment_method.name
end
def amount
object.amount.to_money.to_s
end
def updated_at
object.updated_at.to_formatted_s(:long_ordinal)
end
end