lib/Web/NewsAPI/Source.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Web/NewsAPI/Article.pm ↑ Summary lib/Web/NewsAPI/Types.pm »
1 package Web::NewsAPI::Source;
2  
3 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Web::NewsAPI::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 has 'id' => (
9 required => 1,
10 isa => 'Maybe[Str]',
11 is => 'ro',
12 );
13  
14 1 has 'name' => (
15 required => 1,
16 isa => 'Str',
17 is => 'ro',
18 );
19  
20 1 has 'description' => (
21 isa => 'Str',
22 is => 'ro',
23 );
24  
25 1 has 'category' => (
26 isa => 'Str',
27 is => 'ro',
28 );
29  
30 1 has 'language' => (
31 isa => 'Str',
32 is => 'ro',
33 );
34  
35 1 has 'country' => (
36 isa => 'Str',
37 is => 'ro',
38 );
39  
40 1 has 'url' => (
41 coerce => 1,
42 isa => 'NewsURI',
43 is => 'ro',
44 );
45  
46 1 1;
47  
48 =head1 NAME
49  
50 Web::NewsAPI::Source - Object class representing a News API source
51  
52 =head1 SYNOPSIS
53  
54 use v5.10;
55 use Web::NewsAPI;
56  
57 my $newsapi = Web::NewsAPI->new(
58 api_key => $my_secret_api_key,
59 );
60  
61 say "Here are some sources for English-language science news...";
62 my @sources = $newsapi->sources(
63 category => 'science',
64 language => 'en'
65 );
66 for my $source ( @sources ) {
67 say $source->name;
68 if ( defined $source->id ) {
69 say "...it has the NewsAPI ID " . $source->id;
70 }
71 else {
72 say "...but it doesn't have a NewsAPI ID.";
73 }
74 }
75  
76 =head1 DESCRIPTION
77  
78 Objects of this class represent a News API news source. Generally, you
79 won't create these objects yourself; you'll get them as a result of
80 calling L<sources() on a Web::NewsAPI object|Web::NewsAPI/"sources">.
81  
82 =head1 METHODS
83  
84 =head2 Object attributes
85  
86 These are all read-only attributes, based on information provided by
87 News API. They are all strings, except for C<url>, which is a L<URI>
88 object. Any of them might be undefined, except for C<name>.
89  
90 =over
91  
92 =item *
93  
94 id
95  
96 =item *
97  
98 name
99  
100 =item *
101  
102 description
103  
104 =item *
105  
106 url
107  
108 =item *
109  
110 category
111  
112 =item *
113  
114 language
115  
116 =item *
117  
118 country
119  
120 =back
121  
122 =head1 AUTHOR
123  
124 Jason McIntosh (jmac@jmac.org)
« lib/Web/NewsAPI/Article.pm ↑ Summary lib/Web/NewsAPI/Types.pm »