Bug 23843: Add mapping to Koha::Club::Holds
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/clubs_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> Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
1957cb64ca
commit
af2cd5e303
2 changed files with 26 additions and 6 deletions
|
@ -40,7 +40,7 @@ Represents a hold made for every member of club
|
||||||
|
|
||||||
=head1 API
|
=head1 API
|
||||||
|
|
||||||
=head2 Class Methods
|
=head2 Class methods
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
@ -125,7 +125,26 @@ sub add {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=head3 type
|
|
||||||
|
=head3 to_api_mapping
|
||||||
|
|
||||||
|
This method returns the mapping for representing a Koha::Club::Hold object
|
||||||
|
on the API.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub to_api_mapping {
|
||||||
|
return {
|
||||||
|
id => 'club_hold_id',
|
||||||
|
club_id => 'club_id',
|
||||||
|
biblio_id => 'biblio_id',
|
||||||
|
item_id => 'item_id'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 Internal methods
|
||||||
|
|
||||||
|
=head3 _type
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,10 @@ sub add {
|
||||||
item_type => $item_type
|
item_type => $item_type
|
||||||
});
|
});
|
||||||
|
|
||||||
my $mapping = _to_api($club_hold->unblessed);
|
return $c->render(
|
||||||
|
status => 201,
|
||||||
return $c->render( status => 201, openapi => $mapping );
|
openapi => $club_hold->to_api
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
if ( blessed $_ and $_->isa('Koha::Exceptions::Object') ) {
|
if ( blessed $_ and $_->isa('Koha::Exceptions::Object') ) {
|
||||||
|
|
Loading…
Reference in a new issue