Skip to content

[FEAT]: Create Organization Invitation Link -Backend #53

Open
@Goldyn19

Description

@Goldyn19

Issue: Implement an API for creating Organization invite link

Description

Create an API endpoint to generate invitation links for inviting users to join an organization. This endpoint will validate the input data and generate a unique invitation link for the specified organization.

Acceptance Criteria

API Endpoint Implementation:

  • The endpoint should be accessible at /api/v1/invite/create.
  • The endpoint should accept HTTP POST requests.

Data Validation and Sanitization:

  • The API should validate the request payload to ensure the required fields (organizationId, email) are present and valid.

Invitation Link Generation:

  • Upon successful validation, the API should generate a unique invitation link for the specified organization.
  • The generated invitation link should be stored in the database with an expiration date.

Email Sending:

  • The API should send an email containing the invitation link to the specified email address.
  • The email should contain a clear and concise message with the invitation link.

Response:

  • On success, the API should return a 201 Created status code with the invitation link and a success message.
  • On failure, the API should return a 400 Bad Request status code with appropriate error messages.

Request Example:

POST /api/v1/invite/create

{
  "organizationId": "string",
  "email": "string"
}

Successful Response:

{
  "message": "Invitation link created and sent successfully",
  "data": {
    "invitationLink": "string"
  },
  "status_code": 201
}

Error Response:

{
  "message": "Failed to create invitation link",
  "errors": [
    "Invalid organization ID",
    "Email format is incorrect"
  ],
  "status_code": 400
}

Purpose

Provides a backend service to generate unique invitation links for inviting users to join an organization, ensuring the data is valid, storing the invitation link with an expiration date, and sending the invitation link via email.

Requirements

  • Develop server-side logic to handle invitation link creation.
  • Validate and sanitize incoming data.
  • Generate and store unique invitation links with expiration dates.
  • Send the generated invitation link via email to the specified address.

Expected Outcome

The API endpoint allows administrators to generate invitation links for inviting users to join an organization, ensuring the links are valid and stored with expiration dates.

status_code

  • 201: Invitation link was successfully created.
  • 400:
    • Invalid organization ID
    • Email format is incorrect
  • 500: A server error occurred

Testing

  • Write unit tests to ensure the invitation link creation endpoint validates input correctly and generates unique invitation links.
  • Perform load testing to ensure the endpoint can handle multiple requests.
  • Test various scenarios for generating invitation links (e.g., valid organization ID, invalid organization ID, invalid email format, etc.).
  • Test email delivery to ensure the invitation link is correctly sent to the specified email address.

Metadata

Metadata

Assignees

Labels

orgIssues categorised by organisation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions