summaryrefslogtreecommitdiff
path: root/lib/WebService/ForecastIo/Response.pm
blob: e217c70cafe3cc0a87c9e9b679fcc96c67a6a8b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package WebService::ForecastIo::Response; 
use Moose;
use WebService::ForecastIo::DataPoint;
use WebService::ForecastIo::DataBlock;
use WebService::ForecastIo::Alert;
use JSON;
 
has 'currently' => (
    is => 'ro',
    isa => 'WebService::ForecastIo::DataPoint',
    coerce => 1,
);
 
has [qw(daily hourly minutely)] => (
    is => 'ro',
    isa => 'WebService::ForecastIo::DataBlock',
    coerce => 1,
);
 
has [qw(latitude longitude)] => (
    is => 'ro',
    isa => 'Num',
);
 
has timezone => (
    is => 'ro',
    isa => 'Str',
);
 
has offset => (
    is => 'ro',
    isa => 'Num',
);
 
has alerts => (
    is => 'ro',
    isa => 'WebService::ForecastIo::AlertArray',
    coerce => 1,
);
 
has flags => (
    is => 'ro',
    isa => 'HashRef',
);
 
around BUILDARGS => sub {
    my ($orig,$class,@args) = @_;
 
    if (@args==1 and !ref($args[0])) {
        @args = decode_json($args[0]);
    }
    return $class->$orig(@args);
};
 
1;