Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit b3e4561

Browse files
author
Phil Varner
authored
change create-order endpoint from .../order to .../orders to follow web API conventions (#106)
1 parent da22d32 commit b3e4561

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ none
1313

1414
### Changed
1515

16+
- Create Order endpoint from `.../order` to `.../orders`
1617
- Order field `id` must be a string, instead of previously allowing int. This is because while an
1718
order ID may an integral numeric value, it is not a "number" in the sense that math will be performed
1819
order ID values, so string represents this better.

src/stapi_fastapi/routers/product_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def _create_order(
9191
]
9292

9393
self.add_api_route(
94-
path="/order",
94+
path="/orders",
9595
endpoint=_create_order,
9696
name=f"{self.root_router.name}:{self.product.id}:create-order",
9797
methods=["POST"],

tests/opportunity_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def test_search_opportunities_response(
5858
except Exception as _:
5959
pytest.fail("response is not an opportunity collection")
6060

61-
assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/order")
61+
assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/orders")

tests/order_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def new_order_response(
4444
product_backend._allowed_payloads = create_order_allowed_payloads
4545

4646
res = stapi_client.post(
47-
f"products/{product_id}/order",
47+
f"products/{product_id}/orders",
4848
json=create_order_allowed_payloads[0].model_dump(),
4949
)
5050

tests/product_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_product_response_self_link(
3434
url, body, "order-parameters", f"/products/{product_id}/order-parameters"
3535
)
3636
assert_link(url, body, "opportunities", f"/products/{product_id}/opportunities")
37-
assert_link(url, body, "create-order", f"/products/{product_id}/order")
37+
assert_link(url, body, "create-order", f"/products/{product_id}/orders")
3838

3939

4040
@pytest.mark.parametrize("product_id", ["test-spotlight"])

0 commit comments

Comments
 (0)