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 |
---|---|---|---|---|---|---|---|---|
/volunteer-promotion-wizard/terms | GET | Volunteers () | ALL | Volunteer Promotion Wizard (Step-1) | To get the consent provided by a user | Rajesh Mahendran + Prakhar Seth/Parth Barot | Meena | |
/volunteer-promotion-wizard/terms | POST | Volunteers () | ALL | Volunteer Promotion Wizard (Step-1) | To update the government id provided by a user | Vamsi Bulusu + Prakhar Seth/Parth Barot | Meena | |
/volunteer-promotion-wizard/gov-id | GET | Volunteers () | ALL | Volunteer Promotion Wizard (Step-2) | To get the government id uploaded by a user | Rajesh Mahendran + Prakhar Seth/Parth Barot | ||
/volunteer-promotion-wizard/gov-id | POST | Volunteers () | ALL | Volunteer Promotion Wizard (Step-2) | To update the government id provided by a user | Vamsi Bulusu + Prakhar Seth/Parth Barot | ||
☑️ | /volunteer-promotion-wizard/skills | GET | Volunteers () | ALL | Volunteer Promotion Wizard (Step-3) | To get the total list of available skills | Sai Revanth Tummala + Prakhar Seth/Parth Barot | Sai Revanth Tummala |
☑️ | /volunteer-promotion-wizard/skills | POST | Volunteers () | ALL | Volunteer Promotion Wizard (Step-3) | To update the skills list selected by a user | Sai Revanth Tummala + Prakhar Seth/Parth Barot | Sai Revanth Tummala |
/volunteer-promotion-wizard/availability | GET | Volunteers () | ALL | Volunteer Promotion Wizard (Step-4) | To get the calamity check-box status and availability time windows already selected by the user | Sai Revanth Tummala + Prakhar Seth/Parth Barot | ||
/volunteer-promotion-wizard/availability | POST | Volunteers () | ALL | Volunteer Promotion Wizard (Step-4) | To update the calamity check-box status and availability time windows of a user | Sai Revanth Tummala + Prakhar Seth/Parth Barot | ||
☑️ | /profile/basic-info | GET | Volunteers () | ALL | Profile Section(Your Profile) | To get the profile information of a user | Deepika/Deekshita + Ashan Deen | Himanshu Rathi |
☑️ | /profile/basic-info | POST | Volunteers () | ALL | Profile Section(Your Profile) | To update the profile information of a user | Deepika/Deekshita + Ashan Deen | Himanshu Rathi |
☑️ | /profile/personal-info | GET | Volunteers () | ALL | Profile Section(Personal Information) | To get the personal information of a user | Deepika/Deekshita + Ashan Deen | Himanshu Rathi |
☑️ | /profile/personal-info | POST | Volunteers () | ALL | Profile Section(Personal Information) | To update the personal information of a user | Deepika/Deekshita + Ashan Deen | Himanshu Rathi |
/profile/organization-details | GET | Volunteers () | ALL | Profile Section(Organization Details) | To get the organization details of a user | Deepika/Deekshita + Ashan Deen | ||
/profile/personal-info | POST | Volunteers () | ALL | Profile Section(Organization Details) | To update the organization details of a user | Deepika/Deekshita + Ashan Deen | ||
/profile/notification-status | GET | Volunteers () | ALL | Profile Section(Notification Status) | To get the notification status of a user | Deepika/Deekshita + Ashan Deen | ||
/profile/notification-status | POST | Volunteers () | ALL | Profile Section(Notification Status) | To update the notification status of a user | Deepika/Deekshita + Ashan Deen | ||
/dashboard/my-requests | GET | Request () | ALL | Dashboard Page(My Requests) | To get the requests created by a user | Gaurav/Deekshita + Rashmi | Riya Uchagaonkar | |
/dashboard/other-requests | GET | Request () | ALL | Dashboard Page(Other Requests) | To get the other requests | Gaurav/Deekshita + Rashmi | ||
/dashboard/managed-requests | GET | Request () | ALL | Dashboard Page(Managed Requests) | To get the managed requests | Gaurav/Deekshita + Rashmi | ||
/dashboard/requests/{request-id}/description | GET | Request () | ALL | Dashboard Page -> Click on any request id | To get the description of a particular request-id | Gaurav/Deekshita + Rashmi | ||
/dashboard/requests/{request-id}/description | POST | Request () | ALL | Dashboard Page -> Click on any request id | User can edit description | Gaurav/Deekshita + Rashmi | ||
/dashboard/requests/{request-id}/comments | GET | Request () | ALL | Dashboard Page -> Click on any request id | To get the comments associated with that request | Gaurav/Deekshita + Rashmi | ||
/dashboard/requests/{request-id}/comments | POST | Request () | ALL | Dashboard Page -> Click on any request id | User can submit a new comment | Gaurav/Deekshita + Rashmi | ||
/help-request | POST | Request () | ALL | Dashboard Page -> Create Help Request -> Submit | User can submit a new help request | Gaurav/Mounika + Prakhar Seth | ||
/notifications | GET | Request () | ALL | Dashboard Page -> Notification Icon | To get the notifications associated with a user | Bhavesh Sidhwani + Parth Barot |
- Response: Json object containing all the available skills list
- Description: Returns the json object received from volunteer micro-service
- Request: Json object which has the user selected skills
- Description: Calls 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 volunteer micro-service
- Request: Json object containing all the availability time windows and calamity check-box status of a user
- Description: Calls 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."
}
};
}
};