Koha/api/v1/swagger/paths/acquisitions_orders.json
Tomas Cohen Arazi ade441def4 Bug 20212: Add more embeddable objects to orders
This patch adds options to embed more related objects based on the needs
by parcel.tt.

For filtering by biblioitems fields (ISBN and EAN) I had to make the
'list' method a modified version of the objects->search helper. I
thought of doing it in a more generic way but I didn't find any other
use cases and it would certainly make an already complex piece of code
even more complex.

So this is quite similar, but at some steps the biblio.<biblioitem
field> gets translated into the proper relation names, and the same
happens for prefetching.

A new parameter is also added: only_active. It makes the controller use
Koha::Acquisition::Orders->filter_by_active, avoiding the need to build
complex queries in the UI.

The same handling is done when the order_id parameter is passed (outside
the q= parameters). In this case using Koha::Acquisition::Orders->filter_by_id_including_transfers

This is all respecting the C4::Acquisitions::SearchOrders behaviour.

TL;DR:

This patch adapts the code from the list() sub so it manipulates the
query parameters and the embed header so:
- the biblioitem relationship is prefetch
- any queries on biblio.isbn and biblio.ean are correctly translated into search on the
  biblioitems table.
- Adds an only_active parameter to the /acquisitions/orders route to
  easily request only the active orders.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-01-28 16:44:11 +01:00

405 lines
13 KiB
JSON

{
"/acquisitions/orders": {
"get": {
"x-mojo-to": "Acquisitions::Orders#list",
"operationId": "listOrders",
"tags": [
"acquisitions",
"orders"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "biblio_id",
"in": "query",
"description": "Identifier for a linked bibliographic record",
"required": false,
"type": "integer"
},
{
"name": "basket_id",
"in": "query",
"description": "Identifier for a linked acquisition basket",
"required": false,
"type": "integer"
},
{
"name": "fund_id",
"in": "query",
"description": "Identifier for the fund the order goes against",
"required": false,
"type": "integer"
},
{
"name": "status",
"in": "query",
"description": "Current status for the order. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'",
"required": false,
"type": "string"
},
{
"name": "only_active",
"in": "query",
"description": "If only active orders should be listed",
"required": false,
"type": "boolean"
},
{
"$ref": "../parameters.json#/match"
},
{
"$ref": "../parameters.json#/order_by"
},
{
"$ref": "../parameters.json#/page"
},
{
"$ref": "../parameters.json#/per_page"
},
{
"$ref": "../parameters.json#/q_param"
},
{
"$ref": "../parameters.json#/q_body"
},
{
"$ref": "../parameters.json#/q_header"
}
],
"responses": {
"200": {
"description": "A list of orders",
"schema": {
"type": "array",
"items": {
"$ref": "../definitions.json#/order"
}
}
},
"401": {
"description": "Authentication required",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"403": {
"description": "Access forbidden",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"404": {
"description": "Order not found",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"503": {
"description": "Under maintenance",
"schema": {
"$ref": "../definitions.json#/error"
}
}
},
"x-koha-authorization": {
"permissions": {
"acquisition": [ "order_manage", "order_manage_all" ]
}
},
"x-koha-embed": [
"basket",
"basket.basket_group",
"basket.creator",
"biblio",
"biblio.active_orders+count",
"biblio.holds+count",
"biblio.items+count",
"biblio.suggestions.suggester",
"fund",
"current_item_level_holds+count",
"invoice",
"items",
"subscription"
]
},
"post": {
"x-mojo-to": "Acquisitions::Orders#add",
"operationId": "addOrder",
"tags": [
"acquisitions",
"orders"
],
"parameters": [
{
"name": "body",
"in": "body",
"description": "A JSON object representing an order",
"required": true,
"schema": {
"$ref": "../definitions.json#/order"
}
}
],
"produces": [
"application/json"
],
"responses": {
"201": {
"description": "Order added",
"schema": {
"$ref": "../definitions.json#/order"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"401": {
"description": "Authentication required",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"403": {
"description": "Access forbidden",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"409": {
"description": "Conflict in creating the resource",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"503": {
"description": "Under maintenance",
"schema": {
"$ref": "../definitions.json#/error"
}
}
},
"x-koha-authorization": {
"permissions": {
"acquisition": "order_manage"
}
}
}
},
"/acquisitions/orders/{order_id}": {
"get": {
"x-mojo-to": "Acquisitions::Orders#get",
"operationId": "getOrder",
"tags": [
"acquisitions",
"orders"
],
"parameters": [
{
"$ref": "../parameters.json#/order_id_pp"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "An order",
"schema": {
"$ref": "../definitions.json#/order"
}
},
"401": {
"description": "Authentication required",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"403": {
"description": "Access forbidden",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"404": {
"description": "Order not found",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"503": {
"description": "Under maintenance",
"schema": {
"$ref": "../definitions.json#/error"
}
}
},
"x-koha-authorization": {
"permissions": {
"acquisition": "order_manage"
}
},
"x-koha-embed": [
"basket",
"basket.basket_group",
"basket.creator",
"biblio",
"biblio.active_orders+count",
"biblio.holds+count",
"biblio.items+count",
"biblio.suggestions.suggester",
"fund",
"current_item_level_holds+count",
"invoice",
"items",
"subscription"
]
},
"put": {
"x-mojo-to": "Acquisitions::Orders#update",
"operationId": "updateOrder",
"tags": [
"acquisitions",
"orders"
],
"parameters": [
{
"$ref": "../parameters.json#/order_id_pp"
},
{
"name": "body",
"in": "body",
"description": "A JSON object representing an order",
"required": true,
"schema": {
"$ref": "../definitions.json#/order"
}
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "An order",
"schema": {
"$ref": "../definitions.json#/order"
}
},
"401": {
"description": "Authentication required",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"403": {
"description": "Access forbidden",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"404": {
"description": "Order not found",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"503": {
"description": "Under maintenance",
"schema": {
"$ref": "../definitions.json#/error"
}
}
},
"x-koha-authorization": {
"permissions": {
"acquisition": "order_manage"
}
}
},
"delete": {
"x-mojo-to": "Acquisitions::Orders#delete",
"operationId": "deleteOrder",
"tags": [
"acquisitions",
"orders"
],
"parameters": [
{
"$ref": "../parameters.json#/order_id_pp"
}
],
"produces": [
"application/json"
],
"responses": {
"204": {
"description": "Order deleted"
},
"401": {
"description": "Authentication required",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"403": {
"description": "Access forbidden",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"404": {
"description": "Order not found",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "../definitions.json#/error"
}
},
"503": {
"description": "Under maintenance",
"schema": {
"$ref": "../definitions.json#/error"
}
}
},
"x-koha-authorization": {
"permissions": {
"acquisition": "order_manage"
}
}
}
}
}