Table of Contents

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

content MultipartFormDataContent

The MultipartFormDataContent to add the value to.

value T

The value to add if not null.

name string

The name of the form field.

Returns

MultipartFormDataContent

The MultipartFormDataContent with the value added if not null.

Type Parameters

T

The 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

uriString string

The base URI string to which query parameters will be added.

queryParameters IEnumerable<(string, object)>

A collection of key-value pairs representing the query parameters to add. Values that are null are 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

name string

The name of the activity. Required.

sportType SportTypes

The sport type of the activity. Required.

startDateLocal DateTime

The local start date and time of the activity. Required.

elapsedTime long

The elapsed time of the activity in seconds. Required.

type string

The type of the activity (optional).

description string

The description of the activity (optional).

distance double?

The distance of the activity in meters (optional).

trainer bool?

Indicates if the activity was performed on a trainer (optional).

commute bool?

Indicates if the activity was a commute (optional).

Returns

HttpContent

A HttpContent object containing the activity data.