Bugzilla – Attachment 94628 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::Acquisition::Fund
Bug-23843-Add-mapping-to-KohaAcquisitionFund.patch (text/plain), 3.63 KB, created by
Joonas Kylmälä
on 2019-10-23 14:12:15 UTC
(
hide
)
Description:
Bug 23843: Add mapping to Koha::Acquisition::Fund
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2019-10-23 14:12:15 UTC
Size:
3.63 KB
patch
obsolete
>From 0aecf464d76171b9a4dff2f8ea52bced9cf76591 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 21 Oct 2019 13:47:50 -0300 >Subject: [PATCH] Bug 23843: Add mapping to Koha::Acquisition::Fund >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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/acquisitions_funds.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> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Acquisition/Fund.pm | 29 ++++++++++++++++++++++++++++ > Koha/REST/V1/Acquisitions/Funds.pm | 9 +++++---- > api/v1/swagger/definitions/fund.json | 4 ++++ > 3 files changed, 38 insertions(+), 4 deletions(-) > >diff --git a/Koha/Acquisition/Fund.pm b/Koha/Acquisition/Fund.pm >index 20cc26ea5f..484b19fd09 100644 >--- a/Koha/Acquisition/Fund.pm >+++ b/Koha/Acquisition/Fund.pm >@@ -27,6 +27,35 @@ Koha::Acquisition::Fund object class > > =head1 API > >+=head2 Class methods >+ >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Acquisition::Fund object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ budget_id => 'fund_id', >+ budget_code => 'code', >+ budget_name => 'name', >+ budget_branchcode => 'library_id', >+ budget_amount => 'total_amount', >+ budget_encumb => 'warn_at_percentage', >+ budget_expend => 'warn_at_amount', >+ budget_notes => 'notes', >+ budget_period_id => 'budget_id', >+ timestamp => 'timestamp', >+ budget_owner_id => 'fund_owner_id', >+ budget_permission => 'fund_access', >+ sort1_authcat => 'statistic1_auth_value_category', >+ sort2_authcat => 'statistic2_auth_value_category', >+ budget_parent_id => 'parent_fund_id', >+ }; >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/Koha/REST/V1/Acquisitions/Funds.pm b/Koha/REST/V1/Acquisitions/Funds.pm >index c789e7fd56..21f5e4bacf 100644 >--- a/Koha/REST/V1/Acquisitions/Funds.pm >+++ b/Koha/REST/V1/Acquisitions/Funds.pm >@@ -56,10 +56,11 @@ sub list_funds { > } > > return try { >- my @funds = Koha::Acquisition::Funds->search($filter); >- @funds = map { _to_api($_->TO_JSON) } @funds; >- return $c->render( status => 200, >- openapi => \@funds); >+ my $funds = Koha::Acquisition::Funds->search($filter); >+ return $c->render( >+ status => 200, >+ openapi => $funds->to_api >+ ); > } > catch { > if ( $_->isa('DBIx::Class::Exception') ) { >diff --git a/api/v1/swagger/definitions/fund.json b/api/v1/swagger/definitions/fund.json >index a7e34d619d..265571ed94 100644 >--- a/api/v1/swagger/definitions/fund.json >+++ b/api/v1/swagger/definitions/fund.json >@@ -81,6 +81,10 @@ > ], > "description": "Level of permission for this fund (1: owner, 2: owner, users and library, 3: owner and users)" > }, >+ "parent_fund_id": { >+ "type": [ "integer", "null" ], >+ "description": "Internal identifier for parent fund" >+ }, > "statistic1_auth_value_category": { > "type": [ > "string", >-- >2.17.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