Replace country names with standard ISO code concepts

The DFC version 1.16.0 introduced this new standardisation.
This commit is contained in:
Maikel Linke
2025-11-24 16:59:41 +11:00
parent faf50a1922
commit 81165cd82b
3 changed files with 15 additions and 7 deletions

View File

@@ -7,10 +7,17 @@ class AddressBuilder < DfcBuilder
street: address.address1,
postalCode: address.zipcode,
city: address.city,
country: address.country.name,
country: country(address.country),
region: address.state.name,
latitude: address.latitude,
longitude: address.longitude,
)
end
# The country has to be a value of:
# https://publications.europa.eu/resource/authority/country/0001
def self.country(spree_country)
code = spree_country.iso3
"http://publications.europa.eu/resource/authority/country/#{code}"
end
end

View File

@@ -33,7 +33,8 @@ RSpec.describe AddressBuilder do
end
it "assigns a country" do
expect(result.country).to eq "Australia"
expect(result.country)
.to eq "http://publications.europa.eu/resource/authority/country/AUS"
end
it "assigns a region" do

View File

@@ -63,7 +63,7 @@ paths:
dfc-b:hasStreet: 10 Lovely Street
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
dfc-b:region: Victoria
'404':
description: not found
@@ -407,7 +407,7 @@ paths:
dfc-b:hasStreet: 8 Acres Drive
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
dfc-b:region: Victoria
"/api/dfc/enterprises":
get:
@@ -463,14 +463,14 @@ paths:
dfc-b:hasStreet: 42 Doveton Street
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
dfc-b:region: Victoria
- "@id": http://test.host/api/dfc/addresses/40000
"@type": dfc-b:Address
dfc-b:hasStreet: 42 Doveton Street
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
dfc-b:latitude: -25.345376
dfc-b:longitude: 131.0312006
dfc-b:region: Victoria
@@ -549,7 +549,7 @@ paths:
dfc-b:hasStreet: 42 Doveton Street
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
dfc-b:hasCountry: http://publications.europa.eu/resource/authority/country/AUS
dfc-b:latitude: -25.345376
dfc-b:longitude: 131.0312006
dfc-b:region: Victoria