Source code: https://github.com/tryterra/terra-client-python
class Terra
class Terra
An object that manages getting data, verifying signatures and authenticating users
Initialisation
from terra.base_client import Terra
terra = Terra(api_key: str, dev_id: str, secret: str)
Instance Variables
Instance Variable Name | Returns | Explanation |
---|---|---|
api_key | str | returns the api_kay the class was initiated with |
dev_id | str | returns the dev_id the class was initiated with |
secret | str | returns the secret the class was initiated with |
Methods
Method Name | Returns | Explanation |
---|---|---|
get_activity_for_user | TerraApiResponse | returns an api response that when parsed contains activity data |
get_athlete_for_user | TerraApiResponse | returns an api response that when parsed contains athlete data |
get_body_for_user | TerraApiResponse | returns an api response that when parsed contains body data |
get_daily_for_user | TerraApiResponse | returns an api response that when parsed contains daily data |
get_menstruation_for_user | TerraApiResponse | returns an api response that when parsed contains menstruation data |
get_nutrition_for_user | TerraApiResponse | returns an api response that when parsed contains nutrition data |
get_sleep_for_user | TerraApiResponse | returns an api response that when parsed contains sleep data |
get_user_info | TerraApiResponse | returns an api response that when parsed contains user data |
list_providers | TerraApiResponse | returns an api response that when parsed contains one list for web providers and another for sdk providers |
list_users | TerraApiResponse | returns an api response that when parsed contains a list of all users |
check_terra_signature | bool | returns whether the body was sent from Terra |
handle_flask_webhook | TerraWebhookResponse | returns either data or None type if check_terra_signature failed, specifically for flask |
handle_webhook | TerraWebhookResponse returns a webhook response object | returns either data or None type if check_terra_signature failed |
deauthenticate_user | TerraApiResponse | returns an api response object that when parsed returns a |
generate_authentication_url | TerraApiResponse | returns an api response that when parsed contains details about an authentication session with one provider |
generate_widget_session | TerraApiResponse | returns an api response that when parsed contains details about an authentication session with one of the inputted providers |
from_user_id | User | returns a User object from user_id |
Parsed Webhook Response Types
DataReturned
DataReturned(user: User, type: str, data: List[TerraDataModel])
NoDataReturned
NoDataReturned(user: User, status: str, message: str)
AccessRevokedHookResponse
AccessRevokedHookResponse(user: User, message: str)
AuthHookResponse
AuthHookResponse(reference_id: str, user: User, widget_session_id: str)
UserReauthHookResponse
UserReauthHookResponse(old_user: User, new_user: User, message: str)
UserDeauthHookResponse
UserDeauthHookResponse(user: User, message: str)
ConnectionErrorHookResponse
ConnectionErrorHookResponse(user: User, message: str)
GoogleNoDataSourceHookResponse
GoogleNoDataSourceHookResponse(user: User, message: str)
RequestProcessingHookResponse
RequestProcessingHookResponse(user: User, message: str)
RequestCompletedHookResponse
RequestCompletedHookResponse(user: User, message: str)