@@ -, +, @@ $ kshell k$ prove t/db_dependent/api/v1/checkouts.t --- Koha/Checkout.pm | 25 ++++++++++++++++++++++++- Koha/REST/V1/Checkouts.pm | 8 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-) --- a/Koha/Checkout.pm +++ a/Koha/Checkout.pm @@ -88,7 +88,30 @@ sub patron { return Koha::Patron->_new_from_dbic( $patron_rs ); } -=head3 type +=head3 to_api_mapping + +This method returns the mapping for representing a Koha::Checkout object +on the API. + +=cut + +sub to_api_mapping { + return { + issue_id => 'checkout_id', + borrowernumber => 'patron_id', + itemnumber => 'item_id', + date_due => 'due_date', + branchcode => 'library_id', + returndate => 'checkin_date', + lastreneweddate => 'last_renewed_date', + issuedate => 'checkout_date', + notedate => 'note_date', + }; +} + +=head2 Internal methods + +=head3 _type =cut --- a/Koha/REST/V1/Checkouts.pm +++ a/Koha/REST/V1/Checkouts.pm @@ -92,8 +92,8 @@ sub get { } return $c->render( - status => 200, - openapi => _to_api($checkout->TO_JSON) + status => 200, + openapi => $checkout->to_api ); } @@ -134,8 +134,8 @@ sub renew { $c->res->headers->location( $c->req->url->to_string ); return $c->render( - status => 201, - openapi => _to_api( $checkout->TO_JSON ) + status => 201, + openapi => $checkout->to_api ); } --