};
}
-
-=head3 _to_api
-
-Helper function that maps unblessed Koha::Account::Line objects
-into REST API attribute names.
-
-=cut
-
-sub _to_api {
- my $account_line = shift;
-
- # Rename attributes
- foreach my $column ( keys %{ $Koha::REST::V1::Patrons::Account::to_api_mapping } ) {
- my $mapped_column = $Koha::REST::V1::Patrons::Account::to_api_mapping->{$column};
- if ( exists $account_line->{ $column }
- && defined $mapped_column )
- {
- # key != undef
- $account_line->{ $mapped_column } = delete $account_line->{ $column };
- }
- elsif ( exists $account_line->{ $column }
- && !defined $mapped_column )
- {
- # key == undef
- delete $account_line->{ $column };
- }
- }
-
- return $account_line;
-}
-
-=head3 _to_model
-
-Helper function that maps REST API objects into Koha::Account::Line
-attribute names.
-
-=cut
-
-sub _to_model {
- my $account_line = shift;
-
- foreach my $attribute ( keys %{ $Koha::REST::V1::Patrons::Account::to_model_mapping } ) {
- my $mapped_attribute = $Koha::REST::V1::Patrons::Account::to_model_mapping->{$attribute};
- if ( exists $account_line->{ $attribute }
- && defined $mapped_attribute )
- {
- # key => !undef
- $account_line->{ $mapped_attribute } = delete $account_line->{ $attribute };
- }
- elsif ( exists $account_line->{ $attribute }
- && !defined $mapped_attribute )
- {
- # key => undef / to be deleted
- delete $account_line->{ $attribute };
- }
- }
-
- return $account_line;
-}
-
-=head2 Global variables
-
-=head3 $to_api_mapping
-
-=cut
-
-our $to_api_mapping = {
- accountlines_id => 'account_line_id',
- credit_type_code => 'credit_type',
- debit_type_code => 'debit_type',
- amountoutstanding => 'amount_outstanding',
- borrowernumber => 'patron_id',
- branchcode => 'library_id',
- issue_id => 'checkout_id',
- itemnumber => 'item_id',
- manager_id => 'user_id',
- note => 'internal_note',
-};
-
-=head3 $to_model_mapping
-
-=cut
-
-our $to_model_mapping = {
- account_line_id => 'accountlines_id',
- credit_type => 'credit_type_code',
- debit_type => 'debit_type_code',
- amount_outstanding => 'amountoutstanding',
- checkout_id => 'issue_id',
- internal_note => 'note',
- item_id => 'itemnumber',
- library_id => 'branchcode',
- patron_id => 'borrowernumber',
- user_id => 'manager_id'
-};
-
1;