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 Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
9c1f70a353
commit
64d9579c47
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -185,6 +185,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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue