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

Saayam REST-API Documentation

API List

Status: Implementation Complete(✅) | Implementation In Progress(☑️)

Request Details

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'

Create Help 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

Dashboard

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

Volunteer

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

Volunteer Wizard

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

Notifications

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

Profile

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)

API Documentation

/volunteer/v0.0.1/getSkills

GET

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

POST

  • Request: JSON object that has the user's selected skills
  • Description: Calls the volunteer micro-service with the received JSON object

/volunteer/v0.0.1/updateSkills

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 the volunteer micro-service

POST

  • 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

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** ⚠️