From 07faab4141b57e1cb05724d2f1cc16bcd300a5ce Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 8 Jul 2022 11:55:37 +0100 Subject: [PATCH] Bug 31028: Add relations to Catalog::Concern This patch adds the reporter, resolver and biblio relations to the Catalog::Concern class and exposes them to the API as appropriate. --- Koha/Catalog/Concern.pm | 43 +++++++++++++++++++ .../swagger/definitions/catalog_concern.yaml | 25 ++++++++--- api/v1/swagger/paths/catalog_concerns.yaml | 12 ++++++ 3 files changed, 75 insertions(+), 5 deletions(-) diff --git a/Koha/Catalog/Concern.pm b/Koha/Catalog/Concern.pm index d608da7512..e246c6f742 100644 --- a/Koha/Catalog/Concern.pm +++ b/Koha/Catalog/Concern.pm @@ -26,6 +26,49 @@ Koha::Catalog::Concern - Koha Catalog::Concern Object class =head1 API +=head2 Class methods + +=cut + +=head3 reporter + +Return the patron who submitted this concern + +=cut + +sub reporter { + my ( $self ) = @_; + my $rs = $self->_result->reporter; + return unless $rs; + return Koha::Patron->_new_from_dbic( $rs ); +} + +=head3 resolver + +Return the user who resolved this concern + +=cut + +sub resolver { + my ( $self ) = @_; + my $rs = $self->_result->resolver; + return unless $rs; + return Koha::Patron->_new_from_dbic( $rs ) if $rs; +} + +=head3 biblio + +Return the biblio linked to this concern + +=cut + +sub biblio { + my ( $self ) = @_; + my $rs = $self->_result->biblio; + return unless $rs; + return Koha::Biblio->_new_from_dbic( $rs ); +} + =head2 Internal methods =cut diff --git a/api/v1/swagger/definitions/catalog_concern.yaml b/api/v1/swagger/definitions/catalog_concern.yaml index 01e7b87b92..1e340bd3ca 100644 --- a/api/v1/swagger/definitions/catalog_concern.yaml +++ b/api/v1/swagger/definitions/catalog_concern.yaml @@ -4,26 +4,41 @@ properties: concern_id: type: integer description: Internal concern identifier - added_date: + reported_date: type: - string - "null" format: date-time description: Date the concern was reported + biblio: + type: + - object + - "null" + description: The object representing the biblio the concern is related to biblio_id: type: integer description: Internal identifier for the biblio the concern is related to message: type: string description: Concern details - patron_id: + reporter: + type: + - object + - "null" + description: The object representing the patron who reported the concern + reporter_id: type: integer - description: Internal identifier for the patron the concern was submitted by - resolved_by: + description: Internal identifier for the patron who reported the concern + resolver: + type: + - object + - "null" + description: The object representing the user who resolved the concern + resolver_id: type: - integer - "null" - description: Internal identifier for the patron the concern was resolved by + description: Internal identifier for the user who resolved the concern resolved_date: type: - string diff --git a/api/v1/swagger/paths/catalog_concerns.yaml b/api/v1/swagger/paths/catalog_concerns.yaml index 138d51986b..bf2bef0ab0 100644 --- a/api/v1/swagger/paths/catalog_concerns.yaml +++ b/api/v1/swagger/paths/catalog_concerns.yaml @@ -17,6 +17,18 @@ - $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: + - reporter + - resolver + - biblio + collectionFormat: csv responses: "200": description: A list of concerns -- 2.20.1