Tomas Cohen Arazi
dab0260702
This patch introduces the `api_strings_mapping` method to the *Koha::Item* class, and makes the API spec for the following routes: * GET /items * GET /items/:item_id * GET /acquisitions/orders accept the new `+strings` parameter that can be passed through the `x-koha-embed` header and was introduced by bug 26635. In the case of /acquisitions/orders, you will need to use x-koha-embed: items+strings I introduce it here to highlight the flebility we introduced with bug 26635. The `api_strings_mapping` method has its roots on the cool `columns_to_str` method already present. The main differences: * It is aware of the `public_read_list` for attributes so no hidden information is exposed. * Attribute names get mapped for consistency with the API (e.g. `homebranch` is converted into `home_library_id`, etc). * The data structure it returns includes information about the source for the descriptions (e.g. it it is an authorised value, then `type` will be `av`, and the related category information is returned so dropdowns and such can be built. The same goes for other types as `library`, `item_type` and `call_number_source`. To test: 1. Apply this patch 2. Reload everything 3. Play with your favourite REST tool (e.g. Postman) 4. Try: GET http://localhost:8081/api/v1/items x-koha-embed: +strings => SUCCESS: You get a list of items, they include the new _strings structure, and the contents make sense! 5. Repeat with a specific item: GET http://localhost:8081/api/v1/items/14 x-koha-embed: +strings => SUCCESS: It all makes sense! 6. Sign off :-D Sponsored-by: Virginia Polytechnic Institute and State University Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
303 lines
8.5 KiB
YAML
303 lines
8.5 KiB
YAML
---
|
|
/acquisitions/orders:
|
|
get:
|
|
x-mojo-to: Acquisitions::Orders#list
|
|
operationId: listOrders
|
|
tags:
|
|
- orders
|
|
summary: List 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: "../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"
|
|
- $ref: "../swagger.yaml#/parameters/q_header"
|
|
- $ref: "../swagger.yaml#/parameters/request_id_header"
|
|
- name: x-koha-embed
|
|
in: header
|
|
required: false
|
|
description: Embed list sent as a request header
|
|
type: array
|
|
items:
|
|
type: string
|
|
enum:
|
|
- 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
|
|
- items+strings
|
|
- subscription
|
|
collectionFormat: csv
|
|
responses:
|
|
"200":
|
|
description: A list of orders
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"404":
|
|
description: Order not found
|
|
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
|
|
- order_manage_all
|
|
post:
|
|
x-mojo-to: Acquisitions::Orders#add
|
|
operationId: addOrder
|
|
tags:
|
|
- orders
|
|
summary: Add order
|
|
parameters:
|
|
- name: body
|
|
in: body
|
|
description: A JSON object representing an order
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Order added
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"409":
|
|
description: Conflict in creating the resource
|
|
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/orders/{order_id}":
|
|
get:
|
|
x-mojo-to: Acquisitions::Orders#get
|
|
operationId: getOrder
|
|
tags:
|
|
- orders
|
|
summary: Get order
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/order_id_pp"
|
|
- name: x-koha-embed
|
|
in: header
|
|
required: false
|
|
description: Embed list sent as a request header
|
|
type: array
|
|
items:
|
|
type: string
|
|
enum:
|
|
- 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
|
|
collectionFormat: csv
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: An order
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"404":
|
|
description: Order not found
|
|
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
|
|
put:
|
|
x-mojo-to: Acquisitions::Orders#update
|
|
operationId: updateOrder
|
|
tags:
|
|
- orders
|
|
summary: Update order
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/order_id_pp"
|
|
- name: body
|
|
in: body
|
|
description: A JSON object representing an order
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: An order
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/order"
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"404":
|
|
description: Order not found
|
|
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
|
|
delete:
|
|
x-mojo-to: Acquisitions::Orders#delete
|
|
operationId: deleteOrder
|
|
tags:
|
|
- orders
|
|
summary: Delete order
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/order_id_pp"
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"204":
|
|
description: Order deleted
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"404":
|
|
description: Order not found
|
|
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
|