Hierarchy

  • Terra

Constructors

  • Parameters

    • devID: string
    • apiKey: string
    • secret: string

    Returns Terra

Properties

apiKey: string
devID: string
getActivity: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Activity>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Activity>>
    • Get Activity data for current user

      Returns

      A promise of type Activity Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Activity>>

getBody: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Body>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Body>>
    • Get Body data for current user

      Returns

      A promise of type Body Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Body>>

getDaily: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Daily>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Daily>>
    • Get Daily data for current user

      Returns

      A promise of type Daily Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Daily>>

getMenstruation: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Menstruation>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Menstruation>>
    • Get Menstruation data for current user

      Returns

      A promise of type Menstruation Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Menstruation>>

getNutrition: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Nutrition>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Nutrition>>
    • Get Nutrition data for current user

      Returns

      A promise of type Nutrition Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Nutrition>>

getSleep: ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<Sleep>>) = ...

Type declaration

    • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<Sleep>>
    • Get Sleep data for current user

      Returns

      A promise of type Sleep Data

      Parameters

      • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
        • Optional endDate?: Date
        • Optional retryIfRateLimited?: boolean
        • startDate: Date
        • Optional toWebhook?: boolean
        • userId: string
        • Optional withSamples?: boolean

      Returns Promise<TerraDataResponse<Sleep>>

mutex: Mutex = ...
secret: string

Methods

  • Generate an Auth URL to be authenticate a user

    Returns

    A promise of type Authenticate User Response

    Parameters

    • params: { authFailureRedirectUrl?: string; authSuccessRedirectUrl?: string; facilityId?: string; language?: string; referenceId?: string; resource: string }
      • Optional authFailureRedirectUrl?: string
      • Optional authSuccessRedirectUrl?: string
      • Optional facilityId?: string
      • Optional language?: string
      • Optional referenceId?: string
      • resource: string

    Returns Promise<TerraAuthUserResponse>

  • Checks webhook signature

    Returns

    • A boolean, true if the signature is valid

    Parameters

    • terraSignature: string

      Terra signature string found in header of request sent to webhook endpoint

    • payload: string

      Body of request sent to webhook endpoint

    Returns boolean

  • Deauthenticate Terra user

    Returns

    A promise fulfilled when deauth succeeds

    Parameters

    • userID: string

      Terra user ID

    Returns Promise<void>

  • Synchronises a set of functions. It is meant to be used to handle webhooks if the infrastructure could face race conditions

    Parameters

    • callback: ((...args: any[]) => void)

      Function to be executed, usually the webhook handler

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Rest ...args: any[]

      Extra arguments passed to the handler, usually the request contents

    Returns void

  • Generate a widget session

    Returns

    A promise of type Widget Response

    Parameters

    • params: { authFailureRedirectUrl?: string; authSuccessRedirectUrl?: string; language: string; providers?: string[]; referenceID: string; showDisconnect?: boolean }
      • Optional authFailureRedirectUrl?: string
      • Optional authSuccessRedirectUrl?: string
      • language: string
      • Optional providers?: string[]
      • referenceID: string
      • Optional showDisconnect?: boolean

    Returns Promise<TerraWidgetResponse>

  • Get Athlete data for current user

    Returns

    A promise of type Athlete Data

    Parameters

    • params: { toWebhook?: boolean; userId: string }
      • Optional toWebhook?: boolean
      • userId: string

    Returns Promise<TerraAthleteResponse>

  • Type Parameters

    • T

    Parameters

    Returns ((params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }) => Promise<TerraDataResponse<T>>)

      • (params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }): Promise<TerraDataResponse<T>>
      • Parameters

        • params: { endDate?: Date; retryIfRateLimited?: boolean; startDate: Date; toWebhook?: boolean; userId: string; withSamples?: boolean }
          • Optional endDate?: Date
          • Optional retryIfRateLimited?: boolean
          • startDate: Date
          • Optional toWebhook?: boolean
          • userId: string
          • Optional withSamples?: boolean

        Returns Promise<TerraDataResponse<T>>

  • Get information about a Terra user

    Returns

    A promise of type User

    Parameters

    • params: { referenceID?: string; userID?: string }
      • Optional referenceID?: string
      • Optional userID?: string

    Returns Promise<TerraUserResponse>

  • Checks webhook signature

    Returns

    • The new patched Terra user object.

    Parameters

    • userId: string

      The user ID to patch for

    • referenceId: null | string

      The reference ID to set the userID to (or null to not change)

    • setActive: boolean

      Set if the user is active or not

    Returns Promise<TerraUser>

Generated using TypeDoc