Add some basic attributes to address and order serializers that will be used in the order show api endpoint

This commit is contained in:
luisramos0
2019-09-17 14:32:00 +01:00
parent 69afcf7510
commit 6796d91a07
3 changed files with 8 additions and 2 deletions

View File

@@ -4,7 +4,11 @@ class Api::AddressSerializer < ActiveModel::Serializer
attributes :id, :zipcode, :city, :state_name, :state_id,
:phone, :firstname, :lastname, :address1, :address2, :city, :country_id,
:zipcode
:zipcode, :country_name
def country_name
object.country.andand.name
end
def state_name
object.state.andand.abbr

View File

@@ -1,8 +1,9 @@
class Api::Admin::OrderSerializer < ActiveModel::Serializer
attributes :id, :number, :full_name, :email, :phone, :completed_at, :display_total
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at, :display_total
attributes :edit_path, :state, :payment_state, :shipment_state
attributes :payments_path, :ship_path, :ready_to_ship, :created_at
attributes :distributor_name, :special_instructions, :payment_capture_path
attributes :item_total, :adjustment_total, :payment_total, :total
has_one :distributor, serializer: Api::Admin::IdSerializer
has_one :order_cycle, serializer: Api::Admin::IdSerializer

View File

@@ -1,6 +1,7 @@
module Api
class PaymentSerializer < ActiveModel::Serializer
attributes :amount, :updated_at, :payment_method, :state
def payment_method
object.payment_method.try(:name)
end