@@ -, +, @@ --- Koha/Catalog/Concern.pm | 36 +++++++++++++++++ Koha/REST/V1/Catalog/Concerns.pm | 47 +++++++++++++++++++++- api/v1/swagger/definitions/resolution.yaml | 10 +++++ api/v1/swagger/paths/catalog_concerns.yaml | 43 ++++++++++++++++++++ api/v1/swagger/swagger.yaml | 4 ++ 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 api/v1/swagger/definitions/resolution.yaml --- a/Koha/Catalog/Concern.pm +++ a/Koha/Catalog/Concern.pm @@ -69,6 +69,42 @@ sub biblio { return Koha::Biblio->_new_from_dbic( $rs ); } +=head3 resolve + + $concern = $concern->resolve( + { + resolver => $user, + notify => $boolean, + message => $message + } + ); + +Method to mark a concern as resolved + +=cut + +sub resolve { + my ( $self, $params ) = @_; + + my $resolver = $params->{resolver}; + my $message = $params->{message}; + + $self->set( + { + resolved_date => \'NOW()', + resolver_id => $resolver->borrowernumber, + resolution_message => $message + } + )->store(); + + # Optionally add to message_queue here to notify reporter + if ( $params->{notify} ) { + + } + + return $self; +} + =head2 Internal methods =cut --- a/Koha/REST/V1/Catalog/Concerns.pm +++ a/Koha/REST/V1/Catalog/Concerns.pm @@ -99,8 +99,10 @@ sub update { my $concern = Koha::Catalog::Concerns->find( $c->validation->param('concern_id') ); if ( not defined $concern ) { - return $c->render( status => 404, - openapi => { error => "Object not found" } ); + return $c->render( + status => 404, + openapi => { error => "Object not found" } + ); } return try { @@ -138,4 +140,45 @@ sub delete { }; } +=head3 resolve + +Resolve action, sets the catalog concern to resolved and optionally sends the submitter a notification. + +=cut + +sub resolve { + my $c = shift->openapi->valid_input or return; + + my $concern = + Koha::Catalog::Concerns->find( $c->validation->param('concern_id') ); + + if ( not defined $concern ) { + return $c->render( + status => 404, + openapi => { error => "Object not found" } + ); + } + + my $resolver = $c->stash('koha.user'); + my $body = $c->validation->param('body'); + my $notify = $body->{notify}; + my $message = $body->{message}; + return try { + $concern->resolve( + { + resolver => $resolver, + notify => $notify, + message => $message + } + ); + return $c->render( + status => 204, + openapi => q{} + ); + } + catch { + $c->unhandled_exception($_); + } +} + 1; --- a/api/v1/swagger/definitions/resolution.yaml +++ a/api/v1/swagger/definitions/resolution.yaml @@ -0,0 +1,10 @@ +--- +type: object +properties: + message: + description: Resolution message + type: string + notify: + description: Signal to notify the user + type: boolean +additionalProperties: true --- a/api/v1/swagger/paths/catalog_concerns.yaml +++ a/api/v1/swagger/paths/catalog_concerns.yaml @@ -210,6 +210,49 @@ x-koha-authorization: permissions: editcatalogue: edit_catalogue +"/catalog/concerns/{concern_id}/resolve": + post: + x-mojo-to: Catalog::Concerns#resolve + operationId: resolveConcern + tags: + - concerns + summary: Resolve the concern + parameters: + - $ref: "../swagger.yaml#/parameters/concern_id_pp" + - name: body + in: body + description: A resolution object + required: true + schema: + $ref: "../swagger.yaml#/definitions/resolution" + produces: + - application/json + responses: + "204": + description: Concern resolved + "401": + description: Authentication required + schema: + $ref: "../swagger.yaml#/definitions/error" + "403": + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + "404": + description: Concern not found + schema: + $ref: "../swagger.yaml#/definitions/error" + "500": + description: Internal error + schema: + $ref: "../swagger.yaml#/definitions/error" + "503": + description: Under maintenance + schema: + $ref: "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + editcatalogue: edit_catalogue /public/catalog/concerns: post: x-mojo-to: Catalog::Concerns#add --- a/api/v1/swagger/swagger.yaml +++ a/api/v1/swagger/swagger.yaml @@ -68,6 +68,8 @@ definitions: $ref: ./definitions/renewal.yaml renewals: $ref: ./definitions/renewals.yaml + resolution: + $ref: ./definitions/resolution.yaml return_claim: $ref: ./definitions/return_claim.yaml smtp_server: @@ -131,6 +133,8 @@ paths: $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns" "/catalog/concerns/{concern_id}": $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns~1{concern_id}" + "/catalog/concerns/{concern_id}/resolve": + $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns~1{concern_id}~1resolve" /checkouts: $ref: ./paths/checkouts.yaml#/~1checkouts "/checkouts/{checkout_id}": --