Flutter
Misc
SuccessMessage
class SuccessMessage{
final bool? success;
final String? error;
}Terra initialization
initTerra
static Future<SuccessMessage?> initTerra(
String devID,
String referenceID) asyncString devId ➡ The dev-id provided to you when signing up with Terra Developer Dashboard
String referenceID ➡ A random string used to characterise a user on your server
returns
Future<SuccessMessage>
Connection setup/management
initConnection
static Future<SuccessMessage?> initConnection(
Connection connection,
String token,
bool schedulerOn,
List<CustomPermission> customPermissions)Initialise a device connection. This function needs to be called once only.
Connection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for. (E.g.Connection.appleHealth,Connection.samsung,Connection.healthConnect)String token➡ A token used for authentication. Generate one here: https://docs.tryterra.co/reference/generate-authentication-tokenList<CustomPermissions> customPermissions➡ This is defaulted as an emptySet. If you want to make a more granular permissions request, you may send us a set ofCustomPermissionsbool schedulerOn➡ A boolean dictating if you wish turn on background delivery. Defaults to true. Please see Background Delivery section for setup. On iOS, follow iOS.
returns
Future<SuccessMessage>
getUserId
Returns the user's User ID if the user exists, else returns null
static Future<UserId?> getUserId(Connection connection) asyncConnection connection➡ An ENUM from the Connection class signifying the connection you wish to retrieve user_id from.
returns
Future<UserId?>
Data retrieval
DataMessage
class DataMessage{
final bool? success;
final Map<String, dynamic>? data;
final String? error;
}getActivity
static Future<DataMessage?> getActivity(
Connection connection, DateTime startDate, DateTime endDate, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.DateTime startDate➡ The beginning of the request in either Date or Unix TimestampDateTime endDate➡ The end of the request in either Date or Unix Timestamp(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<DataMessage?>
getDaily
static Future<DataMessage?> getDaily(
Connection connection, DateTime startDate, DateTime endDate, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.DateTime startDate➡ The beginning of the request in either Date or Unix TimestampDateTime endDate➡ The end of the request in either Date or Unix Timestamp(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<DataMessage?>
getSleep
static Future<DataMessage?> getSleep(
Connection connection, DateTime startDate, DateTime endDate, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.DateTime startDate➡ The beginning of the request in either Date or Unix TimestampDateTime endDate➡ The end of the request in either Date or Unix Timestamp(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<DataMessage?>
getNutrition
static Future<DataMessage?> getNutrition(
Connection connection, DateTime startDate, DateTime endDate, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.DateTime startDate➡ The beginning of the request in either Date or Unix TimestampDateTime endDate➡ The end of the request in either Date or Unix Timestamp(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<DataMessage?>
getMenstruation
static Future<DataMessage?> getMenstruation(
Connection connection, DateTime startDate, DateTime endDate, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.DateTime startDate➡ The beginning of the request in either Date or Unix TimestampDateTime endDate➡ The end of the request in either Date or Unix Timestamp(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<DataMessage?>
getAthlete
static Future<DataMessage?> getAthlete(
Connection connection, {bool toWebhook = true}) asyncConnection connection➡ An ENUM from the Connections class signifying the connection you wish to initiate for.(Optional)
bool toWebhook➡ Whether or not to send data to your webhook. If false,DataMessageon the returnedFuturewill contain the data in thedatafield.
returns
Future<SuccessMessage?>: Returns aSuccessMessageobject wrapped in aFuture. This contains information about whether the request was successful or if there was an error.
Writing data
postPlannedWorkout
static Future<SuccessMessage?> postPlannedWorkout(
Connection connection, TerraPlannedWorkout payload) async
Connection connection: Specifies the connection type to which the planned workout data will be posted.payload(TerraPlannedWorkout): The payload containing the details of the planned workout. This includes metadata such as the workout type, duration, and intensity, as well as a list of steps to complete the workout.
returns
Future<SuccessMessage?>: Returns aSuccessMessageobject wrapped in aFuture. This contains information about whether the request was successful or if there was an error.
Android-only methods
Fetches permissions granted by Health connect
grantedPermissions
function grantedPermissions(): Promise<Array<String>>
**returns**
`
Promise<Array<String>>`
Last updated
Was this helpful?