/// <summary> /// Gets an activity stream asynchronously. /// </summary> /// <param name="activityId">The Strava activity id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public async Task<List<ActivityStream>> GetActivityStreamAsync(String activityId, StreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); foreach (StreamType type in (StreamType[])Enum.GetValues(typeof(StreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); String getUrl = String.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", Endpoints.Activity, activityId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); String json = await WebRequest.SendGetAsync(new Uri(getUrl)); return Unmarshaller<List<ActivityStream>>.Unmarshal(json); }
/// <summary> /// Gets a segment stream asynchronously. /// </summary> /// <param name="segmentId">The Strava segment id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public async Task<List<SegmentStream>> GetSegmentStreamAsync(String segmentId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { // Only distance, altitude and latlng stream types are available. StringBuilder types = new StringBuilder(); foreach (SegmentStreamType type in (StreamType[])Enum.GetValues(typeof(SegmentStreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); String getUrl = String.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", Endpoints.Leaderboard, segmentId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); String json = await WebRequest.SendGetAsync(new Uri(getUrl)); return Unmarshaller<List<SegmentStream>>.Unmarshal(json); }
/// <summary> /// Gets a segment effort stream. /// </summary> /// <param name="effortId">The Strava segment effort id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public List<SegmentEffortStream> GetSegmentEffortStream(String effortId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); foreach (SegmentStreamType type in (StreamType[])Enum.GetValues(typeof(SegmentStreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); String getUrl = String.Format("https://www.strava.com/api/v3/segment_efforts/{0}/streams/{1}?{2}&access_token={3}", effortId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); String json = WebRequest.SendGet(new Uri(getUrl)); return Unmarshaller<List<SegmentEffortStream>>.Unmarshal(json); }
/// <summary> /// Gets an activity stream asynchronously. /// </summary> /// <param name="activityId">The Strava activity id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public async Task <List <ActivityStream> > GetActivityStreamAsync(string activityId, StreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); foreach (StreamType type in (StreamType[])Enum.GetValues(typeof(StreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); string getUrl = string.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", Endpoints.Activity, activityId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); string json = await WebRequest.SendGetAsync(new Uri(getUrl)); return(Unmarshaller <List <ActivityStream> > .Unmarshal(json)); }
/// <summary> /// Gets a segment stream asynchronously. /// </summary> /// <param name="segmentId">The Strava segment id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public async Task <List <SegmentStream> > GetSegmentStreamAsync(string segmentId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { // Only distance, altitude and latlng stream types are available. StringBuilder types = new StringBuilder(); foreach (SegmentStreamType type in (StreamType[])Enum.GetValues(typeof(SegmentStreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); string getUrl = string.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", Endpoints.Leaderboard, segmentId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); string json = await WebRequest.SendGetAsync(new Uri(getUrl)); return(Unmarshaller <List <SegmentStream> > .Unmarshal(json)); }
/// <summary> /// Gets a segment effort stream. /// </summary> /// <param name="effortId">The Strava segment effort id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public List <SegmentEffortStream> GetSegmentEffortStream(string effortId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); foreach (SegmentStreamType type in (StreamType[])Enum.GetValues(typeof(SegmentStreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); string getUrl = string.Format("https://www.strava.com/api/v3/segment_efforts/{0}/streams/{1}?{2}&access_token={3}", effortId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", Authentication.AccessToken ); string json = WebRequest.SendGet(new Uri(getUrl)); return(Unmarshaller <List <SegmentEffortStream> > .Unmarshal(json)); }
public List <ActivityStream> GetActivityStream(string activityId, StreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder stringBuilder = new StringBuilder(); StreamType[] array = (StreamType[])Enum.GetValues(typeof(StreamType)); for (int i = 0; i < array.Length; i++) { StreamType streamType = array[i]; if (typeFlags.HasFlag(streamType)) { stringBuilder.Append(streamType.ToString().ToLower()); stringBuilder.Append(","); } } stringBuilder.Remove(stringBuilder.ToString().Length - 1, 1); string text = string.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", "https://www.strava.com/api/v3/activities", activityId, stringBuilder, (resolution != StreamResolution.All) ? ("resolution=" + resolution.ToString().ToLower()) : "", Authentication.AccessToken); string json = WebRequest.SendGet(new Uri(text)); Debug.WriteLine(text); return(Unmarshaller <List <ActivityStream> > .Unmarshal(json)); }
public async Task <List <SegmentEffortStream> > GetSegmentEffortStreamAsync(string effortId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); StreamType[] array = (StreamType[])Enum.GetValues(typeof(SegmentStreamType)); for (int i = 0; i < array.Length; i++) { SegmentStreamType type = (SegmentStreamType)array[i]; if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); string getUrl = string.Format("https://www.strava.com/api/v3/segment_efforts/{0}/streams/{1}?{2}&access_token={3}", effortId, types, (resolution != StreamResolution.All) ? ("resolution=" + resolution.ToString().ToLower()) : "", Authentication.AccessToken); return(Unmarshaller <List <SegmentEffortStream> > .Unmarshal(await WebRequest.SendGetAsync(new Uri(getUrl)))); }
public List <SegmentEffortStream> GetSegmentEffortStream(string effortId, SegmentStreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder stringBuilder = new StringBuilder(); StreamType[] array = (StreamType[])Enum.GetValues(typeof(SegmentStreamType)); for (int i = 0; i < array.Length; i++) { SegmentStreamType segmentStreamType = (SegmentStreamType)array[i]; if (typeFlags.HasFlag(segmentStreamType)) { stringBuilder.Append(segmentStreamType.ToString().ToLower()); stringBuilder.Append(","); } } stringBuilder.Remove(stringBuilder.ToString().Length - 1, 1); string uriString = string.Format("https://www.strava.com/api/v3/segment_efforts/{0}/streams/{1}?{2}&access_token={3}", effortId, stringBuilder, (resolution != StreamResolution.All) ? ("resolution=" + resolution.ToString().ToLower()) : "", Authentication.AccessToken); string json = WebRequest.SendGet(new Uri(uriString)); return(Unmarshaller <List <SegmentEffortStream> > .Unmarshal(json)); }
/// <summary> /// Gets an activity stream. /// </summary> /// <param name="activityId">The Strava activity id.</param> /// <param name="typeFlags">Specifies the type of stream.</param> /// <param name="resolution">Specifies the resolution of the stream.</param> /// <returns>The stream data.</returns> public List <ActivityStream> GetActivityStream(string activityId, StreamType typeFlags, StreamResolution resolution = StreamResolution.All) { StringBuilder types = new StringBuilder(); foreach (StreamType type in (StreamType[])Enum.GetValues(typeof(StreamType))) { if (typeFlags.HasFlag(type)) { types.Append(type.ToString().ToLower()); types.Append(","); } } types.Remove(types.ToString().Length - 1, 1); string getUrl = string.Format("{0}/{1}/streams/{2}?{3}&access_token={4}", Endpoints.Activity, activityId, types, resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "", AuthSettings.ScopeAccessToken ); string json = HttpHelper.GetRequest(getUrl); Debug.WriteLine(getUrl); return(Unmarshaller <List <ActivityStream> > .Unmarshal(json)); }