Skip to content

Files

This branch is 35 commits behind Real-Dev-Squad/website-api-contracts:main.

events

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 19, 2023

Events

Events object

{
    'id': "id", // This is event id
    'name': "string",
    'description': "string",
    'room_id': "string",
    'session_id': "string",
    'template_id': "string",
    'enabled': "boolean",
    'lock': "boolean",
    'region': <'in' | 'us' | 'eu' | 'auto'>,
    'created_by': "<USER_ID_OF_THE_USER_WHO_CREATED_THE_EVENT>",
    'peers': [
      <peer_object_id1>,
      <peer_object_id2>,
      <peer_object_id3>,
      <peer_object_id4>,
      ...
      <peer_object_idn>,
    ],
    'questions': [
      "<question_object_id1>",
      "<question_object_id2>",
      ...
      "<question_object_idn>"
    ],
    'comments': [
      "<comment_object_id1>",
      "<comment_object_id2>",
      ...
      "<comment_object_idn>",
    ],
    'status': <'active' | 'inactive'>
    'timestamps': {
      'created_at': timestamp,
      'updated_at': timestamp,
    }
}

Peers object

{
  'id': string,
  'name': string,
  'joinedEvents': [
    {
      'event_id':"<event_object_id1>",
      'joined_at': timestamp,
      'left_at': timestamp,
      'role': <'host' | 'moderator' | 'guest' | 'maven'>,
    },
    {
      'event_id':"<event_object_id2>",
      'joined_at': timestamp,
      'left_at': timestamp,
      'role': <'host' | 'moderator' | 'guest' | 'maven'>,
    },
    ...
    {
      'event_id':"<event_object_idn>",
      'joined_at': timestamp,
      'left_at': timestamp,
      'role': <'host' | 'moderator' | 'guest' | 'maven'>,
    }
  ],
  'rds_user': {
    is_rds_user:boolean,
    user_id: "<USER_ID_OF_THE_USER_WHO_CREATED_THE_EVENT>"
  },
}

Questions object

{
  'id': string,
  'created_by': "<USER_ID_OF_THE_USER_WHO_CREATED_THE_EVENT>",
  'question': string,
  'is_new': boolean, //default to true,
  'session_id': string,
  'timestamps': {
    'created_at': timestamp,
    'updated_at': timestamp,
  }
}

Comments object

{
  'id': string,
  'comment': string,
  'comment_by': string, //user id of the user who commented
  'is_blocked': boolean,
  'is_pinned': boolean,
  'session_id': string,
  'timestamps': {
    'created_at': timestamp,
    'updated_at': timestamp,
  }
}

Note: The <management_token> for the Authorization is form a connection between RDS backend and 100ms backend.

Requests

Route Description
POST /events Create a new event, either randomly or with the requested configuration
GET /events Get all the events
POST /events/join Generate an auth token for a peer to join a event
GET /events/:id=<EVENT_ID> Retrieves the details of a specific active event.
PATCH /events Update the event, make event enabled/disabled,
PATCH /events/end Trigger this request to end an active event.
POST /events/:id/peers Add a peer to a specific event.
PATCH /events/:id/peers/kickout Kick out a peer from a specific event.
POST /events/:id/codes Generate event codes for a specific event.
GET /events/:id/codes Get event codes for a specific event.

POST - /events

