summaryrefslogtreecommitdiff
path: root/lib/WebService/ForecastIo/Response.pm
blob: 24c53242779423485c7c5d62d0b6adb3d80aabb6 (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 Moo;
use namespace::autoclean;
use Types::Standard -all;
use WebService::ForecastIo::Types -all;
use JSON;
 
has 'currently' => (
    is => 'ro',
    isa => DataPoint,
    coerce => DataPoint->coercion,
);
 
has [qw(daily hourly minutely)] => (
    is => 'ro',
    isa => DataBlock,
    coerce => DataBlock->coercion,
);
 
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 => AlertArray,
    coerce => AlertArray->coercion,
);
 
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;