sphinx-tribes icon indicating copy to clipboard operation
sphinx-tribes copied to clipboard

new endpoint /workflows/response

Open humansinstitute opened this issue 1 year ago • 5 comments

Context

  • Problem: We need to handle responses from Stakwork efficiently and take the next action on the response data.
  • Why it's needed: This endpoint is crucial for maintaining the integrity and accuracy of our workflow tracking system by ensuring that all responses are logged and processed correctly.
  • Larger System Fit: This endpoint is part of the Stakwork Common Workflow Plumbing feature, which aims to streamline and automate workflow processes.
  • Background: The /workflows/response endpoint will update the wf_requests table with response data, ensuring that the status of each request is accurately tracked.

This is related to a broader project defined here: For context see: https://github.com/stakwork/sphinx-tribes/issues/1922

System Schematic:

image

Design

The logical flow to process a response is: image

  1. "/workflow/response"
  2. On receipt of response object.
  3. Use requestUUID to load response data into DB wf_requests
  4. Create action object (union of requestObject and responseObject) POST to /workflow/action
{
    "source": "string",
    "requestUUID": "string",
    "action": "string"
    "workflowID": interger,
    "formData": { object },
    "responseData": { object }
}
  • Endpoint: /workflows/response

  • HTTP Method: POST

  • Request Body: JSON object containing response data from Stakwork.

    • Example:
      {
        "request_id": "12345",
        "status": "completed",
        "response_data": {
          "key1": "value1",
          "key2": "value2"
        }
      }
      
  • Database Interaction: Update the wf_requests table with the response data based on request_id.

  • Database Interaction: Use the wf_processing_map to check for next processing action based on action.

Task Breakdown

  • [ ] Dependancy for handler: https://github.com/stakwork/sphinx-tribes/issues/1937
  • [x] #1941
  • [x] #1942
  • [x] #1943

Assignment Criteria

  • Required Knowledge/Skills:
    • Proficiency in the primary programming language and framework used in the project.
    • Understanding of RESTful API design and database operations.
  • Communication Channels:
    • Ensure you are live on Sphinx V2 for team communication.

Acceptance Criteria

  • [ ] The /workflows/response endpoint accepts POST requests with valid JSON response data.
  • [ ] The endpoint updates the wf_requests table with the correct response data based on request_id.
  • [ ] The endpoint returns a 200 HTTP status code and a success message upon successful update.
  • [ ] The endpoint returns an appropriate error message and status code for invalid requests or update failures.
  • [ ] The implementation includes unit tests covering both successful and failure scenarios.
  • [ ] The endpoint is documented in the API documentation.

humansinstitute avatar Nov 11 '24 02:11 humansinstitute

@humansinstitute I can help?

MuhammadUmer44 avatar Nov 11 '24 02:11 MuhammadUmer44

@humansinstitute Please assign me?

samiyadev786 avatar Nov 11 '24 03:11 samiyadev786

@humansinstitute assign me?

MahtabBukhari avatar Nov 11 '24 04:11 MahtabBukhari

This would be blocked until this ticket is merged to allow access to the wf_requests table: https://github.com/stakwork/sphinx-tribes/issues/1925

humansinstitute avatar Nov 11 '24 04:11 humansinstitute

@humansinstitute, Please assign me?

aliraza556 avatar Nov 11 '24 05:11 aliraza556