Bugzilla – Attachment 172943 Details for
Bug 38204
Add `GET /acquisitions/baskets`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38204: Add api endpoint to list baskets
Bug-38204-Add-api-endpoint-to-list-baskets.patch (text/plain), 5.60 KB, created by
Matt Blenkinsop
on 2024-10-18 10:11:22 UTC
(
hide
)
Description:
Bug 38204: Add api endpoint to list baskets
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-10-18 10:11:22 UTC
Size:
5.60 KB
patch
obsolete
>From 5ee1514fea65fe67e663bea99008d9d7281d5f77 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 2 Oct 2024 15:35:27 +0000 >Subject: [PATCH] Bug 38204: Add api endpoint to list baskets > >This patch adds an API endpoint to list baskets >It uses CanUserManageBasket to respect the users permissions and sysprefs > >Test plan: >1) prove t/db_dependent/api/v1/acquisitions_baskets.t >--- > Koha/REST/V1/Acquisitions/Baskets.pm | 24 +++++++++ > api/v1/swagger/definitions/basket.yaml | 27 +++++++--- > .../swagger/paths/acquisitions_baskets.yaml | 49 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 2 + > 4 files changed, 96 insertions(+), 6 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Baskets.pm b/Koha/REST/V1/Acquisitions/Baskets.pm >index da6152fbb3d..bcd013bb0f5 100644 >--- a/Koha/REST/V1/Acquisitions/Baskets.pm >+++ b/Koha/REST/V1/Acquisitions/Baskets.pm >@@ -59,4 +59,28 @@ sub list_managers { > }; > } > >+=head3 list >+ >+Return a list of baskets >+ >+=cut >+ >+sub list { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ >+ my $baskets_rs = Koha::Acquisition::Baskets->new; >+ my $baskets = $c->objects->search( $baskets_rs ); >+ >+ return $c->render( >+ status => 200, >+ openapi => $baskets >+ ); >+ } >+ catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ > 1; >diff --git a/api/v1/swagger/definitions/basket.yaml b/api/v1/swagger/definitions/basket.yaml >index 8ab8ff1d69e..2866a077019 100644 >--- a/api/v1/swagger/definitions/basket.yaml >+++ b/api/v1/swagger/definitions/basket.yaml >@@ -5,7 +5,9 @@ properties: > type: integer > description: Internal identifier for the basket > name: >- type: string >+ type: >+ - string >+ - "null" > description: Basket name > internal_note: > type: >@@ -18,7 +20,9 @@ properties: > - "null" > description: Vendor note > contract_id: >- type: integer >+ type: >+ - integer >+ - "null" > description: Internal identifier of the linked contract > creation_date: > type: >@@ -35,7 +39,7 @@ properties: > vendor_id: > type: integer > description: Internal identifier for the vendor >- authorised_by: >+ creator_id: > type: > - integer > - "null" >@@ -45,12 +49,12 @@ properties: > - integer > - "null" > description: links this basket to its group (aqbasketgroups.id) >- delivery_library: >+ delivery_library_id: > type: > - string > - "null" > description: basket delivery place >- billing_library: >+ billing_library_id: > type: > - string > - "null" >@@ -63,12 +67,23 @@ properties: > standing: > type: boolean > description: If the orders in this basket are standing >+ closed: >+ type: boolean >+ description: Is the basket closed >+ note: >+ type: >+ - string >+ - "null" >+ description: basket notes > create_items: >- type: string >+ type: >+ - string >+ - "null" > enum: > - ordering > - receiving > - cataloguing >+ - null > description: "When items should be created for orders in this basket (Options: > 'ordering', 'receiving', 'cataloguing'. Null means system wide config)" > additionalProperties: false >diff --git a/api/v1/swagger/paths/acquisitions_baskets.yaml b/api/v1/swagger/paths/acquisitions_baskets.yaml >index f3e8a0d2cb3..010b53af949 100644 >--- a/api/v1/swagger/paths/acquisitions_baskets.yaml >+++ b/api/v1/swagger/paths/acquisitions_baskets.yaml >@@ -1,4 +1,53 @@ > --- >+/acquisitions/baskets: >+ get: >+ x-mojo-to: Acquisitions::Baskets#list >+ operationId: listBaskets >+ description: This resource returns a list of baskets >+ summary: List of baskets >+ tags: >+ - baskets >+ parameters: >+ - $ref: "../swagger.yaml#/parameters/match" >+ - $ref: "../swagger.yaml#/parameters/order_by" >+ - $ref: "../swagger.yaml#/parameters/page" >+ - $ref: "../swagger.yaml#/parameters/per_page" >+ - $ref: "../swagger.yaml#/parameters/q_param" >+ - $ref: "../swagger.yaml#/parameters/q_body" >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: A list of baskets >+ schema: >+ type: array >+ items: >+ $ref: "../swagger.yaml#/definitions/basket" >+ "400": >+ description: | >+ Bad request. Possible `error_code` attribute values: >+ >+ * `invalid_query` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ acquisition: order_manage > /acquisitions/baskets/managers: > get: > x-mojo-to: Acquisitions::Baskets#list_managers >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index dd72361380e..559cd14ffa1 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -181,6 +181,8 @@ definitions: > vendor_issue: > $ref: ./definitions/vendor_issue.yaml > paths: >+ /acquisitions/baskets: >+ $ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets > /acquisitions/baskets/managers: > $ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers > /acquisitions/edifiles: >-- >2.39.3 (Apple Git-146)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38204
:
172943
|
172944
|
173020
|
173021
|
173259
|
173366
|
173367
|
173368
|
173369