mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
The customer endpoint now serves 2-letter ISO codes for countries and accepts these for updates. It also serves and accepts region codes (abbreviations) like VIC for Victoria. Updates treat these fields as case-insensitive and either code or name have to be present. This commit also updates the Swagger documentation.
29 lines
687 B
Ruby
29 lines
687 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class AddressSerializer < BaseSerializer
|
|
attributes :phone, :latitude, :longitude
|
|
|
|
attribute :first_name, &:firstname
|
|
attribute :last_name, &:lastname
|
|
attribute :street_address_1, &:address1
|
|
attribute :street_address_2, &:address2
|
|
attribute :postal_code, &:zipcode
|
|
attribute :locality, &:city
|
|
attribute :region do |object|
|
|
{
|
|
name: object.state.name,
|
|
code: object.state.abbr,
|
|
}
|
|
end
|
|
attribute :country do |object|
|
|
{
|
|
name: object.country.name,
|
|
code: object.country.iso,
|
|
}
|
|
end
|
|
end
|
|
end
|
|
end
|