From 685f04a4416764f748a0b1cf0ebfb9f2fce2e4a6 Mon Sep 17 00:00:00 2001 From: Mark Hofstetter Date: Tue, 13 Jun 2023 17:32:28 +0200 Subject: [PATCH] infrastructure f merge api https://bugs.koha-community.org/show_bug.cgi?id=33036 --- Koha/REST/V1/Biblios.pm | 23 +++++++++++++ api/v1/swagger/paths/biblios_merge.yaml | 45 +++++++++++++++++++++++++ api/v1/swagger/swagger.yaml | 2 ++ 3 files changed, 70 insertions(+) create mode 100644 api/v1/swagger/paths/biblios_merge.yaml diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 6457d49d7a..0c0a62a1e7 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -859,4 +859,27 @@ sub list { }; } +sub merge { + my $c = shift->openapi->valid_input or return; + my $bn = $c->validation->param('biblio_id'); + my $bn_merge = $c->validation->param('biblio_id_to_merge'); + my $biblio = Koha::Biblios->find( $bn ); + if ( not defined $biblio ) { + return $c->render( + status => 404, + openapi => { error => sprintf("[%s] biblio to merge into not found", $bn) } + ); + } + + my $biblio_to_merge = Koha::Biblios->find( $bn_merge ); + if ( not defined $biblio_to_merge ) { + return $c->render( + status => 404, + openapi => { error => sprintf("[%s] biblio to merge from not found", $bn_merge) } + ); + } + + return $c->render( status => 200, openapi => sprintf("OK %s <= %s, %s, %s", $bn, $bn_merge, $biblio->title, $biblio_to_merge->title) ); +} + 1; diff --git a/api/v1/swagger/paths/biblios_merge.yaml b/api/v1/swagger/paths/biblios_merge.yaml new file mode 100644 index 0000000000..867796eda1 --- /dev/null +++ b/api/v1/swagger/paths/biblios_merge.yaml @@ -0,0 +1,45 @@ +--- +"/biblios/{biblio_id}/merge/{biblio_id_to_merge}": + put: + x-mojo-to: Biblios#merge + operationId: mergeBiblios + tags: + - merge_biblios + summary: Merge Biblios + parameters: + - name: biblio_id + in: path + description: Bilblionumber to be merged into + required: true + type: string + - name: biblio_id_to_merge + in: path + required: true + description: Biblionumber from which to merge + type: string + responses: + '200': + description: OK message +## schema: +## type: string +## items: +## "$ref": "../swagger.yaml#/definitions/item_group" +## '401': +## description: Authentication required +## schema: +## "$ref": "../swagger.yaml#/definitions/error" +## '403': +## description: Access forbidden +## schema: +## "$ref": "../swagger.yaml#/definitions/error" +## '500': +## description: Internal server error +## schema: +## "$ref": "../swagger.yaml#/definitions/error" +## '503': +## description: Under maintenance +## schema: +## "$ref": "../swagger.yaml#/definitions/error" + x-koha-authorization: + permissions: + catalogue: "manage_item_groups" diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 9e60aa77a2..d32fc45551 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -183,6 +183,8 @@ paths: $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items" "/biblios/{biblio_id}/item_groups/{item_group_id}/items/{item_id}": $ref: "./paths/biblios_item_groups.yaml#/~1biblios~1{biblio_id}~1item_groups~1{item_group_id}~1items~1{item_id}" + "/biblios/{biblio_id}/merge/{biblio_id_to_merge}": + $ref: "./paths/biblios_merge.yaml#/~1biblios~1{biblio_id}~1merge~1{biblio_id_to_merge}" "/cash_registers/{cash_register_id}/cashups": $ref: "./paths/cash_registers.yaml#/~1cash_registers~1{cash_register_id}~1cashups" "/cashups/{cashup_id}": -- 2.20.1