Skip to content

Commit

Permalink
Merge pull request #32 from hassaku63/add-category-api-types
Browse files Browse the repository at this point in the history
Add type hint for category API
  • Loading branch information
hassaku63 authored Sep 3, 2023
2 parents eca3add + 2f1bd37 commit e91c5e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
24 changes: 20 additions & 4 deletions backlog/category.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from typing import List, TypedDict, NewType


class CategoryResponse(TypedDict):
id: int
projectId: int
name: str
displayOrder: int


ListCategoryResponse = NewType("ListCategoryResponse", List[CategoryResponse])
AddCategoryResponse = NewType("AddCategoryResponse", CategoryResponse)
UpdateCategoryResponse = NewType("UpdateCategoryResponse", CategoryResponse)
DeleteCategoryResponse = NewType("DeleteCategoryResponse", CategoryResponse)


class Category(object):
def __init__(self, api) -> None:
self.api = api

def list(self, projectIdOrKey: str):
def list(self, projectIdOrKey: str) -> ListCategoryResponse:
"""List categories
https://developer.nulab.com/ja/docs/backlog/api/2/get-category-list/#
Expand All @@ -16,7 +32,7 @@ def list(self, projectIdOrKey: str):

return resp.json()

def add(self, projectIdOrKey: str, name: str):
def add(self, projectIdOrKey: str, name: str) -> AddCategoryResponse:
"""Add category
https://developer.nulab.com/docs/backlog/api/2/add-category/#add-category
Expand All @@ -30,7 +46,7 @@ def add(self, projectIdOrKey: str, name: str):

return resp.json()

def update(self, projectIdOrKey: str, id: int, name: str):
def update(self, projectIdOrKey: str, id: int, name: str) -> UpdateCategoryResponse:
"""Update category
https://developer.nulab.com/docs/backlog/api/2/update-category/#
Expand All @@ -48,7 +64,7 @@ def update(self, projectIdOrKey: str, id: int, name: str):

return resp.json()

def delete(self, projectIdOrKey: str, id: int):
def delete(self, projectIdOrKey: str, id: int) -> DeleteCategoryResponse:
"""Delete category
https://developer.nulab.com/docs/backlog/api/2/delete-category/#
Expand Down

0 comments on commit e91c5e3

Please sign in to comment.