Create a new event, either randomly or with the requested configuration.

  • Params:
    • None
  • Query
    • None
  • Body
    • name=[string] - required (name is the name of the event which is case-insensitive. Accepted characters are a-z, A-Z, 0-9, and . - : _)
    • description=[string] - required (description describes the usage of the event.)
    • template_id=[string] - required (template_id which can be found from dashboard)
    • region=[string] - required (region in which you want to create event.)
    {
      "name": "new-event-1662723668",
      "description": "This is a sample description for the event",
      "template_id": "<template_id that you wish to associate w/ the event>",
      "region": "in"
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 201
      • Content:
        {
          "id": "<id>",
          "name": "<event_name>",
          "description": "This is a sample description for the event",
          "enabled": true,
          "created_by": "user_id",
          "room_id": "<room_id>",
          "template_id": "<template_id>",
          "region": "in",
          "created_at": "YYYY-MM-DDTHH:MM:SS.sssZ",
          "updated_at": "YYYY-MM-DDTHH:MM:SS.sssZ"
        }
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 401
      • Content: { 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }
    • Code: 500
      • Content { 'statusCode': 500, 'error': 'Internal server error', 'message': 'Couldn't create event. Please try again later'

GET /events

Get all the created events.

  • Params
    • None
  • Query
    • enabled: true/false
    • limit: Number of events in one response
    • offset: Start of response
      • ex: For 1-10 limit: 10, offset: 0; 11-20 limit: 10, offset: 10;
  • Body
    • None
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "limit": 10,
          "data": ["<event_object>", "<event_object>"],
          "start": "<room_id>"
        }
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 401
      • Content: { 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }
    • Code: 500
      • Content { 'statusCode': 500, 'error': 'Internal server error', 'message': 'Couldn't get events. Please try again later'

POST - /events/join

Generate an auth token for a peer to join a event.

To join the event (for guests, host, maven, moderator)

  • Params:
    • None
  • Query
    • None
  • Body
    • Required: event_id=[string] (The ID of the event to which the user belongs)
    • Required: user_id=[string] (The ID of the user for whom the token is being generated)
    • Required: role=[string] (The role of the user in the event)
    {
      "event_id": "<event_id>",
      "user_id": "<user_id>",
      "role": "<role>"
    }
  • Headers
    • Content-Type: application/json
  • Success Response:
    • Code: 201
      • Content:
        {
          "token": "<auth_token>",
          "message": "Token generated successfully!",
          "success": true
        }
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 500
      • Content { "message": "Some error occured!", "success": false }

GET - /events/:id=<event_id>

Retrieves the details of a specific active event_id.

  • Params:
    • id=[string] (The ID of the event to retrieve)
  • Query
    • None
  • Body
    • isActiveRoom=[boolean] - required (isActiveRoom indicates whether the room is active or not)
  • Headers
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • if room is active
      • Code: 200
      • Content:
        {
          "id": "<event_id>",
          "name": "<event_name>",
          "customer_id": "<customer_id>",
          "session": {
            "id": "<session_id>",
            "created_at": "YYYY-MM-DDTHH:MM:SS.sssZ",
            "peers": ["<peer_object>", "<peer_object>", "<peer_object>"]
          }
        }
    • if room is not active
      • Code: 200
      • Content:
          <event_object>
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 401
      • Content: { 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }
    • Code: 404
      • Content { 'statusCode': 404, 'error': 'Not Found', 'message': 'Event not found' }
    • Code: 500
      • Content { 'statusCode': 500, 'error': 'Internal server error', 'message': 'Unable to retrieve event details' }

PATCH - /events

Update the event, make event enabled/disabled,

  • Params:
    • None
  • Query
    • None
  • Body
    • Required: id=[string] (event id)
    • Required: enabled=[boolean] (Flag to indicate if the event is enabled)
    {
      "id": "<event_id>",
      "enabled": false
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "message": "Event is enabled."
        }
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 401
      • Content: { 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }
    • Code: 404
      • Content { 'statusCode': 404, 'error': 'Not Found', 'message': 'Event not found' }
    • Code: 500
      • Content { 'statusCode': 500, 'error': 'Internal server error', 'message': 'Couldn't update event. Please try again later'

PATCH - /events/end

Trigger this request to end an active event.

  • Params:
    • None
  • Query
    • None
  • Body
    • <event_id> (required) : string - The ID of the event to end an active event.
    • reason=[string] - required (reason for ending the event)
    • lock=[boolean] - required (if true, no new peers will be allowed to join the event after it is ended.)
    {
      "id": "<event_id>",
      "reason": "Class has ended",
      "lock": false
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "message": "Event ended successfully."
        }
  • Error Response:
    • Code: 400
      • Content: { 'statusCode': 400, 'error': 'Bad Request', 'message': 'Invalid request body or missing required parameters' }
    • Code: 401
      • Content: { 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }
    • Code: 404
      • Content { 'statusCode': 404, 'error': 'Not Found', 'message': 'Event not found' }
    • Code: 500
      • Content { 'statusCode': 500, 'error': 'Internal server error', 'message': 'Couldn't end the event. Please try again later'}

POST - /events/:id/peers

Use this request to add a participant to an event.

  • Params:
    • :id (required) : string - The ID of the event to which you want to add a participant.
  • Query
    • None
  • Body
    • peerId (required) : string - The ID of the participant to be added.
    • name (required) : string - The name of the participant.
    • role (required) : string - The role of the participant.
    • joinedAt (required) : string - The timestamp when the participant joined the event.
    {
      "peerId": "<peer_id>",
      "name": "John Doe",
      "role": "Participant",
      "joinedAt": "2023-09-09T12:00:00Z"
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "data": {
            "peerId": "<peer_id>",
            "name": "John Doe",
            "role": "Participant",
            "joinedAt": "2023-09-09T12:00:00Z"
          },
          "message": "Selected Participant is added to the event."
        }
  • Error Response:
    • Code: 400
      • Content:
        {
          "statusCode": 400,
          "error": "Bad Request",
          "message": "Invalid request body or missing required parameters"
        }
    • Code: 500
      • Content:
        {
          "statusCode": 500,
          "error": "Internal Server Error",
          "message": "You can't add the selected Participant. Please ask Admin or Host for help."
        }

PATCH - /events/:id/peers/kickout

Use this request to remove a participant from an event.

  • Params:
    • :id (required) : string - The ID of the event from which you want to remove a participant.
  • Query
    • None
  • Body
    • peerId (required) : string - The ID of the participant to be removed.
    • reason (required) : string - The reason for removing the participant.
    {
      "peerId": "<peer_id>",
      "reason": "Inappropriate behavior"
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "message": "Selected Participant is removed from the event."
        }
  • Error Response:
    • Code: 400
      • Content:
        {
          "statusCode": 400,
          "error": "Bad Request",
          "message": "Invalid request body or missing required parameters"
        }
    • Code: 500
      • Content:
        {
          "statusCode": 500,
          "error": "Internal Server Error",
          "message": "You can't remove the selected Participant. Please ask the Admin or Host for help."
        }

POST - /events/:id/codes

Use this request to generate an event code for a specific event.

  • Params:
    • :id (required) : string - The ID of the event for which you want to generate a code.
  • Query
    • None
  • Body
    • eventCode (required) : string - The code to be generated for the event.
    • role (required) : string - The role for which the code is being generated. Currently, this feature is only available for "mavens."
    {
      "eventCode": "ABC123",
      "role": "maven"
    }
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 201
      • Content:
        {
          "message": "Event code created successfully!",
          "data": [
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "satyam75",
              "role": "maven",
              "id": "3042c55c-89ad-4273-b553-d65b203ea251"
            },
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "sanket75",
              "role": "maven",
              "id": "4c9b0986-a9e9-4ad7-985f-c542e88563bd"
            },
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "prerana75",
              "role": "maven",
              "id": "4af0b60d-5f10-4f79-b2ac-1dcf68b6332a"
            }
          ]
        }
  • Error Response:
    • Code: 400
      • Content:
        {
          "message": "Currently, the room codes feature is only for mavens!"
        }
    • Code: 500
      • Content:
        {
          "statusCode": 500,
          "error": "Internal Server Error",
          "message": "Couldn't create event code. Please try again later."
        }

GET - /events/:id/codes

Use this request to get event codes for a particular event.

  • Params:
    • :id (required) : string - The ID of the event for which you want to retrieve codes.
  • Query
    • None
  • Headers
    • Content-Type: application/json
    • Authorization: Bearer <management_token>
  • Cookie
    • rds-session: <JWT>
  • Success Response:
    • Code: 200
      • Content:
        {
          "message": "Event codes are successfully fetched for the event!",
          "data": [
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "satyam75",
              "role": "maven",
              "id": "3042c55c-89ad-4273-b553-d65b203ea251"
            },
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "sanket75",
              "role": "maven",
              "id": "4c9b0986-a9e9-4ad7-985f-c542e88563bd"
            },
            {
              "event_id": "64d4eeb24467618438785156",
              "code": "prerana75",
              "role": "maven",
              "id": "4af0b60d-5f10-4f79-b2ac-1dcf68b6332a"
            }
          ]
        }
  • Error Response:
    • Code: 500
      • Content:
        {
          "statusCode": 500,
          "error": "Internal Server Error",
          "message": "Something went wrong while getting the event codes!"
        }