Skip to content

Users

Users

Bases: GenericRequestMethod

Class responsible to make calls to Kanbanize users endpoints

Source code in kanbanize_sdk/endpoints/users.py
 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
class Users(GenericRequestMethod):
    """
    Class responsible to make calls to Kanbanize users endpoints
    """
    endpoint = '/users'

    def list(self, params: UsersListParams | dict | None = None) -> list:
        """
        This method is responsible to list all user in the platform.

        Parameters:
            params: It's a dataclass object that provide all possible parameters to be used to list the users.

        Returns:
            An array of objects that represents the users
        """

        params = params.to_dict() if isinstance(params, UsersListParams) else params

        return self.service.get(
            self.endpoint,
            params=params
        )

    def insert(self, body: UsersInsertBody | dict) -> dict:
        """
        This method is responsible to invite a user to the platform.

        Parameters:
            body: It's a dataclass object that provide the essential request body needed to invite an user to the platform.

        Returns:
            An user object with the basic information data
        """

        payload = body.to_dict() if isinstance(body, UsersInsertBody) else body

        return self.service.post(self.endpoint, data=payload)

    def get(self, user_id: int) -> dict:
        """
        This method is responsible to get one user from the platform.

        Parameters:
            user_id: An integer parameter that represents the user identification.

        Returns:
            A searched user object
        """
        return self.service.get(self.endpoint + f'/{user_id}')

    def update(self, user_id: int, body: UsersUpdateBody | dict) -> dict:
        """
        This method is responsible to update an user in the platform.

        Parameters:
            user_id: An integer parameter that represents the user identification.
            body: It's a dataclass object that represent the body option to be updated.

        Returns:
            The updated user object
        """

        payload = body.to_dict() if isinstance(body, UsersUpdateBody) else body

        return self.service.patch(self.endpoint + f'/{user_id}', data=payload)

    def delete(self, user_id: int) -> None:
        """
        This method is responsible to remove an user from the platform.

        Parameters:
            user_id: An integer parameter that represents the user identification.

        """
        self.service.delete(self.endpoint + f'/{user_id}')

delete(user_id)

This method is responsible to remove an user from the platform.

Parameters:

Name Type Description Default
user_id int

An integer parameter that represents the user identification.

required
Source code in kanbanize_sdk/endpoints/users.py
72
73
74
75
76
77
78
79
80
def delete(self, user_id: int) -> None:
    """
    This method is responsible to remove an user from the platform.

    Parameters:
        user_id: An integer parameter that represents the user identification.

    """
    self.service.delete(self.endpoint + f'/{user_id}')

get(user_id)

This method is responsible to get one user from the platform.

Parameters:

Name Type Description Default
user_id int

An integer parameter that represents the user identification.

required

Returns:

Type Description
dict

A searched user object

Source code in kanbanize_sdk/endpoints/users.py
44
45
46
47
48
49
50
51
52
53
54
def get(self, user_id: int) -> dict:
    """
    This method is responsible to get one user from the platform.

    Parameters:
        user_id: An integer parameter that represents the user identification.

    Returns:
        A searched user object
    """
    return self.service.get(self.endpoint + f'/{user_id}')

insert(body)

This method is responsible to invite a user to the platform.

Parameters:

Name Type Description Default
body UsersInsertBody | dict

It's a dataclass object that provide the essential request body needed to invite an user to the platform.

required

Returns:

Type Description
dict

An user object with the basic information data

Source code in kanbanize_sdk/endpoints/users.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def insert(self, body: UsersInsertBody | dict) -> dict:
    """
    This method is responsible to invite a user to the platform.

    Parameters:
        body: It's a dataclass object that provide the essential request body needed to invite an user to the platform.

    Returns:
        An user object with the basic information data
    """

    payload = body.to_dict() if isinstance(body, UsersInsertBody) else body

    return self.service.post(self.endpoint, data=payload)

list(params=None)

This method is responsible to list all user in the platform.

Parameters:

Name Type Description Default
params UsersListParams | dict | None

It's a dataclass object that provide all possible parameters to be used to list the users.

None

Returns:

Type Description
list

An array of objects that represents the users

Source code in kanbanize_sdk/endpoints/users.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def list(self, params: UsersListParams | dict | None = None) -> list:
    """
    This method is responsible to list all user in the platform.

    Parameters:
        params: It's a dataclass object that provide all possible parameters to be used to list the users.

    Returns:
        An array of objects that represents the users
    """

    params = params.to_dict() if isinstance(params, UsersListParams) else params

    return self.service.get(
        self.endpoint,
        params=params
    )

update(user_id, body)

This method is responsible to update an user in the platform.

Parameters:

Name Type Description Default
user_id int

An integer parameter that represents the user identification.

required
body UsersUpdateBody | dict

It's a dataclass object that represent the body option to be updated.

required

Returns:

Type Description
dict

The updated user object

Source code in kanbanize_sdk/endpoints/users.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def update(self, user_id: int, body: UsersUpdateBody | dict) -> dict:
    """
    This method is responsible to update an user in the platform.

    Parameters:
        user_id: An integer parameter that represents the user identification.
        body: It's a dataclass object that represent the body option to be updated.

    Returns:
        The updated user object
    """

    payload = body.to_dict() if isinstance(body, UsersUpdateBody) else body

    return self.service.patch(self.endpoint + f'/{user_id}', data=payload)