Files
openfoodnetwork/app/serializers/api/v1/address_serializer.rb
Maikel Linke 6c0d4cffe5 Allow customer's address update with country code
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.
2022-07-19 09:49:42 +10:00

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