Skip to content

Card

Bases: Card_

Source code in src/plankapy/interfaces.py
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
class Card(Card_):

    @property 
    def _included(self) -> JSONHandler.JSONResponse:
        route = self.routes.get_card(id=self.id)
        return route()['included']


    @property
    def creator(self) -> User:
        """User that created the card

        Returns:
            User: Creator of the card
        """
        user_route = self.routes.get_user(id=self.creatorUserId)
        return User(**user_route()['item']).bind(self.routes)

    @property
    def board(self) -> Board:
        """Board the card belongs to

        Returns:
            Board: Board instance
        """
        board_route = self.routes.get_board(id=self.boardId)
        return Board(**board_route()['item']).bind(self.routes)

    @property
    def list(self) -> List:
        """List the card belongs to

        Returns:
            List: List instance
        """
        for list in self.board.lists:
            if list.id == self.listId:
                return list

    @property
    def labels(self) -> QueryableList[Label]:
        """All labels on the card

        Returns:
            Queryable List of all labels on the card
        """
        return QueryableList([
            cardLabel.label
            for cardLabel in self.board.cardLabels
            if cardLabel.cardId == self.id
        ])

    @property
    def members(self) -> QueryableList[User]:
        """All users assigned to the card

        Returns:
            Queryable List of all users assigned to the card
        """
        return QueryableList([
            cardMembership.user
            for cardMembership in self.board.cardMemberships
            if cardMembership.cardId == self.id
        ])

    @property
    def comments(self) -> QueryableList[Action]:
        """All comments on the card

        Returns:
            Queryable List of all comments on the card
        """
        route = self.routes.get_action_index(cardId=self.id)
        return QueryableList([
            Action(**action).bind(self.routes)
            for action in route()['items']
        ])

    @property
    def tasks(self) -> QueryableList[Task]:
        """All tasks on the card

        Returns:
            Queryable List of all tasks on the card
        """
        return QueryableList([
            task
            for task in self.board.tasks
            if task.cardId == self.id
        ])

    @property
    def attachments(self) -> QueryableList[Attachment]:
        """All attachments on the card

        Returns:
            Queryable List of all attachments on the card
        """
        return QueryableList(
            Attachment(**attachment).bind(self.routes)
            for attachment in self._included['attachments'])

    @property
    def due_date(self) -> datetime | None:
        """Due date of the card in datetime format

        Note:
            The `dueDate` attribute is stored as an ISO 8601 string, this property will return
            the due date as a python datetime object

        Returns:
            Due date of the card
        """
        return datetime.fromisoformat(self.dueDate) if self.dueDate else None

    def move(self, list: List) -> Card:
        """Moves the card to a new list

        Args:
            list (List): List instance to move the card to

        Returns:
            Card: The moved card instance
        """
        self.listId = list.id
        self.boardId = list.boardId
        self.update()
        return self

    def duplicate(self) -> Card:
        """Duplicates the card

        Note:
            Duplicating a card will always insert it one slot below the original card

        Returns:
            Card: The duplicated card instance
        """
        route = self.routes.post_duplicate_card(id=self.id)
        return Card(**route(**self)['item']).bind(self.routes)

    # Not currently working without a file upload endpoint
    # For this to work, we'd need to take the attacment data, post it to the filesystem,
    # Then take the response object and dumb those values (url, coverUrl) into a new
    # Attachment object then post it to the card using the `post_attachment(cardId)` route
    def add_attachment(self, file_path: Path) -> Attachment:
        """Adds an attachment to the card

        Args:
            attachment (Path | <url>): Attachment instance to add (can be a file path or url)

        Returns:
            Attachment: New attachment instance
        """
        route = self.routes.post_attachment(cardId=self.id)
        return Attachment(**route(_file=file_path)['item']).bind(self.routes)

    def add_label(self, label: Label) -> CardLabel:
        """Adds a label to the card

        Args:
            label (Label): Label instance to add

        Returns:
            CardLabel: New card label instance
        """
        route = self.routes.post_card_label(cardId=self.id)
        return CardLabel(**route(labelId=label.id, cardId=self.id)['item']).bind(self.routes)

    def add_member(self, user: User) -> CardMembership:
        """Adds a user to the card

        Args:
            user (User): User instance to add

        Returns:
            CardMembership: New card membership instance
        """
        route = self.routes.post_card_membership(cardId=self.id)
        return CardMembership(**route(userId=user.id, cardId=self.id)['item']).bind(self.routes)

    def add_comment(self, comment: str) -> Action:
        """Adds a comment to the card

        Note:
            Comments can only be added by the authenticated user, all comments made
            through plankapy will be attributed to the user in `planka.me`

        Args:
            comment (str): Comment to add

        Returns:
            Action: New comment action instance
        """
        route = self.routes.post_comment_action(cardId=self.id)        
        return Action(**route(text=comment, cardId=self.id)['item']).bind(self.routes)

    @overload
    def add_task(self, task: Task) -> Task: ...

    @overload
    def add_task(self, name: str, position: int=0, 
                 isCompleted: bool=False, isDeleted: bool=False) -> Task: ...

    def add_task(self, *args, **kwargs) -> Task:
        """Adds a task to the card

        Args:
            name (str): Name of the task (required)
            position (int): Position of the task (default: 0)
            isCompleted (bool): Whether the task is completed (default: False)
            isDeleted (bool): Whether the task is deleted (default: False)

        Args: Alternate
            task (Task): Task instance to create

        Returns:
            Task: New task instance
        """
        overload = parse_overload(
            args, kwargs, 
            model='task', 
            options=('name', 'position', 'isCompleted', 'isDeleted'), 
            required=('name',)) # Only name requires user provided value

        route = self.routes.post_task(cardId=self.id)

        # Required arguments with defaults must be manually assigned
        overload['position'] = overload.get('position', 0)
        overload['isCompleted'] = overload.get('isCompleted', False)
        overload['isDeleted'] = overload.get('isDeleted', False)

        return Task(**route(**overload)['item']).bind(self.routes)

    def add_stopwatch(self) -> Stopwatch:
        """Adds a stopwatch to the card if there is not one already

        Warning:
            The stopwatch stored in the Card instance dictionary is actually a dictionary
            that is used to update the stopwatch on Planka. When you access the stopwatch
            attribute with `card.stopwatch`, a `Stopwatch` instance is generated. This is
            an implementation detail to keep the stopwatch interface separate from the Card
            interface.

            Example:
                ```python
                >>> card.add_stopwatch()
                >>> card.stopwatch
                Stopwatch(startedAt=None, total=0)

                >>> card.__dict__['stopwatch']
                {'startedAt': None, 'total': 0}

                >>> card.stopwatch.start()
                >>> card.stopwatch
                Stopwatch(startedAt=datetime.datetime(2024, 9, 30, 0, 0, 0), total=0)

                >>> card.__dict__['stopwatch']
                {'startedAt': '2024-9-30T00:00:00Z', 'total': 0}
                ```

        Returns:
            Stopwatch: A stopwatch instance used to track time on the card
        """
        self.refresh()

        if not self.stopwatch:
            with self.editor():
                self.stopwatch = {**Stopwatch(startedAt=None, total=0).stop()}
        return self.stopwatch

    def remove_attachment(self, attachment: Attachment) -> Attachment | None:
        """Removes an attachment from the card

        Args:
            attachment (Attachment): Attachment instance to remove

        Note:
            This method will remove the attachment from the card, but the attachment itself will not be deleted

        Returns:
            Card: The card instance with the attachment removed
        """
        for card_attachment in self.attachments:
            if card_attachment.id == attachment.id:
                return card_attachment.delete()
        return None

    def remove_label(self, label: Label) -> Card:
        """Removes a label from the card

        Args:
            label (Label): Label instance to remove

        Note:
            This method will remove the label from the card, but the label itself will not be deleted

        Returns:
            Card: The card instance with the label removed   
        """
        for card_label in self.board.cardLabels:
            if card_label.cardId == self.id and card_label.labelId == label.id:
                card_label.delete()
        return self

    def remove_member(self, user: User) -> Card:
        """Removes a user from the card

        Args:
            user (User): User instance to remove

        Note:
            This method will remove the user from the card, but the user itself will not be deleted

        Returns:
            Card: The card instance with the user removed
        """
        for card_membership in self.board.cardMemberships:
            if card_membership.cardId == self.id and card_membership.userId == user.id:
                card_membership.delete()
        return self

    def remove_comment(self, comment_action: Action) -> Card:
        """Pass a comment from self.comments to remove it

        Args:
            comment_action (Action): Comment instance to remove

        Note:
            This method will remove the comment from the card, but the comment itself will not be deleted

        Returns:
            Card: The card instance with the comment removed
        """
        for comment in self.comments:
            if comment.id == comment_action.id:
                comment.delete()
        return self

    def remove_stopwatch(self) -> Stopwatch:
        """Removes the stopwatch from the card

        Returns:
            Stopwatch: The stopwatch instance that was removed
        """
        self.refresh()
        with self.editor():
            _stopwatch = self.stopwatch
            self.stopwatch = None
        return _stopwatch

    # Stopwatch handling is a bit weird, this is a hacky override to always show the user a Stopwatch instance
    def __getattribute__(self, name):
        if name == 'stopwatch':
            current = super().__getattribute__(name)
            if not current:
                current = {'startedAt':None, 'total':0}
            return Stopwatch(_card=self, **current)
        return super().__getattribute__(name)

    def __setattr__(self, name, value):
        if name == 'stopwatch' and isinstance(value, Stopwatch):
            super().__setattr__(name, dict(value))
        else:
            super().__setattr__(name, value)

    def set_due_date(self, due_date: datetime  | None) -> Card:
        """Sets the due date of the card

        Args:
            dueDate (datetime): Due date of the card (None to remove)

        Returns:
            Card: The card instance with the due date set
        """
        with self.editor():
            self.dueDate = due_date.isoformat() if due_date else None
        return self

    @overload
    def update(self) -> Card: ...

    @overload
    def update(self, card: Card) -> Card: ...

    @overload
    def update(self, name: str, position: int=0, 
                    description: str=None, dueDate: datetime=None,
                    isDueDateCompleted: bool=None,
                    stopwatch: Stopwatch=None, boardId: int=None,
                    listId: int=None, creatorUserId: int=None,
                    coverAttachmentId: int=None, isSubscribed: bool=None) -> Card: ...

    def update(self, *args, **kwargs) -> Card:
        """Updates the card with new values

        Tip:
            It's recommended to use a `card.editor()` context manager to update the card

            Example:
            ```python
            >>> with card.editor():
            ...    card.name='New Name'

            >>> card
            Card(name='New Name', ...)
            ``

        Args:
            name (str): Name of the card (optional)
            position (int): Position of the card (optional)
            description (str): Description of the card (optional)
            dueDate (datetime): Due date of the card (optional)
            isDueDateCompleted (bool): Whether the due date is completed (optional)
            stopwatch (Stopwatch): Stopwatch of the card (optional)
            boardId (int): Board id of the card (optional)
            listId (int): List id of the card (optional)
            creatorUserId (int): Creator user id of the card (optional)
            coverAttachmentId (int): Cover attachment id of the card (optional)
            isSubscribed (bool): Whether the card is subscribed (optional)

        Args: Alternate
            card (Card): Card instance to update (required)

        Note:
            If no arguments are provided, the card will update itself with the current values stored in its attributes

        Returns:
            Card: Updated card instance
        """
        overload = parse_overload(
            args, kwargs, 
            model='card', 
            options=('name', 'position', 'description', 'dueDate', 
                    'isDueDateCompleted', 'stopwatch', 
                    'creatorUserId', 'coverAttachmentId', 
                    'isSubscribed'), 
            noarg=self)

        route = self.routes.patch_card(id=self.id)
        self.__init__(**route(**overload)['item'])
        return self

    def delete(self) -> Card:
        """Deletes the card

        Danger:
            This action is irreversible and cannot be undone

        Returns:
            Card: The deleted card instance
        """
        self.refresh()
        route = self.routes.delete_card(id=self.id)
        route()
        return self

    def refresh(self):
        """Refreshes the card data

        Note:
            This method is used to update the card instance with the latest data from the server
        """
        route = self.routes.get_card(id=self.id)
        self.__init__(**route()['item'])

