-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
base: master
Are you sure you want to change the base?
[DFC Orders II] Create orders endpoint #13208
Conversation
Hi @mkllnk , can you please take a look and let me know if this is what you had in mind? |
if current_enterprise.distributed_orders.create user: current_user | ||
head :created |
There was a problem hiding this comment.
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.
context "with given enterprise id" do | ||
let(:enterprise_id) { 10_000 } | ||
|
||
run_test! { | ||
expect(enterprise.distributed_orders.count).to eq 1 | ||
} | ||
end |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know!
386011d
to
23e0706
Compare
c32d817
to
43e39ff
Compare
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.
43e39ff
to
f8afb02
Compare
@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.
f8afb02
to
d58d4e8
Compare
(just pushed up some lint fixes and fixup commits) |
# 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
def self.price_measure(variant) | ||
measures = DfcLoader.vocabulary("measures") | ||
|
||
case variant.currency | ||
when "AUD" | ||
measures.AUSTRALIANDOLLAR | ||
when "CAD" | ||
measures.CANADIANDOLLAR | ||
when "EUR" |
There was a problem hiding this comment.
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.
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.
d58d4e8
to
59b3d3a
Compare
What? Why?
What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates