observation-js Documentation - v1.14.0
    Preparing search index...

    Class Groups

    Index

    Constructors

    Methods

    • Fetches the groups for the current authenticated user.

      Returns Promise<Paginated<Group>>

      A promise that resolves to a paginated list of the user's groups.

      If the request is not authenticated.

      If the request fails.

    • Fetches the details of a specific group by its ID. The authenticated user must be a member of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      Returns Promise<Group>

      A promise that resolves to the group object.

      If the user is not a member or not authenticated.

      If the request fails.

    • Fetches a public summary of a group using an invite code. This does not require authentication.

      Parameters

      • groupId: number

        The unique identifier of the group.

      • inviteCode: string

        The invite code for the group.

      Returns Promise<GroupSummary>

      A promise that resolves to the group's public summary.

      If the group or invite code is invalid.

    • Creates a new group.

      Parameters

      • name: string

        The name of the new group.

      • photo: Blob | Buffer<ArrayBufferLike>

        The group's photo/avatar as a Blob or Buffer.

      Returns Promise<Group>

      A promise that resolves to the newly created group object.

      If the request is not authenticated.

      If the request fails.

    • Updates an existing group's details. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group to update.

      • data: { name?: string; photo?: Blob | Buffer<ArrayBufferLike> }

        An object containing the data to update (name and/or photo).

      Returns Promise<Group>

      A promise that resolves to the updated group object.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Deletes a group. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group to delete.

      Returns Promise<void>

      A promise that resolves when the group is successfully deleted.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Renews the invite code for a group. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      Returns Promise<Group>

      A promise that resolves to the updated group object with a new invite link.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Joins a group using an invite code.

      Parameters

      • groupId: number

        The unique identifier of the group to join.

      • inviteCode: string

        The invite code for the group.

      Returns Promise<void>

      A promise that resolves when the user has successfully joined the group.

      If the request is not authenticated.

      If the invite code is invalid or the request fails.

    • Leaves a group. The authenticated user must be a member of the group.

      Parameters

      • groupId: number

        The unique identifier of the group to leave.

      Returns Promise<void>

      A promise that resolves when the user has successfully left the group.

      If the user is not a member or not authenticated.

      If the request fails.

    • Removes a member from a group. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      • memberId: number

        The unique identifier of the member to remove.

      Returns Promise<void>

      A promise that resolves when the member is successfully removed.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Fetches the available challenge templates that can be used to create group challenges.

      Returns Promise<Paginated<ChallengeTemplate>>

      A promise that resolves to a paginated list of challenge templates.

      If the request is not authenticated.

      If the request fails.

    • Fetches the challenges for a specific group. The authenticated user must be a member of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      Returns Promise<Paginated<Challenge>>

      A promise that resolves to a paginated list of challenges for the group.

      If the user is not a member or not authenticated.

      If the request fails.

    • Creates a new challenge for a group from a template. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      • data: { template: number; start_date_time: string; end_date_time: string }

        An object containing the challenge details (template ID, start, and end times).

      Returns Promise<Challenge>

      A promise that resolves to the newly created challenge.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Updates an existing group challenge. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      • challengeId: number

        The unique identifier of the challenge to update.

      • data: { start_date_time?: string; end_date_time?: string }

        An object containing the data to update (start and/or end times).

      Returns Promise<Challenge>

      A promise that resolves to the updated challenge.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Deletes a group challenge. The authenticated user must be an admin of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      • challengeId: number

        The unique identifier of the challenge to delete.

      Returns Promise<void>

      A promise that resolves when the challenge is successfully deleted.

      If the user is not an admin or not authenticated.

      If the request fails.

    • Fetches observations for a specific group. The authenticated user must be a member of the group.

      Parameters

      • groupId: number

        The unique identifier of the group.

      Returns Promise<
          { next: null
          | string; previous: null | string; results: Observation[] },
      >

      A promise that resolves to a list of observations. Note: This response is not paginated in the standard way.

      If the user is not a member or not authenticated.

      If the request fails.