Completed
Pull Request — master (#46)
by
unknown
01:41
created

Client::getClubAnnouncements()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
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 79
    public function __construct(ServiceInterface $service)
30
    {
31 79
        $this->service = $service;
32 79
    }
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/routes/#list
75
     * @param   int $id
76
     * @return  array
77
     * @throws  ClientException
78
     */
79 1
    public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
80
    {
81
        try {
82 1
            return $this->service->getAthleteRoutes($id, $type, $after, $page, $per_page);
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);
0 ignored issues
show
Unused Code introduced by
The call to ServiceInterface::createActivity() has too many arguments starting with $private.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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);
0 ignored issues
show
Unused Code introduced by
The call to ServiceInterface::uploadActivity() has too many arguments starting with $external_id.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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
     * Get route details
639
     *
640
     * @link    https://strava.github.io/api/v3/routes/#list
641
     * @param   int $id
642
     * @return  array
643
     * @throws  Exception
644
     */
645 2
    public function getRoute($id)
646
    {
647
        try {
648 2
            return $this->service->getRoute($id);
649 1
        } catch (ServiceException $e) {
650 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
651
        }
652
    }
653
654
    /**
655
     * Get route as GPX.
656
     *
657
     * @link    https://developers.strava.com/docs/reference/#api-Routes-getRouteAsGPX
658
     * @param   int $id
659
     * @return  string
660
     * @throws  Exception
661
     */
662 2
    public function getRouteAsGPX($id)
663
    {
664
        try {
665 2
            return $this->service->getRouteAsGPX($id);
666 1
        } catch (ServerException $e) {
0 ignored issues
show
Bug introduced by
The class Strava\API\ServerException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
667 1
            throw new ClientException('[SERVICE] ' . $e->getMessage());
668
        }
669
    }
670
671
    /**
672
     * Get route as TCX.
673
     *
674
     * @link    https://developers.strava.com/docs/reference/#api-Routes-getRouteAsTCX
675
     * @param   int $id
676
     * @return  string
677
     * @throws  Exception
678
     */
679
    public function getRouteAsTCX($id)
680
    {
681
        try {
682
            return $this->service->getRouteAsTCX($id);
683
        } catch (ServerException $e) {
0 ignored issues
show
Bug introduced by
The class Strava\API\ServerException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
684
            throw new ClientException('[SERVICE] ' . $e->getMessage());
685
        }
686
    }
687
688 2
    /**
689
     * Retrieve a segment
690
     *
691 2
     * @link    https://strava.github.io/api/v3/segments/#retrieve
692 1
     * @param   int $id
693 1
     * @return  array
694
     * @throws  Exception
695
     */
696
    public function getSegment($id)
697
    {
698
        try {
699
            return $this->service->getSegment($id);
700
        } catch (ServiceException $e) {
701
            throw new ClientException('[SERVICE] ' . $e->getMessage());
702
        }
703
    }
704
705
    /**
706
     * Segment leaderboards
707
     *
708 2
     * @link    https://strava.github.io/api/v3/segments/#leaderboard
709
     * @param   int $id
710
     * @param   string $gender
711 2
     * @param   string $age_group
712 1
     * @param   string $weight_class
713 1
     * @param   boolean $following
714
     * @param   int $club_id
715
     * @param   string $date_range
716
     * @param   int $context_entries
717
     * @param   int $page
718
     * @param   int $per_page
719
     * @return  array
720
     * @throws  Exception
721
     */
722
    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)
723
    {
724
        try {
725
            return $this->service->getSegmentLeaderboard($id, $gender, $age_group, $weight_class, $following, $club_id, $date_range, $context_entries, $page, $per_page);
726
        } catch (ServiceException $e) {
727
            throw new ClientException('[SERVICE] ' . $e->getMessage());
728
        }
729
    }
730 2
731
    /**
732
     * Segment explorer
733 2
     *
734 1
     * @link    https://strava.github.io/api/v3/segments/#explore
735 1
     * @param   string $bounds
736
     * @param   string $activity_type
737
     * @param   int $min_cat
738
     * @param   int $max_cat
739
     * @return  array
740
     * @throws  Exception
741
     */
742
    public function getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null)
743
    {
744
        try {
745
            return $this->service->getSegmentExplorer($bounds, $activity_type, $min_cat, $max_cat);
746
        } catch (ServiceException $e) {
747
            throw new ClientException('[SERVICE] ' . $e->getMessage());
748
        }
749
    }
750 2
751
    /**
752
     * List efforts filtered by athlete and/or a date range
753 2
     *
754 1
     * @link    https://strava.github.io/api/v3/segments/#efforts
755 1
     * @param   int $id
756
     * @param   int $athlete_id
757
     * @param   string $start_date_local
758
     * @param   string $end_date_local
759
     * @param   int $page
760
     * @param   int $per_page
761
     * @return  array
762
     * @throws  Exception
763
     */
764
    public function getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null)
765
    {
766
        try {
767
            return $this->service->getSegmentEffort($id, $athlete_id, $start_date_local, $end_date_local, $page, $per_page);
768
        } catch (ServiceException $e) {
769
            throw new ClientException('[SERVICE] ' . $e->getMessage());
770 2
        }
771
    }
772
773 2
    /**
774 1
     * Retrieve activity streams
775 1
     *
776
     * @link    https://strava.github.io/api/v3/streams/#activity
777
     * @param   int $id
778
     * @param   string $types
779
     * @param   string $resolution
780
     * @param   string $series_type
781
     * @return  array
782
     * @throws  Exception
783
     */
784
    public function getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance')
785
    {
786
        try {
787
            return $this->service->getStreamsActivity($id, $types, $resolution, $series_type);
788
        } catch (ServiceException $e) {
789 2
            throw new ClientException('[SERVICE] ' . $e->getMessage());
790
        }
791
    }
792 2
793 1
    /**
794 1
     * Retrieve effort streams
795
     *
796
     * @link    https://strava.github.io/api/v3/streams/#effort
797
     * @param   int $id
798
     * @param   string $types
799
     * @param   string $resolution
800
     * @param   string $series_type
801
     * @return  array
802
     * @throws  Exception
803
     */
804
    public function getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance')
805
    {
806 2
        try {
807
            return $this->service->getStreamsEffort($id, $types, $resolution, $series_type);
808
        } catch (ServiceException $e) {
809 2
            throw new ClientException('[SERVICE] ' . $e->getMessage());
810 1
        }
811 1
    }
812
813
    /**
814
     * Retrieve segment streams
815
     * @link    https://strava.github.io/api/v3/streams/#segment
816
     * @param   int $id
817
     * @param   string $types
818
     * @param   string $resolution
819
     * @param   string $series_type
820
     * @return  array
821
     * @throws  Exception
822
     */
823
    public function getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance')
824
    {
825
        try {
826
            return $this->service->getStreamsSegment($id, $types, $resolution, $series_type);
827
        } catch (ServiceException $e) {
828
            throw new ClientException('[SERVICE] ' . $e->getMessage());
829
        }
830
    }
831
832
    /**
833
     * Retrieve route streams
834
     *
835
     * @link    https://strava.github.io/api/v3/streams/#routes
836
     * @param   int $id
837
     * @return  array
838
     * @throws  Exception
839
     */
840
    public function getStreamsRoute($id)
841
    {
842
        try {
843
            return $this->service->getStreamsRoute($id);
844
        } catch (ServiceException $e) {
845
            throw new ClientException('[SERVICE] ' . $e->getMessage());
846
        }
847
    }
848
}
849