|
Lines 1476-1481
sub add_guarantor {
Link Here
|
| 1476 |
)->store(); |
1476 |
)->store(); |
| 1477 |
} |
1477 |
} |
| 1478 |
|
1478 |
|
|
|
1479 |
=head3 to_api |
| 1480 |
|
| 1481 |
my $json = $patron->to_api; |
| 1482 |
|
| 1483 |
Overloaded method that returns a JSON representation of the Koha::Patron object, |
| 1484 |
suitable for API output. |
| 1485 |
|
| 1486 |
=cut |
| 1487 |
|
| 1488 |
sub to_api { |
| 1489 |
my ( $self ) = @_; |
| 1490 |
|
| 1491 |
my $json_patron = $self->SUPER::to_api; |
| 1492 |
|
| 1493 |
$json_patron->{restricted} = ( $self->is_debarred ) |
| 1494 |
? Mojo::JSON->true |
| 1495 |
: Mojo::JSON->false; |
| 1496 |
|
| 1497 |
return $json_patron; |
| 1498 |
} |
| 1499 |
|
| 1500 |
=head3 to_api_mapping |
| 1501 |
|
| 1502 |
This method returns the mapping for representing a Koha::Patron object |
| 1503 |
on the API. |
| 1504 |
|
| 1505 |
=cut |
| 1506 |
|
| 1507 |
sub to_api_mapping { |
| 1508 |
return { |
| 1509 |
borrowernotes => 'staff_notes', |
| 1510 |
borrowernumber => 'patron_id', |
| 1511 |
branchcode => 'library_id', |
| 1512 |
categorycode => 'category_id', |
| 1513 |
checkprevcheckout => 'check_previous_checkout', |
| 1514 |
contactfirstname => undef, # Unused |
| 1515 |
contactname => undef, # Unused |
| 1516 |
contactnote => 'altaddress_notes', |
| 1517 |
contacttitle => undef, # Unused |
| 1518 |
dateenrolled => 'date_enrolled', |
| 1519 |
dateexpiry => 'expiry_date', |
| 1520 |
dateofbirth => 'date_of_birth', |
| 1521 |
debarred => undef, # replaced by 'restricted' |
| 1522 |
debarredcomment => undef, # calculated, API consumers will use /restrictions instead |
| 1523 |
emailpro => 'secondary_email', |
| 1524 |
flags => undef, # permissions manipulation handled in /permissions |
| 1525 |
gonenoaddress => 'incorrect_address', |
| 1526 |
guarantorid => 'guarantor_id', |
| 1527 |
lastseen => 'last_seen', |
| 1528 |
lost => 'patron_card_lost', |
| 1529 |
opacnote => 'opac_notes', |
| 1530 |
othernames => 'other_name', |
| 1531 |
password => undef, # password manipulation handled in /password |
| 1532 |
phonepro => 'secondary_phone', |
| 1533 |
relationship => 'relationship_type', |
| 1534 |
sex => 'gender', |
| 1535 |
smsalertnumber => 'sms_number', |
| 1536 |
sort1 => 'statistics_1', |
| 1537 |
sort2 => 'statistics_2', |
| 1538 |
streetnumber => 'street_number', |
| 1539 |
streettype => 'street_type', |
| 1540 |
zipcode => 'postal_code', |
| 1541 |
B_address => 'altaddress_address', |
| 1542 |
B_address2 => 'altaddress_address2', |
| 1543 |
B_city => 'altaddress_city', |
| 1544 |
B_country => 'altaddress_country', |
| 1545 |
B_email => 'altaddress_email', |
| 1546 |
B_phone => 'altaddress_phone', |
| 1547 |
B_state => 'altaddress_state', |
| 1548 |
B_streetnumber => 'altaddress_street_number', |
| 1549 |
B_streettype => 'altaddress_street_type', |
| 1550 |
B_zipcode => 'altaddress_postal_code', |
| 1551 |
altcontactaddress1 => 'altcontact_address', |
| 1552 |
altcontactaddress2 => 'altcontact_address2', |
| 1553 |
altcontactaddress3 => 'altcontact_city', |
| 1554 |
altcontactcountry => 'altcontact_country', |
| 1555 |
altcontactfirstname => 'altcontact_firstname', |
| 1556 |
altcontactphone => 'altcontact_phone', |
| 1557 |
altcontactsurname => 'altcontact_surname', |
| 1558 |
altcontactstate => 'altcontact_state', |
| 1559 |
altcontactzipcode => 'altcontact_postal_code' |
| 1560 |
}; |
| 1561 |
} |
| 1562 |
|
| 1479 |
=head2 Internal methods |
1563 |
=head2 Internal methods |
| 1480 |
|
1564 |
|
| 1481 |
=head3 _type |
1565 |
=head3 _type |