67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
from datetime import datetime
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
import requests
|
|
|
|
from . import _BASE_URL, _headers, _with_token
|
|
|
|
|
|
@_with_token
|
|
def get(token: str) -> List[Dict[str, Any]]:
|
|
r = requests.get(f'{_BASE_URL}/projects', headers=_headers(token))
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_project(project_id: int, token: str) -> Dict[str, Any]:
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}',
|
|
headers=_headers(token))
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_stories(project_id: int, token: str) -> List[Dict[str, Any]]:
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}/stories',
|
|
headers=_headers(token))
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_memberships(project_id: int, token: str) -> List[Dict[str, Any]]:
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}/memberships',
|
|
headers=_headers(token))
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_iterations(project_id: int, scope: str, token: str) \
|
|
-> List[Dict[str, Any]]:
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}/iterations',
|
|
headers=_headers(token), params={'scope': scope})
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_story_transitions(str, project_id: int, token: str,
|
|
after: Optional[datetime] = None,
|
|
before: Optional[datetime] = None) \
|
|
-> List[Dict[str, Any]]:
|
|
parameters = {}
|
|
if after:
|
|
parameters['occurred_after'] = after.isoformat()
|
|
if before:
|
|
parameters['occurred_before'] = before.isoformat()
|
|
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}/story_transitions',
|
|
headers=_headers(token), params=parameters)
|
|
return r.json()
|
|
|
|
|
|
@_with_token
|
|
def get_history_days(project_id: int, start: datetime, token: str) \
|
|
-> Dict[str, Any]:
|
|
r = requests.get(f'{_BASE_URL}/projects/{project_id}/history/days',
|
|
headers=_headers(token),
|
|
params={'start_date': start.isoformat()})
|
|
return r.json()
|