line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::NationBuilder; |
2
|
1
|
|
|
1
|
|
135130
|
use Moo; |
|
1
|
|
|
|
|
19634
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
with 'WebService::NationBuilder::HTTP'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2124
|
use Carp qw(croak); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
926
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.0107'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has access_token => ( is => 'rw' ); |
10
|
|
|
|
|
|
|
has subdomain => ( is => 'rw' ); |
11
|
|
|
|
|
|
|
has domain => ( is => 'ro', default => 'nationbuilder.com' ); |
12
|
|
|
|
|
|
|
has version => ( is => 'ro', default => 'v1' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has sites_uri => ( is => 'ro', default => 'sites' ); |
15
|
|
|
|
|
|
|
has people_uri => ( is => 'ro', default => 'people' ); |
16
|
|
|
|
|
|
|
has tags_uri => ( is => 'ro', default => 'tags' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub get_sites { |
19
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
20
|
0
|
|
|
|
|
|
return $self->http_get_all($self->sites_uri, $params); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub create_person { |
24
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
25
|
0
|
|
|
|
|
|
my $person = $self->http_post($self->people_uri, { |
26
|
|
|
|
|
|
|
person => $params }); |
27
|
0
|
0
|
|
|
|
|
return $person ? $person->{person} : 0; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub push_person { |
31
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
32
|
0
|
|
|
|
|
|
my $person = $self->http_put($self->people_uri . '/push', { |
33
|
|
|
|
|
|
|
person => $params }); |
34
|
0
|
0
|
|
|
|
|
return $person ? $person->{person} : 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub update_person { |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $params) = @_; |
39
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
40
|
0
|
|
|
|
|
|
my $person = $self->http_put($self->people_uri . "/$id", { |
41
|
|
|
|
|
|
|
person => $params }); |
42
|
0
|
0
|
|
|
|
|
return $person ? $person->{person} : 0; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_person { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
47
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
48
|
0
|
|
|
|
|
|
my $person = $self->http_get($self->people_uri . "/$id"); |
49
|
0
|
0
|
|
|
|
|
return $person ? $person->{person} : 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub delete_person { |
53
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
54
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
55
|
0
|
|
|
|
|
|
return $self->http_delete($self->people_uri . "/$id"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get_person_tags { |
59
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
60
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
61
|
0
|
|
|
|
|
|
my $taggings = $self->http_get($self->people_uri . "/$id/taggings"); |
62
|
0
|
0
|
|
|
|
|
return $taggings ? $taggings->{taggings} : 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub match_person { |
66
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
67
|
0
|
|
|
|
|
|
return $self->http_get($self->people_uri . '/match', $params)->{person}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_people { |
71
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
72
|
0
|
|
|
|
|
|
return $self->http_get_all($self->people_uri, $params); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_tags { |
76
|
0
|
|
|
0
|
1
|
|
my ($self, $params) = @_; |
77
|
0
|
|
|
|
|
|
return $self->http_get_all($self->tags_uri, $params); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub set_tag { |
81
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $tag) = @_; |
82
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
83
|
0
|
0
|
|
|
|
|
croak 'The tag param is missing' unless defined $tag; |
84
|
0
|
|
|
|
|
|
my $tagging = $self->http_put($self->people_uri . "/$id/taggings", { |
85
|
|
|
|
|
|
|
tagging => { tag => $tag }, |
86
|
|
|
|
|
|
|
}); |
87
|
0
|
0
|
|
|
|
|
return $tagging ? $tagging->{tagging} : 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub delete_tag { |
91
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $tag) = @_; |
92
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
93
|
0
|
0
|
|
|
|
|
croak 'The tag param is missing' unless defined $tag; |
94
|
0
|
|
|
|
|
|
return $self->http_delete($self->people_uri . "/$id/taggings/$tag"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# ABSTRACT: NationBuilder API bindings |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |