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

(-)a/Koha/Object.pm (-5 / +10 lines)
Lines 490-503 sub attributes_from_api { Link Here
490
    my $from_api_mapping = $self->from_api_mapping;
490
    my $from_api_mapping = $self->from_api_mapping;
491
491
492
    my $params;
492
    my $params;
493
    my $columns_info = $self->_result->result_source->columns_info;
493
494
494
    while (my ($key, $value) = each %{ $from_api_params } ) {
495
    while (my ($key, $value) = each %{ $from_api_params } ) {
495
        if ( exists $from_api_mapping->{$key} ) {
496
        my $koha_field_name =
496
            $params->{$from_api_mapping->{$key}} = $value;
497
          exists $from_api_mapping->{$key}
497
        }
498
          ? $from_api_mapping->{$key}
498
        else {
499
          : $key;
499
            $params->{$key} = $value;
500
501
        if ( _date_or_datetime_column_type( $columns_info->{$koha_field_name}->{data_type} ) ) {
502
            $value = dt_from_string($value, 'rfc3339');
500
        }
503
        }
504
505
        $params->{$koha_field_name} = $value;
501
    }
506
    }
502
507
503
    return $params;
508
    return $params;
(-)a/Koha/Patron.pm (-26 lines)
Lines 1566-1596 sub to_api { Link Here
1566
    return $json_patron;
1566
    return $json_patron;
1567
}
1567
}
1568
1568
1569
=head3 attributes_from_api
1570
1571
    my $attrs = $patron->attributes_from_api( $attrs );
1572
1573
Overloaded method that implement specific data transformations after
1574
calling the original Koha::Object->attributes_from_api method.
1575
1576
=cut
1577
1578
sub attributes_from_api {
1579
    my ( $self, $attrs ) = @_;
1580
1581
    $attrs = $self->SUPER::attributes_from_api( $attrs );
1582
1583
    if ( exists $attrs->{lastseen} ) {
1584
        $attrs->{lastseen} = dt_from_string($attrs->{lastseen}, 'rfc3339');
1585
    }
1586
1587
    if ( exists $attrs->{updated_on} ) {
1588
        $attrs->{updated_on} = dt_from_string($attrs->{updated_on}, 'rfc3339');
1589
    }
1590
1591
    return $attrs;
1592
}
1593
1594
=head3 to_api_mapping
1569
=head3 to_api_mapping
1595
1570
1596
This method returns the mapping for representing a Koha::Patron object
1571
This method returns the mapping for representing a Koha::Patron object
1597
- 

Return to bug 23893