attachments property

All attachments on the card

Returns:

Type Description
QueryableList[Attachment]

Queryable List of all attachments on the card

board property

Board the card belongs to

Returns:

Name Type Description
Board Board

Board instance

comments property

All comments on the card

Returns:

Type Description
QueryableList[Action]

Queryable List of all comments on the card

creator property

User that created the card

Returns:

Name Type Description
User User

Creator of the card

due_date property

Due date of the card in datetime format

Note

The dueDate attribute is stored as an ISO 8601 string, this property will return the due date as a python datetime object

Returns:

Type Description
datetime | None

Due date of the card

labels property

All labels on the card

Returns:

Type Description
QueryableList[Label]

Queryable List of all labels on the card

list property

List the card belongs to

Returns:

Name Type Description
List List

List instance

members property

All users assigned to the card

Returns:

Type Description
QueryableList[User]

Queryable List of all users assigned to the card

tasks property

All tasks on the card

Returns:

Type Description
QueryableList[Task]

Queryable List of all tasks on the card

add_attachment(file_path)

Adds an attachment to the card

Parameters:

Name Type Description Default
attachment Path | <url>

Attachment instance to add (can be a file path or url)

required

Returns:

Name Type Description
Attachment Attachment

New attachment instance

Source code in src/plankapy/interfaces.py
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
def add_attachment(self, file_path: Path) -> Attachment:
    """Adds an attachment to the card

    Args:
        attachment (Path | <url>): Attachment instance to add (can be a file path or url)

    Returns:
        Attachment: New attachment instance
    """
    route = self.routes.post_attachment(cardId=self.id)
    return Attachment(**route(_file=file_path)['item']).bind(self.routes)

