This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCategory.py
87 lines (64 loc) · 3.05 KB
/
Category.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from requests import Response
from typing import Optional
from pybacklogpy.BacklogConfigure import BacklogConfigure
from pybacklogpy.modules import RequestSender
class Category:
def __init__(self, config: Optional[BacklogConfigure] = None):
self.base_path = 'projects'
_config = config if config else None
self.rs = RequestSender(_config)
def get_category_list(self,
project_id_or_key: str,
) -> Response:
"""
カテゴリー一覧の取得
https://developer.nulab.com/ja/docs/backlog/api/2/get-category-list/
:param project_id_or_key: プロジェクトのID または プロジェクトキー
:return: レスポンス
"""
path = self.base_path + '/{project_id_or_key}/categories'.format(project_id_or_key=project_id_or_key)
return self.rs.send_get_request(path=path, url_param={})
def update_category(self,
project_id_or_key: str,
category_id: int,
name: str,
) -> Response:
"""
カテゴリー情報の更新
https://developer.nulab.com/ja/docs/backlog/api/2/update-category/
:param project_id_or_key: プロジェクトのID または プロジェクトキー
:param category_id: カテゴリーのID
:param name: カテゴリーの名前
:return: レスポンス
"""
path = self.base_path + '/{project_id_or_key}/categories/{category_id}'\
.format(project_id_or_key=project_id_or_key, category_id=category_id)
payloads = {'name': name}
return self.rs.send_patch_request(path=path, request_param=payloads)
def add_category(self,
project_id_or_key: str,
name: str,
) -> Response:
"""
カテゴリーの追加
https://developer.nulab.com/ja/docs/backlog/api/2/add-category/
:param project_id_or_key: プロジェクトのID または プロジェクトキー
:param name: カテゴリーの名前
:return: レスポンス
"""
path = self.base_path + '/{project_id_or_key}/categories'.format(project_id_or_key=project_id_or_key)
payloads = {'name': name}
return self.rs.send_post_request(path=path, request_param=payloads)
def delete_category(self,
project_id_or_key: str,
category_id: int) -> Response:
"""
カテゴリーの削除
https://developer.nulab.com/ja/docs/backlog/api/2/delete-category/
:param project_id_or_key: プロジェクトのID または プロジェクトキー
:param category_id: カテゴリーのID
:return: レスポンス
"""
path = self.base_path + '/projects/{project_id_or_key}/categories/{category_id}'\
.format(project_id_or_key=project_id_or_key, category_id=category_id)
return self.rs.send_delete_request(path=path, request_param={})