1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Strava\API\Service; |
4
|
|
|
|
5
|
|
|
use GuzzleHttp\Client; |
6
|
|
|
use GuzzleHttp\Psr7\Response; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Strava REST Service |
10
|
|
|
* |
11
|
|
|
* @author Bas van Dorst |
12
|
|
|
* @package StravaPHP |
13
|
|
|
*/ |
14
|
|
|
class REST implements ServiceInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* REST adapter |
18
|
|
|
* @var Client |
19
|
|
|
*/ |
20
|
|
|
protected $adapter; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Application token |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $token; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Initiate this REST service with the application token and a instance |
30
|
|
|
* of the REST adapter (Guzzle). |
31
|
|
|
* |
32
|
|
|
* @param string $token |
33
|
|
|
* @param Client $adapter |
34
|
|
|
*/ |
35
|
45 |
|
public function __construct($token, Client $adapter) |
36
|
|
|
{ |
37
|
45 |
|
if (is_object($token) && method_exists($token, 'getToken')) { |
38
|
|
|
$token = $token->getToken(); |
39
|
|
|
} |
40
|
45 |
|
$this->token = $token; |
41
|
45 |
|
$this->adapter = $adapter; |
42
|
45 |
|
} |
43
|
|
|
|
44
|
44 |
|
private function getToken() |
45
|
|
|
{ |
46
|
44 |
|
return $this->token; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get a request result. |
51
|
|
|
* Returns an array with a response body or and error code => reason. |
52
|
|
|
* @param Response $response |
53
|
|
|
* @return array|mixed |
54
|
|
|
*/ |
55
|
44 |
|
private function getResult($response) |
56
|
|
|
{ |
57
|
44 |
|
$status = $response->getStatusCode(); |
58
|
|
|
|
59
|
44 |
|
if ($status == 200 || $status == 201) { |
60
|
44 |
|
return json_decode($response->getBody(), JSON_PRETTY_PRINT); |
61
|
|
|
} else { |
62
|
|
|
return [$status => $response->getReasonPhrase()]; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get an API request response and handle possible exceptions. |
68
|
|
|
* |
69
|
|
|
* @param string $method |
70
|
|
|
* @param string $path |
71
|
|
|
* @param array $parameters |
72
|
|
|
* |
73
|
|
|
* @return array|mixed|string |
74
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
75
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
76
|
|
|
*/ |
77
|
44 |
|
private function getResponse($method, $path, $parameters) |
78
|
|
|
{ |
79
|
|
|
try { |
80
|
44 |
|
$response = $this->adapter->request($method, $path, $parameters); |
81
|
44 |
|
return $this->getResult($response); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
catch (\Exception $e) { |
84
|
|
|
return $e->getMessage(); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
2 |
|
public function getAthlete($id = null) |
89
|
|
|
{ |
90
|
2 |
|
$path = 'athlete'; |
91
|
2 |
|
if (isset($id) && $id !== null) { |
92
|
1 |
|
$path = 'athletes/' . $id; |
93
|
|
|
} |
94
|
2 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
95
|
2 |
|
return $this->getResponse('GET', $path, $parameters); |
96
|
|
|
} |
97
|
|
|
|
98
|
1 |
|
public function getAthleteStats($id) |
99
|
|
|
{ |
100
|
1 |
|
$path = 'athletes/' . $id . '/stats'; |
101
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
102
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
103
|
|
|
} |
104
|
|
|
|
105
|
1 |
|
public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null) |
106
|
|
|
{ |
107
|
1 |
|
$path = 'athletes/' . $id . '/routes'; |
108
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
109
|
1 |
|
'type' => $type, |
110
|
1 |
|
'after' => $after, |
111
|
1 |
|
'page' => $page, |
112
|
1 |
|
'per_page' => $per_page, |
113
|
1 |
|
'access_token' => $this->getToken(), |
114
|
|
|
]; |
115
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
116
|
|
|
} |
117
|
|
|
|
118
|
1 |
|
public function getAthleteClubs() |
119
|
|
|
{ |
120
|
1 |
|
$path = 'athlete/clubs'; |
121
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
122
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
123
|
|
|
} |
124
|
|
|
|
125
|
1 |
|
public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null) |
126
|
|
|
{ |
127
|
1 |
|
$path = 'athlete/activities'; |
128
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
129
|
1 |
|
'before' => $before, |
130
|
1 |
|
'after' => $after, |
131
|
1 |
|
'page' => $page, |
132
|
1 |
|
'per_page' => $per_page, |
133
|
1 |
|
'access_token' => $this->getToken(), |
134
|
|
|
]; |
135
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
136
|
|
|
} |
137
|
|
|
|
138
|
2 |
|
public function getAthleteFriends($id = null, $page = null, $per_page = null) |
139
|
|
|
{ |
140
|
2 |
|
$path = 'athlete/friends'; |
141
|
2 |
|
if (isset($id) && $id !== null) { |
142
|
1 |
|
$path = 'athletes/' . $id . '/friends'; |
143
|
|
|
} |
144
|
2 |
|
$parameters['query'] = [ |
|
|
|
|
145
|
2 |
|
'page' => $page, |
146
|
2 |
|
'per_page' => $per_page, |
147
|
2 |
|
'access_token' => $this->getToken(), |
148
|
|
|
]; |
149
|
2 |
|
return $this->getResponse('GET', $path, $parameters); |
150
|
|
|
} |
151
|
|
|
|
152
|
2 |
|
public function getAthleteFollowers($id = null, $page = null, $per_page = null) |
153
|
|
|
{ |
154
|
2 |
|
$path = 'athlete/followers'; |
155
|
2 |
|
if (isset($id) && $id !== null) { |
156
|
1 |
|
$path = 'athletes/' . $id . '/followers'; |
157
|
|
|
} |
158
|
2 |
|
$parameters['query'] = [ |
|
|
|
|
159
|
2 |
|
'page' => $page, |
160
|
2 |
|
'per_page' => $per_page, |
161
|
2 |
|
'access_token' => $this->getToken(), |
162
|
|
|
]; |
163
|
2 |
|
return $this->getResponse('GET', $path, $parameters); |
164
|
|
|
} |
165
|
|
|
|
166
|
1 |
|
public function getAthleteBothFollowing($id, $page = null, $per_page = null) |
167
|
|
|
{ |
168
|
1 |
|
$path = 'athletes/' . $id . '/both-following'; |
169
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
170
|
1 |
|
'page' => $page, |
171
|
1 |
|
'per_page' => $per_page, |
172
|
1 |
|
'access_token' => $this->getToken(), |
173
|
|
|
]; |
174
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
175
|
|
|
} |
176
|
|
|
|
177
|
1 |
|
public function getAthleteKom($id, $page = null, $per_page = null) |
178
|
|
|
{ |
179
|
1 |
|
$path = 'athletes/' . $id . '/koms'; |
180
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
181
|
1 |
|
'page' => $page, |
182
|
1 |
|
'per_page' => $per_page, |
183
|
1 |
|
'access_token' => $this->getToken(), |
184
|
|
|
]; |
185
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
186
|
|
|
} |
187
|
|
|
|
188
|
1 |
|
public function getAthleteZones() |
189
|
|
|
{ |
190
|
1 |
|
$path = 'athlete/zones'; |
191
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
192
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
193
|
|
|
} |
194
|
|
|
|
195
|
2 |
|
public function getAthleteStarredSegments($id = null, $page = null, $per_page = null) |
196
|
|
|
{ |
197
|
2 |
|
$path = 'segments/starred'; |
198
|
2 |
|
if (isset($id) && $id !== null) { |
199
|
1 |
|
$path = 'athletes/' . $id . '/segments/starred'; |
200
|
|
|
// ...wrong in Strava documentation |
201
|
|
|
} |
202
|
2 |
|
$parameters['query'] = [ |
|
|
|
|
203
|
2 |
|
'page' => $page, |
204
|
2 |
|
'per_page' => $per_page, |
205
|
2 |
|
'access_token' => $this->getToken(), |
206
|
|
|
]; |
207
|
2 |
|
return $this->getResponse('GET', $path, $parameters); |
208
|
|
|
} |
209
|
|
|
|
210
|
1 |
|
public function updateAthlete($city, $state, $country, $sex, $weight) |
211
|
|
|
{ |
212
|
1 |
|
$path = 'athlete'; |
213
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
214
|
1 |
|
'city' => $city, |
215
|
1 |
|
'state' => $state, |
216
|
1 |
|
'country' => $country, |
217
|
1 |
|
'sex' => $sex, |
218
|
1 |
|
'weight' => $weight, |
219
|
1 |
|
'access_token' => $this->getToken(), |
220
|
|
|
]; |
221
|
1 |
|
return $this->getResponse('PUT', $path, $parameters); |
222
|
|
|
} |
223
|
|
|
|
224
|
1 |
|
public function getActivity($id, $include_all_efforts = null) |
225
|
|
|
{ |
226
|
1 |
|
$path = 'activities/' . $id; |
227
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
228
|
1 |
|
'include_all_efforts' => $include_all_efforts, |
229
|
1 |
|
'access_token' => $this->getToken(), |
230
|
|
|
]; |
231
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
232
|
|
|
} |
233
|
|
|
|
234
|
1 |
|
public function getActivityComments($id, $markdown = null, $page = null, $per_page = null) |
235
|
|
|
{ |
236
|
1 |
|
$path = 'activities/' . $id . '/comments'; |
237
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
238
|
1 |
|
'markdown' => $markdown, |
239
|
1 |
|
'page' => $page, |
240
|
1 |
|
'per_page' => $per_page, |
241
|
1 |
|
'access_token' => $this->getToken(), |
242
|
|
|
]; |
243
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
244
|
|
|
} |
245
|
|
|
|
246
|
1 |
|
public function getActivityKudos($id, $page = null, $per_page = null) |
247
|
|
|
{ |
248
|
1 |
|
$path = 'activities/' . $id . '/kudos'; |
249
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
250
|
1 |
|
'page' => $page, |
251
|
1 |
|
'per_page' => $per_page, |
252
|
1 |
|
'access_token' => $this->getToken(), |
253
|
|
|
]; |
254
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
255
|
|
|
} |
256
|
|
|
|
257
|
1 |
|
public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true') |
258
|
|
|
{ |
259
|
1 |
|
$path = 'activities/' . $id . '/photos'; |
260
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
261
|
1 |
|
'size' => $size, |
262
|
1 |
|
'photo_sources' => $photo_sources, |
263
|
1 |
|
'access_token' => $this->getToken(), |
264
|
|
|
]; |
265
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
266
|
|
|
} |
267
|
|
|
|
268
|
1 |
|
public function getActivityZones($id) |
269
|
|
|
{ |
270
|
1 |
|
$path = 'activities/' . $id . '/zones'; |
271
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
272
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
273
|
|
|
} |
274
|
|
|
|
275
|
1 |
|
public function getActivityLaps($id) |
276
|
|
|
{ |
277
|
1 |
|
$path = 'activities/' . $id . '/laps'; |
278
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
279
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
280
|
|
|
} |
281
|
|
|
|
282
|
1 |
|
public function getActivityUploadStatus($id) |
283
|
|
|
{ |
284
|
1 |
|
$path = 'uploads/' . $id; |
285
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
286
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
287
|
|
|
} |
288
|
|
|
|
289
|
1 |
|
public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null) |
290
|
|
|
{ |
291
|
1 |
|
$path = 'activities'; |
292
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
293
|
1 |
|
'name' => $name, |
294
|
1 |
|
'type' => $type, |
295
|
1 |
|
'start_date_local' => $start_date_local, |
296
|
1 |
|
'elapsed_time' => $elapsed_time, |
297
|
1 |
|
'description' => $description, |
298
|
1 |
|
'distance' => $distance, |
299
|
1 |
|
'private' => $private, |
300
|
1 |
|
'trainer' => $trainer, |
301
|
1 |
|
'access_token' => $this->getToken(), |
302
|
|
|
]; |
303
|
1 |
|
return $this->getResponse('POST', $path, $parameters); |
304
|
|
|
} |
305
|
|
|
|
306
|
1 |
|
public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null) |
307
|
|
|
{ |
308
|
1 |
|
$path = 'uploads'; |
309
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
310
|
1 |
|
'activity_type' => $activity_type, |
311
|
1 |
|
'name' => $name, |
312
|
1 |
|
'description' => $description, |
313
|
1 |
|
'private' => $private, |
314
|
1 |
|
'trainer' => $trainer, |
315
|
1 |
|
'commute' => $commute, |
316
|
1 |
|
'data_type' => $data_type, |
317
|
1 |
|
'external_id' => $external_id, |
318
|
1 |
|
'file' => curl_file_create($file), |
319
|
1 |
|
'file_hack' => '@' . ltrim($file, '@'), |
320
|
1 |
|
'access_token' => $this->getToken(), |
321
|
|
|
]; |
322
|
1 |
|
return $this->getResponse('POST', $path, $parameters); |
323
|
|
|
} |
324
|
|
|
|
325
|
1 |
|
public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null) |
326
|
|
|
{ |
327
|
1 |
|
$path = 'activities/' . $id; |
328
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
329
|
1 |
|
'name' => $name, |
330
|
1 |
|
'type' => $type, |
331
|
1 |
|
'private' => $private, |
332
|
1 |
|
'commute' => $commute, |
333
|
1 |
|
'trainer' => $trainer, |
334
|
1 |
|
'gear_id' => $gear_id, |
335
|
1 |
|
'description' => $description, |
336
|
1 |
|
'access_token' => $this->getToken(), |
337
|
|
|
]; |
338
|
1 |
|
return $this->getResponse('PUT', $path, $parameters); |
339
|
|
|
} |
340
|
|
|
|
341
|
1 |
|
public function deleteActivity($id) |
342
|
|
|
{ |
343
|
1 |
|
$path = 'activities/' . $id; |
344
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
345
|
1 |
|
return $this->getResponse('DELETE', $path, $parameters); |
346
|
|
|
} |
347
|
|
|
|
348
|
1 |
|
public function getGear($id) |
349
|
|
|
{ |
350
|
1 |
|
$path = 'gear/' . $id; |
351
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
352
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
353
|
|
|
} |
354
|
|
|
|
355
|
1 |
|
public function getClub($id) |
356
|
|
|
{ |
357
|
1 |
|
$path = 'clubs/' . $id; |
358
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
359
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
360
|
|
|
} |
361
|
|
|
|
362
|
1 |
|
public function getClubMembers($id, $page = null, $per_page = null) |
363
|
|
|
{ |
364
|
1 |
|
$path = 'clubs/' . $id . '/members'; |
365
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
366
|
1 |
|
'page' => $page, |
367
|
1 |
|
'per_page' => $per_page, |
368
|
1 |
|
'access_token' => $this->getToken(), |
369
|
|
|
]; |
370
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
371
|
|
|
} |
372
|
|
|
|
373
|
1 |
|
public function getClubActivities($id, $page = null, $per_page = null) |
374
|
|
|
{ |
375
|
1 |
|
$path = 'clubs/' . $id . '/activities'; |
376
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
377
|
1 |
|
'page' => $page, |
378
|
1 |
|
'per_page' => $per_page, |
379
|
1 |
|
'access_token' => $this->getToken(), |
380
|
|
|
]; |
381
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
382
|
|
|
} |
383
|
|
|
|
384
|
1 |
|
public function getClubAnnouncements($id) |
385
|
|
|
{ |
386
|
1 |
|
$path = 'clubs/' . $id . '/announcements'; |
387
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
388
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
389
|
|
|
} |
390
|
|
|
|
391
|
1 |
|
public function getClubGroupEvents($id) |
392
|
|
|
{ |
393
|
1 |
|
$path = 'clubs/' . $id . '/group_events'; |
394
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
395
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
396
|
|
|
} |
397
|
|
|
|
398
|
1 |
|
public function joinClub($id) |
399
|
|
|
{ |
400
|
1 |
|
$path = 'clubs/' . $id . '/join'; |
401
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
402
|
1 |
|
return $this->getResponse('POST', $path, $parameters); |
403
|
|
|
} |
404
|
|
|
|
405
|
1 |
|
public function leaveClub($id) |
406
|
|
|
{ |
407
|
1 |
|
$path = 'clubs/' . $id . '/leave'; |
408
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
409
|
1 |
|
return $this->getResponse('POST', $path, $parameters); |
410
|
|
|
} |
411
|
|
|
|
412
|
1 |
|
public function getRoute($id) |
413
|
|
|
{ |
414
|
1 |
|
$path = 'routes/' . $id; |
415
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
416
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
public function getRouteAsGPX($id) |
420
|
|
|
{ |
421
|
|
|
$path = 'routes/' . $id . '/export_gpx'; |
422
|
|
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
423
|
|
|
return $this->getResponse('GET', $path, $parameters); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
public function getRouteAsTCX($id) |
427
|
|
|
{ |
428
|
|
|
$path = 'routes/' . $id . '/export_tcx'; |
429
|
|
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
430
|
|
|
return $this->getResponse('GET', $path, $parameters); |
431
|
|
|
} |
432
|
|
|
|
433
|
1 |
|
public function getSegment($id) |
434
|
|
|
{ |
435
|
1 |
|
$path = 'segments/' . $id; |
436
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
437
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
438
|
|
|
} |
439
|
|
|
|
440
|
1 |
|
public function getSegmentLeaderboard($id, $gender = null, $age_group = null, $weight_class = null, $following = null, $club_id = null, $date_range = null, $context_entries = null, $page = null, $per_page = null) |
441
|
|
|
{ |
442
|
1 |
|
$path = 'segments/' . $id . '/leaderboard'; |
443
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
444
|
1 |
|
'gender' => $gender, |
445
|
1 |
|
'age_group' => $age_group, |
446
|
1 |
|
'weight_class' => $weight_class, |
447
|
1 |
|
'following' => $following, |
448
|
1 |
|
'club_id' => $club_id, |
449
|
1 |
|
'date_range' => $date_range, |
450
|
1 |
|
'context_entries' => $context_entries, |
451
|
1 |
|
'page' => $page, |
452
|
1 |
|
'per_page' => $per_page, |
453
|
1 |
|
'access_token' => $this->getToken(), |
454
|
|
|
]; |
455
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
456
|
|
|
} |
457
|
|
|
|
458
|
1 |
|
public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null) |
459
|
|
|
{ |
460
|
1 |
|
$path = 'segments/explore'; |
461
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
462
|
1 |
|
'bounds' => $bounds, |
463
|
1 |
|
'activity_type' => $activity_type, |
464
|
1 |
|
'min_cat' => $min_cat, |
465
|
1 |
|
'max_cat' => $max_cat, |
466
|
1 |
|
'access_token' => $this->getToken(), |
467
|
|
|
]; |
468
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
469
|
|
|
} |
470
|
|
|
|
471
|
1 |
|
public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null) |
472
|
|
|
{ |
473
|
1 |
|
$path = 'segments/' . $id . '/all_efforts'; |
474
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
475
|
1 |
|
'athlete_id' => $athlete_id, |
476
|
1 |
|
'start_date_local' => $start_date_local, |
477
|
1 |
|
'end_date_local' => $end_date_local, |
478
|
1 |
|
'page' => $page, |
479
|
1 |
|
'per_page' => $per_page, |
480
|
1 |
|
'access_token' => $this->getToken(), |
481
|
|
|
]; |
482
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
483
|
|
|
} |
484
|
|
|
|
485
|
1 |
|
public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance') |
486
|
|
|
{ |
487
|
1 |
|
$path = 'activities/' . $id . '/streams/' . $types; |
488
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
489
|
1 |
|
'resolution' => $resolution, |
490
|
1 |
|
'series_type' => $series_type, |
491
|
1 |
|
'access_token' => $this->getToken(), |
492
|
|
|
]; |
493
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
494
|
|
|
} |
495
|
|
|
|
496
|
1 |
|
public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance') |
497
|
|
|
{ |
498
|
1 |
|
$path = 'segment_efforts/' . $id . '/streams/' . $types; |
499
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
500
|
1 |
|
'resolution' => $resolution, |
501
|
1 |
|
'series_type' => $series_type, |
502
|
1 |
|
'access_token' => $this->getToken(), |
503
|
|
|
]; |
504
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
505
|
|
|
} |
506
|
|
|
|
507
|
1 |
|
public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance') |
508
|
|
|
{ |
509
|
1 |
|
$path = 'segments/' . $id . '/streams/' . $types; |
510
|
1 |
|
$parameters['query'] = [ |
|
|
|
|
511
|
1 |
|
'resolution' => $resolution, |
512
|
1 |
|
'series_type' => $series_type, |
513
|
1 |
|
'access_token' => $this->getToken(), |
514
|
|
|
]; |
515
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
516
|
|
|
} |
517
|
|
|
|
518
|
1 |
|
public function getStreamsRoute($id) |
519
|
|
|
{ |
520
|
1 |
|
$path = 'routes/' . $id . '/streams'; |
521
|
1 |
|
$parameters['query'] = ['access_token' => $this->getToken()]; |
|
|
|
|
522
|
1 |
|
return $this->getResponse('GET', $path, $parameters); |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
} |
526
|
|
|
|
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.