You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create API endpoints to retrieve two types of organization information for a registered user:
Organizations owned by the user
Organizations the user belongs to (as a member)
These endpoints are part of the administration user management system. They must be secured so that only admin users can access them. Additionally, both endpoints must implement pagination for performance optimization.
Acceptance Criteria
Organizations owned by a user:
Endpoint: GET /api/v1/admin/users/{id}/organizations/owned
Returns a paginated list of organizations that the user owns.
Organizations a user belongs to:
Endpoint: GET /api/v1/admin/users/{id}/organizations/member
Returns a paginated list of organizations that the user is a member of.
For both endpoints:
Accept HTTP GET requests.
Retrieve organizations from the database using the provided user ID.
Return a 200 OK status code with the organizations in the response body.
Support pagination through query parameters (e.g., page and limit).
Be secured and accessible only to an admin user.
API Endpoints
1. Get Organizations Owned by a User
Request
GET api/v1/admin/users/{id}/organizations/owned?offset=1&limit=10
{
"status_code": 200,
"message": "completed",
"data":{
"meta": {
"total_pages": 5,
"current_page": 1,
"page_size": 10,
"total_count": 50,
"has_previous": false,
"has_next": true
},
"organizations": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Example Owned Org",
"description": "Description of the organization",
"industry": "Tech"
}
]
}
}
{
"status_code": 404,
"message": "User not found"
}
{
"status_code": 400,
"message": "Valid user ID must be provided"
}
2. Get organizations a user belongs to
Request
GET /api/v1/admin/users/{id}/organizations/member?offset=1&limit=10
{
"status_code": 200,
"message": "Request completed successfully",
"data":{
"meta_data": {
"total_pages": 5,
"current_page": 1,
"page_size": 10,
"total_count": 50,
"has_previous": false,
"has_next": true },
"organizations": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Example Member Org",
"description": "Description of the organization",
"industry": "Finance"
}
]
}
}
{
"status_code": 404,
"message": "User not found"
}
{
"status_code": 400,
"message": "Valid user ID must be provided"
}
Purpose
To provide admin users with detailed organization information about a registered user by retrieving:
Organizations the user owns.
Organizations the user belongs to as a member.
Requirements
Develop server-side logic to retrieve both lists of organizations using the user ID.
Securely handle data retrieval and comply with security standards.
Validate the user ID and implement pagination using query parameters.
Expected Outcome
The API endpoints will allow admin users to retrieve a user's owned and member organizations with proper validation, pagination, and security measures.
Tasks
Route Definition
GET /api/v1/admin/users/{id}/organizations/owned
GET /api/v1/admin/users/{id}/organizations/member
Implementation
Validate the provided user ID.
Retrieve the relevant organizations from the database.
Return paginated results using the page and limit query parameters.
Security
Ensure endpoints are secured and accessible only to admin users.
Error Handling
Return 400 Bad Request if the user ID is missing or invalid.
Return 404 Not Found if the user does not exist.
Testing
Unit Tests: Validate input, pagination, and data retrieval logic.
Integration Tests: Verify end-to-end functionality of the endpoints.
Security Tests: Confirm that data protection and access control standards are met.
The text was updated successfully, but these errors were encountered:
Description
Create API endpoints to retrieve two types of organization information for a registered user:
These endpoints are part of the administration user management system. They must be secured so that only admin users can access them. Additionally, both endpoints must implement pagination for performance optimization.
Acceptance Criteria
Organizations owned by a user:
GET /api/v1/admin/users/{id}/organizations/owned
Organizations a user belongs to:
GET /api/v1/admin/users/{id}/organizations/member
For both endpoints:
200 OK
status code with the organizations in the response body.page
andlimit
).API Endpoints
1. Get Organizations Owned by a User
Request
GET api/v1/admin/users/{id}/organizations/owned?offset=1&limit=10
2. Get organizations a user belongs to
Request
GET /api/v1/admin/users/{id}/organizations/member?offset=1&limit=10
Purpose
To provide admin users with detailed organization information about a registered user by retrieving:
Requirements
Expected Outcome
The API endpoints will allow admin users to retrieve a user's owned and member organizations with proper validation, pagination, and security measures.
Tasks
Route Definition
GET /api/v1/admin/users/{id}/organizations/owned
GET /api/v1/admin/users/{id}/organizations/member
Implementation
page
andlimit
query parameters.Security
Error Handling
400 Bad Request
if the user ID is missing or invalid.404 Not Found
if the user does not exist.Testing
The text was updated successfully, but these errors were encountered: