예제 #1
0
    def __init__(self,
                 token='',
                 api_endpoint='https://api.todoist.com',
                 session=None):
        self.api_endpoint = api_endpoint
        self.reset_state()
        self.token = token  # User's API token
        self.temp_ids = {}  # Mapping of temporary ids to real ids
        self.queue = []  # Requests to be sent are appended here
        self.session = session or requests.Session(
        )  # Session instance for requests

        # managers
        self.projects = ProjectsManager(self)
        self.project_notes = ProjectNotesManager(self)
        self.items = ItemsManager(self)
        self.labels = LabelsManager(self)
        self.filters = FiltersManager(self)
        self.notes = NotesManager(self)
        self.live_notifications = LiveNotificationsManager(self)
        self.reminders = RemindersManager(self)
        self.locations = LocationsManager(self)
        self.invitations = InvitationsManager(self)
        self.biz_invitations = BizInvitationsManager(self)
        self.user = UserManager(self)
        self.collaborators = CollaboratorsManager(self)
        self.collaborator_states = CollaboratorStatesManager(self)
예제 #2
0
    def __init__(self,
                 token='',
                 api_endpoint='https://api.todoist.com',
                 session=None):
        self.api_endpoint = api_endpoint
        self.seq_no = 0  # Sequence number since last update
        self.seq_no_partial = {}  # Sequence number of partial syncs
        self.seq_no_global = 0  # Global sequence number since last update
        self.seq_no_global_partial = {
        }  # Global sequence number of partial syncs
        self.state = {  # Local copy of all of the user's objects
            'CollaboratorStates': [],
            'Collaborators': [],
            'DayOrders': {},
            'DayOrdersTimestamp': '',
            'Filters': [],
            'Items': [],
            'Labels': [],
            'LiveNotifications': [],
            'LiveNotificationsLastRead': -1,
            'Locations': [],
            'Notes': [],
            'ProjectNotes': [],
            'Projects': [],
            'Reminders': [],
            'Settings': {},
            'SettingsNotifications': {},
            'User': {},
            'UserId': -1,
            'WebStaticVersion': -1,
        }
        self.token = token  # User's API token
        self.temp_ids = {}  # Mapping of temporary ids to real ids
        self.queue = []  # Requests to be sent are appended here
        self.session = session or requests.Session(
        )  # Session instance for requests

        # managers
        self.projects = ProjectsManager(self)
        self.project_notes = ProjectNotesManager(self)
        self.items = ItemsManager(self)
        self.labels = LabelsManager(self)
        self.filters = FiltersManager(self)
        self.notes = NotesManager(self)
        self.live_notifications = LiveNotificationsManager(self)
        self.reminders = RemindersManager(self)
        self.locations = LocationsManager(self)
        self.invitations = InvitationsManager(self)
        self.biz_invitations = BizInvitationsManager(self)
        self.user = UserManager(self)
        self.collaborators = CollaboratorsManager(self)
        self.collaborator_states = CollaboratorStatesManager(self)
예제 #3
0
파일: api.py 프로젝트: bschulz01/TaskBoard
    def __init__(
        self,
        token="",
        api_endpoint="https://api.todoist.com",
        api_version=DEFAULT_API_VERSION,
        session=None,
        cache="~/.todoist-sync/",
    ):
        self.api_endpoint = api_endpoint
        self.api_version = api_version
        self.reset_state()
        self.token = token  # User's API token
        self.temp_ids = {}  # Mapping of temporary ids to real ids
        self.queue = []  # Requests to be sent are appended here
        self.session = session or requests.Session(
        )  # Session instance for requests

        # managers
        self.biz_invitations = BizInvitationsManager(self)
        self.collaborators = CollaboratorsManager(self)
        self.collaborator_states = CollaboratorStatesManager(self)
        self.filters = FiltersManager(self)
        self.invitations = InvitationsManager(self)
        self.items = ItemsManager(self)
        self.labels = LabelsManager(self)
        self.live_notifications = LiveNotificationsManager(self)
        self.locations = LocationsManager(self)
        self.notes = NotesManager(self)
        self.projects = ProjectsManager(self)
        self.project_notes = ProjectNotesManager(self)
        self.reminders = RemindersManager(self)
        self.sections = SectionsManager(self)
        self.user = UserManager(self)
        self.user_settings = UserSettingsManager(self)

        self.activity = ActivityManager(self)
        self.backups = BackupsManager(self)
        self.business_users = BusinessUsersManager(self)
        self.completed = CompletedManager(self)
        self.emails = EmailsManager(self)
        self.quick = QuickManager(self)
        self.templates = TemplatesManager(self)
        self.uploads = UploadsManager(self)

        self.items_archive = ItemsArchiveManagerMaker(self)
        self.sections_archive = SectionsArchiveManagerMaker(self)

        if cache:  # Read and write user state on local disk cache
            self.cache = os.path.expanduser(cache)
            self._read_cache()
        else:
            self.cache = None