Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Add emails to objects functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lefcha committed Mar 29, 2017
1 parent a472cf6 commit 197961a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions todoist/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from todoist.managers.templates import TemplatesManager
from todoist.managers.backups import BackupsManager
from todoist.managers.quick import QuickManager
from todoist.managers.emails import EmailsManager


class SyncError(Exception):
Expand Down Expand Up @@ -82,6 +83,7 @@ def __init__(self,
self.templates = TemplatesManager(self)
self.backups = BackupsManager(self)
self.quick = QuickManager(self)
self.emails = EmailsManager(self)

if cache: # Read and write user state on local disk cache
self.cache = os.path.expanduser(cache)
Expand Down
20 changes: 20 additions & 0 deletions todoist/managers/emails.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from .generic import Manager


class EmailsManager(Manager):
def get_or_create(self, obj_type, obj_id, **kwargs):
"""
Get or create email to an object.
"""
params = {'token': self.token, 'obj_type': obj_type, 'obj_id': obj_id}
params.update(kwargs)
return self.api._get('emails/get_or_create', params=params)

def disable(self, obj_type, obj_id, **kwargs):
"""
Disable email to an object.
"""
params = {'token': self.token, 'obj_type': obj_type, 'obj_id': obj_id}
params.update(kwargs)
return self.api._get('emails/disable', params=params)

0 comments on commit 197961a

Please sign in to comment.