add_comment(comment)

Adds a comment to the card

Note

Comments can only be added by the authenticated user, all comments made through plankapy will be attributed to the user in planka.me

Parameters:

Name Type Description Default
comment str

Comment to add

required

Returns:

Name Type Description
Action Action

New comment action instance

Source code in src/plankapy/interfaces.py
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
def add_comment(self, comment: str) -> Action:
    """Adds a comment to the card

    Note:
        Comments can only be added by the authenticated user, all comments made
        through plankapy will be attributed to the user in `planka.me`

    Args:
        comment (str): Comment to add

    Returns:
        Action: New comment action instance
    """
    route = self.routes.post_comment_action(cardId=self.id)        
    return Action(**route(text=comment, cardId=self.id)['item']).bind(self.routes)

add_label(label)

Adds a label to the card

Parameters:

Name Type Description Default
label Label

Label instance to add

required

Returns:

Name Type Description
CardLabel CardLabel

New card label instance

Source code in src/plankapy/interfaces.py
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
def add_label(self, label: Label) -> CardLabel:
    """Adds a label to the card

    Args:
        label (Label): Label instance to add

    Returns:
        CardLabel: New card label instance
    """
    route = self.routes.post_card_label(cardId=self.id)
    return CardLabel(**route(labelId=label.id, cardId=self.id)['item']).bind(self.routes)

