Publish phone numbers as objects

The standard introduced this a while ago but I didn't notice.

We have to update integrations like Disco Regen now.
This commit is contained in:
Maikel Linke
2025-11-24 16:43:33 +11:00
parent 2e09a96c4b
commit 5f237adda2
2 changed files with 18 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ class EnterpriseBuilder < DfcBuilder
catalogItems: catalog_items,
emails: [enterprise.email_address].compact,
localizations: [address],
phoneNumbers: [enterprise.phone].compact,
phoneNumbers: phone_numbers(enterprise),
socialMedias: SocialMediaBuilder.social_medias(enterprise),
logo: enterprise.logo_url(:small),
mainContact: contact(enterprise),
@@ -71,4 +71,15 @@ class EnterpriseBuilder < DfcBuilder
lastName:, # rubocop:disable Naming/VariableName
)
end
def self.phone_numbers(enterprise)
return [] if enterprise.phone.blank?
number = DataFoodConsortium::Connector::PhoneNumber.new(
nil,
phoneNumber: enterprise.phone,
)
[number]
end
end

View File

@@ -435,7 +435,9 @@ paths:
- "@id": http://test.host/api/dfc/enterprises/10000
"@type": dfc-b:Enterprise
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
dfc-b:hasPhoneNumber: 0404 444 000 200
dfc-b:hasPhoneNumber:
"@type": dfc-b:PhoneNumber
dfc-b:phoneNumber: 0404 444 000 200
dfc-b:email: hello@example.org
dfc-b:websitePage: https://openfoodnetwork.org
dfc-b:hasSocialMedia: http://test.host/api/dfc/enterprises/10000/social_medias/facebook
@@ -520,7 +522,9 @@ paths:
- "@id": http://test.host/api/dfc/enterprises/10000
"@type": dfc-b:Enterprise
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
dfc-b:hasPhoneNumber: 0404 444 000 200
dfc-b:hasPhoneNumber:
"@type": dfc-b:PhoneNumber
dfc-b:phoneNumber: 0404 444 000 200
dfc-b:email: hello@example.org
dfc-b:websitePage: https://openfoodnetwork.org
dfc-b:hasSocialMedia: http://test.host/api/dfc/enterprises/10000/social_medias/facebook