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