| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Strava::Athlete::Activity; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
51
|
use v5.010; |
|
|
4
|
|
|
|
|
22
|
|
|
|
4
|
|
|
|
|
188
|
|
|
4
|
4
|
|
|
4
|
|
20
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
136
|
|
|
5
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
136
|
|
|
6
|
4
|
|
|
4
|
|
18
|
use Moo; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
29
|
|
|
7
|
4
|
|
|
4
|
|
1153
|
use Method::Signatures; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
28
|
|
|
8
|
4
|
|
|
4
|
|
1794
|
use Scalar::Util qw(looks_like_number); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
307
|
|
|
9
|
4
|
|
|
4
|
|
20
|
use Carp qw(croak); |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
197
|
|
|
10
|
4
|
|
|
4
|
|
21
|
use Scalar::Util::Reftype; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
200
|
|
|
11
|
4
|
|
|
4
|
|
22
|
use experimental 'switch'; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
31
|
|
|
12
|
4
|
|
|
4
|
|
615
|
use Data::Dumper; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
3760
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: A Strava Activity Object |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION: Generated by DZP::OurPkg:Version |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Validation functions |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $Ref = sub { |
|
22
|
|
|
|
|
|
|
croak "auth isn't a 'WebService::Strava::Auth' object!" unless reftype( $_[0] )->class eq "WebService::Strava::Auth"; |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $Bool = sub { |
|
26
|
|
|
|
|
|
|
croak "$_[0] must be 0|1" unless $_[0] =~ /^[01]$/; |
|
27
|
|
|
|
|
|
|
}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $Num = sub { |
|
30
|
|
|
|
|
|
|
croak "$_[0] isn't a valid id" unless looks_like_number $_[0]; |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Debugging hooks in case things go weird. (Thanks @pjf) |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
36
|
|
|
|
|
|
|
my $orig = shift; |
|
37
|
|
|
|
|
|
|
my $class = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if ($WebService::Strava::DEBUG) { |
|
40
|
|
|
|
|
|
|
warn "Building task with:\n"; |
|
41
|
|
|
|
|
|
|
warn Dumper(\@_), "\n"; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $class->$orig(@_); |
|
45
|
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Authentication Object |
|
48
|
|
|
|
|
|
|
has 'auth' => ( is => 'ro', required => 1, isa => $Ref ); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Defaults + Required |
|
51
|
|
|
|
|
|
|
has 'id' => ( is => 'ro', required => 1, isa => $Num); |
|
52
|
|
|
|
|
|
|
has '_build' => ( is => 'ro', default => sub { 1 }, isa => $Bool ); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Segment Effort |
|
55
|
|
|
|
|
|
|
has 'name' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has 'resource_state' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
58
|
|
|
|
|
|
|
has 'indicates level of detail' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
59
|
|
|
|
|
|
|
has 'external_id' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
60
|
|
|
|
|
|
|
has 'provided at upload' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
61
|
|
|
|
|
|
|
has 'athlete' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
62
|
|
|
|
|
|
|
has 'description' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
63
|
|
|
|
|
|
|
has 'distance' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
64
|
|
|
|
|
|
|
has 'moving_time' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
65
|
|
|
|
|
|
|
has 'elapsed_time' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
66
|
|
|
|
|
|
|
has 'total_elevation_gain' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
67
|
|
|
|
|
|
|
has 'type' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
68
|
|
|
|
|
|
|
has 'start_date' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
69
|
|
|
|
|
|
|
has 'start_date_local' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
70
|
|
|
|
|
|
|
has 'time_zone' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
71
|
|
|
|
|
|
|
has 'start_latlng' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
72
|
|
|
|
|
|
|
has 'end_latlng' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
73
|
|
|
|
|
|
|
has 'location_city' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
74
|
|
|
|
|
|
|
has 'location_state' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
75
|
|
|
|
|
|
|
has 'location_country' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
76
|
|
|
|
|
|
|
has 'achievement_count' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
77
|
|
|
|
|
|
|
has 'kudos_count' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
78
|
|
|
|
|
|
|
has 'comment_count' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
79
|
|
|
|
|
|
|
has 'athlete_count' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
80
|
|
|
|
|
|
|
has 'photo_count' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
81
|
|
|
|
|
|
|
has 'map' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
82
|
|
|
|
|
|
|
has 'trainer' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
83
|
|
|
|
|
|
|
has 'commute' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
84
|
|
|
|
|
|
|
has 'manual' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
85
|
|
|
|
|
|
|
has 'private' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
86
|
|
|
|
|
|
|
has 'flagged' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
87
|
|
|
|
|
|
|
has 'workout_type' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
88
|
|
|
|
|
|
|
has 'gear_id' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
89
|
|
|
|
|
|
|
has 'gear' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
90
|
|
|
|
|
|
|
has 'average_speed' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
91
|
|
|
|
|
|
|
has 'meters per second' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
92
|
|
|
|
|
|
|
has 'max_speed' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
93
|
|
|
|
|
|
|
has 'average_cadence' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
94
|
|
|
|
|
|
|
has 'average_temp' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
95
|
|
|
|
|
|
|
has 'average_watts' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
96
|
|
|
|
|
|
|
has 'kilojoules' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
97
|
|
|
|
|
|
|
has 'average_heartrate' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
98
|
|
|
|
|
|
|
has 'max_heartrate' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
99
|
|
|
|
|
|
|
has 'calories' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
100
|
|
|
|
|
|
|
has 'truncated' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
101
|
|
|
|
|
|
|
has 'has_kudoed' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
102
|
|
|
|
|
|
|
has 'segment_efforts' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
103
|
|
|
|
|
|
|
has 'splits_metric' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
104
|
|
|
|
|
|
|
has 'splits_standard' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
105
|
|
|
|
|
|
|
has 'best_efforts' => ( is => 'ro', lazy => 1, builder => '_build_activity' ); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub BUILD { |
|
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
if ($self->{_build}) { |
|
111
|
0
|
|
|
|
|
|
$self->_build_activity(); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
|
|
|
return; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
4
|
0
|
|
4
|
|
2125
|
method _build_activity() { |
|
|
0
|
|
|
0
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $activity = $self->auth->get_api("/activities/$self->{id}"); |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
foreach my $key (keys %{ $activity }) { |
|
|
0
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
given ( $key ) { |
|
121
|
0
|
|
|
|
|
|
when ("athlete") { $self->_instantiate("Athlete", $key, $activity->{$key}); } |
|
|
0
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
when (/segment_efforts/) { $self->_instantiate("Athlete::Segment_Effort", $key, $activity->{$key}); } |
|
|
0
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
default { $self->{$key} = $activity->{$key}; } |
|
|
0
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
4
|
|
|
4
|
|
979
|
use WebService::Strava::Athlete; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
80
|
|
|
131
|
4
|
|
|
4
|
|
17
|
use WebService::Strava::Athlete::Segment_Effort; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
69
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
4
|
0
|
|
4
|
|
11525
|
method _instantiate($type, $key, $data) { |
|
|
0
|
0
|
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if (ref($data) eq "ARRAY") { |
|
135
|
0
|
|
|
|
|
|
my $index = 0; |
|
136
|
0
|
|
|
|
|
|
foreach my $item (@{$data}) { |
|
|
0
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
@{$data}[$index] = "WebService::Strava::$type"->new(auth => $self->auth, id => $item->{id}, _build => 0); |
|
|
0
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$index++; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
0
|
|
|
|
|
|
$self->{$key} = $data; |
|
141
|
|
|
|
|
|
|
} else { |
|
142
|
0
|
|
|
|
|
|
$self->{$key} = "WebService::Strava::$type"->new(auth => $self->auth, id => $data->{id}, _build => 0); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
|
|
|
|
|
return; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
4
|
0
|
|
4
|
|
3106
|
method retrieve() { |
|
|
0
|
|
|
0
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$self->_build_activity(); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=pod |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=encoding UTF-8 |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 NAME |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
WebService::Strava::Athlete::Activity - A Strava Activity Object |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 VERSION |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
version 0.05 |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $activity = WebService::Strava::Athlete::Activity->new( auth => $auth, id => '229781' ); |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Upon instantiation will retrieve the activity matching the id. |
|
175
|
|
|
|
|
|
|
Requires a pre-authenticated WebService::Strava::Auth object. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 METHODS |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 retrieve() |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$activity->retrieve(); |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
When a Activity object and is lazy loaded, you can call retrieve it by calling |
|
184
|
|
|
|
|
|
|
this method. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 AUTHOR |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Leon Wright < techman@cpan.org > |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Leon Wright. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
195
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |