From 81165cd82ba1dc6e5e4d05da68aab9eb86d829f6 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Mon, 24 Nov 2025 16:59:41 +1100 Subject: [PATCH] Replace country names with standard ISO code concepts The DFC version 1.16.0 introduced this new standardisation. --- engines/dfc_provider/app/services/address_builder.rb | 9 ++++++++- .../dfc_provider/spec/services/address_builder_spec.rb | 3 ++- swagger/dfc.yaml | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/engines/dfc_provider/app/services/address_builder.rb b/engines/dfc_provider/app/services/address_builder.rb index 5f20a0e67c..d164d96477 100644 --- a/engines/dfc_provider/app/services/address_builder.rb +++ b/engines/dfc_provider/app/services/address_builder.rb @@ -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 diff --git a/engines/dfc_provider/spec/services/address_builder_spec.rb b/engines/dfc_provider/spec/services/address_builder_spec.rb index da9830b323..11ad51ff10 100644 --- a/engines/dfc_provider/spec/services/address_builder_spec.rb +++ b/engines/dfc_provider/spec/services/address_builder_spec.rb @@ -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 diff --git a/swagger/dfc.yaml b/swagger/dfc.yaml index ab79b0da91..da5fd02007 100644 --- a/swagger/dfc.yaml +++ b/swagger/dfc.yaml @@ -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