mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
We can extend this service class when there are other APIs. And hopefully the DFC will provide a standard for this discovery at some point.
17 lines
666 B
Ruby
17 lines
666 B
Ruby
# frozen_string_literal: true
|
|
|
|
# The DFC standard doesn't include endpoint discovery yet.
|
|
# So for now we are guessing URLs based on our FDC pilot project.
|
|
class FdcUrlBuilder
|
|
attr_reader :catalog_url, :orders_url, :sale_session_url
|
|
|
|
# At the moment, we start with a product link like this:
|
|
#
|
|
# https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts/44519466467635
|
|
def initialize(semantic_id)
|
|
@catalog_url, _slash, _id = semantic_id.rpartition("/")
|
|
@orders_url = @catalog_url.sub("/SuppliedProducts", "/Orders")
|
|
@sale_session_url = @catalog_url.sub("/SuppliedProducts", "/SalesSession/#")
|
|
end
|
|
end
|