View | Details | Raw Unified | Return to bug 23893
Collapse All | Expand All

(-)a/Koha/Patron.pm (+24 lines)
Lines 1565-1570 sub to_api { Link Here
1565
    return $json_patron;
1565
    return $json_patron;
1566
}
1566
}
1567
1567
1568
sub attributes_from_api {
1569
    my ( $self, $attrs ) = @_;
1570
1571
    $attrs = $self->SUPER::attributes_from_api( $attrs );
1572
1573
    if ( exists $attrs->{lost} ) {
1574
        $attrs->{lost} = ($attrs->{lost}) ? 1 : 0;
1575
    }
1576
1577
    if ( exists $attrs->{ gonenoaddress} ) {
1578
        $attrs->{gonenoaddress} = ($attrs->{gonenoaddress}) ? 1 : 0;
1579
    }
1580
1581
    if ( exists $attrs->{lastseen} ) {
1582
        $attrs->{lastseen} = output_pref({ str => $attrs->{lastseen}, dateformat => 'sql' });
1583
    }
1584
1585
    if ( exists $attrs->{updated_on} ) {
1586
        $attrs->{updated_on} = output_pref({ str => $attrs->{updated_on}, dateformat => 'sql' });
1587
    }
1588
1589
    return $attrs;
1590
}
1591
1568
=head3 to_api_mapping
1592
=head3 to_api_mapping
1569
1593
1570
This method returns the mapping for representing a Koha::Patron object
1594
This method returns the mapping for representing a Koha::Patron object
(-)a/Koha/REST/V1/Patrons.pm (-7 / +3 lines)
Lines 123-131 sub add { Link Here
123
123
124
    return try {
124
    return try {
125
125
126
        my $body = _to_model( $c->validation->param('body') );
126
        my $patron = Koha::Patron->new_from_api( $c->validation->param('body') )->store;
127
128
        my $patron = Koha::Patron->new( _to_model($body) )->store;
129
127
130
        $c->res->headers->location( $c->req->url->to_string . '/' . $patron->borrowernumber );
128
        $c->res->headers->location( $c->req->url->to_string . '/' . $patron->borrowernumber );
131
        return $c->render(
129
        return $c->render(
Lines 196-206 sub update { Link Here
196
     }
194
     }
197
195
198
    return try {
196
    return try {
199
        my $body = _to_model($c->validation->param('body'));
200
197
201
        $patron->set($body)->store;
198
        $patron->set_from_api($c->validation->param('body'))->store;
202
        $patron->discard_changes;
199
        $patron->discard_changes;
203
        return $c->render( status => 200, openapi => $patron );
200
        return $c->render( status => 200, openapi => $patron->to_api );
204
    }
201
    }
205
    catch {
202
    catch {
206
        unless ( blessed $_ && $_->can('rethrow') ) {
203
        unless ( blessed $_ && $_->can('rethrow') ) {
207
- 

Return to bug 23893