1
|
|
|
<?php |
2
|
|
|
namespace Strava\API; |
3
|
|
|
|
4
|
|
|
use Strava\API\Service\ServiceInterface; |
5
|
|
|
use Strava\API\Exception as ClientException; |
6
|
|
|
use Strava\API\Service\Exception as ServiceException; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Strava API Client |
10
|
|
|
* |
11
|
|
|
* @author Bas van Dorst |
12
|
|
|
* @package StravaPHP |
13
|
|
|
*/ |
14
|
|
|
class Client { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var ServiceInterface $service |
18
|
|
|
*/ |
19
|
|
|
protected $service; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Initiate this class with a subclass of ServiceInterface. There are two |
23
|
|
|
* service subclasses available: |
24
|
|
|
* - Service\REST: Service which makes calls to the live Strava API |
25
|
|
|
* - Service\Stub: Service stub for test purposes (unit tests) |
26
|
|
|
* |
27
|
|
|
* @param ServiceInterface $service |
28
|
|
|
*/ |
29
|
72 |
|
public function __construct(ServiceInterface $service) { |
30
|
72 |
|
$this->service = $service; |
31
|
72 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Retrieve current athlete |
35
|
|
|
* |
36
|
|
|
* @link http://strava.github.io/api/v3/athlete/#get-details, |
37
|
|
|
* http://strava.github.io/api/v3/athlete/#get-another-details |
38
|
|
|
* @param int $id |
39
|
|
|
* @return array |
40
|
|
|
* @throws Exception |
41
|
|
|
*/ |
42
|
2 |
|
public function getAthlete($id = null) { |
43
|
|
|
try { |
44
|
2 |
|
return $this->service->getAthlete($id); |
45
|
1 |
|
} catch (ServiceException $e) { |
46
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Retrieve athlete stats |
52
|
|
|
* |
53
|
|
|
* Only available for the authenticated athlete. |
54
|
|
|
* |
55
|
|
|
* @link http://strava.github.io/api/v3/athlete/#stats |
56
|
|
|
* @param int $id |
57
|
|
|
* @return array |
58
|
|
|
* @throws ClientException |
59
|
|
|
*/ |
60
|
1 |
|
public function getAthleteStats($id) { |
61
|
|
|
try { |
62
|
1 |
|
return $this->service->getAthleteStats($id); |
63
|
|
|
} catch (ServiceException $e) { |
64
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* List athlete clubs |
70
|
|
|
* |
71
|
|
|
* @link http://strava.github.io/api/v3/clubs/#get-athletes |
72
|
|
|
* @return array |
73
|
|
|
* @throws Exception |
74
|
|
|
*/ |
75
|
2 |
|
public function getAthleteClubs() { |
76
|
|
|
try { |
77
|
2 |
|
return $this->service->getAthleteClubs(); |
78
|
1 |
|
} catch (ServiceException $e) { |
79
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* List athlete activities |
85
|
|
|
* |
86
|
|
|
* @link http://strava.github.io/api/v3/activities/#get-activities |
87
|
|
|
* @param string $before |
88
|
|
|
* @param string $after |
89
|
|
|
* @param int $page |
90
|
|
|
* @param int $per_page |
91
|
|
|
* @return array |
92
|
|
|
* @throws Exception |
93
|
|
|
*/ |
94
|
2 |
|
public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null) { |
95
|
|
|
try { |
96
|
2 |
|
return $this->service->getAthleteActivities($before, $after, $page, $per_page); |
97
|
1 |
|
} catch (ServiceException $e) { |
98
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* List athlete friends |
104
|
|
|
* |
105
|
|
|
* @link http://strava.github.io/api/v3/follow/#friends |
106
|
|
|
* @param int $id |
107
|
|
|
* @param int $page |
108
|
|
|
* @param int $per_page |
109
|
|
|
* @return array |
110
|
|
|
* @throws Exception |
111
|
|
|
*/ |
112
|
2 |
|
public function getAthleteFriends($id = null, $page = null, $per_page = null) { |
113
|
|
|
try { |
114
|
2 |
|
return $this->service->getAthleteFriends($id, $page, $per_page); |
115
|
1 |
|
} catch (ServiceException $e) { |
116
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* List athlete followers |
122
|
|
|
* |
123
|
|
|
* @link http://strava.github.io/api/v3/follow/#followers |
124
|
|
|
* @param int $id |
125
|
|
|
* @param int $page |
126
|
|
|
* @param int $per_page |
127
|
|
|
* @return array |
128
|
|
|
* @throws Exception |
129
|
|
|
*/ |
130
|
2 |
|
public function getAthleteFollowers($id = null, $page = null, $per_page = null) { |
131
|
|
|
try { |
132
|
2 |
|
return $this->service->getAthleteFollowers($id, $page, $per_page); |
133
|
1 |
|
} catch (ServiceException $e) { |
134
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* List both following |
140
|
|
|
* |
141
|
|
|
* @link http://strava.github.io/api/v3/follow/#both |
142
|
|
|
* @param int $id |
143
|
|
|
* @param int $page |
144
|
|
|
* @param int $per_page |
145
|
|
|
* @return array |
146
|
|
|
* @throws Exception |
147
|
|
|
*/ |
148
|
2 |
|
public function getAthleteBothFollowing($id, $page = null, $per_page = null) { |
149
|
|
|
try { |
150
|
2 |
|
return $this->service->getAthleteBothFollowing($id, $page, $per_page); |
151
|
1 |
|
} catch (ServiceException $e) { |
152
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* List athlete K/QOMs/CRs |
158
|
|
|
* |
159
|
|
|
* @link http://strava.github.io/api/v3/athlete/#koms |
160
|
|
|
* @param int $id |
161
|
|
|
* @param int $page |
162
|
|
|
* @param int $per_page |
163
|
|
|
* @return array |
164
|
|
|
* @throws Exception |
165
|
|
|
*/ |
166
|
2 |
|
public function getAthleteKom($id, $page = null, $per_page = null) { |
167
|
|
|
try { |
168
|
2 |
|
return $this->service->getAthleteKom($id, $page, $per_page); |
169
|
1 |
|
} catch (ServiceException $e) { |
170
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* List starred segment |
176
|
|
|
* |
177
|
|
|
* @link http://strava.github.io/api/v3/segments/#starred |
178
|
|
|
* @param int $id |
179
|
|
|
* @param int $page |
180
|
|
|
* @param int $per_page |
181
|
|
|
* @return array |
182
|
|
|
* @throws Exception |
183
|
|
|
*/ |
184
|
2 |
|
public function getAthleteStarredSegments($id = null, $page = null, $per_page = null) { |
185
|
|
|
try { |
186
|
2 |
|
return $this->service->getAthleteStarredSegments($id, $page, $per_page); |
187
|
1 |
|
} catch (ServiceException $e) { |
188
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Update current athlete |
194
|
|
|
* |
195
|
|
|
* @link http://strava.github.io/api/v3/athlete/#update |
196
|
|
|
* @param string $city |
197
|
|
|
* @param string $state |
198
|
|
|
* @param string $country |
199
|
|
|
* @param string $sex |
200
|
|
|
* @param float $weight |
201
|
|
|
* @return array |
202
|
|
|
* @throws Exception |
203
|
|
|
*/ |
204
|
2 |
|
public function updateAthlete($city, $state, $country, $sex, $weight){ |
205
|
|
|
try { |
206
|
2 |
|
return $this->service->updateAthlete($city, $state, $country, $sex, $weight); |
207
|
1 |
|
} catch (ServiceException $e) { |
208
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Retrieve activity from user followers |
214
|
|
|
* |
215
|
|
|
* @link https://strava.github.io/api/v3/activities/#get-feed |
216
|
|
|
* |
217
|
|
|
* @param type $before |
218
|
|
|
* @param type $page |
219
|
|
|
* @param type $per_page |
220
|
|
|
* @return type |
221
|
|
|
* @throws ClientException |
222
|
2 |
|
*/ |
223
|
|
|
public function getAthleteActivitiesFollowing($before = null, $page = null, $per_page = null) { |
224
|
2 |
|
try { |
225
|
1 |
|
return $this->service->getActivityFollowing($before, $page, $per_page); |
|
|
|
|
226
|
1 |
|
} catch (ServiceException $e) { |
227
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Retrieve an activity |
234
|
|
|
* |
235
|
|
|
* @link http://strava.github.io/api/v3/athlete/#get-details, |
236
|
|
|
* http://strava.github.io/api/v3/athlete/#get-another-details |
237
|
|
|
* @param int $id |
238
|
|
|
* @param boolean $include_all_efforts |
239
|
|
|
* @return array |
240
|
|
|
* @throws Exception |
241
|
2 |
|
*/ |
242
|
|
|
public function getActivity($id, $include_all_efforts = null) { |
243
|
2 |
|
try { |
244
|
1 |
|
return $this->service->getActivity($id, $include_all_efforts); |
245
|
1 |
|
} catch (ServiceException $e) { |
246
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* List activity comments |
252
|
|
|
* |
253
|
|
|
* @link http://strava.github.io/api/v3/comments/#list |
254
|
|
|
* @param int $id |
255
|
|
|
* @param boolean $markdown |
256
|
|
|
* @param int $page |
257
|
|
|
* @param int $per_page |
258
|
|
|
* @return array |
259
|
2 |
|
* @throws Exception |
260
|
|
|
*/ |
261
|
2 |
|
public function getActivityComments($id, $markdown = null, $page = null, $per_page = null) { |
262
|
1 |
|
try { |
263
|
1 |
|
return $this->service->getActivityComments($id, $markdown, $page, $per_page); |
264
|
|
|
} catch (ServiceException $e) { |
265
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
266
|
|
|
} |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* List activity kudoers |
271
|
|
|
* |
272
|
|
|
* @link http://strava.github.io/api/v3/kudos/#list |
273
|
|
|
* @param int $id |
274
|
|
|
* @param int $page |
275
|
|
|
* @param int $per_page |
276
|
|
|
* @return array |
277
|
2 |
|
* @throws Exception |
278
|
|
|
*/ |
279
|
2 |
|
public function getActivityKudos($id, $page = null, $per_page = null) { |
280
|
1 |
|
try { |
281
|
1 |
|
return $this->service->getActivityKudos($id, $page, $per_page); |
282
|
|
|
} catch (ServiceException $e) { |
283
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* List activity photos |
289
|
|
|
* |
290
|
|
|
* @link http://strava.github.io/api/v3/photos/#list |
291
|
|
|
* @param int $id |
292
|
|
|
* @param int $size In pixels. |
293
|
2 |
|
* @param string $photo_sources Must be "true". |
294
|
|
|
* @return array |
295
|
2 |
|
* @throws Exception |
296
|
1 |
|
*/ |
297
|
1 |
|
public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true') { |
298
|
|
|
try { |
299
|
|
|
return $this->service->getActivityPhotos($id, $size, $photo_sources); |
300
|
|
|
} catch (ServiceException $e) { |
301
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* List activity zones |
307
|
|
|
* |
308
|
|
|
* @link http://strava.github.io/api/v3/activities/#zones |
309
|
2 |
|
* @param int $id |
310
|
|
|
* @return array |
311
|
2 |
|
* @throws Exception |
312
|
1 |
|
*/ |
313
|
1 |
|
public function getActivityZones($id) { |
314
|
|
|
try { |
315
|
|
|
return $this->service->getActivityZones($id); |
316
|
|
|
} catch (ServiceException $e) { |
317
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
318
|
|
|
} |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* List activity laps |
323
|
|
|
* |
324
|
|
|
* @link http://strava.github.io/api/v3/activities/#laps |
325
|
2 |
|
* @param int $id |
326
|
|
|
* @return array |
327
|
2 |
|
* @throws Exception |
328
|
1 |
|
*/ |
329
|
1 |
|
public function getActivityLaps($id) { |
330
|
|
|
try { |
331
|
|
|
return $this->service->getActivityLaps($id); |
332
|
|
|
} catch (ServiceException $e) { |
333
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
334
|
|
|
} |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Check upload status |
339
|
|
|
* |
340
|
|
|
* @link http://strava.github.io/api/v3/uploads/#get-status |
341
|
|
|
* @param int $id |
342
|
|
|
* @return array |
343
|
|
|
* @throws Exception |
344
|
|
|
*/ |
345
|
|
|
public function getActivityUploadStatus($id) { |
346
|
2 |
|
try { |
347
|
|
|
return $this->service->getActivityUploadStatus($id); |
348
|
2 |
|
} catch (ServiceException $e) { |
349
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
350
|
1 |
|
} |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Create an activity |
355
|
|
|
* |
356
|
|
|
* @link http://strava.github.io/api/v3/activities/#create |
357
|
|
|
* @param string $name |
358
|
|
|
* @param string $type |
359
|
|
|
* @param string $start_date_local |
360
|
|
|
* @param int $elapsed_time |
361
|
|
|
* @param string $description |
362
|
|
|
* @param float $distance |
363
|
|
|
* @return array |
364
|
|
|
* @throws Exception |
365
|
|
|
*/ |
366
|
|
|
public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null) { |
367
|
|
|
try { |
368
|
|
|
return $this->service->createActivity($name, $type, $start_date_local, $elapsed_time, $description, $distance); |
369
|
|
|
} catch (ServiceException $e) { |
370
|
2 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
371
|
|
|
} |
372
|
2 |
|
} |
373
|
1 |
|
|
374
|
1 |
|
/** |
375
|
|
|
* Upload an activity |
376
|
|
|
* |
377
|
|
|
* @link http://strava.github.io/api/v3/uploads/#post-file |
378
|
|
|
* @param mixed $file |
379
|
|
|
* @param string $activity_type |
380
|
|
|
* @param string $name |
381
|
|
|
* @param string $description |
382
|
|
|
* @param int $private |
383
|
|
|
* @param int $trainer |
384
|
|
|
* @param int $commute |
385
|
|
|
* @param string $data_type |
386
|
|
|
* @param string $external_id |
387
|
|
|
* @return array |
388
|
|
|
* @throws Exception |
389
|
|
|
*/ |
390
|
|
|
public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null) { |
391
|
|
|
try { |
392
|
|
|
return $this->service->uploadActivity($file, $activity_type, $name, $description, $private, $trainer, $commute, $data_type, $external_id); |
|
|
|
|
393
|
2 |
|
} catch (ServiceException $e) { |
394
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
395
|
2 |
|
} |
396
|
1 |
|
} |
397
|
1 |
|
|
398
|
|
|
/** |
399
|
|
|
* Update an activity |
400
|
|
|
* |
401
|
|
|
* @link http://strava.github.io/api/v3/activities/#put-updates |
402
|
|
|
* @param int $id |
403
|
|
|
* @param string $name |
404
|
|
|
* @param string $type |
405
|
|
|
* @param boolean $private |
406
|
|
|
* @param boolean $commute |
407
|
|
|
* @param boolean $trainer |
408
|
|
|
* @param string $gear_id |
409
|
2 |
|
* @param string $description |
410
|
|
|
* @return array |
411
|
2 |
|
* @throws Exception |
412
|
1 |
|
*/ |
413
|
1 |
|
public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null) { |
414
|
|
|
try { |
415
|
|
|
return $this->service->updateActivity($id, $name, $type, $private, $commute, $trainer, $gear_id, $description); |
416
|
|
|
} catch (ServiceException $e) { |
417
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
418
|
|
|
} |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* Delete an activity |
423
|
|
|
* |
424
|
|
|
* @link http://strava.github.io/api/v3/activities/#delete |
425
|
|
|
* @param int $id |
426
|
2 |
|
* @return array |
427
|
|
|
* @throws Exception |
428
|
2 |
|
*/ |
429
|
1 |
|
public function deleteActivity($id) { |
430
|
1 |
|
try { |
431
|
|
|
return $this->service->deleteActivity($id); |
432
|
|
|
} catch (ServiceException $e) { |
433
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Retrieve gear |
440
|
|
|
* |
441
|
|
|
* @link http://strava.github.io/api/v3/gear/ |
442
|
2 |
|
* @param int $id |
443
|
|
|
* @return array |
444
|
2 |
|
* @throws Exception |
445
|
1 |
|
*/ |
446
|
1 |
|
public function getGear($id) { |
447
|
|
|
try { |
448
|
|
|
return $this->service->getGear($id); |
449
|
|
|
} catch (ServiceException $e) { |
450
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
451
|
|
|
} |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* Retrieve a club |
456
|
|
|
* |
457
|
|
|
* @link http://strava.github.io/api/v3/clubs/#get-details |
458
|
|
|
* @param int $id |
459
|
|
|
* @return array |
460
|
2 |
|
* @throws Exception |
461
|
|
|
*/ |
462
|
2 |
|
public function getClub($id) { |
463
|
1 |
|
try { |
464
|
1 |
|
return $this->service->getClub($id); |
465
|
|
|
} catch (ServiceException $e) { |
466
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* List club members |
472
|
|
|
* |
473
|
|
|
* @link http://strava.github.io/api/v3/clubs/#get-members |
474
|
|
|
* @param int $id |
475
|
|
|
* @param int $page |
476
|
|
|
* @param int $per_page |
477
|
|
|
* @return array |
478
|
2 |
|
* @throws Exception |
479
|
|
|
*/ |
480
|
2 |
|
public function getClubMembers($id, $page = null, $per_page = null) { |
481
|
1 |
|
try { |
482
|
1 |
|
return $this->service->getClubMembers($id, $page, $per_page); |
483
|
|
|
} catch (ServiceException $e) { |
484
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* List club activities |
490
|
|
|
* |
491
|
|
|
* @link http://strava.github.io/api/v3/clubs/#get-activities |
492
|
|
|
* @param int $id |
493
|
|
|
* @param int $page |
494
|
2 |
|
* @param int $per_page |
495
|
|
|
* @return array |
496
|
2 |
|
* @throws Exception |
497
|
1 |
|
*/ |
498
|
1 |
|
public function getClubActivities($id, $page = null, $per_page = null) { |
499
|
|
|
try { |
500
|
|
|
return $this->service->getClubActivities($id, $page, $per_page); |
501
|
|
|
} catch (ServiceException $e) { |
502
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
503
|
|
|
} |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
/** |
507
|
|
|
* List club announcements |
508
|
|
|
* |
509
|
|
|
* @link https://strava.github.io/api/v3/clubs/#get-announcements |
510
|
2 |
|
* @param int $id |
511
|
|
|
* @return array |
512
|
2 |
|
* @throws Exception |
513
|
1 |
|
*/ |
514
|
1 |
|
public function getClubAnnouncements($id) { |
515
|
|
|
try { |
516
|
|
|
return $this->service->getClubAnnouncements($id); |
517
|
|
|
} catch (ServiceException $e) { |
518
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
519
|
|
|
} |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* List club group events |
524
|
|
|
* |
525
|
|
|
* @link https://strava.github.io/api/v3/clubs/#get-group-events |
526
|
2 |
|
* @param int $id |
527
|
|
|
* @return array |
528
|
2 |
|
* @throws Exception |
529
|
1 |
|
*/ |
530
|
1 |
|
public function getClubGroupEvents($id) { |
531
|
|
|
try { |
532
|
|
|
return $this->service->getClubGroupEvents($id); |
533
|
|
|
} catch (ServiceException $e) { |
534
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
535
|
|
|
} |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Join a club |
540
|
|
|
* |
541
|
|
|
* @link https://strava.github.io/api/v3/clubs/#join |
542
|
2 |
|
* @param int $id |
543
|
|
|
* @return array |
544
|
2 |
|
* @throws Exception |
545
|
1 |
|
*/ |
546
|
1 |
|
public function joinClub($id) { |
547
|
|
|
try { |
548
|
|
|
return $this->service->joinClub($id); |
549
|
|
|
} catch (ServiceException $e) { |
550
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
551
|
|
|
} |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* Leave a club |
556
|
|
|
* |
557
|
|
|
* @link https://strava.github.io/api/v3/clubs/#leave |
558
|
2 |
|
* @param int $id |
559
|
|
|
* @return array |
560
|
2 |
|
* @throws Exception |
561
|
1 |
|
*/ |
562
|
1 |
|
public function leaveClub($id) { |
563
|
|
|
try { |
564
|
|
|
return $this->service->leaveClub($id); |
565
|
|
|
} catch (ServiceException $e) { |
566
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
567
|
|
|
} |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Retrieve a segment |
572
|
|
|
* |
573
|
|
|
* @link http://strava.github.io/api/v3/segments/#retrieve |
574
|
|
|
* @param int $id |
575
|
|
|
* @return array |
576
|
|
|
* @throws Exception |
577
|
|
|
*/ |
578
|
|
|
public function getSegment($id) { |
579
|
|
|
try { |
580
|
|
|
return $this->service->getSegment($id); |
581
|
|
|
} catch (ServiceException $e) { |
582
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
583
|
2 |
|
} |
584
|
|
|
} |
585
|
2 |
|
|
586
|
1 |
|
/** |
587
|
1 |
|
* Segment leaderboards |
588
|
|
|
* |
589
|
|
|
* @link http://strava.github.io/api/v3/segments/#leaderboard |
590
|
|
|
* @param int $id |
591
|
|
|
* @param string $gender |
592
|
|
|
* @param string $age_group |
593
|
|
|
* @param string $weight_class |
594
|
|
|
* @param boolean $following |
595
|
|
|
* @param int $club_id |
596
|
|
|
* @param string $date_range |
597
|
|
|
* @param int $context_entries |
598
|
|
|
* @param int $page |
599
|
|
|
* @param int $per_page |
600
|
|
|
* @return array |
601
|
|
|
* @throws Exception |
602
|
2 |
|
*/ |
603
|
|
|
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) { |
604
|
2 |
|
try { |
605
|
1 |
|
return $this->service->getSegmentLeaderboard($id, $gender, $age_group, $weight_class, $following, $club_id, $date_range, $context_entries, $page, $per_page); |
606
|
1 |
|
} catch (ServiceException $e) { |
607
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
608
|
|
|
} |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
/** |
612
|
|
|
* Segment explorer |
613
|
|
|
* |
614
|
|
|
* @link http://strava.github.io/api/v3/segments/#explore |
615
|
|
|
* @param string $bounds |
616
|
|
|
* @param string $activity_type |
617
|
|
|
* @param int $min_cat |
618
|
|
|
* @param int $max_cat |
619
|
|
|
* @return array |
620
|
|
|
* @throws Exception |
621
|
|
|
*/ |
622
|
|
|
public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null) { |
623
|
2 |
|
try { |
624
|
|
|
return $this->service->getSegmentExplorer($bounds, $activity_type, $min_cat, $max_cat); |
625
|
2 |
|
} catch (ServiceException $e) { |
626
|
1 |
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
627
|
1 |
|
} |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* List efforts filtered by athlete and/or a date range |
632
|
|
|
* |
633
|
|
|
* @link http://strava.github.io/api/v3/segments/#efforts |
634
|
|
|
* @param int $id |
635
|
|
|
* @param int $athlete_id |
636
|
|
|
* @param string $start_date_local |
637
|
|
|
* @param string $end_date_local |
638
|
|
|
* @param int $page |
639
|
|
|
* @param int $per_page |
640
|
|
|
* @return array |
641
|
|
|
* @throws Exception |
642
|
2 |
|
*/ |
643
|
|
|
public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null) { |
644
|
2 |
|
try { |
645
|
1 |
|
return $this->service->getSegmentEffort($id, $athlete_id, $start_date_local, $end_date_local, $page, $per_page); |
646
|
1 |
|
} catch (ServiceException $e) { |
647
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
648
|
|
|
} |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Retrieve activity streams |
653
|
|
|
* |
654
|
|
|
* @link http://strava.github.io/api/v3/streams/#activity |
655
|
|
|
* @param int $id |
656
|
|
|
* @param string $types |
657
|
|
|
* @param string $resolution |
658
|
|
|
* @param string $series_type |
659
|
|
|
* @return array |
660
|
|
|
* @throws Exception |
661
|
2 |
|
*/ |
662
|
|
|
public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance') { |
663
|
2 |
|
try { |
664
|
1 |
|
return $this->service->getStreamsActivity($id, $types, $resolution, $series_type); |
665
|
1 |
|
} catch (ServiceException $e) { |
666
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
667
|
|
|
} |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* Retrieve effort streams |
672
|
|
|
* |
673
|
|
|
* @link http://strava.github.io/api/v3/streams/#effort |
674
|
|
|
* @param int $id |
675
|
|
|
* @param string $types |
676
|
|
|
* @param string $resolution |
677
|
|
|
* @param string $series_type |
678
|
|
|
* @return array |
679
|
2 |
|
* @throws Exception |
680
|
|
|
*/ |
681
|
2 |
|
public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance') { |
682
|
1 |
|
try { |
683
|
1 |
|
return $this->service->getStreamsEffort($id, $types, $resolution, $series_type); |
684
|
|
|
} catch (ServiceException $e) { |
685
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
686
|
|
|
} |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Retrieve segment streams |
691
|
|
|
* @link http://strava.github.io/api/v3/streams/#segment |
692
|
|
|
* @param int $id |
693
|
|
|
* @param string $types |
694
|
|
|
* @param string $resolution |
695
|
|
|
* @param string $series_type |
696
|
|
|
* @return array |
697
|
|
|
* @throws Exception |
698
|
|
|
*/ |
699
|
|
|
public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance') { |
700
|
|
|
try { |
701
|
|
|
return $this->service->getStreamsSegment($id, $types, $resolution, $series_type); |
702
|
|
|
} catch (ServiceException $e) { |
703
|
|
|
throw new ClientException('[SERVICE] '.$e->getMessage()); |
704
|
|
|
} |
705
|
|
|
} |
706
|
|
|
} |
707
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.