Bug 29668 - Add API route to create a basket
Summary: Add API route to create a basket
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Julian Maurice
QA Contact:
URL:
Keywords:
Depends on: 38204
Blocks:
  Show dependency treegraph
 
Reported: 2021-12-09 07:26 UTC by Julian Maurice
Modified: 2025-06-06 18:40 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 29668: Add API route to add a basket (8.84 KB, patch)
2021-12-09 07:27 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 29668: Add API route to add a basket (14.90 KB, patch)
2025-06-06 15:16 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 29668: Move tests (4.31 KB, patch)
2025-06-06 15:16 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 29668: Adapt to current guidelines (1.88 KB, patch)
2025-06-06 15:16 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2021-12-09 07:26:06 UTC

    
Comment 1 Julian Maurice 2021-12-09 07:27:42 UTC
Created attachment 128371 [details] [review]
Bug 29668: Add API route to add a basket

Example usage:

POST /api/v1/acquisitions/baskets

{
    "vendor_id": 1,
    "name": "Basket #1",
}

Test plan:
1. Try requesting this endpoint with your favorite API tool
   (I recommend https://github.com/frigus02/RESTer)
2. Run `prove t/db_dependent/api/v1/acquisitions_baskets/post.t`
Comment 2 Paul Derscheid 2022-05-20 10:37:45 UTC
This isn't compatible with the current master branch because of some changes in the api directory structure, but I think you already know.

Some merge conflicts have to be resolved. There is the new route acquisitions/baskets/managers which probably wasn't there yet when this patch was written.
Comment 3 Fridolin Somers 2025-06-05 14:18:44 UTC
Must also be rebased now that Bug 38204 is in
Comment 4 Tomás Cohen Arazi (tcohen) 2025-06-06 15:16:06 UTC
Created attachment 183072 [details] [review]
Bug 29668: Add API route to add a basket

Example usage:

POST /api/v1/acquisitions/baskets

{
    "vendor_id": 1,
    "name": "Basket #1",
}

Test plan:
1. Try requesting this endpoint with your favorite API tool
   (I recommend https://github.com/frigus02/RESTer)
2. Run `prove t/db_dependent/api/v1/acquisitions_baskets/post.t`

Edit (tcohen): Re-did the commit with some fixes in the spec

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Tomás Cohen Arazi (tcohen) 2025-06-06 15:16:09 UTC
Created attachment 183073 [details] [review]
Bug 29668: Move tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi (tcohen) 2025-06-06 15:16:12 UTC
Created attachment 183074 [details] [review]
Bug 29668: Adapt to current guidelines

The added patches make some changes:

* $c->req->json is used to access the request body, as explained by the
  Mojolicious OpenAPI plugin author it should be done.
* Instead of calling `$basket->to_api` we use the `$c->objects->to_api`
  helper which deals with calling context (embeds, etc). Otherwise it
  would require doing it manually if embeds are added.
* Tests are grouped together the same way the rest of them are.

To test:
1. Apply this patches
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/acquisitions_baskets.t
=> SUCCESS: Tests pass!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>