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 <tomascohen@theke.io>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2019-10-08 15:43:10 -03:00 committed by Martin Renvoize
parent 1800a2e6b8
commit f4936fd46a
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 3 additions and 3 deletions

View File

@ -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') ) {