Skip to content

Task API: Add Statuses, 404 Handling & Session Task Create/Delete #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 16, 2025

Conversation

AleksandrMolchagin
Copy link
Member

@AleksandrMolchagin AleksandrMolchagin commented May 14, 2025

The following PR has 4 updates:

1. Update GET tasks/{taskId} to handle cases where the task is not found. In such cases, the response should be as follows:

{
    "message": "The task with the given ID does not exist.",
    "error": "Something went wrong while retrieving the task record.",
    "detailedError": "Something went wrong while retrieving the task record.",
    "errorType": "CUSTOM:SALESFORCE_TASK_GET:NOT_FOUND"
}

2. New endpoint GET /tasks/statuses to retrieve available statuses:
image

4. Delete corresponding Task records when a Session with tasks is deleted:
image
More in docs.
Flowchart:

%%{init:{
    "flowchart": {
      "nodeSpacing": 20,
      "rankSpacing": 20
    },
    "themeCSS": ".node text { font-size: 10px !important; }"
}}%%
flowchart TD
    A["Start (request received)"]
    A --> C["Extract sessionId"]
    C --> D{"Does the session exist?"}
    D -- No --> Z1["Return 'Session does not exist' (404)"]
    D -- Yes --> E["Query linked Assessments"]
    E --> F{"Any Assessments found?"}
    F -- Yes --> Z2["Return 'Session is active' (409)"]
    F -- No --> G["Query linked SCORES_Task__c records"]
    G --> H["Query linked Attendance__c records"]
    H --> I["Filter Attendance to those with Attended__c = 'true'"]
    I --> J{"Any attended records?"}
    J -- Yes --> Z2
    J -- No --> K["Build list of Task IDs + Attendance IDs + sessionId"]
    K --> L["Delete Tasks, Attendance records, and Session"]
    L --> M{"Deletion successful?"}
    M -- No --> Z3["Raise internal error (500)"]
    M -- Yes --> Z4["Return success:true (200)"]
    Z1 & Z2 & Z3 & Z4 --> End["End"]
Loading

4. Create a corresponding "Take Attendance" Task record when a Session is created
image
Requires CoachId in payload. Task creation be disabled by setting createAttendanceTask=false More in docs.
Flowchart:

%%{init:{
    "flowchart": {
      "nodeSpacing": 20,
      "rankSpacing": 20
    },
    "themeCSS": ".node text { font-size: 10px !important; }"
}}%%
flowchart TD
    A["Start (request received)"]
    A --> B["Extract body & query params"]
    B --> C["Build Session__c payload"]
    C --> D["Create Session__c"]
    D --> E{"Creation successful?"}
    E -- No --> Z1["Raise internal error (500)"]
    E -- Yes --> F["Store SessionId"]
    F --> G{"createAttendanceTask=true AND CoachId present?"}
    G -- No --> H["Skip task creation"]
    G -- Yes --> I["Build SCORES_Task__c payload"]
    I --> J["POST /tasks"]
    J --> K{"Task created?"}
    K -- No --> Z2["Surface task error (500)"]
    K -- Yes --> L["Capture TaskId and Attendance Records"]
    H & L --> Z3["Return success (201)"]
    Z1 & Z2 & Z3 --> End["End"]
Loading

@AleksandrMolchagin
Copy link
Member Author

Updated with the recent changes.

@AleksandrMolchagin AleksandrMolchagin changed the title GET tasks/{taskId}: Task not found handling Task API: Add Statuses, 404 Handling & Session Task Create/Delete May 15, 2025
@AleksandrMolchagin AleksandrMolchagin merged commit c4b9efa into master May 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants