Skip to content

Commit

Permalink
Merge pull request #5 from sanghunka/v1.0.0
Browse files Browse the repository at this point in the history
V1.0.0
  • Loading branch information
sanghunka authored Oct 29, 2022
2 parents e3a71f7 + 83a0f41 commit f2c6090
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 20 deletions.
6 changes: 4 additions & 2 deletions pyswit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from pyswit.workspace import Workspace
from pyswit.channel import Channel
from pyswit.message import Message
from pyswit.idea import Idea
from pyswit.project import Project
from pyswit.task import Task

__version__ = "0.0.8"
__version__ = "1.0.0"


class Pyswit:
Expand All @@ -14,7 +15,8 @@ def __init__(self, access_token: str):

self.user = User(**api_args)
self.workspace = Workspace(**api_args)
self.message = Message(**api_args)
self.channel = Channel(**api_args)
self.message = Message(**api_args)
self.idea = Idea(**api_args)
self.project = Project(**api_args)
self.task = Task(**api_args)
80 changes: 80 additions & 0 deletions pyswit/idea.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from pyswit.baseAPI import BaseAPI


class Idea(BaseAPI):
class Comment(BaseAPI):
def create(self, idea_id: str, content: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def list(self, idea_id: str, offset: str = None, limit: int = None):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def remove(self, id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

class Reaction(BaseAPI):
def create(self, idea_id: str, reaction_name: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def remove(self, idea_id: str, reaction_name: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def __init__(self, access_token: str):
super().__init__(access_token=access_token)
self.comment = self.Comment(
access_token=access_token, endpoint=self._class_name
)
self.reaction = self.Reaction(
access_token=access_token, endpoint=self._class_name
)

def create(self, channel_id: str, content: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def info(self, id: str):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def list(self, channel_id: str, offset: str = None, limit: int = None):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def remove(self, id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)
30 changes: 30 additions & 0 deletions pyswit/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,39 @@ def list(self, project_id: str, limit: int = None, offset: str = None):
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

class Bucket(BaseAPI):
def create(self, project_id: str, name: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def info(self, id: str, project_id: str):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def list(self, project_id: str, limit: int = None, offset: str = None):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def update(self, id: str, name: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def __init__(self, access_token: str):
super().__init__(access_token=access_token)
self.user = self.User(access_token=access_token, endpoint=self._class_name)
self.bucket = self.Bucket(access_token=access_token, endpoint=self._class_name)

def archive(self, id: str, archive: bool = None):
data = self.params_to_dict(locals())
Expand Down
115 changes: 115 additions & 0 deletions pyswit/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,121 @@


class Task(BaseAPI):
class Assignee(BaseAPI):
def add(self, task_id: str, user_id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def remove(self, task_id: str, user_id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

class Checklist(BaseAPI):
def create(self, task_id: str, content: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def info(self, id: str):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def list(self, task_id: str, limit: int = None, offset: str = None):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def remove(self, id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def update(self, id: str, content: str, is_complete: bool = None):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

class Comment(BaseAPI):
def create(self, task_id: str, content: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def list(self, task_id: str, limit: int = None, offset: str = None):
params = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(accept="application/json")
return self.get(url=url, headers=headers, params=params)

def remove(self, id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def update(self, id: str, content: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

class Follow(BaseAPI):
def add(self, task_id: str, user_id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def remove(self, task_id: str, user_id: str):
data = self.params_to_dict(locals())
url = self.get_endpoint_url()
headers = self.get_headers(
accept="application/json", content_type="application/json"
)
return self.post(url=url, headers=headers, data=data)

def __init__(self, access_token: str):
super().__init__(access_token=access_token)
self.assignee = self.Assignee(
access_token=access_token, endpoint=self._class_name
)
self.checklist = self.Checklist(
access_token=access_token, endpoint=self._class_name
)
self.comment = self.Comment(
access_token=access_token, endpoint=self._class_name
)
self.follow = self.Follow(access_token=access_token, endpoint=self._class_name)

def create(
self,
project_id: str,
Expand Down
47 changes: 29 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,40 @@ webhook(url=webhook_url, text="Hello, World!")
| | POST | message.reaction.create | :white_check_mark: |
| | POST | message.reaction.remove | :white_check_mark: |
| | POST | message.remove | :white_check_mark: |
| Ideas | | | |
| Ideas | POST | idea.comment.create | :white_check_mark: |
| | GET | idea.comment.list | :white_check_mark: |
| | POST | idea.comment.remove | :white_check_mark: |
| | POST | idea.create | :white_check_mark: |
| | GET | idea.info | :white_check_mark: |
| | GET | idea.list | :white_check_mark: |
| | POST | idea.remove | :white_check_mark: |
| | POST | idea.reaction.create | :white_check_mark: |
| | POST | idea.reaction.remove | :white_check_mark: |
| Projects | POST | project.archive | :white_check_mark: |
| | POST | project.create | :white_check_mark: |
| | GET | project.info | :white_check_mark: |
| | GET | project.list | :white_check_mark: |
| | GET | project.tagList | :white_check_mark: |
| | POST | project.update | :white_check_mark: |
| | GET | project.user.list | :white_check_mark: |
| Project buckets | | | |
| Tasks | POST | task.assignee.add | |
| | POST | task.asignee.remove | |
| | POST | task.checklist.create | |
| | GET | task.checklist.info | |
| | GET | task.checklist.list | |
| | POST | task.checklist.remove | |
| | POST | task.checklist.update | |
| | POST | task.comment.create | |
| | GET | task.comment.list | |
| | POST | task.comment.remove | |
| | POST | task.comment.update | |
| Project buckets | POST | project.bucket.create | :white_check_mark: |
| | GET | project.bucket.info | :white_check_mark: |
| | GET | project.bucket.list | :white_check_mark: |
| | POST | project.bucket.update | :white_check_mark: |
| Tasks | POST | task.assignee.add | :white_check_mark: |
| | POST | task.asignee.remove | :white_check_mark: |
| | POST | task.checklist.create | :white_check_mark: |
| | GET | task.checklist.info | :white_check_mark: |
| | GET | task.checklist.list | :white_check_mark: |
| | POST | task.checklist.remove | :white_check_mark: |
| | POST | task.checklist.update | :white_check_mark: |
| | POST | task.comment.create | :white_check_mark: |
| | GET | task.comment.list | :white_check_mark: |
| | POST | task.comment.remove | :white_check_mark: |
| | POST | task.comment.update | :white_check_mark: |
| | POST | task.create | :white_check_mark: |
| | POST | task.follow.add | |
| | POST | task.follow.remove | |
| | POST | task.follow.add | :white_check_mark: |
| | POST | task.follow.remove | :white_check_mark: |
| | GET | task.info | :white_check_mark: |
| | GET | task.list | :white_check_mark: |
| | GET | task.listByColumn | :white_check_mark: |
Expand All @@ -131,8 +142,8 @@ webhook(url=webhook_url, text="Hello, World!")
| | POST | task.update | :white_check_mark: |
| Posts | | | :x: |
| Boards | | | :x: |
| Custom fileds | | | |
| Approvals | | | |
| Custom fileds | | | :x: |
| Approvals | | | :x: |

- Advanced Only API: `Posts`, `Boards`
- Advanced Only API: `Posts`, `Boards`, `Custom fileds`, `Approvals`
- Pyswit has no plan to support Advanced Only API

0 comments on commit f2c6090

Please sign in to comment.