API Documentation - saayam-for-all/api GitHub Wiki
Status: Implementation Complete(✅) | Implementation In Progress(☑️)
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/requests/v0.0.1/record/{request_id} | GET | Requests | ALL | Request Details | Get Request Details | |||
/requests/v0.0.1/record/{request_id} | PUT | Requests | ALL | Request Details | Update Request Details | |||
/requests/v0.0.1/record/{request_id}/comments | GET | Requests | ALL | Comments | Get Comments | |||
/requests/v0.0.1/record/{request_id}/comments | PUT | Requests | ALL | Comments | Update Comments | |||
/ml/v0.0.1/record/{request_id}/emergencyContact | GET | ML | ALL | Emergency Contact | Get Emergency Contact (country=US) | |||
✅ | /mobileapp/genai/v0.0.1/generate_answer | POST | GenAI | ALL | AI Integration | Fetch More Information - Available as REST API & integrated with webapp/mobileapp | ||
/volunteers/v0.0.1/record/{request_id}/ | GET | Volunteers | ALL | Volunteer Management | Get list of available Volunteers | |||
/volunteers/v0.0.1/record/{request_id}/ | GET | Volunteers | ALL | Volunteer Management | Get already assigned volunteers | |||
/volunteers/v0.0.1/record/{request_id}/ | PUT | Volunteers | ALL | Volunteer Management | Update assigned volunteers | |||
/volunteerorgs/v0.0.1/record/{request_id}/organizations | GET | Volunteer Organizations | ALL | Organization Management | Get Volunteer Organizations | |||
/volunteerorgs/v0.0.1/record/{request_id}/organizations | PUT | Volunteer Organizations | ALL | Organization Management | Update Volunteer Organizations | |||
/volunteers/v0.01/getAssignedVolunteer/{request_id} | GET | Volunteers | ALL | Request Edit | Get Assigned Volunteer for 'Edit request' |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/ml/v0.0.1/timeBasedFraudDetection | GET | ML | ALL | Fraud Detection | Time based fraud detection | |||
/requests/v0.0.1/help-request | POST | Requests | ALL | Help Request | Create help request |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/requests/v0.0.1/get-requests | GET | Requests | ALL | Dashboard | Get user's help requests | |||
/requests/v0.0.1/managed-requests | GET | Requests | ALL | Dashboard | Get managed help requests | |||
/volunteer/v0.01/isAddressFilled | GET | Volunteers | ALL | Profile | Get if user has filled address flag | |||
/Volunteer/v0.01/getProfilePic | GET | Volunteers | ALL | Profile | Get Profile Picture | |||
/volunteer/v0.0.1/getUserId | POST | Volunteers | ALL | User Management | Get User Id from email |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
✅ | /0.0.1/users | GET | Users | ALL | User Management | User Creation (From Volunteer micro list) | ||
✅ | /0.0.1/users | POST | Users | ALL | User Management | User Creation | ||
/0.0.1/users | GET | Users | ALL | User Management | User Creation With Pagination (?page=1&size=10) | |||
/0.0.1/users/profile | GET | Users | ALL | Profile | Get User using Profile | |||
/0.0.1/users/profile/{userId} | POST | Users | ALL | Profile | Update User Profile using userId | |||
/0.0.1/users/profile/{userId} | PUT | Users | ALL | Profile | Get User profile using userid |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/0.0.1/volunteers/createvolunteer | POST | Volunteers | ALL | Volunteer Wizard | Volunteer Creation | |||
/0.0.1/volunteers/updatevolunteer | PUT | Volunteers | ALL | Volunteer Wizard | Update Volunteer | |||
/0.0.1/volunteers/updatestep1 | PUT | Volunteers | ALL | Volunteer Wizard | Volunteer Step 1 | |||
/0.0.1/volunteers/updatestep2 | PUT | Volunteers | ALL | Volunteer Wizard | Volunteer Step 2 | |||
/0.0.1/volunteers/updatestep3 | PUT | Volunteers | ALL | Volunteer Wizard | Volunteer Step 3 | |||
/0.0.1/volunteers/updatestep4 | PUT | Volunteers | ALL | Volunteer Wizard | Volunteer Step 4 | |||
/volunteer/v0.0.1/getStep | GET | Volunteers | ALL | Volunteer Wizard | Get number of steps completed in the volunteer wizard | |||
/volunteer/v0.0.1/uploadGovtId | POST | Volunteers | ALL | Volunteer Wizard | Upload volunteer ID docs to S3 |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/volunteer/v0.0.1/getVolunteerMatch | GET | Volunteers | ALL | Notifications | Get volunteer match notification to volunteer | |||
/volunteer/v0.0.1/saveAcceptance | POST | Volunteers | ALL | Notifications | Save volunteer acceptance of match | |||
/volunteer/v0.0.1/getAssignedVolunteer | GET | Volunteers | ALL | Notifications | Send volunteer assignment notification to user/beneficiary | |||
/request/v0.0.1/getRequestCreated | GET | Requests | ALL | Notifications | Send request created notification to the User |
Status | API | METHOD | Backend-Service (Owner/Contact) | User-Group Access | Client Feature | Short Description | Assignor (web-app + mobile-app) | Assignee |
---|---|---|---|---|---|---|---|---|
/volunteer/v0.0.1/updateGovtId | PUT | Volunteers | ALL | Profile | Update volunteer ID docs to S3 | |||
/volunteer/v0.0.1/getSkills | GET | Volunteers | ALL | Profile | Get volunteer skills | |||
/volunteer/v0.0.1/updateSkills | PUT | Volunteers | ALL | Profile | Update volunteer skills | |||
/volunteer/v0.0.1/getAvailability | GET | Volunteers | ALL | Profile | Get volunteer availability | |||
/volunteer/v0.0.1/updateAvailability | PUT | Volunteers | ALL | Profile | Update volunteer availability | |||
/volunteer/v0.0.1/getPreferences | GET | Volunteers | ALL | Profile | Get user preferences | |||
/volunteer/v0.0.1/addPreferences | POST | Volunteers | ALL | Profile | Add user preferences | |||
/volunteer/v0.0.1/updatePreferences | PUT | Volunteers | ALL | Profile | Update user preferences | |||
/volunteer/v0.0.1/uploadProfilePic | POST | Volunteers | ALL | Profile | Add Profile picture | |||
/volunteer/v0.0.1/getPicture | GET | Volunteers | ALL | Profile | Get profile picture | |||
/volunteer/v0.0.1/updatePicture | PUT | Volunteers | ALL | Profile | Update profile picture | |||
/volunteer/v0.0.1/getPersonalinfo | GET | Volunteers | ALL | Profile | Get Personal Information | |||
/volunteer/v0.0.1/updatePersonalinfo | PUT | Volunteers | ALL | Profile | Update Personal Information | |||
/volunteer/v0.0.1/getOrgdetails | GET | Volunteers | ALL | Profile | Get Organisation Details | |||
/volunteer/v0.0.1/updateOrgdetails | PUT | Volunteers | ALL | Profile | Update Organisation Details | |||
/volunteer/v0.0.1/updateProfile | PUT | Volunteers | ALL | Profile | Update Your Profile (Profile info) |
- Response: JSON object containing the available skills list
- Description: Returns the JSON object received from the volunteer micro-service
- Request: JSON object that has the user's selected skills
- Description: Calls the volunteer micro-service with the received JSON object
- Response: JSON object containing all the availability time windows and calamity check-box status of a user
- Description: Returns the JSON object received from the volunteer micro-service
- Request: JSON object containing all the availability time windows and calamity check-box status of a user
- Description: Calls the volunteer micro-service with the received JSON object
- Command to get JWT token -
aws cognito-idp admin-initiate-auth --user-pool-id <USER_POOL_ID> --client-id <CLIENT_ID> --auth-flow ADMIN_NO_SRP_AUTH --auth-parameters USERNAME=<EMAIL>,PASSWORD=<PASSWORD>
- In
Authorization
, select cognito authorizer - In
Request validator
, select appropriate validation option(None
in this case)
- Used below
Mapping Template
{
"httpMethod": "$context.httpMethod",
"cognitoEmail": "$context.authorizer.claims['email']",
"cognitoGroups": "$context.authorizer.claims['cognito:groups']"
}
- Used below
Mapping Template
#set($inputRoot = $input.path('$'))
#set($context.responseOverride.status = $inputRoot.statusCode)
$input.json('$')
- In
Authorization
, select cognito authorizer - In
Request validator
, select appropriate validation option(Validate body
in this case) - Used below Model for
Request-body
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "CheckedCategoriesModel",
"type": "object",
"properties": {
"checkedCategories": {
"type": "object",
"description": "A required object for checked categories",
"additionalProperties": {
"type": "object",
"description": "Subcategories can have nested objects"
}
}
},
"required": [
"checkedCategories"
]
}
- References:
- Used below
Mapping Template
{
"httpMethod": "$context.httpMethod",
"cognitoEmail": "$context.authorizer.claims['email']",
"cognitoGroups": "$context.authorizer.claims['cognito:groups']",
"body": $input.body
}
- References:
- Used below
Mapping Template
#set($inputRoot = $input.path('$'))
#set($context.responseOverride.status = $inputRoot.statusCode)
$input.json('$')
-
References:
- https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-examples.html
- https://repost.aws/knowledge-center/api-gateway-status-codes-rest-api
- https://kennbrodhagen.net/2016/03/09/how-to-return-a-custom-error-object-and-status-code-from-api-gateway-with-lambda/
- https://ncoughlin.com/posts/aws-pass-errors-from-lambda-to-api-gateway
- https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
export const handler = async (event) => {
try {
console.log("Event: ", JSON.stringify(event, null, 2));
// Extract variables from the event object
const httpMethod = event.httpMethod;
const cognitoEmail = event.cognitoEmail;
const cognitoGroups = event.cognitoGroups;
const body = event.body;
// Initialize response structure
const response = {
"statusCode": 200,
"data": ""
};
// Handle GET method
if (httpMethod === "GET") {
// Check if necessary variables are available
if (!cognitoEmail) {
response.statusCode = 400;
response.data = {
error: "Missing required cognitoEmail."
};
return response;
}
// Mock data processing for GET
const data = {
message: `Will send the user-email (${cognitoEmail}) to volunteer microservice and get the user skills data`,
groups: `You belong to groups: ${cognitoGroups}`
};
// Return success response
response.data = data;
return response;
}
// Handle POST method
else if (httpMethod === "POST") {
if (!body || !cognitoEmail) {
response.statusCode = 400;
response.data = {
error: "Missing request body or cognitoEmail."
};
return response;
}
if (!body.hasOwnProperty("notify")) {
response.statusCode = 400;
response.data = {
error: "Missing the notify field"
};
return response;
}
// Mock data processing for POST
const result = {
requestBody: body,
message: `Will send the user-email (${cognitoEmail}) and above requestBody to volunteer microservice to update the user skills data`,
groups: `You belong to groups: ${cognitoGroups}`
};
// Return success response
response.data = result;
return response;
}
// Handle unsupported methods
else {
response.statusCode = 405;
response.data = {
error: `Method ${httpMethod} not allowed.`
};
return response;
}
}
// General error handling
catch (error) {
console.error("Error processing request: ", error);
return {
"statusCode": 500,
"data": {
error: "Internal server error."
}
};
}
};