mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Merge pull request #13748 from mkllnk/connector
Bump DFC version from 1.14 to 1.16 with new country and phone format
This commit is contained in:
13
Gemfile.lock
13
Gemfile.lock
@@ -267,7 +267,7 @@ GEM
|
||||
activerecord (>= 5.a)
|
||||
database_cleaner-core (~> 2.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
datafoodconsortium-connector (1.1.0)
|
||||
datafoodconsortium-connector (1.2.0)
|
||||
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
|
||||
date (3.5.0)
|
||||
debug (1.11.0)
|
||||
@@ -388,7 +388,7 @@ GEM
|
||||
hashery (2.1.2)
|
||||
hashie (5.0.0)
|
||||
highline (2.0.3)
|
||||
htmlentities (4.3.4)
|
||||
htmlentities (4.4.2)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.14.7)
|
||||
concurrent-ruby (~> 1.0)
|
||||
@@ -675,14 +675,19 @@ GEM
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rdf (3.3.2)
|
||||
rdf (3.3.4)
|
||||
bcp47_spec (~> 0.2)
|
||||
bigdecimal (~> 3.1, >= 3.1.5)
|
||||
link_header (~> 0.0, >= 0.0.8)
|
||||
logger (~> 1.5)
|
||||
ostruct (~> 0.6)
|
||||
readline (~> 0.0)
|
||||
rdoc (6.15.1)
|
||||
erb
|
||||
psych (>= 4.0.0)
|
||||
tsort
|
||||
readline (0.0.4)
|
||||
reline
|
||||
redcarpet (3.6.1)
|
||||
redis (5.4.1)
|
||||
redis-client (>= 0.22.0)
|
||||
@@ -696,7 +701,7 @@ GEM
|
||||
responders (3.1.1)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
rexml (3.4.2)
|
||||
rexml (3.4.4)
|
||||
roadie (5.2.1)
|
||||
css_parser (~> 1.4)
|
||||
nokogiri (~> 1.15)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -168,6 +168,7 @@ paths:
|
||||
dfc-b:sku: AR
|
||||
dfc-b:stockLimitation: 0
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
dfc-b:managedBy: http://test.host/api/dfc/enterprises/10000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
"@type": dfc-b:SuppliedProduct
|
||||
dfc-b:name: Apple - 1g
|
||||
@@ -224,6 +225,7 @@ paths:
|
||||
dfc-b:sku: AR
|
||||
dfc-b:stockLimitation: 0
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
dfc-b:managedBy: http://test.host/api/dfc/enterprises/10000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
"@type": dfc-b:Offer
|
||||
dfc-b:hasPrice:
|
||||
@@ -405,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:
|
||||
@@ -433,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
|
||||
@@ -459,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
|
||||
@@ -489,6 +493,7 @@ paths:
|
||||
dfc-b:sku: APP
|
||||
dfc-b:stockLimitation: 5
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
dfc-b:managedBy: http://test.host/api/dfc/enterprises/10000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/social_medias/facebook
|
||||
"@type": dfc-b:SocialMedia
|
||||
dfc-b:name: facebook
|
||||
@@ -517,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
|
||||
@@ -542,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
|
||||
@@ -565,6 +572,7 @@ paths:
|
||||
dfc-b:sku: APP
|
||||
dfc-b:stockLimitation: 5
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
dfc-b:managedBy: http://test.host/api/dfc/enterprises/10000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/social_medias/facebook
|
||||
"@type": dfc-b:SocialMedia
|
||||
dfc-b:name: facebook
|
||||
@@ -835,6 +843,7 @@ paths:
|
||||
dfc-b:sku: BP
|
||||
dfc-b:stockLimitation: 5
|
||||
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
dfc-b:managedBy: http://test.host/api/dfc/enterprises/10000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
"@type": dfc-b:SuppliedProduct
|
||||
dfc-b:name: Pesto - 1g
|
||||
|
||||
Reference in New Issue
Block a user