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