WWW-Bund
view release on metacpan or search on metacpan
lib/WWW/Bund.pm view on Meta::CPAN
package WWW::Bund;
our $VERSION = '0.002';
# ABSTRACT: Perl client for German Federal Government APIs (bund.dev)
use Moo;
use WWW::Bund::Registry;
use WWW::Bund::Caller;
use WWW::Bund::Auth;
use WWW::Bund::Cache;
use WWW::Bund::RateLimit;
use WWW::Bund::LWPIO;
use WWW::Bund::API::Autobahn;
use WWW::Bund::API::NINA;
use WWW::Bund::API::PegelOnline;
use WWW::Bund::API::Tagesschau;
use WWW::Bund::API::Bundestag;
use WWW::Bund::API::DWD;
use File::Spec;
use namespace::clean;
has io => (
is => 'lazy',
builder => sub { WWW::Bund::LWPIO->new },
);
has cache_dir => (
is => 'lazy',
builder => sub {
my $base = $ENV{XDG_CACHE_HOME}
// File::Spec->catdir($ENV{HOME} // (getpwuid($<))[7], '.cache');
File::Spec->catdir($base, 'www-bund');
},
);
has registry => (
is => 'lazy',
builder => sub { WWW::Bund::Registry->new },
);
has auth => (
is => 'lazy',
builder => sub { WWW::Bund::Auth->new },
);
has cache => (
is => 'lazy',
builder => sub {
my $self = shift;
WWW::Bund::Cache->new(cache_dir => $self->cache_dir);
},
);
has rate_limiter => (
is => 'lazy',
builder => sub { WWW::Bund::RateLimit->new },
);
has caller => (
is => 'lazy',
builder => sub {
my $self = shift;
WWW::Bund::Caller->new(
registry => $self->registry,
auth => $self->auth,
cache => $self->cache,
rate_limiter => $self->rate_limiter,
io => $self->io,
);
},
);
# Generic call interface
sub call {
my ($self, $api, $endpoint, %opts) = @_;
return $self->caller->call($api, $endpoint, %opts);
}
# Discovery
sub list {
my ($self, %filters) = @_;
return $self->registry->list(%filters);
}
( run in 0.664 second using v1.01-cache-2.11-cpan-9789f410c06 )