-
public interface TerraClientV2
Interface for facilities to make requests to the Terra API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Future<TerraApiResponse<Void>>
deauthenticateUser(PartialUser user)
Asynchronously makes a request to the/auth/deauthenticateUser
endpoint to deauthenticate the given user with Terra, terminating the connection.Future<TerraApiResponse<AuthenticationResponse>>
generateAuthenticationURL(String resource)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL.Future<TerraApiResponse<AuthenticationResponse>>
generateAuthenticationURL(String resource, String reference_id)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL.Future<TerraApiResponse<AuthenticationResponse>>
generateAuthenticationURL(String resource, String reference_id, String auth_success_redirect_url)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL.Future<TerraApiResponse<AuthenticationResponse>>
generateAuthenticationURL(String resource, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers, String reference_id)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url, String language)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<GenerateWidgetResponse>>
generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url, String language, boolean show_disconnect)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.Future<TerraApiResponse<Activity>>
getActivityForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/activity
endpoint to fetch the activity data for the given user.Future<TerraApiResponse<Activity>>
getActivityForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/activity
endpoint to fetch the activity data for the given user.Future<? extends TerraApiResponse<? extends User>>
getAllUsers()
Makes a request to the/subscriptions
endpoint to fetch all users registered with your developer ID.Future<TerraApiResponse<Athlete>>
getAthleteForUser(PartialUser user)
Asynchronously makes a request to the/athlete
endpoint to fetch the athlete data for the given user.Future<TerraApiResponse<Athlete>>
getAthleteForUser(PartialUser user, RequestConfig requestConfig)
Asynchronously makes a request to the/athlete
endpoint to fetch the athlete data for the given user.Future<TerraApiResponse<Body>>
getBodyForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/body
endpoint to fetch the body data for the given user.Future<TerraApiResponse<Body>>
getBodyForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/body
endpoint to fetch the body data for the given user.Future<TerraApiResponse<Daily>>
getDailyForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/daily
endpoint to fetch the daily data for the given user.Future<TerraApiResponse<Daily>>
getDailyForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/daily
endpoint to fetch the daily data for the given user.Future<TerraApiResponse<Menstruation>>
getMenstruationForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/menstruation
endpoint to fetch the menstruation data for the given user.Future<TerraApiResponse<Menstruation>>
getMenstruationForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/menstruation
endpoint to fetch the menstruation data for the given user.Future<TerraApiResponse<Nutrition>>
getNutritionForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/nutrition
endpoint to fetch the nutrition data for the given user.Future<TerraApiResponse<Nutrition>>
getNutritionForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/nutrition
endpoint to fetch the nutrition data for the given user.Future<TerraApiResponse<Sleep>>
getSleepForUser(PartialUser user, Instant startTime, @Nullable Instant endTime)
Asynchronously makes a request to the/sleep
endpoint to fetch the sleep data for the given user.Future<TerraApiResponse<Sleep>>
getSleepForUser(PartialUser user, Instant startTime, @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/sleep
endpoint to fetch the sleep data for the given user.Future<? extends TerraApiResponse<? extends User>>
getUser(PartialUser user)
Asynchronously makes a request to the/userInfo
endpoint to fetch the details for the user represented by the givenPartialUser
.Future<? extends TerraApiResponse<? extends User>>
getUser(String userId)
Makes a request to the/userInfo
endpoint to fetch the details for the user with the given ID.Future<TerraApiResponse<ProvidersResponse>>
listProviders()
Asynchronously makes a request to the/integrations
endpoint to fetch a list of all available providers.PartialUser
userFromId(String userId)
Create a new temporaryPartialUser
object, without making an API call, that can be passed in to theuser
parameter of the data request methods of this class.
-
-
-
Method Detail
-
userFromId
PartialUser userFromId(String userId)
Create a new temporaryPartialUser
object, without making an API call, that can be passed in to theuser
parameter of the data request methods of this class.
This allows you to fetch data without having to make an extra unnecessary API request to the/userInfo
endpoint.- Parameters:
userId
- the ID of the user to be created- Returns:
- the created
PartialUser
object - Throws:
NullPointerException
- if the userId passed is null
-
getAllUsers
Future<? extends TerraApiResponse<? extends User>> getAllUsers()
Makes a request to the/subscriptions
endpoint to fetch all users registered with your developer ID.- Returns:
- future that will contain the API response upon completion
-
getUser
Future<? extends TerraApiResponse<? extends User>> getUser(String userId)
Makes a request to the/userInfo
endpoint to fetch the details for the user with the given ID. ThisUser
object can then subsequently be used to fetch data through the other available methods.
Note that the fetched user will both be available throughTerraApiResponse.getUser()
, and will also be the single item in theTerraApiResponse.getParsedData()
list.- Parameters:
userId
- ID of the user to get information for- Returns:
- future that will contain the fetched
User
object upon completion
-
getUser
Future<? extends TerraApiResponse<? extends User>> getUser(PartialUser user)
Asynchronously makes a request to the/userInfo
endpoint to fetch the details for the user represented by the givenPartialUser
.
Note that the fetched user will both be available throughTerraApiResponse.getUser()
, and will also be the single item in theTerraApiResponse.getParsedData()
list.- Parameters:
user
- thePartialUser
to get information for- Returns:
- future that will contain the fetched
User
object upon completion
-
listProviders
Future<TerraApiResponse<ProvidersResponse>> listProviders()
Asynchronously makes a request to the/integrations
endpoint to fetch a list of all available providers.- Returns:
- future that will contain the fetched
ProvidersResponse
upon completion
-
generateAuthenticationURL
Future<TerraApiResponse<AuthenticationResponse>> generateAuthenticationURL(String resource)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL. Note that no data will be returned with the API response.- Parameters:
resource
- the resource to authenticate a user for- Returns:
- future that will contain the API response upon completion
-
generateAuthenticationURL
Future<TerraApiResponse<AuthenticationResponse>> generateAuthenticationURL(String resource, String reference_id)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL. Note that no data will be returned with the API response.- Parameters:
resource
- the resource to authenticate a user forreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.- Returns:
- future that will contain the API response upon completion
-
generateAuthenticationURL
Future<TerraApiResponse<AuthenticationResponse>> generateAuthenticationURL(String resource, String reference_id, String auth_success_redirect_url)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL. Note that no data will be returned with the API response.- Parameters:
resource
- the resource to authenticate a user forreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)- Returns:
- future that will contain the API response upon completion
-
generateAuthenticationURL
Future<TerraApiResponse<AuthenticationResponse>> generateAuthenticationURL(String resource, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url)
Asynchronously makes a request to the/auth/authenticateUser
endpoint to authenticate a user for the specified resource
If successful, the response will have a 200 status code with the authentication URL. Note that no data will be returned with the API response.- Parameters:
resource
- the resource to authenticate a user forreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)auth_failure_redirect_url
- is the URL for user redirection upon unsuccessful auth (supports deeplinks)- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect to- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers, String reference_id)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect toreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect toreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect toreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)auth_failure_redirect_url
- is the URL for user redirection upon unsuccessful auth (supports deeplinks)- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url, String language)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect toreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)auth_failure_redirect_url
- is the URL for user redirection upon unsuccessful auth (supports deeplinks)language
- is the language you would like the widget to be displayed in- Returns:
- future that will contain the API response upon completion
-
generateWidgetSession
Future<TerraApiResponse<GenerateWidgetResponse>> generateWidgetSession(String providers, String reference_id, String auth_success_redirect_url, String auth_failure_redirect_url, String language, boolean show_disconnect)
Asynchronously makes a request to the/auth/generateWidgetSession
endpoint to generate a widget session for user authentication
If successful, the response will have a 200 status code with the widget session link.- Parameters:
providers
- the resources on widget for a user connect toreference_id
- the identifier to associate with the user being authenticated. This can be used to reconcile the user with your internal systems.auth_success_redirect_url
- is the URL for user redirection upon successful auth (supports deeplinks)auth_failure_redirect_url
- is the URL for user redirection upon unsuccessful auth (supports deeplinks)language
- is the language you would like the widget to be displayed inshow_disconnect
- is whether to show the disconnect button once the user is connected- Returns:
- future that will contain the API response upon completion
-
deauthenticateUser
Future<TerraApiResponse<Void>> deauthenticateUser(PartialUser user)
Asynchronously makes a request to the/auth/deauthenticateUser
endpoint to deauthenticate the given user with Terra, terminating the connection.
If successful, the response will have a 200 status code. Note that no data will be returned with the API response.- Parameters:
user
- the user to deauthenticate- Returns:
- future that will contain the API response upon completion
-
getAthleteForUser
Future<TerraApiResponse<Athlete>> getAthleteForUser(PartialUser user)
Asynchronously makes a request to the/athlete
endpoint to fetch the athlete data for the given user.
Note that if athlete data is available for the given user, it will be available as the single item in the list returned byTerraApiResponse.getParsedData()
.- Parameters:
user
- the user to fetch the athlete data for- Returns:
- future that will contain the API response upon completion
-
getAthleteForUser
Future<TerraApiResponse<Athlete>> getAthleteForUser(PartialUser user, RequestConfig requestConfig)
Asynchronously makes a request to the/athlete
endpoint to fetch the athlete data for the given user. Note that only thetoWebhook
configuration property ofRequestConfig
will be considered in this case.
Note that if athlete data is available for the given user, it will be available as the single item in the list returned byTerraApiResponse.getParsedData()
.- Parameters:
user
- the user to fetch the athlete data forrequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getActivityForUser
Future<TerraApiResponse<Activity>> getActivityForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/activity
endpoint to fetch the activity data for the given user.- Parameters:
user
- the user to fetch the activity data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getActivityForUser
Future<TerraApiResponse<Activity>> getActivityForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/activity
endpoint to fetch the activity data for the given user.- Parameters:
user
- the user to fetch the activity data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getBodyForUser
Future<TerraApiResponse<Body>> getBodyForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/body
endpoint to fetch the body data for the given user.- Parameters:
user
- the user to fetch the body data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getBodyForUser
Future<TerraApiResponse<Body>> getBodyForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/body
endpoint to fetch the body data for the given user.- Parameters:
user
- the user to fetch the body data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getDailyForUser
Future<TerraApiResponse<Daily>> getDailyForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/daily
endpoint to fetch the daily data for the given user.- Parameters:
user
- the user to fetch the daily data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getDailyForUser
Future<TerraApiResponse<Daily>> getDailyForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/daily
endpoint to fetch the daily data for the given user.- Parameters:
user
- the user to fetch the daily data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getMenstruationForUser
Future<TerraApiResponse<Menstruation>> getMenstruationForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/menstruation
endpoint to fetch the menstruation data for the given user.- Parameters:
user
- the user to fetch the menstruation data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getMenstruationForUser
Future<TerraApiResponse<Menstruation>> getMenstruationForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/menstruation
endpoint to fetch the menstruation data for the given user.- Parameters:
user
- the user to fetch the menstruation data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getNutritionForUser
Future<TerraApiResponse<Nutrition>> getNutritionForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/nutrition
endpoint to fetch the nutrition data for the given user.- Parameters:
user
- the user to fetch the nutrition data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getNutritionForUser
Future<TerraApiResponse<Nutrition>> getNutritionForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/nutrition
endpoint to fetch the nutrition data for the given user.- Parameters:
user
- the user to fetch the nutrition data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
getSleepForUser
Future<TerraApiResponse<Sleep>> getSleepForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime)
Asynchronously makes a request to the/sleep
endpoint to fetch the sleep data for the given user.- Parameters:
user
- the user to fetch the sleep data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data before- Returns:
- future that will contain the API response upon completion
-
getSleepForUser
Future<TerraApiResponse<Sleep>> getSleepForUser(PartialUser user, Instant startTime, @Nullable @Nullable Instant endTime, RequestConfig requestConfig)
Asynchronously makes a request to the/sleep
endpoint to fetch the sleep data for the given user.- Parameters:
user
- the user to fetch the sleep data forstartTime
- the start time to fetch data sinceendTime
- then end time to fetch data beforerequestConfig
- the config to use for this request- Returns:
- future that will contain the API response upon completion
-
-