add_member(user)

Adds a user to the card

Parameters:

Name Type Description Default
user User

User instance to add

required

Returns:

Name Type Description
CardMembership CardMembership

New card membership instance

Source code in src/plankapy/interfaces.py
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
def add_member(self, user: User) -> CardMembership:
    """Adds a user to the card

    Args:
        user (User): User instance to add

    Returns:
        CardMembership: New card membership instance
    """
    route = self.routes.post_card_membership(cardId=self.id)
    return CardMembership(**route(userId=user.id, cardId=self.id)['item']).bind(self.routes)

add_stopwatch()

Adds a stopwatch to the card if there is not one already

Warning

The stopwatch stored in the Card instance dictionary is actually a dictionary that is used to update the stopwatch on Planka. When you access the stopwatch attribute with card.stopwatch, a Stopwatch instance is generated. This is an implementation detail to keep the stopwatch interface separate from the Card interface.

Example:

>>> card.add_stopwatch()
>>> card.stopwatch
Stopwatch(startedAt=None, total=0)

>>> card.__dict__['stopwatch']
{'startedAt': None, 'total': 0}

>>> card.stopwatch.start()
>>> card.stopwatch
Stopwatch(startedAt=datetime.datetime(2024, 9, 30, 0, 0, 0), total=0)

