/// <summary> /// Gets all the starred segments of an Athlete. /// </summary> /// <returns>A list of segments that are starred by the athlete.</returns> private async Task <List <SegmentSummary> > GetStarredSegmentsFromServiceAsync(string athleteId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); var defaultDistanceUnitType = await _settingsService.GetStoredDistanceUnitTypeAsync(); string getUrl = $"{Endpoints.Athletes}/{athleteId}/segments/starred?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var segments = Unmarshaller <List <SegmentSummary> > .Unmarshal(json); foreach (SegmentSummary segment in segments) { StravaService.SetMetricUnits(segment, defaultDistanceUnitType); } return(segments); } catch (Exception ex) { //TODO: Glenn - Use logger to log errors ( Google ) } return(null); }
private async Task <Segment> GetSegmentFromServiceAsync(string segmentId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); var defaultDistanceUnitType = await _settingsService.GetStoredDistanceUnitTypeAsync(); string getUrl = $"{Endpoints.Segment}/{segmentId}?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var segment = Unmarshaller <Segment> .Unmarshal(json); StravaService.SetMetricUnits(segment, defaultDistanceUnitType); return(segment); } catch (Exception ex) { string title = $"StravaSegmentService.GetSegmentFromServiceAsync - segmentId {segmentId}"; _logService.LogException(title, ex); } return(null); }
private async Task <Segment> GetSegmentFromServiceAsync(string segmentId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); var defaultDistanceUnitType = await _settingsService.GetStoredDistanceUnitTypeAsync(); string getUrl = $"{Endpoints.Segment}/{segmentId}?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var segment = Unmarshaller <Segment> .Unmarshal(json); StravaService.SetMetricUnits(segment, defaultDistanceUnitType); return(segment); } catch (Exception ex) { #if !DEBUG _errorMessage.Clear(); _errorMessage.AppendLine($"StravaSegmentService.GetSegmentFromServiceAsync - segmentId {segmentId}"); _errorMessage.AppendLine(ex.Message); ServiceLocator.Current.GetInstance <IGoogleAnalyticsService>().Tracker.SendException(_errorMessage.ToString(), false); #endif } return(null); }
private async Task <List <Photo> > GetPhotosFromServiceAsync(string activityId) { try { _perflog.GetPhotosFromService(false, activityId); var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = $"{Endpoints.Activity}/{activityId}/photos?photo_sources=true&size=600&access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var results = Unmarshaller <List <Photo> > .Unmarshal(json); _perflog.GetPhotosFromService(true, activityId); return(results); } catch (Exception ex) { #if !DEBUG _errorMessage.Clear(); _errorMessage.AppendLine($"StravaActivityService.GetPhotosFromServiceAsync - activityId {activityId}"); _errorMessage.AppendLine(ex.Message); ServiceLocator.Current.GetInstance <IGoogleAnalyticsService>().Tracker.SendException(_errorMessage.ToString(), false); #endif } return(null); }
private async Task <List <Photo> > GetPhotosFromServiceAsync(string activityId) { try { _perflog.GetPhotosFromService(false, activityId); var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = $"{Endpoints.Activity}/{activityId}/photos?photo_sources=true&size=600&access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var results = Unmarshaller <List <Photo> > .Unmarshal(json); _perflog.GetPhotosFromService(true, activityId); return(results); } catch (Exception ex) { string title = $"StravaActivityService.GetPhotosFromServiceAsync - activityId {activityId}"; _logService.LogException(title, ex); } return(null); }
private async Task <AthleteSummary> GetAthleteFromServiceAsync(string athleteId) { try { _perflog.GetAthleteFromServiceAsync(false, athleteId); var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = string.Format("{0}/{1}?access_token={2}", Endpoints.Athletes, athleteId, accessToken); string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var result = Unmarshaller <AthleteSummary> .Unmarshal(json); if (result != null) { ConsolidateWithCache(result); } _perflog.GetAthleteFromServiceAsync(true, athleteId); return(result); } catch (Exception ex) { string title = $"StravaAthleteService.GetAthleteFromServiceAsync - athleteId {athleteId}"; _logService.LogException(title, ex); } return(null); }
private async Task <AthleteSummary> GetAthleteFromServiceAsync(string athleteId) { try { _perflog.GetAthleteFromServiceAsync(false, athleteId); var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = string.Format("{0}/{1}?access_token={2}", Endpoints.Athletes, athleteId, accessToken); string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var result = Unmarshaller <AthleteSummary> .Unmarshal(json); if (result != null) { ConsolidateWithCache(result); } _perflog.GetAthleteFromServiceAsync(true, athleteId); return(result); } catch (Exception ex) { #if !DEBUG _errorMessage.Clear(); _errorMessage.AppendLine($"StravaAthleteService.GetAthleteFromServiceAsync - athleteId {athleteId}"); _errorMessage.AppendLine(ex.Message); ServiceLocator.Current.GetInstance <IGoogleAnalyticsService>().Tracker.SendException(_errorMessage.ToString(), false); #endif } return(null); }
private async Task <Club> GetClubFromServiceAsync(string clubId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = $"{Endpoints.Club}/{clubId}?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); return(Unmarshaller <Club> .Unmarshal(json)); } catch (Exception ex) { //TODO: Glenn - Use logger to log errors ( Google ) } return(null); }
private async Task <Club> GetClubFromServiceAsync(string clubId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = $"{Endpoints.Club}/{clubId}?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); return(Unmarshaller <Club> .Unmarshal(json)); } catch (Exception ex) { string title = $"StravaClubService.GetClubFromServiceAsync - clubId {clubId}"; _logService.LogException(title, ex); } return(null); }
private async Task <AthleteSummary> GetAthleteFromServiceAsync(string athleteId) { try { _perflog.GetAthleteFromServiceAsync(false, athleteId); var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = string.Format("{0}/{1}?access_token={2}", Endpoints.Athletes, athleteId, accessToken); string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); var result = Unmarshaller <Athlete> .Unmarshal(json); if (result != null) { ConsolidateWithCache(result); } _perflog.GetAthleteFromServiceAsync(true, athleteId); return(result); } catch (Exception ex) { //TODO: Glenn - Use logger to log errors ( Google ) } return(null); }
private async Task <Club> GetClubFromServiceAsync(string clubId) { try { var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync(); string getUrl = $"{Endpoints.Club}/{clubId}?access_token={accessToken}"; string json = await _stravaWebClient.GetAsync(new Uri(getUrl)); return(Unmarshaller <Club> .Unmarshal(json)); } catch (Exception ex) { #if !DEBUG _errorMessage.Clear(); _errorMessage.AppendLine($"StravaClubService.GetClubFromServiceAsync - clubId {clubId}"); _errorMessage.AppendLine(ex.Message); ServiceLocator.Current.GetInstance <IGoogleAnalyticsService>().Tracker.SendException(_errorMessage.ToString(), false); #endif } return(null); }