API-INSEE-Sirene

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "ExtUtils::MakeMaker" : "0"
         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "HTTP::Request::Common" : "6.18",
            "HTTP::Status" : "6.18",
            "JSON" : "2.9",
            "LWP::UserAgent" : "6.15",
            "POSIX" : "1.65",
            "Switch" : "2.17",
            "perl" : "5.024001"
         }
      }
   },
   "release_status" : "stable",

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: API-INSEE-Sirene
no_index:
  directory:
    - t
    - inc
requires:
  HTTP::Request::Common: '6.18'
  HTTP::Status: '6.18'
  JSON: '2.9'
  LWP::UserAgent: '6.15'
  POSIX: '1.65'
  Switch: '2.17'
  perl: '5.024001'
version: 4.04
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile  view on Meta::CPAN


#   MakeMaker Parameters:

#     ABSTRACT_FROM => q[lib/API/INSEE/Sirene.pm]
#     AUTHOR => [q[FOUQUET Justin <jfouquet at lncsa dot fr>]]
#     BUILD_REQUIRES => {  }
#     CONFIGURE_REQUIRES => {  }
#     LICENSE => q[perl_5]
#     MIN_PERL_VERSION => q[5.024001]
#     NAME => q[API::INSEE::Sirene]
#     PREREQ_PM => { HTTP::Request::Common=>q[6.18], HTTP::Status=>q[6.18], JSON=>q[2.9], LWP::UserAgent=>q[6.15], POSIX=>q[1.65], Switch=>q[2.17] }
#     TEST_REQUIRES => {  }
#     VERSION_FROM => q[lib/API/INSEE/Sirene.pm]
#     clean => { FILES=>q[MANIFEST API-INSEE-Sirene-*.tar.gz debian.bak debian/libapi-insee-sirene-perl*] }

# --- MakeMaker post_initialize section:


# --- MakeMaker const_config section:

# These definitions are from config.sh (via /usr/lib/x86_64-linux-gnu/perl/5.28/Config.pm).

