teambition.api.events 源代码

# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from optionaldict import optionaldict

from teambition.api.base import TeambitionAPI


[文档]class Events(TeambitionAPI):
[文档] def get(self, id=None, project_id=None): """ 获取日程 详情请参考 http://docs.teambition.com/wiki/events#events-get :param id: 可选,日程 ID :param project_id: 可选,项目 ID :return: 返回的 JSON 数据包 """ endpoint = 'api/events' if id: endpoint = 'api/events/{0}'.format(id) elif project_id: endpoint = 'api/projects/{0}/events'.format(project_id) return self._get(endpoint)
[文档] def create(self, project_id, title, start_date, end_date, location=None, status=None, reminders=None, content=None, recurrence=None, source_id=None, mode=None, visiable='members', tag_ids=None): """ 新建日程 详情请参考 http://docs.teambition.com/wiki/events#events-create :param project_id: 项目 ID :param title: 内容 :param start_date: 开始时间 :param end_date: 结束时间 :param location: 可选,地点 :param status: 可选,状态 :param reminders: 可选,提醒 :param content: 可选,备注 :param recurrence: 可选,重复日程规则列表 :param source_id: 可选,需要派生的重复日程 :param mode: 可选,新建模式,可选值为 single, after :param visiable: 可选,可见范围,默认为 members,可选 involves :param tag_ids: 可选,标签 ID 列表 :return: 返回的 JSON 数据包 """ data = optionaldict( _projectId=project_id, title=title, startDate=start_date, endDate=end_date, location=location, status=status, reminders=reminders, content=content, recurrence=recurrence, _sourceId=source_id, mode=mode, visiable=visiable, tagIds=tag_ids ) return self._post( 'api/events', data=data )
[文档] def delete(self, id): """ 删除日程 详情请参考 http://docs.teambition.com/wiki/events#events-delete :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._delete('api/events/{0}'.format(id))
[文档] def update(self, id, title=None, start_date=None, end_date=None, location=None, status=None, reminders=None, content=None): """ 更新日程 详情请参考 http://docs.teambition.com/wiki/events#events-update :param id: 日程 ID :param title: 内容 :param start_date: 开始时间 :param end_date: 结束时间 :param location: 可选,地点 :param status: 可选,状态 :param reminders: 可选,提醒 :param content: 可选,备注 """ data = optionaldict( title=title, startDate=start_date, endDate=end_date, location=location, status=status, reminders=reminders, content=content ) return self._put( 'api/events/{0}'.format(id), data=data )
[文档] def like(self, id): """ 赞日程 详情请参考 http://docs.teambition.com/wiki/events#events-like :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._post('api/events/{0}/like'.format(id))
[文档] def archive(self, id): """ 归档日程 详情请参考 http://docs.teambition.com/wiki/events#events-archive :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._post('api/events/{0}/archive'.format(id))
[文档] def unarchive(self, id): """ 取消归档日程 详情请参考 http://docs.teambition.com/wiki/events#events-unarchive :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._delete('api/events/{0}/archive'.format(id))
[文档] def update_tags(self, id, tag_ids): """ 更新日程标签 详情请参考 http://docs.teambition.com/wiki/events#events-update-tags :param id: 日程 ID :param tag_ids: 标签 ID 列表 :return: 返回的 JSON 数据包 """ return self._put( 'api/events/{0}/tagIds'.format(id), data={ 'tagIds': tag_ids } )
[文档] def get_tags(self, id): """ 获取日程标签列表 :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._get('api/events/{0}/tags'.format(id))
[文档] def remove_tag(self, id, tag_id): """ 移除标签 :param id: 日程 ID :param tag_id: 标签 ID :return: 返回的 JSON 数据包 """ return self._delete('api/events/{0}/tags/{1}'.format(id, tag_id))
[文档] def add_tag(self, id, tag_id): """ 关联标签 :param id: 日程 ID :param tag_id: 标签 ID :return: 返回的 JSON 数据包 """ return self._put('api/events/{0}/tags/{1}'.format(id, tag_id))
[文档] def link_post(self, id, linked_id): """ 关联分享 :param id: 任务 ID :param linked_id: 关联分享 ID :return: 返回的 JSON 数据包 """ return self.create_objectlink(id, linked_id, 'post')
[文档] def get_activities(self, id): """ 获取日程动态 :param id: 日程 ID :return: 返回的 JSON 数据包 """ return self._get( 'api/activities', params={'_boundToObjectId': id} )
[文档] def like_repeat_event(self, id, timestamp): """ 点赞重复日程 :param id: 日程 ID :param timestamp: 时间戳 :return: 返回的 JSON 数据包 """ return self._post( 'api/events/{0}/like_repeat_event'.format(id), data={ 'timestamp': timestamp } )
[文档] def comments_repeat_event(self, id, content, timestamp, attachments=None, mentions=None): """ 评论重复日程 :param id: 日程 ID :param content: 评论内容 :param timestamp: 时间戳 :param attachments: 可选,work(文件)ID列表 :param mentions: 可选,提及 :return: 返回的 JSON 数据包 """ data = optionaldict( content=content, timestamp=timestamp, attachments=attachments, mentions=mentions ) return self._post( 'api/events/{0}/comments_repeat_event'.format(id), data=data )