Bugzilla – Attachment 58994 Details for
Bug 17856
Add API endpoint for item types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Added REST API endpoint for item types
Added-REST-API-endpoint-for-item-types.patch (text/plain), 5.38 KB, created by
Jiri Kozlovsky
on 2017-01-15 02:16:22 UTC
(
hide
)
Description:
Added REST API endpoint for item types
Filename:
MIME Type:
Creator:
Jiri Kozlovsky
Created:
2017-01-15 02:16:22 UTC
Size:
5.38 KB
patch
obsolete
>From 80da92fb181194be85d140235f65a2f9f7a3761f Mon Sep 17 00:00:00 2001 >From: Jiri Kozlovsky <mail@jkozlovsky.cz> >Date: Sun, 15 Jan 2017 02:13:24 +0000 >Subject: [PATCH] Added REST API endpoint for item types > >To test: >1) Go to /api/v1/item_types >2) Check there were returned all item types > >I'm sorry I couldn't create unit tests because I have somehow broken >kohadevbox installation :/ .. nor "koha-shell kohadevbox" works :( > >https://bugs.koha-community.org/show_bug.cgi?id=17856 >--- > Koha/REST/V1/ItemTypes.pm | 32 +++++++++++++++++++ > api/v1/swagger/definitions.json | 3 ++ > api/v1/swagger/definitions/item_type.json | 51 +++++++++++++++++++++++++++++++ > api/v1/swagger/paths.json | 3 ++ > api/v1/swagger/paths/item_types.json | 22 +++++++++++++ > 5 files changed, 111 insertions(+) > create mode 100644 Koha/REST/V1/ItemTypes.pm > create mode 100644 api/v1/swagger/definitions/item_type.json > create mode 100644 api/v1/swagger/paths/item_types.json > >diff --git a/Koha/REST/V1/ItemTypes.pm b/Koha/REST/V1/ItemTypes.pm >new file mode 100644 >index 0000000..7c66011 >--- /dev/null >+++ b/Koha/REST/V1/ItemTypes.pm >@@ -0,0 +1,32 @@ >+package Koha::REST::V1::ItemTypes; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Mojo::Base 'Mojolicious::Controller'; >+ >+use Koha::ItemTypes; >+ >+sub list { >+ my ($c, $args, $cb) = @_; >+ >+ my $item_types = Koha::ItemTypes->search; >+ >+ $c->$cb($item_types->unblessed, 200); >+} >+ >+1; >diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json >index d27167b..ae89181 100644 >--- a/api/v1/swagger/definitions.json >+++ b/api/v1/swagger/definitions.json >@@ -5,6 +5,9 @@ > "patron": { > "$ref": "definitions/patron.json" > }, >+ "item_type": { >+ "$ref": "definitions/item_type.json" >+ }, > "holds": { > "$ref": "definitions/holds.json" > }, >diff --git a/api/v1/swagger/definitions/item_type.json b/api/v1/swagger/definitions/item_type.json >new file mode 100644 >index 0000000..9908707 >--- /dev/null >+++ b/api/v1/swagger/definitions/item_type.json >@@ -0,0 +1,51 @@ >+{ >+ "type": "object", >+ "properties": { >+ "itemtype": { >+ "description": "unique key identifying itemtype", >+ "type": "string" >+ }, >+ "description": { >+ "description": "a plain text explanation of the item type", >+ "type": ["string", "null"] >+ }, >+ "rentalcharge": { >+ "description": "the amount charged when this item is checked out/issued", >+ "type": ["string", "null"] >+ }, >+ "notforloan": { >+ "description": "1 if the item is not for loan, 0 if the item is available for loan", >+ "type": ["string", "null"] >+ }, >+ "imageurl": { >+ "description": "URL for the item type icon", >+ "type": ["string", "null"] >+ }, >+ "summary": { >+ "description": "information from the summary field, may include HTML", >+ "type": ["string", "null"] >+ }, >+ "checkinmsg": { >+ "description": "message that is displayed when an item with the given item type is checked in", >+ "type": ["string", "null"] >+ }, >+ "checkinmsgtype": { >+ "description": "type (CSS class) for the checkinmsg, can be 'alert' or 'message'", >+ "type": ["string", "null"] >+ }, >+ "sip_media_type": { >+ "description": "SIP2 protocol media type for this itemtype", >+ "type": ["string", "null"] >+ }, >+ "hideinopac": { >+ "description": "Hide the item type from the search options in OPAC", >+ "type": "string" >+ }, >+ "searchcategory": { >+ "description": "Group this item type with others with the same value on OPAC search options", >+ "type": ["string", "null"] >+ } >+ }, >+ "additionalProperties": false, >+ "required": ["itemtype"] >+} >diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json >index b1fcf40..2247726 100644 >--- a/api/v1/swagger/paths.json >+++ b/api/v1/swagger/paths.json >@@ -5,6 +5,9 @@ > "/cities/{cityid}": { > "$ref": "paths/cities.json#/~1cities~1{cityid}" > }, >+ "/item_types": { >+ "$ref": "paths/item_types.json#/~1item_types" >+ }, > "/holds": { > "$ref": "paths/holds.json#/~1holds" > }, >diff --git a/api/v1/swagger/paths/item_types.json b/api/v1/swagger/paths/item_types.json >new file mode 100644 >index 0000000..5a6fc56 >--- /dev/null >+++ b/api/v1/swagger/paths/item_types.json >@@ -0,0 +1,22 @@ >+{ >+ "/item_types": { >+ "get": { >+ "operationId": "listItemTypes", >+ "tags": ["item_types"], >+ "produces": [ >+ "application/json" >+ ], >+ "responses": { >+ "200": { >+ "description": "A list of item types", >+ "schema": { >+ "type": "array", >+ "items": { >+ "$ref": "../definitions.json#/item_type" >+ } >+ } >+ } >+ } >+ } >+ } >+} >-- >2.1.4
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 17856
: 58994