REST API (2) ‐ Users - najat-mansour/task-go GitHub Wiki

Registration (Sign Up)

Endpoint

POST /task-go/v1/users/

Request Body

{
  "username": "najat-mansour",
  "password": "Najat#Mansour28",
  "firstName": "Najat",
  "lastName": "Mansour",
  "email": "[email protected]",
  "birthdate": "2003-01-28",
  "gender": "FEMALE",
  "address": {
    "country": "Palestine",
    "city": "Nablus",
    "town": "",
    "street": ""
  }
}

Possible Responses

✅ 201 Created

{
  "message": "User registered successfully."
}

⚠️ 400 Bad Request

{
  "error": "Weak Password."
}

⚠️ 409 Conflict

{
  "error": "Username or email already exists."
}

Update User Information

Endpoint

PATCH /task-go/v1/users/{id}

Headers

Header Value
Authorization Bearer {JWT}

Path Parameters

Parameter Type Description
id string UUID of the user to be updated.

Request Body

{
  "password": "Najat#Mansour28",
  "firstName": "Najat",
  "lastName": "Mansour",
  "birthdate": "2003-01-28",
  "gender": "FEMALE",
  "address": {
    "country": "Palestine",
    "city": "Nablus",
    "town": "",
    "street": ""
  },
  "app_rate": 5
}

All fields are optional.

Possible Responses

✅ 200 OK

{
  "message": "User information updated successfully."
}

⚠️ 400 Bad Request

{
  "error": "Invalid input format."
}

⚠️ 400 Bad Request

{
  "error": "Weak Password."
}

🔐 401 Unauthorized

{
  "error": "Unauthorized. Token missing or invalid."
}

❌ 404 Not Found

{
  "error": "User not found."
}

Get All Users

Endpoint

GET /task-go/v1/users/

Headers

Header Value
Authorization Bearer <JWT>

Possible Responses

✅ 200 OK

[
  {
    "id": "user-uuid",
    "username": "najat-mansour",
    "firstName": "Najat",
    "lastName": "Mansour",
    "email": "[email protected]",
    "birthdate": "2003-01-28",
    "gender": "FEMALE",
    "address": {
      "country": "Palestine",
      "city": "Nablus",
      "town": "",
      "street": ""
    },
    "createdAt": "2025-05-02T18:00:00",
    "app_rate": 5
  }
]

🔐 401 Unauthorized

{
  "error": "Unauthorized. Token missing or invalid."
}

❌ 404 Not Found

{
  "error": "No users found."
}

Get User by ID

Endpoint

GET /task-go/v1/users/id/{id}

Headers

Header Value
Authorization Bearer <JWT>

Path Parameters

Parameter Type Description
id string UUID of the user.

Possible Responses

✅ 200 OK

{
  "id": "user-uuid",
  "username": "najat-mansour",
  "firstName": "Najat",
  "lastName": "Mansour",
  "email": "[email protected]",
  "birthdate": "2003-01-28",
  "gender": "FEMALE",
  "address": {
    "country": "Palestine",
    "city": "Nablus",
    "town": "",
    "street": ""
  },
  "createdAt": "2025-05-02T18:00:00",
  "app_rate": 5
}

🔐 401 Unauthorized

{
  "error": "Unauthorized. Token missing or invalid."
}

❌ 404 Not Found

{
  "error": "User not found."
}

Get User by Username

Endpoint

GET /task-go/v1/users/username/{username}

Headers

Header Value
Authorization Bearer <JWT>

Path Parameters

Parameter Type Description
username string Username of the user to find.

Possible Responses

✅ 200 OK

{
  "id": "user-uuid",
  "username": "najat-mansour",
  "firstName": "Najat",
  "lastName": "Mansour",
  "email": "[email protected]",
  "birthdate": "2003-01-28",
  "gender": "FEMALE",
  "address": {
    "country": "Palestine",
    "city": "Nablus",
    "town": "",
    "street": ""
  },
  "createdAt": "2025-05-02T18:00:00",
  "app_rate": 5
}

🔐 401 Unauthorized

{
  "error": "Unauthorized. Token missing or invalid."
}

❌ 404 Not Found

{
  "error": "User not found with this username."
}

Get User by Email

Endpoint

GET /task-go/v1/users/email/{email}

Headers

Header Value
Authorization Bearer <JWT>

Path Parameters

Parameter Type Description
email string Email of the user.

Possible Responses

✅ 200 OK

{
  "id": "user-uuid",
  "username": "najat-mansour",
  "firstName": "Najat",
  "lastName": "Mansour",
  "email": "[email protected]",
  "birthdate": "2003-01-28",
  "gender": "FEMALE",
  "address": {
    "country": "Palestine",
    "city": "Nablus",
    "town": "",
    "street": ""
  },
  "createdAt": "2025-05-02T18:00:00",
  "app_rate": 5
}

🔐 401 Unauthorized

{
  "error": "Unauthorized. Token missing or invalid."
}

❌ 404 Not Found

{
  "error": "User not found with this email."
}
⚠️ **GitHub.com Fallback** ⚠️