NAME
Web::NewsAPI::Source - Object class representing a News API source
SYNOPSIS
use v5.10;
use Web::NewsAPI;
my $newsapi = Web::NewsAPI->new(
api_key => $my_secret_api_key,
);
say "Here are some sources for English-language science news...";
my @sources = $newsapi->sources(
category => 'science',
language => 'en'
);
for my $source ( @sources ) {
say $source->name;
if ( defined $source->id ) {
say "...it has the NewsAPI ID " . $source->id;
}
else {
say "...but it doesn't have a NewsAPI ID.";
}
}
DESCRIPTION
Objects of this class represent a News API news source. Generally, you won't create these objects yourself; you'll get them as a result of calling sources() on a Web::NewsAPI object.
METHODS
Object attributes
These are all read-only attributes, based on information provided by News API. They are all strings, except for url
, which is a URI object. Any of them might be undefined, except for name
.
id
my $id = $source->id;
name
my $name = $source->name;
description
my $desc = $source->description;
url
my $url = $source->url;
category
my $category = $source->category;
language
my $language_code = $source->language;
country
my $country_code = $source_country;
AUTHOR
Jason McIntosh (jmac@jmac.org)