mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
19 lines
522 B
Ruby
19 lines
522 B
Ruby
require 'open_food_network/last_used_address'
|
|
|
|
class Api::Admin::UserSerializer < ActiveModel::Serializer
|
|
attributes :id, :email
|
|
|
|
has_one :ship_address, serializer: Api::AddressSerializer
|
|
has_one :bill_address, serializer: Api::AddressSerializer
|
|
|
|
def ship_address
|
|
object.ship_address ||
|
|
OpenFoodNetwork::LastUsedAddress.new(object.email).last_used_ship_address
|
|
end
|
|
|
|
def bill_address
|
|
object.bill_address ||
|
|
OpenFoodNetwork::LastUsedAddress.new(object.email).last_used_bill_address
|
|
end
|
|
end
|