thefueley / scholar-power-api

UMGC CMSC 495 API for Scholar Power Workout App
GNU General Public License v3.0
0 stars 0 forks source link

Update updateWorkout methods #65

Closed thefueley closed 1 year ago

thefueley commented 1 year ago

Updated endpoint for updating workouts.
PUT /api/v1/workout/{plan_id}

Send full contents of desired workout plan. For example:

{
    "uid": "1", 
    "name": "Krypteia", 
    "exercises": [ 
        {
            "id": "12",
            "sets": "3", 
            "reps": "20", 
            "load": "100", 
            "exercise_id": "11"
        },
        {   
            "id": "13",
            "sets": "2", 
            "reps": "2", 
            "load": "100", 
            "exercise_id": "100"
        },
        {   
            "sets": "3", 
            "reps": "3", 
            "load": "50",
            "exercise_id": "21"
        }
    ]
}

The above request will update exercise id's 12 and 13 in this plan. It will also create a new exercise, assigning a new id. Notice there is no "id" in that element. Any remaining exercises in the workout plan are deleted.