>>> card.__dict__['stopwatch']
{'startedAt': '2024-9-30T00:00:00Z', 'total': 0}

Returns:

Name Type Description
Stopwatch Stopwatch

A stopwatch instance used to track time on the card

Source code in src/plankapy/interfaces.py
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
def add_stopwatch(self) -> Stopwatch:
    """Adds a stopwatch to the card if there is not one already

    Warning:
        The stopwatch stored in the Card instance dictionary is actually a dictionary
        that is used to update the stopwatch on Planka. When you access the stopwatch
        attribute with `card.stopwatch`, a `Stopwatch` instance is generated. This is
        an implementation detail to keep the stopwatch interface separate from the Card
        interface.

        Example:
            ```python
            >>> card.add_stopwatch()
            >>> card.stopwatch
            Stopwatch(startedAt=None, total=0)

            >>> card.__dict__['stopwatch']
            {'startedAt': None, 'total': 0}

            >>> card.stopwatch.start()
            >>> card.stopwatch
            Stopwatch(startedAt=datetime.datetime(2024, 9, 30, 0, 0, 0), total=0)

            >>> card.__dict__['stopwatch']
            {'startedAt': '2024-9-30T00:00:00Z', 'total': 0}
            ```

    Returns:
        Stopwatch: A stopwatch instance used to track time on the card
    """
    self.refresh()

    if not self.stopwatch:
        with self.editor():
            self.stopwatch = {**Stopwatch(startedAt=None, total=0).stop()}
    return self.stopwatch

add_task(*args, **kwargs)

add_task(task: Task) -> Task
add_task(name: str, position: int = 0, isCompleted: bool = False, isDeleted: bool = False) -> Task

Adds a task to the card

Parameters:

Name Type Description Default
name str

Name of the task (required)

required
position int

Position of the task (default: 0)

required
isCompleted bool

Whether the task is completed (default: False)

required
isDeleted bool

Whether the task is deleted (default: False)

required

Alternate

Name Type Description Default
task Task

Task instance to create

required

Returns:

Name Type Description
Task Task

New task instance

Source code in src/plankapy/interfaces.py
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
def add_task(self, *args, **kwargs) -> Task:
    """Adds a task to the card

    Args:
        name (str): Name of the task (required)
        position (int): Position of the task (default: 0)
        isCompleted (bool): Whether the task is completed (default: False)
        isDeleted (bool): Whether the task is deleted (default: False)

    Args: Alternate
        task (Task): Task instance to create

    Returns:
        Task: New task instance
    """
    overload = parse_overload(
        args, kwargs, 
        model='task', 
        options=('name', 'position', 'isCompleted', 'isDeleted'), 
        required=('name',)) # Only name requires user provided value

    route = self.routes.post_task(cardId=self.id)

    # Required arguments with defaults must be manually assigned
    overload['position'] = overload.get('position', 0)
    overload['isCompleted'] = overload.get('isCompleted', False)
    overload['isDeleted'] = overload.get('isDeleted', False)

    return Task(**route(**overload)['item']).bind(self.routes)

delete()

Deletes the card

Danger

This action is irreversible and cannot be undone

Returns:

Name Type Description
Card Card

The deleted card instance

Source code in src/plankapy/interfaces.py
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
def delete(self) -> Card:
    """Deletes the card

    Danger:
        This action is irreversible and cannot be undone

    Returns:
        Card: The deleted card instance
    """
    self.refresh()
    route = self.routes.delete_card(id=self.id)
    route()
    return self

duplicate()

Duplicates the card

Note

Duplicating a card will always insert it one slot below the original card

Returns:

Name Type Description
Card Card

The duplicated card instance

Source code in src/plankapy/interfaces.py
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
def duplicate(self) -> Card:
    """Duplicates the card

    Note:
        Duplicating a card will always insert it one slot below the original card

    Returns:
        Card: The duplicated card instance
    """
    route = self.routes.post_duplicate_card(id=self.id)
    return Card(**route(**self)['item']).bind(self.routes)

move(list)

Moves the card to a new list

Parameters:

Name Type Description Default
list List

List instance to move the card to

required

Returns:

Name Type Description
Card Card

The moved card instance

Source code in src/plankapy/interfaces.py
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
def move(self, list: List) -> Card:
    """Moves the card to a new list

    Args:
        list (List): List instance to move the card to

    Returns:
        Card: The moved card instance
    """
    self.listId = list.id
    self.boardId = list.boardId
    self.update()
    return self

refresh()

Refreshes the card data

Note

This method is used to update the card instance with the latest data from the server

Source code in src/plankapy/interfaces.py
2239
2240
2241
2242
2243
2244
2245
2246
def refresh(self):
    """Refreshes the card data

    Note:
        This method is used to update the card instance with the latest data from the server
    """
    route = self.routes.get_card(id=self.id)
    self.__init__(**route()['item'])

remove_attachment(attachment)

Removes an attachment from the card

Parameters:

Name Type Description Default
attachment Attachment

Attachment instance to remove

required
Note

This method will remove the attachment from the card, but the attachment itself will not be deleted

Returns:

Name Type Description
Card Attachment | None

The card instance with the attachment removed

Source code in src/plankapy/interfaces.py
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
def remove_attachment(self, attachment: Attachment) -> Attachment | None:
    """Removes an attachment from the card

    Args:
        attachment (Attachment): Attachment instance to remove

    Note:
        This method will remove the attachment from the card, but the attachment itself will not be deleted

    Returns:
        Card: The card instance with the attachment removed
    """
    for card_attachment in self.attachments:
        if card_attachment.id == attachment.id:
            return card_attachment.delete()
    return None

remove_comment(comment_action)

Pass a comment from self.comments to remove it

Parameters:

Name Type Description Default
comment_action Action

Comment instance to remove

required
Note

This method will remove the comment from the card, but the comment itself will not be deleted

Returns:

Name Type Description
Card Card

The card instance with the comment removed

Source code in src/plankapy/interfaces.py
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
def remove_comment(self, comment_action: Action) -> Card:
    """Pass a comment from self.comments to remove it

    Args:
        comment_action (Action): Comment instance to remove

    Note:
        This method will remove the comment from the card, but the comment itself will not be deleted

    Returns:
        Card: The card instance with the comment removed
    """
    for comment in self.comments:
        if comment.id == comment_action.id:
            comment.delete()
    return self

remove_label(label)

Removes a label from the card

Parameters:

Name Type Description Default
label Label

Label instance to remove

required
Note

This method will remove the label from the card, but the label itself will not be deleted

Returns:

Name Type Description
Card Card

The card instance with the label removed

Source code in src/plankapy/interfaces.py
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
def remove_label(self, label: Label) -> Card:
    """Removes a label from the card

    Args:
        label (Label): Label instance to remove

    Note:
        This method will remove the label from the card, but the label itself will not be deleted

    Returns:
        Card: The card instance with the label removed   
    """
    for card_label in self.board.cardLabels:
        if card_label.cardId == self.id and card_label.labelId == label.id:
            card_label.delete()
    return self

remove_member(user)

Removes a user from the card

Parameters:

Name Type Description Default
user User

User instance to remove

required
Note

This method will remove the user from the card, but the user itself will not be deleted

Returns:

Name Type Description
Card Card

The card instance with the user removed

Source code in src/plankapy/interfaces.py
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
def remove_member(self, user: User) -> Card:
    """Removes a user from the card

    Args:
        user (User): User instance to remove

    Note:
        This method will remove the user from the card, but the user itself will not be deleted

    Returns:
        Card: The card instance with the user removed
    """
    for card_membership in self.board.cardMemberships:
        if card_membership.cardId == self.id and card_membership.userId == user.id:
            card_membership.delete()
    return self

remove_stopwatch()

Removes the stopwatch from the card

Returns:

Name Type Description
Stopwatch Stopwatch

The stopwatch instance that was removed

Source code in src/plankapy/interfaces.py
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
def remove_stopwatch(self) -> Stopwatch:
    """Removes the stopwatch from the card

    Returns:
        Stopwatch: The stopwatch instance that was removed
    """
    self.refresh()
    with self.editor():
        _stopwatch = self.stopwatch
        self.stopwatch = None
    return _stopwatch

set_due_date(due_date)

Sets the due date of the card

Parameters:

Name Type Description Default
dueDate datetime

Due date of the card (None to remove)

required

Returns:

Name Type Description
Card Card

The card instance with the due date set

Source code in src/plankapy/interfaces.py
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
def set_due_date(self, due_date: datetime  | None) -> Card:
    """Sets the due date of the card

    Args:
        dueDate (datetime): Due date of the card (None to remove)

    Returns:
        Card: The card instance with the due date set
    """
    with self.editor():
        self.dueDate = due_date.isoformat() if due_date else None
    return self

update(*args, **kwargs)

update() -> Card
update(card: Card) -> Card
update(name: str, position: int = 0, description: str = None, dueDate: datetime = None, isDueDateCompleted: bool = None, stopwatch: Stopwatch = None, boardId: int = None, listId: int = None, creatorUserId: int = None, coverAttachmentId: int = None, isSubscribed: bool = None) -> Card

Updates the card with new values

Tip

It's recommended to use a card.editor() context manager to update the card

Example: ```python

with card.editor(): ... card.name='New Name'

card Card(name='New Name', ...) ``

Parameters:

Name Type Description Default
name str

Name of the card (optional)

required
position int

Position of the card (optional)

required
description str

Description of the card (optional)

required
dueDate datetime

Due date of the card (optional)

required
isDueDateCompleted bool

Whether the due date is completed (optional)

required
stopwatch Stopwatch

Stopwatch of the card (optional)

required
boardId int

Board id of the card (optional)

required
listId int

List id of the card (optional)

required
creatorUserId int

Creator user id of the card (optional)

required
coverAttachmentId int

Cover attachment id of the card (optional)

required
isSubscribed bool

Whether the card is subscribed (optional)

required

Alternate

Name Type Description Default
card Card

Card instance to update (required)

required
Note

If no arguments are provided, the card will update itself with the current values stored in its attributes

Returns:

Name Type Description
Card Card

Updated card instance

Source code in src/plankapy/interfaces.py
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
def update(self, *args, **kwargs) -> Card:
    """Updates the card with new values

    Tip:
        It's recommended to use a `card.editor()` context manager to update the card

        Example:
        ```python
        >>> with card.editor():
        ...    card.name='New Name'

        >>> card
        Card(name='New Name', ...)
        ``

    Args:
        name (str): Name of the card (optional)
        position (int): Position of the card (optional)
        description (str): Description of the card (optional)
        dueDate (datetime): Due date of the card (optional)
        isDueDateCompleted (bool): Whether the due date is completed (optional)
        stopwatch (Stopwatch): Stopwatch of the card (optional)
        boardId (int): Board id of the card (optional)
        listId (int): List id of the card (optional)
        creatorUserId (int): Creator user id of the card (optional)
        coverAttachmentId (int): Cover attachment id of the card (optional)
        isSubscribed (bool): Whether the card is subscribed (optional)

    Args: Alternate
        card (Card): Card instance to update (required)

    Note:
        If no arguments are provided, the card will update itself with the current values stored in its attributes

    Returns:
        Card: Updated card instance
    """
    overload = parse_overload(
        args, kwargs, 
        model='card', 
        options=('name', 'position', 'description', 'dueDate', 
                'isDueDateCompleted', 'stopwatch', 
                'creatorUserId', 'coverAttachmentId', 
                'isSubscribed'), 
        noarg=self)

    route = self.routes.patch_card(id=self.id)
    self.__init__(**route(**overload)['item'])
    return self