diff --git a/code/web/openapi/aspen_openapi.json b/code/web/openapi/aspen_openapi.json index feb5f949e4..48cd74f117 100644 --- a/code/web/openapi/aspen_openapi.json +++ b/code/web/openapi/aspen_openapi.json @@ -7,7 +7,7 @@ "name": "GPL v2", "url": "https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" }, - "description": "The API provided by Aspen Discovery for use in other applications, mobile apps, etc" + "description": "The API provided by Aspen Discovery for use in other applications, mobile apps, etc." }, "servers": [ { @@ -59,6 +59,42 @@ } ], "paths": { + "/SystemAPI?method=getLocalIllForm": { + "get": { + "tags": ["SystemAPI"], + "summary": "Get Local ILL Form", + "description": "Returns information needed to display a Local ILL Form to the user.", + "parameters": [ + { + "in" : "query", + "name": "formId", + "schema": { + "type": "integer" + }, + "description": "The ID of the form to return information about", + "example": "1" + } + ], + "responses" : { + "200" : { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LocalIllFormResult" + } + } + } + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/Unauthorized" + } + } + } + }, "/UserAPI?method=isLoggedIn": { "get": { "tags": ["UserAPI"], @@ -128,46 +164,188 @@ } } } + }, + "/UserAPI?method=submitLocalIllRequest": { + "post" : { + "tags": ["UserAPI"], + "summary": "Submit Local ILL Request", + "description": "Submits a Local ILL Request for the user.", + "parameters": [ + { + "in" : "query", + "name": "username", + "schema": { + "type": "string" + }, + "description": "The username or barcode for the patron", + "example": "23025003575917" + }, + { + "in" : "query", + "name": "password", + "schema": { + "type": "string" + }, + "description": "The password or pin for the patron", + "example": "7604" + } + ], + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LoginResult" + } + } + } + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/Unauthorized" + } + } + } } }, "components": { - "responses": { - "BadRequest": { - "description": "Bad Request - Invalid method or parameters", - "type": "object", - "properties": { - "error": { - "type": "string", - "example": "invalid_method" - } + "responses": { + "BadRequest": { + "description": "Bad Request - Invalid method or parameters", + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "invalid_method" } - }, - "Unauthorized": { - "description": "Unauthorized - Request requires authentication", - "type": "object", - "properties": { - "error": { + } + }, + "Unauthorized": { + "description": "Unauthorized - Request requires authentication", + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "unauthorized_access" + } + } + }, + "NotFound": { + "description": "The specified resource was not found.", + "type": "object", + "properties": { + "error": { + "type": "string" + } + } + } + }, + "schemas": { + "BasicResult": { + "type": "object", + "properties": { + "result" : { + "type": "boolean" + } + } + }, + "BasicAPIResult": { + "type": "object", + "properties": { + "result" : { + "success": { + "type": "boolean", + "description": "Whether the user method was successful or not", + "example": "true" + }, + "message": { + "type": "string", + "description": "Additional information about why the method failed or information about the success suitable for display to the patron" + }, + "title": { "type": "string", - "example": "unauthorized_access" + "nullable": "true", + "description": "The title of the message for display to the patron" } } - }, - "NotFound": { - "description": "The specified resource was not found.", - "type": "object", - "properties": { - "error": { - "type": "string" + } + }, + "FormFieldResult": { + "type": "object", + "properties": { + "result" : { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "The type of field to display" + }, + "property": { + "type": "string", + "description": "The property the field is representing. Should not be shown to the user" + }, + "display": { + "type": "string", + "description": "Has values of show or hide to determine if the form should be shown to the user" + }, + "label": { + "type": "string", + "description": "The label for the field" + }, + "description" : { + "type": "string", + "description": "The description for the field, can be shown as a tooltip or under the field" + }, + "required" : { + "type": "boolean", + "description": "Whether the field must be filled out by the patron" + } } } } }, - "schemas": { - "BasicResult": { + "LocalIllFormResult": { "type": "object", "properties": { "result" : { - "type": "boolean" + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the user method was successful or not", + "example": "true" + }, + "message": { + "type": "string", + "description": "Additional information about why the method failed" + }, + "title": { + "type": "string", + "nullable": "true", + "description": "The title of the form or error message" + }, + "buttonLabel": { + "type": "string", + "nullable": "true", + "description": "The label to display for the submit button" + }, + "buttonLabelProcessing": { + "type": "string", + "nullable": "true", + "description": "The label to display for the submit button while the request is being processed" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FormFieldResult" + }, + "nullable": "true", + "description": "An array of field information to be displayed" + } + } } } }, diff --git a/code/web/release_notes/24.12.00.MD b/code/web/release_notes/24.12.00.MD index 5077f5d24d..ac6bdf7c40 100644 --- a/code/web/release_notes/24.12.00.MD +++ b/code/web/release_notes/24.12.00.MD @@ -3,6 +3,10 @@ ## Aspen Discovery Updates // mark - Grove +### API Updates +- Add a new API to retrieve a LocalIllForm Configuration. (DIS-34) (*MDN*) +- Add a new API to submit a Local ILL request. (DIS-34) (*MDN*) + ### Indexing Updates - Add a new format for Tonies based on a publisher (260b, 264b, 710a) containing Boxine and a title (245a) containing Tonie. (*MDN*) - Add a new format for Yoto based on a publisher (260b, 264b, 710a) containing Yoto and a title (245a) containing Yoto. (*MDN*) diff --git a/code/web/services/API/SystemAPI.php b/code/web/services/API/SystemAPI.php index 5457d3978d..74e717e229 100644 --- a/code/web/services/API/SystemAPI.php +++ b/code/web/services/API/SystemAPI.php @@ -37,6 +37,7 @@ function launch() { 'getBulkTranslations', 'getLanguages', 'getVdxForm', + 'getLocalIllForm', 'getSelfCheckSettings', 'getSystemMessages', 'dismissSystemMessage', @@ -912,7 +913,8 @@ function getDevelopmentPriorities(): array { ]; } - function getVdxForm() { + /** @noinspection PhpUnused */ + function getVdxForm() : array { $result = [ 'success' => false, 'title' => 'Error', @@ -994,6 +996,70 @@ function getVdxForm() { return $result; } + /** @noinspection PhpUnused */ + function getLocalIllForm(): array { + $result = [ + 'success' => false, + 'title' => 'Error', + 'message' => 'Unable to load VDX form', + ]; + + require_once ROOT_DIR . '/sys/InterlibraryLoan/LocalIllForm.php'; + + if (isset($_REQUEST['formId'])) { + $formId = $_REQUEST['formId']; + } else { + return [ + 'success' => false, + 'title' => translate([ + 'text' => 'Invalid Configuration', + 'isPublicFacing' => true, + ]), + 'message' => translate([ + 'text' => 'A LocalIll form id was not given.', + 'isPublicFacing' => true, + ]), + ]; + } + + $localIllForm = new LocalIllForm(); + $localIllForm->id = $formId; + if ($localIllForm->find(true)) { + $localIllFormFields = $localIllForm->getFormFieldsForApi(); + $result = [ + 'success' => true, + 'title' => translate([ + 'text' => 'Request Title', + 'isPublicFacing' => true, + ]), + 'message' => '', + 'buttonLabel' => translate([ + 'text' => 'Place Request', + 'isPublicFacing' => true, + ]), + 'buttonLabelProcessing' => translate([ + 'text' => 'Placing Request', + 'isPublicFacing' => true, + ]), + 'fields' => $localIllFormFields, + ]; + } else { + return [ + 'success' => false, + 'title' => translate([ + 'text' => 'Invalid Configuration', + 'isPublicFacing' => true, + ]), + 'message' => translate([ + 'text' => 'Unable to find the specified form.', + 'isPublicFacing' => true, + ]), + ]; + } + + return $result; + } + public function getSelfCheckSettings(): array { if (isset($_REQUEST['locationId'])) { $location = new Location(); diff --git a/code/web/services/API/UserAPI.php b/code/web/services/API/UserAPI.php index 7c3ba84f81..7b01d55550 100644 --- a/code/web/services/API/UserAPI.php +++ b/code/web/services/API/UserAPI.php @@ -70,6 +70,7 @@ function launch() { 'getNotificationPushToken', 'submitVdxRequest', 'cancelVdxRequest', + 'submitLocalIllRequest', 'getNotificationPreference', 'setNotificationPreference', 'getNotificationPreferences', @@ -940,7 +941,7 @@ function getPatronProfile(): array { //Add Interlibrary Loan $userData->hasInterlibraryLoan = false; - if ($user->hasInterlibraryLoan()) { + if ($user->getInterlibraryLoanType() == 'vdx') { $userData->hasInterlibraryLoan = true; require_once ROOT_DIR . '/Drivers/VdxDriver.php'; $driver = new VdxDriver(); @@ -3501,7 +3502,7 @@ function activateAllHolds() { } /** @noinspection PhpUnused */ - function submitVdxRequest() { + function submitVdxRequest() : array { $user = $this->getUserForApiCall(); if ($user && !($user instanceof AspenError)) { require_once ROOT_DIR . '/Drivers/VdxDriver.php'; @@ -3533,7 +3534,7 @@ function submitVdxRequest() { } /** @noinspection PhpUnused */ - function cancelVdxRequest() { + function cancelVdxRequest() : array { $user = $this->getUserForApiCall(); $title = translate([ 'text' => 'Error', @@ -3562,14 +3563,27 @@ function cancelVdxRequest() { } } + /** @noinspection PhpUnused */ + function submitLocalIllRequest() : array { + $user = $this->getUserForApiCall(); + if ($user && !($user instanceof AspenError)) { + return $user->submitLocalIllRequest(); + } else { + return [ + 'success' => false, + 'message' => 'Login unsuccessful', + ]; + } + } + /** * Loads the reading history for the user. Includes print, eContent, and OverDrive titles. * Note: The return of this method can be quite lengthy if the patron has a large number of items in their reading history. * * Parameters: *