From 0827e10c39e29e1483941eac5e28ef641052dbe7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 May 2022 18:27:20 +0200 Subject: [PATCH] Bug 32030: ERM - related agreement - REST API Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/ERM/Agreements.pm | 4 +++ api/v1/swagger/definitions/erm_agreement.yaml | 5 ++++ .../erm_agreement_relationship.yaml | 30 +++++++++++++++++++ api/v1/swagger/paths/erm_agreements.yaml | 4 +++ 4 files changed, 43 insertions(+) create mode 100644 api/v1/swagger/definitions/erm_agreement_relationship.yaml diff --git a/Koha/REST/V1/ERM/Agreements.pm b/Koha/REST/V1/ERM/Agreements.pm index 09110f5f62..3d64e95609 100644 --- a/Koha/REST/V1/ERM/Agreements.pm +++ b/Koha/REST/V1/ERM/Agreements.pm @@ -94,11 +94,13 @@ sub add { my $periods = delete $body->{periods} // []; my $user_roles = delete $body->{user_roles} // []; my $agreement_licenses = delete $body->{agreement_licenses} // []; + my $agreement_relationships = delete $body->{agreement_relationships} // []; my $agreement = Koha::ERM::Agreement->new_from_api($body)->store; $agreement->periods($periods); $agreement->user_roles($user_roles); $agreement->agreement_licenses($agreement_licenses); + $agreement->agreement_relationships($agreement_relationships); $c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); return $c->render( @@ -173,11 +175,13 @@ sub update { my $periods = delete $body->{periods} // []; my $user_roles = delete $body->{user_roles} // []; my $agreement_licenses = delete $body->{agreement_licenses} // []; + my $agreement_relationships = delete $body->{agreement_relationships} // []; $agreement->set_from_api($body)->store; $agreement->periods($periods); $agreement->user_roles($user_roles); $agreement->agreement_licenses($agreement_licenses); + $agreement->agreement_relationships($agreement_relationships); $c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); return $c->render( diff --git a/api/v1/swagger/definitions/erm_agreement.yaml b/api/v1/swagger/definitions/erm_agreement.yaml index 2c23a499c8..c1f41f8cd9 100644 --- a/api/v1/swagger/definitions/erm_agreement.yaml +++ b/api/v1/swagger/definitions/erm_agreement.yaml @@ -49,6 +49,11 @@ properties: description: role for users items: $ref: erm_agreement_user_role.yaml + agreement_relationships: + type: array + description: agreement relationships + items: + $ref: erm_agreement_relationship.yaml agreement_licenses: type: array description: agreement licenses diff --git a/api/v1/swagger/definitions/erm_agreement_relationship.yaml b/api/v1/swagger/definitions/erm_agreement_relationship.yaml new file mode 100644 index 0000000000..d3ba3c258f --- /dev/null +++ b/api/v1/swagger/definitions/erm_agreement_relationship.yaml @@ -0,0 +1,30 @@ +--- +type: object +properties: + agreement_id: + type: integer + description: Internal agreement identifier + related_agreement_id: + type: integer + description: Internal related agreement identifier + relationship: + description: relationship between the agreements + type: string + enum: + - supersedes + - is-superseded-by + - provides_post-cancellation_access_for + - has-post-cancellation-access-in + - tracks_demand-driven_acquisitions_for + - has-demand-driven-acquisitions-in + - has_backfile_in + - has_frontfile_in + - related_to + notes: + type: + - string + - "null" +additionalProperties: false +required: + - related_agreement_id + - relationship diff --git a/api/v1/swagger/paths/erm_agreements.yaml b/api/v1/swagger/paths/erm_agreements.yaml index 8c2c31bf68..e8b7358ab3 100644 --- a/api/v1/swagger/paths/erm_agreements.yaml +++ b/api/v1/swagger/paths/erm_agreements.yaml @@ -189,6 +189,9 @@ - user_roles.patron - agreement_licenses - agreement_licenses.license + - agreement_relationships + - agreement_relationships.agreement + - agreement_relationships.related_agreement put: x-mojo-to: ERM::Agreements#update operationId: updateErmAgreements @@ -247,6 +250,7 @@ - periods - user_roles - agreement_licenses + - agreement_relationships delete: x-mojo-to: ERM::Agreements#delete operationId: deleteErmAgreements -- 2.39.5