Newer
Older
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
from multipledispatch import dispatch
# from library.leankit.models.User import User
class CardConnection():
parents: list
children: list
def __iter__(self):
yield 'parents', self.parents
yield 'children', self.children
class CardExternalLink():
label: str
url: str
def __iter__(self):
yield 'label', self.label
yield 'url', self.url
class CardCustomField(object):
fieldId: str
value: str
def __iter__(self):
yield 'fieldId', self.fieldId
yield 'value', self.value
class Card(object):
boardId: str
title: str
typeId: str
assignedUserIds: list
description: str
size: int
laneId: str
connections: dict
mirrorSourceCardId: str
copiedFromCardId: str
blockReason: str
priority: str
customIconId: str
customId: str
externalLink: list
index: int
plannedStart: str
plannedFinish: str
tags: list
wipOverrideComment: str
customFields: list
@dispatch()
def __init__(self):
"""parameterless constructor for json deserialization support"""
pass
@dispatch(str, str)
def __init__(self, boardId: str, title: str):
self.boardId = boardId
self.title = title
def __iter__(self):
for attr_name in dir(self):
if not attr_name.startswith("__"):
print(attr_name)
yield attr_name, getattr(self, attr_name)
# @dispatch(User)
# def assign_user(self, user: User):
# self.assign_user(user.id)
@dispatch(str)
def assign_user(self, userid: str):
if userid not in self.assignedUserIds:
self.assignedUserIds.append(userid)
# @dispatch(User)
# def unassign_user(self, user: User):
# self.unassign_user(user.id)
@dispatch(str)
def unassign_user(self, userid: str):
if userid in self.assignedUserIds:
self.assignedUserIds.remove(userid)
# def card_decoder(obj):
# if 'boardId' in obj and 'title' in obj:
# new_card = Card(obj['boardId'], obj['title'])
# if 'typeId' in obj:
# new_card['typeId'] = obj['typeId']
#
# if 'assignedUserIds' in obj:
# new_card['assignedUserIds'] = obj['assignedUserIds']
#
# # TODO set others, or generate using inspection/reflection
# return new_card
# return obj
# cardObj = json.loads('{"__type__": "Card", "rollNumber":1, "name": "Ault kelly", "marks": 78}', object_hook=studentDecoder)
# {
# "boardId": "944576308",
# "title": "The title of the card",
# "typeId": "944576314",
# "assignedUserIds": [ "478440842" ],
# "description": "The card description",
# "size": 1,
# "laneId": "944576326",
# "connections": {
# "parents": ["945202295"],
# "children": ["945250930"]
# },
# "mirrorSourceCardId": "945202295",
# "copiedFromCardId": "945261794",
# "blockReason": "The block reason",
# "priority": "normal",
# "customIconId": "944576317",
# "customId": "Card header text",
# "externalLink": {
# "label": "The link label",
# "url": "https://www.leankit.com"
# },
# "index": 1,
# "plannedStart": "2020-01-20",
# "plannedFinish": "2020-02-01",
# "tags": [
# "tagOne",
# "tagTwo"
# ],
# "wipOverrideComment": "The override reason",
# "customFields": [ {
# "fieldId": "945250752",
# "value": "This is the field value"
# } ]
# }