API-INSEE-Sirene

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

            The module now handles this case correctly and returns the json body instead of dumping the request.
        - In general way, the module now correctly handles the different HTTP response codes given by the API
        - Better handling of tokens renewal
        - Added searchLegalUnitBySIREN method
        - Added searchEstablishmentBySIRET method
        - Added getCustomCriteria method
        - Added searchByCustomCriteria method
        - Added setMaxResults method
        - Added setDebugMode method
        - Added setProxy method
        - Added setTimeout method
        - Added setCredentials method
        - Added MIN_DIGIT constant 
        - Removed CLIENT_AUTH constant
        - Removed getEstablishmentsByCriteria function
        - Removed getLegalUnitsByCriteria function
        - Removed getUserAgentInitialized function
        - Updated documentation

3.507
        - Updated documentation

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

        user_agent       => undef,
        token_expiration => undef,
        max_results      => undef,
        debug_mode       => 0,
        current_endpoint => undef,
    }, $class;

    $self->_initUserAgent();
    $self->setProxy($proxy);
    $self->setMaxResults($max_results);
    $self->setTimeout($timeout);

    return $self;
}

sub setCredentials {
    my ($self, $credentials) = @_;

    $self->{'credentials'} = $credentials;
}

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


    $self->{'debug_mode'} = $debug_value;
}

sub setProxy {
    my ($self, $proxy) = @_;

    defined $proxy ? $self->{'user_agent'}->proxy([ 'http', 'https' ], $proxy) : $self->{'user_agent'}->env_proxy;
}

sub setTimeout {
    my ($self, $timeout) = @_;

    $timeout //= DEFAULT_TIMEOUT;
    $self->{'user_agent'}->timeout($timeout);
}

sub setCurrentEndpoint {
    my ($self, $endpoint) = @_;

    $self->{'current_endpoint'} = $endpoint;

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

=head1 CONSTANTS

=head2 DEFAULT_MAX_RESULTS

The API's default number of results for each request. You can override it with the C<< setMaxResults >> method. A too big value may impact response time and general performances.

This constant is set to 20 results.

=head2 DEFAULT_TIMEOUT

This constant specifies how many seconds the client module has to wait for server response before giving up. You can override it with the C<< setTimeout >> method.

This constant is set to 20 seconds.

=head2 HARD_MAX_RESULTS

The maximum number of results that you can get. This value can't be increased (restricted by API). If you try to send a request with a higher value, the C<nombre> parameter will be forced to HARD_MAX_RESULTS value.

This constant is set to 1000 results.

=head2 MAX_SIREN_LENGTH

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

Used to override the B<< DEFAULT_MAX_RESULTS >> value to get more results, within the limit of B<< HARD_MAX_RESULTS >> value.

  $sirene->setMaxResults(30);

=head2 setProxy

You can define which proxy server must be used to send requests. The system's proxy settings are used by default.

  $sirene->setProxy('https://myproxy.com:1234');

=head2 setTimeout

Used to override the B<< DEFAULT_TIMEOUT >> value.

  $sirene->setTimeout(40);

=head1 PARAMETERS

All search methods take an optional C<< $desired_fields >> parameter that comes in three differents flavours:

  my $fields_that_interest_me = ['dateCreationUniteLegale', 'sigleUniteLegale'];
  my $response_json = $sirene->getLegalUnitBySIREN(123456789, $fields_that_interest_me);

  # or
  my $response_json = $sirene->getLegalUnitBySIREN(123456789, 'dateCreationUniteLegale');



( run in 0.243 second using v1.01-cache-2.11-cpan-a5abf4f5562 )