| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Strava::Club; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
31
|
use v5.010; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
138
|
|
|
4
|
4
|
|
|
4
|
|
13
|
use strict; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
88
|
|
|
5
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
78
|
|
|
6
|
4
|
|
|
4
|
|
14
|
use Moo; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
17
|
|
|
7
|
4
|
|
|
4
|
|
847
|
use Method::Signatures; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
25
|
|
|
8
|
4
|
|
|
4
|
|
1266
|
use Scalar::Util qw(looks_like_number); |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
259
|
|
|
9
|
4
|
|
|
4
|
|
19
|
use Carp qw(croak); |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
152
|
|
|
10
|
4
|
|
|
4
|
|
23
|
use Scalar::Util::Reftype; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
147
|
|
|
11
|
4
|
|
|
4
|
|
17
|
use Data::Dumper; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
1767
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: A Strava Club Object |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION: Generated by DZP::OurPkg:Version |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Validation functions |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $Ref = sub { |
|
21
|
|
|
|
|
|
|
croak "auth isn't a 'WebService::Strava::Auth' object!" unless reftype( $_[0] )->class eq "WebService::Strava::Auth"; |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $Bool = sub { |
|
25
|
|
|
|
|
|
|
croak "$_[0] must be 0|1" unless $_[0] =~ /^[01]$/; |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $Num = sub { |
|
29
|
|
|
|
|
|
|
croak "$_[0] isn't a valid id" unless looks_like_number $_[0]; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Debugging hooks in case things go weird. (Thanks @pjf) |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
35
|
|
|
|
|
|
|
my $orig = shift; |
|
36
|
|
|
|
|
|
|
my $class = shift; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ($WebService::Strava::DEBUG) { |
|
39
|
|
|
|
|
|
|
warn "Building task with:\n"; |
|
40
|
|
|
|
|
|
|
warn Dumper(\@_), "\n"; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return $class->$orig(@_); |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Authentication Object |
|
47
|
|
|
|
|
|
|
has 'auth' => ( is => 'ro', required => 1, isa => $Ref ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Defaults + Required |
|
50
|
|
|
|
|
|
|
has 'id' => ( is => 'ro', required => 1, isa => $Num); |
|
51
|
|
|
|
|
|
|
has '_build' => ( is => 'ro', default => sub { 1 }, isa => $Bool ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'profile' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
54
|
|
|
|
|
|
|
has 'name' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
55
|
|
|
|
|
|
|
has 'state' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
56
|
|
|
|
|
|
|
has 'city' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
57
|
|
|
|
|
|
|
has 'sport_type' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
58
|
|
|
|
|
|
|
has 'description' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
59
|
|
|
|
|
|
|
has 'member_count' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
60
|
|
|
|
|
|
|
has 'country' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
61
|
|
|
|
|
|
|
has 'club_type' => ( is => 'ro', lazy => 1, builder => '_build_club' ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub BUILD { |
|
64
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if ($self->{_build}) { |
|
67
|
0
|
|
|
|
|
|
$self->_build_club(); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
|
|
|
|
return; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
4
|
0
|
|
4
|
|
2164
|
method _build_club() { |
|
|
0
|
|
|
0
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $club = $self->auth->get_api("/clubs/$self->{id}"); |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
foreach my $key (keys %{ $club }) { |
|
|
0
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->{$key} = $club->{$key}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
4
|
0
|
|
4
|
|
2192
|
method retrieve() { |
|
|
0
|
|
|
0
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$self->_build_club(); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
4
|
0
|
|
4
|
|
24539
|
method list_members(:$members = 25, :$page = 1) { |
|
|
0
|
0
|
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# TODO: Handle pagination better use #4's solution when found. |
|
90
|
0
|
|
|
|
|
|
my $data = $self->auth->get_api("/clubs/$self->{id}/members?per_page=$members&page=$page"); |
|
91
|
0
|
|
|
|
|
|
my $index = 0; |
|
92
|
0
|
|
|
|
|
|
foreach my $member (@{$data}) { |
|
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
@{$data}[$index] = WebService::Strava::Athlete->new(id => $member->{id}, auth => $self->auth, _build => 0); |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$index++; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
0
|
|
|
|
|
|
return $data; |
|
97
|
|
|
|
|
|
|
}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
4
|
0
|
|
4
|
|
26129
|
method list_activities(:$activities = 25, :$page = 1) { |
|
|
0
|
0
|
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# TODO: Handle pagination better use #4's solution when found. |
|
102
|
0
|
|
|
|
|
|
my $data = $self->auth->get_api("/clubs/$self->{id}/activities?per_page=$activities&page=$page"); |
|
103
|
0
|
|
|
|
|
|
my $index = 0; |
|
104
|
0
|
|
|
|
|
|
foreach my $activity (@{$data}) { |
|
|
0
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
@{$data}[$index] = WebService::Strava::Athlete::Activity->new(id => $activity->{id}, auth => $self->auth, _build => 0); |
|
|
0
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$index++; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
0
|
|
|
|
|
|
return $data; |
|
109
|
|
|
|
|
|
|
}; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=pod |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=encoding UTF-8 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 NAME |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
WebService::Strava::Club - A Strava Club Object |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 VERSION |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
version 0.05 |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This will return a Club Gear Object. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
An Athlete can be a member of one or many clubs. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 retrieve() |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$club->retrieve(); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
When a Club object is lazy loaded, you can call retrieve it by calling |
|
142
|
|
|
|
|
|
|
this method. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 list_members |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$club->list_members([page => 2], [activities => 100]); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns an arrayRef of L<WebService::Strava::Athlete> objects for the Club. Takes 2 optional |
|
149
|
|
|
|
|
|
|
parameters of 'page' and 'members' (per page). |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The results are paginated and a maximum of 200 results can be returned |
|
152
|
|
|
|
|
|
|
per page. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 list_activities |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$club->list_activities([page => 2], [activities => 100]); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns an arrayRef of L<WebService::Strava::Athlete::Activity> objects for the club. Takes 2 optional |
|
159
|
|
|
|
|
|
|
parameters of 'page' and 'activities' (per page). |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The results are paginated and a maximum of 200 results can be returned |
|
162
|
|
|
|
|
|
|
per page. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Leon Wright < techman@cpan.org > |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Leon Wright. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
173
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |