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

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

Return to bug 23893