Files
openfoodnetwork/app/serializers/api/current_order_serializer.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

25 lines
669 B
Ruby

# frozen_string_literal: true
class Api::CurrentOrderSerializer < ActiveModel::Serializer
attributes :id, :item_total, :email, :shipping_method_id,
:display_total, :payment_method_id
has_one :bill_address, serializer: Api::AddressSerializer
has_one :ship_address, serializer: Api::AddressSerializer
has_many :line_items, serializer: Api::LineItemSerializer
has_many :finalised_line_items, serializer: Api::LineItemSerializer
def payment_method_id
object.payments.first.andand.payment_method_id
end
def shipping_method_id
object.shipping_method.andand.id
end
def display_total
object.display_total.money.to_f
end
end