openoakland / TrashTalk

Repo for artifacts of the Trash Talk app for organizing cleanups and graffiti abatement.
Other
7 stars 10 forks source link

Update API and Cleanup models to facilitate creation of Cleanups from frontend #164

Open thinhngo opened 6 years ago

thinhngo commented 6 years ago

This is required by the React frontend after a cleanup has been created. Here's my strawman:

POST /api/v1/cleanups/[cleanupId]/tools

POST body would include this JSON:

[
    {   
        'id': 123 
    },  
    {   
        'id': 456 
    }   
]

It would also be nice to be able to add cleanups to the cleanup JSON body. This might look something like:

{
    'id': 789,
    'title': 'My Cleanup'
    'tools': [
        {
            'id': 123
        },
        {
            'id': 456
        }
    ]   
    ...
}  
thinhngo commented 6 years ago

Here's where I landed on this. The POST/PATCH/PUT bodies look something like this:

{
        "id": 123, // Or no id if we're POSTing
        "title": "Homeroom",
        "description": "",
        "start": "2018-04-20T13:29:29Z",
        "end": "2018-04-20T14:29:30Z",
        "location": {
            "latitude": "37.828600",
            "longitude": "-122.260000",
            "query": "Homeroom!"
        },
        "required_tools": [
            {
                "tool": 4,
                "quantity": 3
            },
            {
                "tool": 5,
                "quantity": 3
            }
        ]
}