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:
parent
1800a2e6b8
commit
f4936fd46a
|
|
@ -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') ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue