Passed
Push — master ( 26aae1...72fb83 )
by
unknown
04:02 queued 02:17
created

Client::getRouteAsTCX()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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