API-INSEE-Sirene

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


4.03
        - Removed unused import
        - Updated README
        - Updated documentation

4.02
        - The getCustomCriteria method doesn't take $use_historized_field parameter anymore
          The module will now auto-detect historized fields
        - Added setCurrentEndpoint method
        - Aliases are now mapped with more fields
        - Updated documentation

4.01
        - Updated dependencies in Makefile.PL

4.00
        - Major internal restructuration
        - The module version number is no longer depending on the INSEE's API version number
        - The module is now using OOP
        - The module will now send requests using POST method when possible.

lib/API/INSEE/Sirene.pm  view on Meta::CPAN

    $parameters->{'champs'} = $self->_buildFields($usefull_fields, $desired_fields) if (defined $desired_fields && $desired_fields ne 'all');
    $parameters->{'q'}      = sprintf('(%s)', $criteria) if defined $criteria;

    return $parameters;
}

sub _buildFields {
    my ($self, $usefull_fields, $desired_fields) = @_;

    if (defined $desired_fields) {
        return $self->_mapAliases($desired_fields);
    }
    else {
        return join ',', @{ $usefull_fields };
    }
}

sub _mapAliases {
    my ($self, $desired_fields) = @_;

    my @desired_fields = ref $desired_fields eq 'ARRAY' ? @{ $desired_fields } : $desired_fields;

    foreach my $desired_field (@desired_fields) {
        if (exists $useful_fields_aliases->{$desired_field}) {
            if (ref $useful_fields_aliases->{$desired_field} eq 'ARRAY') {
                $desired_field = join ',', @{ $useful_fields_aliases->{$desired_field} };
            }
            else {



( run in 0.323 second using v1.01-cache-2.11-cpan-49f99fa48dc )