Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DFC Orders II] Create orders endpoint #13208

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

dacook
Copy link
Member

@dacook dacook commented Mar 12, 2025

What? Why?

What should we test?

  • Visit ... page.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

@dacook dacook self-assigned this Mar 12, 2025
@dacook
Copy link
Member Author

dacook commented Mar 12, 2025

Hi @mkllnk , can you please take a look and let me know if this is what you had in mind?
The integration spec could probably be in a separate file

Comment on lines 10 to 11
if current_enterprise.distributed_orders.create user: current_user
head :created
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later we'll need to return the order to provide the client with an id.

Comment on lines 66 to 87
context "with given enterprise id" do
let(:enterprise_id) { 10_000 }

run_test! {
expect(enterprise.distributed_orders.count).to eq 1
}
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may already know this, but Swagger documents only the last example in a group. It overrides the data of the previous ones.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know!

@dacook dacook force-pushed the dfc-orders-endpoint-12181 branch from 386011d to 23e0706 Compare March 12, 2025 06:14
@dacook dacook force-pushed the dfc-orders-endpoint-12181 branch 13 times, most recently from c32d817 to 43e39ff Compare March 19, 2025 06:13
dacook added 3 commits March 20, 2025 10:07
But there's not much in the object, we need to check what's required.
But I need to know what details are going to be included. probably sales session. and line items of course.
@dacook dacook force-pushed the dfc-orders-endpoint-12181 branch from 43e39ff to f8afb02 Compare March 19, 2025 23:26
@dacook dacook requested a review from mkllnk March 20, 2025 00:15
@dacook
Copy link
Member Author

dacook commented Mar 20, 2025

@mkllnk I've achieved end to end, with a few little fixes along the way. Can you please review and confirm if ok to proceed this way?

Probably should have just hardcoded it. Hopefully we can remove this soon anyway.
@dacook dacook force-pushed the dfc-orders-endpoint-12181 branch from f8afb02 to d58d4e8 Compare March 20, 2025 00:35
@dacook
Copy link
Member Author

dacook commented Mar 20, 2025

(just pushed up some lint fixes and fixup commits)

Comment on lines +8 to +10
# Known product link formats:
# * https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts/44519466467635
# * http://test.host/api/dfc/enterprises/10000/supplied_products/10001 (OFN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I guess now it's a DfcUrlBuilder instead of an FdcUrlBuilder.


it "assigns a price without unknown currency" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • without known
  • with unknown

@catalog_url, _slash, _id = semantic_id.rpartition("/")
@orders_url = @catalog_url.sub("/SuppliedProducts", "/Orders")
base_url, _slash, _id = semantic_id.rpartition("/")
@catalog_url = base_url.sub("/supplied_products", "/catalog_items")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DFC standard doesn't define how much of the graph to include in an endpoint. It also doesn't define listing endpoints like these catalog URLs (yet). That's why OFN and FDC are different. Neither is wrong.

Comment on lines +4 to +9
def self.catalog_item(variant, include_product: true)
id = urls.enterprise_catalog_item_url(
enterprise_id: variant.supplier_id,
id: variant.id,
)
product = SuppliedProductBuilder.supplied_product(variant)
product = SuppliedProductBuilder.supplied_product(variant) if include_product
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 Maybe better to just remove the product and the caller of catalog_item can decide to add it separately?

Hm, but I guess that we now build the catalog item twice, once for the enterprise and once for the product. It would be good to avoid that.


order = current_enterprise.distributed_orders.build(user: current_user)

# rubocop:disable Style/GuardClause
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it as easy to return an error instead of disabling Rubocop here?

Comment on lines +42 to +50
def self.price_measure(variant)
measures = DfcLoader.vocabulary("measures")

case variant.currency
when "AUD"
measures.AUSTRALIANDOLLAR
when "CAD"
measures.CANADIANDOLLAR
when "EUR"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good workaround. I tried getting the QUDT vocabulary to work but it's defined in a completely different way and the DFC Connector parser doesn't understand it. So let's wait until it's actually a standard.

dacook added 9 commits March 20, 2025 16:07
I'm probably not understanding the full context, but it seems weird that the initial FDC pilot works by loading the catalog from the supplied_products URL.

Alternatively, maybe we coudl load the catalog from the OFN supplied_products index endpoint. But it dosn't exist yet.
It's required by the FdcOfferBroker.
Simpler this way.
ned to rethink where. is it a OrderLineItem builder? or soemthing else.
@dacook dacook force-pushed the dfc-orders-endpoint-12181 branch from d58d4e8 to 59b3d3a Compare March 20, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress ⚙
Development

Successfully merging this pull request may close these issues.

2 participants