return $url;
}
+=head3 to_api_mapping
+
+This method returns the mapping for representing a Koha::Biblio object
+on the API.
+
+=cut
+
+sub to_api_mapping {
+ return {
+ biblionumber => 'biblio_id',
+ frameworkcode => 'framework_id',
+ unititle => 'uniform_title',
+ seriestitle => 'series_title',
+ copyrightdate => 'copyright_date',
+ datecreated => 'creation_date'
+ };
+}
+
+=head2 Internal methods
+
=head3 type
=cut
=head1 API
-=head2 Class Methods
+=head2 Class methods
+
+=head3 to_api_mapping
+
+This method returns the mapping for representing a Koha::Biblioitem object
+on the API.
=cut
-=head3 type
+sub to_api_mapping {
+ return {
+ agerestriction => 'age_restriction',
+ biblioitemnumber => undef, # meaningless
+ collectionissn => 'collection_issn',
+ collectiontitle => 'collection_title',
+ collectionvolume => 'collection_volume',
+ editionresponsibility => undef, # obsolete, not mapped
+ editionstatement => 'edition_statement',
+ illus => 'illustrations',
+ itemtype => 'item_type',
+ lccn => 'lc_control_number',
+ place => 'publication_place',
+ publicationyear => 'publication_year',
+ publishercode => 'publisher',
+ size => 'material_size',
+ totalissues => 'serial_total_issues',
+ volumedate => 'volume_date',
+ volumedesc => 'volume_description',
+
+ };
+}
+
+=head2 Internal methods
+
+=head3 _type
=cut
=head1 API
-=head2 Class methods
+=head2 Methods
=head3 get
=head2 Internal methods
-
-=head3 _to_api
-
-Helper function that maps unblessed Koha::Patron objects into REST api
-attribute names.
-
-=cut
-
-sub _to_api {
- my $biblio = shift;
-
- # Rename attributes
- foreach my $column ( keys %{$Koha::REST::V1::Biblios::to_api_mapping} ) {
- my $mapped_column = $Koha::REST::V1::Biblios::to_api_mapping->{$column};
- if ( exists $biblio->{$column}
- && defined $mapped_column )
- {
- # key != undef
- $biblio->{$mapped_column} = delete $biblio->{$column};
- }
- elsif ( exists $biblio->{$column}
- && !defined $mapped_column )
- {
- # key == undef
- delete $biblio->{$column};
- }
- }
-
- return $biblio;
-}
-
-
=head3 build_json_biblio
Internal method that returns all the attributes from the biblio and biblioitems tables
my $biblio = $args->{biblio};
- my $response = $biblio->TO_JSON;
- my $biblioitem = $biblio->biblioitem->TO_JSON;
+ my $response = $biblio->to_api;
+ my $biblioitem = $biblio->biblioitem->to_api;
foreach my $key ( keys %{ $biblioitem } ) {
$response->{$key} = $biblioitem->{$key};
}
- return _to_api($response);
+ return $response;
}
-
-=head2 Global variables
-
-=head3 $to_api_mapping
-
-=cut
-
-our $to_api_mapping = {
- agerestriction => 'age_restriction',
- biblioitemnumber => undef, # meaningless
- biblionumber => 'biblio_id',
- collectionissn => 'collection_issn',
- collectiontitle => 'collection_title',
- collectionvolume => 'collection_volume',
- copyrightdate => 'copyright_date',
- datecreated => 'creation_date',
- editionresponsibility => undef, # obsolete, not mapped
- editionstatement => 'edition_statement',
- frameworkcode => 'framework_id',
- illus => 'illustrations',
- itemtype => 'item_type',
- lccn => 'lc_control_number',
- place => 'publication_place',
- publicationyear => 'publication_year',
- publishercode => 'publisher',
- seriestitle => 'series_title',
- size => 'material_size',
- totalissues => 'serial_total_issues',
- unititle => 'uniform_title',
- volumedate => 'volume_date',
- volumedesc => 'volume_description',
-};
-
1;