API Documentation - saayam-for-all/api GitHub Wiki

Saayam REST-API Documentation

API List

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

API Documentation

/volunteer-promotion-wizard/skills

GET

  • Response: Json object containing all the available skills list
  • Description: Returns the json object received from volunteer micro-service

POST

  • Request: Json object which has the user selected skills
  • Description: Calls volunteer micro-service with the received json object

/volunteer-promotion-wizard/availability

GET

  • 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

POST

  • 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

Implementation steps followed for skills api:

  • 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>

GET - Method:

1. Method Request:

  • In Authorization, select cognito authorizer
  • In Request validator, select appropriate validation option(None in this case)

2. Integration Request:

  • Used below Mapping Template
{
  "httpMethod": "$context.httpMethod",
  "cognitoEmail": "$context.authorizer.claims['email']",
  "cognitoGroups": "$context.authorizer.claims['cognito:groups']"
}

3. Integration Response:

  • Used below Mapping Template
#set($inputRoot = $input.path('$'))
#set($context.responseOverride.status = $inputRoot.statusCode)
$input.json('$')

POST - Method:

1. Method Request:

  • 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"
  ]
}

2. Integration Request:

  • Used below Mapping Template
{
  "httpMethod": "$context.httpMethod",
  "cognitoEmail": "$context.authorizer.claims['email']",
  "cognitoGroups": "$context.authorizer.claims['cognito:groups']",
  "body": $input.body
}

3. Integration Response:

  • Used below Mapping Template
#set($inputRoot = $input.path('$'))
#set($context.responseOverride.status = $inputRoot.statusCode)
$input.json('$')

Lambda Function Should Handle All Types Of Methods(GET,POST,...) If Possible:

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."
            }
        };
    }
};
⚠️ **GitHub.com Fallback** ⚠️