Bugzilla – Attachment 94591 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::Hold
Bug-23843-Add-mapping-to-KohaHold.patch (text/plain), 2.94 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-10-22 19:01:35 UTC
(
hide
)
Description:
Bug 23843: Add mapping to Koha::Hold
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-10-22 19:01:35 UTC
Size:
2.94 KB
patch
obsolete
>From 8afd0bdfe9e89e0031c1f7cd1b5b755a06b2c138 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 21 Oct 2019 13:26:07 -0300 >Subject: [PATCH] Bug 23843: Add mapping to Koha::Hold > >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/holds.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/Hold.pm | 34 +++++++++++++++++++++++++++++++++- > Koha/REST/V1/Holds.pm | 10 ++++++++-- > 2 files changed, 41 insertions(+), 3 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 30188ae69e..05afea8591 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -400,7 +400,39 @@ sub _move_to_old { > return Koha::Old::Hold->new( $hold_infos )->store; > } > >-=head3 type >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Hold object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ reserve_id => 'hold_id', >+ borrowernumber => 'patron_id', >+ reservedate => 'hold_date', >+ biblionumber => 'biblio_id', >+ branchcode => 'pickup_library_id', >+ notificationdate => undef, >+ reminderdate => undef, >+ cancellationdate => 'cancelation_date', >+ reservenotes => 'notes', >+ found => 'status', >+ itemnumber => 'item_id', >+ waitingdate => 'waiting_date', >+ expirationdate => 'expiration_date', >+ lowestPriority => 'lowest_priority', >+ suspend => 'suspended', >+ suspend_until => 'suspended_until', >+ itemtype => 'item_type', >+ item_level_hold => 'item_level', >+ }; >+} >+ >+=head2 Internal methods >+ >+=head3 _type > > =cut > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 00faf2ffed..41e93fc308 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -184,7 +184,10 @@ sub add { > > my $hold = Koha::Holds->find($hold_id); > >- return $c->render( status => 201, openapi => _to_api($hold->TO_JSON) ); >+ return $c->render( >+ status => 201, >+ openapi => $hold->to_api >+ ); > } > catch { > if ( blessed $_ and $_->isa('Koha::Exceptions') ) { >@@ -258,7 +261,10 @@ sub edit { > C4::Reserves::ModReserve($params); > $hold->discard_changes; # refresh > >- return $c->render( status => 200, openapi => _to_api( $hold->TO_JSON ) ); >+ return $c->render( >+ status => 200, >+ openapi => $hold->to_api >+ ); > } > > =head3 delete >-- >2.23.0
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