summaryrefslogtreecommitdiff
path: root/lib/Dakkar/TweetArchive.pm
blob: f023359f166a66e4530a30ecb7f0743f90b40eee (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
56
package Dakkar::TweetArchive; 
use 5.024;
use Moo;
use experimental 'signatures';
use Twitter::API;
use Types::Standard qw(Str InstanceOf);
use namespace::autoclean;
 
has [qw(consumer_key consumer_secret access_token access_token_secret)] => (
    is => 'ro',
    required => 1,
    isa => Str,
);
 
has client => (
    is => 'lazy',
    isa => InstanceOf['Twitter::API'],
);
 
sub _build_client($self) {
    my $nt = Twitter::API->new_with_traits(
        traits => [qw{Enchilada RateLimiting}],
        # AutoCursor => { 
        #     max_calls      => 16, 
        #     force_cursor   => 1, 
        #     array_accessor => 'users', 
        #     methods        => [qw/friends followers/], 
        # }, 
        consumer_key => $self->consumer_key,
        consumer_secret => $self->consumer_secret,
        access_token => $self->access_token,
        access_token_secret => $self->access_token_secret,
    );
 
    return $nt;
}
 
sub home_timeline($self,$since_id) {
    return $self->client->home_timeline({
        include_entities => 1,
        trim_user => 0,
        exclude_replies => 0,
        $since_id ? ( since_id => $since_id ) : () ),
        count => 200,
    });
}
 
sub friends($self) {
    return $self->client->friends({count=>200});
}
 
sub followers($self) {
    return $self->client->followers({count=>200});
}
 
1;