Makefile  view on Meta::CPAN

	$(NOECHO) $(ECHO) 'license: perl' >> META_new.yml
	$(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml
	$(NOECHO) $(ECHO) '  url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml
	$(NOECHO) $(ECHO) '  version: '\''1.4'\''' >> META_new.yml
	$(NOECHO) $(ECHO) 'name: API-INSEE-Sirene' >> META_new.yml
	$(NOECHO) $(ECHO) 'no_index:' >> META_new.yml
	$(NOECHO) $(ECHO) '  directory:' >> META_new.yml
	$(NOECHO) $(ECHO) '    - t' >> META_new.yml
	$(NOECHO) $(ECHO) '    - inc' >> META_new.yml
	$(NOECHO) $(ECHO) 'requires:' >> META_new.yml
	$(NOECHO) $(ECHO) '  HTTP::Request::Common: '\''6.18'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  HTTP::Status: '\''6.18'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  JSON: '\''2.9'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  LWP::UserAgent: '\''6.15'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  POSIX: '\''1.65'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  Switch: '\''2.17'\''' >> META_new.yml
	$(NOECHO) $(ECHO) '  perl: '\''5.024001'\''' >> META_new.yml
	$(NOECHO) $(ECHO) 'version: 4.04' >> META_new.yml
	$(NOECHO) $(ECHO) 'x_serialization_backend: '\''CPAN::Meta::YAML version 0.018'\''' >> META_new.yml
	-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
	$(NOECHO) $(ECHO) Generating META.json

Makefile  view on Meta::CPAN

	$(NOECHO) $(ECHO) '            "ExtUtils::MakeMaker" : "0"' >> META_new.json
	$(NOECHO) $(ECHO) '         }' >> META_new.json
	$(NOECHO) $(ECHO) '      },' >> META_new.json
	$(NOECHO) $(ECHO) '      "configure" : {' >> META_new.json
	$(NOECHO) $(ECHO) '         "requires" : {' >> META_new.json
	$(NOECHO) $(ECHO) '            "ExtUtils::MakeMaker" : "0"' >> META_new.json
	$(NOECHO) $(ECHO) '         }' >> META_new.json
	$(NOECHO) $(ECHO) '      },' >> META_new.json
	$(NOECHO) $(ECHO) '      "runtime" : {' >> META_new.json
	$(NOECHO) $(ECHO) '         "requires" : {' >> META_new.json
	$(NOECHO) $(ECHO) '            "HTTP::Request::Common" : "6.18",' >> META_new.json
	$(NOECHO) $(ECHO) '            "HTTP::Status" : "6.18",' >> META_new.json
	$(NOECHO) $(ECHO) '            "JSON" : "2.9",' >> META_new.json
	$(NOECHO) $(ECHO) '            "LWP::UserAgent" : "6.15",' >> META_new.json
	$(NOECHO) $(ECHO) '            "POSIX" : "1.65",' >> META_new.json
	$(NOECHO) $(ECHO) '            "Switch" : "2.17",' >> META_new.json
	$(NOECHO) $(ECHO) '            "perl" : "5.024001"' >> META_new.json
	$(NOECHO) $(ECHO) '         }' >> META_new.json
	$(NOECHO) $(ECHO) '      }' >> META_new.json
	$(NOECHO) $(ECHO) '   },' >> META_new.json
	$(NOECHO) $(ECHO) '   "release_status" : "stable",' >> META_new.json

Makefile  view on Meta::CPAN



# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd :
	$(NOECHO) $(ECHO) '<SOFTPKG NAME="API-INSEE-Sirene" VERSION="4.04">' > API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '    <ABSTRACT>An interface for the Sirene API of INSEE</ABSTRACT>' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '    <AUTHOR>FOUQUET Justin &lt;jfouquet at lncsa dot fr&gt;</AUTHOR>' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '    <IMPLEMENTATION>' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <PERLCORE VERSION="5,024001,0,0" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="HTTP::Request::Common" VERSION="6.18" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="HTTP::Status" VERSION="6.18" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="JSON::" VERSION="2.9" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="LWP::UserAgent" VERSION="6.15" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="POSIX::" VERSION="1.65" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <REQUIRE NAME="Switch::" VERSION="2.17" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <ARCHITECTURE NAME="x86_64-linux-gnu-thread-multi-5.28" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '        <CODEBASE HREF="" />' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '    </IMPLEMENTATION>' >> API-INSEE-Sirene.ppd
	$(NOECHO) $(ECHO) '</SOFTPKG>' >> API-INSEE-Sirene.ppd

Makefile.PL  view on Meta::CPAN

use 5.024001;
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME              => 'API::INSEE::Sirene',
    VERSION_FROM      => 'lib/API/INSEE/Sirene.pm',
    MIN_PERL_VERSION  => '5.024001',
    PREREQ_PM         => {
        'HTTP::Request::Common' => 6.18,
        'HTTP::Status'          => 6.18,
        'JSON'                  => 2.90,
        'LWP::UserAgent'        => 6.15,
        'POSIX'                 => 1.65,
        'Switch'                => 2.17,
    },
    ABSTRACT_FROM     => 'lib/API/INSEE/Sirene.pm',
    AUTHOR            => 'FOUQUET Justin <jfouquet at lncsa dot fr>',
    LICENSE           => 'perl_5',

README  view on Meta::CPAN


   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

HTTP::Request::Common
HTTP::Status
JSON
LWP::UserAgent
POSIX
Switch

COPYRIGHT AND LICENCE

Copyright (C) 2018-2021 by Les Nouveaux Constructeurs

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

package API::INSEE::Sirene;

use strict;
use warnings;

use Carp 'croak';
use JSON;
use HTTP::Request::Common qw/ GET POST /;
use HTTP::Status ':constants';
use List::Util 'any';
use LWP::UserAgent;
use POSIX 'strftime';
use Switch;

our $VERSION = 4.04;

use constant {
    API_AUTH_URL        => 'https://api.insee.fr/token',

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

=head1 DEPENDENCIES

=over 4

=item * L<< Carp|https://perldoc.perl.org/Carp >>

=item * L<< JSON|https://metacpan.org/pod/JSON >>

=item * L<< List::Util|https://perldoc.perl.org/List::Util >>

=item * L<< HTTP::Request::Common|https://metacpan.org/pod/HTTP::Request::Common >>

=item * L<< HTTP::Status|https://metacpan.org/pod/HTTP::Status >> B<< version < 6.26 >>

=item * L<< LWP::UserAgent|https://metacpan.org/pod/LWP::UserAgent >>

=item * L<< POSIX::strftime|https://metacpan.org/pod/POSIX#strftime >>

=item * L<< Switch|https://metacpan.org/pod/Switch >>

=back

t/API-INSEE-Sirene.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use HTTP::Request;

BEGIN { use_ok('API::INSEE::Sirene') };

my $sirene = API::INSEE::Sirene->new('fake_credential');

$sirene->setCurrentEndpoint('siren');
my @oks_custom_criteria = (
#   [ expected_result, field_name, value ... ],
    [ '(siret:"12345678901234"~ OR siret:*12345678901234*)',                'siret',                   '12345678901234',         ],
    [ '(siret:"12345678901234"~ OR siret:*12345678901234*)',                'siret',                   '12345678901234',         ],

t/API-INSEE-Sirene.t  view on Meta::CPAN

foreach (@oks_request_GET) {
    my ($method, @args) = @{$_};

    can_ok($sirene, $method);

    my ($err, $request) = $sirene->$method(@args);

    ok(0 == $err);
    $request =~ s/^Sent request:\n//m;

    my $r = HTTP::Request->parse($request);

    ok($r->method eq 'GET');
    ok($r->uri =~ qr{/sire[nt]/\d{9,14}\?});
}

my @oks_request_POST = (
    [ 'getEstablishmentsByUsualName', 'foo' ],
    [ 'getEstablishmentsByName',      'foo' ],
);

t/API-INSEE-Sirene.t  view on Meta::CPAN

foreach (@oks_request_POST) {
    my ($method, @args) = @{$_};

    can_ok($sirene, $method);

    my ($err, $request) = $sirene->$method(@args);

    ok(0 == $err);
    $request =~ s/^Sent request:\n//m;

    my $r = HTTP::Request->parse($request);

    ok($r->method eq 'POST');
    ok($r->uri =~ qr{/siret$});

    my %param = ();
    foreach my $param (split '&', $r->content) {
        my ($key, $value) = split '=', $param;
        $param{$key} = $value;
    }



( run in 0.548 second using v1.01-cache-2.11-cpan-de7293f3b23 )