Bugzilla – Attachment 94507 Details for
Bug 23843
Make existing endpoints use Koha::Object(s)->to_api
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23843: Add mapping to Koha::Checkout
Bug-23843-Add-mapping-to-KohaCheckout.patch (text/plain), 2.42 KB, created by
Martin Renvoize (ashimema)
on 2019-10-22 07:57:01 UTC
(
hide
)
Description:
Bug 23843: Add mapping to Koha::Checkout
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-10-22 07:57:01 UTC
Size:
2.42 KB
patch
obsolete
>From 78b7de5f7165693cdc8933782a67396ccf7c5fe6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 21 Oct 2019 13:24:45 -0300 >Subject: [PATCH] Bug 23843: Add mapping to Koha::Checkout > >This patch adds a to_api_mapping method to the class. This in effect >enables calling ->to_api on the object. The mapping is borrowed from the >API controller. It is not removed from the controller so we are able to >verify (through the tests) that there is no behavior change. >Once this is pushed we need to implement the counter-wise methods and >clean the controllers. >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/api/v1/checkouts.t >=> SUCCESS: Tests pass >2. Apply this patch >3. Repeat (1) >=> SUCCESS: Tests still pass! >4. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Checkout.pm | 25 ++++++++++++++++++++++++- > Koha/REST/V1/Checkouts.pm | 8 ++++---- > 2 files changed, 28 insertions(+), 5 deletions(-) > >diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm >index b7a752cdc5..1cba41ea3f 100644 >--- a/Koha/Checkout.pm >+++ b/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 > >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index b3a0699006..c8ded14ef7 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/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 > ); > } > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23843
:
94470
|
94471
|
94472
|
94473
|
94474
|
94475
|
94476
|
94477
|
94478
|
94496
|
94506
|
94507
|
94508
|
94509
|
94510
|
94511
|
94512
|
94513
|
94514
|
94587
|
94588
|
94589
|
94590
|
94591
|
94592
|
94593
|
94594
|
94595
|
94596
|
94619
|
94620
|
94621
|
94622
|
94623
|
94624
|
94625
|
94626
|
94627
|
94628