Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] API Endpoint For Organisation Creation by users #148

Open
5 tasks
fawizzy opened this issue Jul 23, 2024 · 2 comments
Open
5 tasks

[FEAT] API Endpoint For Organisation Creation by users #148

fawizzy opened this issue Jul 23, 2024 · 2 comments
Labels

Comments

@fawizzy
Copy link
Contributor

fawizzy commented Jul 23, 2024

Description

Develop a backend API for creating organisations, including authentication and authorization checks, input validation, and error handling.

Acceptance Criteria

  • Create Organisation Endpoint

  • Accepts HTTP POST requests at /api/v1/organisations.

  • Create a new organisation with a 201 Created status code if the user request is valid.

  • Validate all supplied fields.

  • If validation fails, return a 422 Unprocessable Entity status code with detailed error messages

Request Body

{
  "name": "String",
  "description": "String",
  "email": "string",
  "industry": "string",
  "type": "string",
  "country": "string",
  "address": "string",
  "state": "string",

}

Successful Response

{
  "status": "success",
  "message": "organisation created successfully",
  "data": {
    "id": "String",
    "name": "String",
    "description": "String",
    "owner_id": "string",
    "slug" : "string",
    "email": "string",
    "industry": "string",
    "type": "string",
    "country": "string",
    "address": "string",
    "state": "string",
    "created_at": "2024-01-01T12:00:00Z",
    "updated_at": "2024-06-01T12:00:00Z"
  },
 "status_code": 201
}

Unsuccessful Response

{
  "status": "Bad Request",
  "message": "Client error",
  "status_code": 400
}

Validation Error Response

{
  "errors": [
    {
      "field": "String",
      "message": "String"
    }
  ]
}

Unauthenticated Error Response

{
  "status": "Unauthorized",
  "message": "User not authenticated",
  "status_code": 401
}

Database Design

Table organisations {
  id uuid [primary key]
  slug varchar(255) [unique]
  owner_id uuid [foreign key to users(id)]
  name varchar(255)
  email varchar(255)
  industry varchar(255)
  type varchar(255)
  country varchar(255)
  address varchar(255)
  state varchar(255)
  description text
  created_at timestamp
  updated_at timestamp
}

Table organisations_user {
  user_id uuid [foreign key to users(id)]
  organisation_id uuid [foreign key to organisations(id)]
  role varchar(255)
  created_at timestamp
  updated_at timestamp
}

Ref: users.id < organisations_user.user_id
Ref: organisations.id < organisations_user.organisation_id

Documentation

API Documentation

  • Ensure that API documentation is updated to include details about the new endpoint, request/response formats, error handling, and authentication requirements.
    Technical Notes

  • Include any additional technical notes or considerations.

Testing Requirements

Unit Tests

  • Write unit tests to validate input data and SMS sending logic.

Integration Tests

  • Ensure end-to-end functionality is tested with integration tests.
@AdeGneus
Copy link
Contributor

This is nice but use the format we gave. Use checkbox for the acceptance criteria

@fawizzy
Copy link
Contributor Author

fawizzy commented Jul 23, 2024

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants