mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
28 lines
728 B
Ruby
28 lines
728 B
Ruby
class Api::Admin::CustomerSerializer < ActiveModel::Serializer
|
|
attributes :id, :email, :enterprise_id, :user_id, :code, :tags, :tag_list, :name
|
|
attributes :allow_charges, :default_card_present?
|
|
|
|
has_one :ship_address, serializer: Api::AddressSerializer
|
|
has_one :bill_address, serializer: Api::AddressSerializer
|
|
|
|
def tag_list
|
|
object.tag_list.join(",")
|
|
end
|
|
|
|
def name
|
|
object.name.presence || object.bill_address.andand.full_name
|
|
end
|
|
|
|
def tags
|
|
object.tag_list.map do |tag|
|
|
tag_rule_map = options[:tag_rule_mapping].andand[tag]
|
|
tag_rule_map || { text: tag, rules: nil }
|
|
end
|
|
end
|
|
|
|
def default_card_present?
|
|
return unless object.user
|
|
object.user.default_card.present?
|
|
end
|
|
end
|