Doist / todoist-python

DEPRECATED The official Todoist Python API library
MIT License
533 stars 73 forks source link

TemplatesManager does not support temporary project IDs #69

Open kquinsland opened 4 years ago

kquinsland commented 4 years ago

Hi there.

Thanks for your client library. It's certainly making some parts of this software much easier to write. I am grateful that you've managed to implement broad support for local changes before calling commit().

I'd like to request that TemplatesManager be made aware of temporary project IDs so the broad support for local changes becomes more broad...

I do understand that this may create some additional complexity, but I think that the implementation could end up being relatively simple, as you already use the temp_id_mapping to update the local cache and in my skim through the API, I don't see a glaringly obvious reason why a file-upload can't be queued up like everything else.

When i try to upload a ./templates/test.csv to a project that's not yet been commit()ed:

Attempting to apply the template file:`./templates/test.csv` to the _new_prj:`test project`/($89cfd3c0-2f60-11ea-8610-acde48001122)
2020-01-04 18:10:26,686 (DEBUG) [connectionpool.py   _make_request:437 ]: https://api.todoist.com:443 "POST /sync/v8/templates/import_into_project HTTP/1.1" 400 179
{
    'error_tag': 'INVALID_ARGUMENT_VALUE',
    'error_code': 20,
    'http_code': 400,
    'error_extra': {
        'expected': 'number',
        'argument': 'project_id',
        'retry_after': 2
    },
    'error': 'Invalid argument value'
}

For now i'll make the commit() call after each projects.add() call, but since the software i am writing is designed for bulk/batch changes, I sometimes hit rate-limits w/ this approach ^.

Please let me know if this is a change is something that can be implemented or not.

Thanks!