From f4936fd46a284aeb1976965b83a6a29caefa2890 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 8 Oct 2019 15:43:10 -0300 Subject: [PATCH] Bug 23770: (follow-up) Use ->to_api in /cities This patch aims to prove the behaviour does not differ. So you can run the tests for the endpoints, and the behaviour remains. The mappings and methods cannot be removed until $c->objects->search is fixed to make use of them as well. That will happen once all used Koha::Object-based classes implement the mappings. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/cities.t => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi Signed-off-by: Josef Moravec Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize --- Koha/REST/V1/Cities.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm index 5a579b4ee4..222f7c0015 100644 --- a/Koha/REST/V1/Cities.pm +++ b/Koha/REST/V1/Cities.pm @@ -65,7 +65,7 @@ sub get { openapi => { error => "City not found" } ); } - return $c->render( status => 200, openapi => _to_api($city->TO_JSON) ); + return $c->render( status => 200, openapi => $city->to_api ); } =head3 add @@ -78,7 +78,7 @@ sub add { return try { my $city = Koha::City->new( _to_model( $c->validation->param('body') ) ); $city->store; - return $c->render( status => 200, openapi => _to_api($city->TO_JSON) ); + return $c->render( status => 200, openapi => $city->to_api ); } catch { if ( $_->isa('DBIx::Class::Exception') ) { @@ -114,7 +114,7 @@ sub update { my $params = $c->req->json; $city->set( _to_model($params) ); $city->store(); - return $c->render( status => 200, openapi => _to_api($city->TO_JSON) ); + return $c->render( status => 200, openapi => $city->to_api ); } catch { if ( $_->isa('Koha::Exceptions::Object') ) { -- 2.39.5