Class ActivitiesApiExtensions
- Namespace
- Tudormobile.Strava.Api
- Assembly
- Tudormobile.Strava.dll
Provides static helpers and extension methods for IActivitiesApi.
public static class ActivitiesApiExtensions
- Inheritance
-
ActivitiesApiExtensions
- Inherited Members
Methods
AddOptionalContent<T>(MultipartFormDataContent, T?, string)
Adds an optional value as a StringContent to the MultipartFormDataContent if the value is not null.
public static MultipartFormDataContent AddOptionalContent<T>(this MultipartFormDataContent content, T? value, string name)
Parameters
contentMultipartFormDataContentThe MultipartFormDataContent to add the value to.
valueTThe value to add if not null.
namestringThe name of the form field.
Returns
- MultipartFormDataContent
The MultipartFormDataContent with the value added if not null.
Type Parameters
TThe type of the value to add. Must be nullable.
Remarks
Boolean values are converted to "1" for true and "0" for false.
AddQueryToUriString(string, IEnumerable<(string, object?)>)
Appends query parameters to a URI string.
public static string AddQueryToUriString(string uriString, IEnumerable<(string, object?)> queryParameters)
Parameters
uriStringstringThe base URI string to which query parameters will be added.
queryParametersIEnumerable<(string, object)>A collection of key-value pairs representing the query parameters to add. Values that are
nullare ignored.
Returns
- string
The URI string with the appended query parameters.
CreateActivityPostContent(string, SportTypes, DateTime, long, string?, string?, double?, bool?, bool?)
Creates an HttpContent instance for posting a new activity to the Strava API.
public static HttpContent CreateActivityPostContent(string name, SportTypes sportType, DateTime startDateLocal, long elapsedTime, string? type = null, string? description = null, double? distance = null, bool? trainer = null, bool? commute = null)
Parameters
namestringThe name of the activity. Required.
sportTypeSportTypesThe sport type of the activity. Required.
startDateLocalDateTimeThe local start date and time of the activity. Required.
elapsedTimelongThe elapsed time of the activity in seconds. Required.
typestringThe type of the activity (optional).
descriptionstringThe description of the activity (optional).
distancedouble?The distance of the activity in meters (optional).
trainerbool?Indicates if the activity was performed on a trainer (optional).
commutebool?Indicates if the activity was a commute (optional).
Returns
- HttpContent
A HttpContent object containing the activity data.