-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c15da4
commit 557156e
Showing
7 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/pyconnectwise/endpoints/change_request/UserIdEndpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint | ||
from pyconnectwise.interfaces import IGettable | ||
from pyconnectwise.models.change_request import ChangeRequestMsg, UserIdMsg, UserIdObject | ||
from pyconnectwise.types import JSON, ConnectWiseManageRequestParams | ||
|
||
if TYPE_CHECKING: | ||
from pyconnectwise.clients.connectwise_client import ConnectWiseClient | ||
|
||
|
||
class UserIdEndpoint( | ||
ConnectWiseEndpoint, | ||
IGettable[list[ChangeRequestMsg], ConnectWiseManageRequestParams], | ||
): | ||
def __init__(self, client: "ConnectWiseClient", parent_endpoint: ConnectWiseEndpoint = None) -> None: | ||
ConnectWiseEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) | ||
IGettable.__init__(self, list[ChangeRequestMsg]) | ||
|
||
def get(self, data: JSON | None = None, params: ConnectWiseManageRequestParams | None = None) -> UserIdMsg: | ||
""" | ||
Performs a GET request against the /api/change_requests endpoint. | ||
Parameters: | ||
data (dict[str, Any]): The data to send in the request body. | ||
params (dict[str, int | str]): The parameters to send in the request query string. | ||
Returns: | ||
list[ChangeRequestMsg]: The parsed response data. | ||
""" | ||
obj = self._parse_one(UserIdObject, super()._make_request("GET", data=data, params=params).json()) | ||
return obj.msg |
42 changes: 42 additions & 0 deletions
42
src/pyconnectwise/endpoints/change_request/UsersEndpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint | ||
from pyconnectwise.endpoints.change_request.UserIdEndpoint import UserIdEndpoint | ||
from pyconnectwise.interfaces import IGettable | ||
from pyconnectwise.models.change_request import ChangeRequestMsg, ChangeTypeData, UserIdMsg | ||
from pyconnectwise.types import JSON, ConnectWiseManageRequestParams | ||
|
||
if TYPE_CHECKING: | ||
from pyconnectwise.clients.connectwise_client import ConnectWiseClient | ||
|
||
|
||
class UsersEndpoint( | ||
ConnectWiseEndpoint, | ||
IGettable[list[ChangeRequestMsg], ConnectWiseManageRequestParams], | ||
): | ||
def __init__(self, client: "ConnectWiseClient", parent_endpoint: ConnectWiseEndpoint = None) -> None: | ||
ConnectWiseEndpoint.__init__(self, client, "users", parent_endpoint=parent_endpoint) | ||
IGettable.__init__(self, list[ChangeTypeData]) | ||
|
||
# TODO - Handle paginated? | ||
|
||
# TODO - Figure out if there are other endpoints! | ||
# TODO - Handle the fact that the TLD is different! | ||
|
||
def id(self, _id: str) -> UserIdEndpoint: | ||
child = UserIdEndpoint(self.client, parent_endpoint=self) | ||
child._id = _id | ||
return child | ||
|
||
def get(self, data: JSON | None = None, params: ConnectWiseManageRequestParams | None = None) -> list[UserIdMsg]: | ||
""" | ||
Performs a GET request against the /api/change_requests endpoint. | ||
Parameters: | ||
data (dict[str, Any]): The data to send in the request body. | ||
params (dict[str, int | str]): The parameters to send in the request query string. | ||
Returns: | ||
list[ChangeTypeData]: The parsed response data. | ||
""" | ||
# TODO - Throw out the msg total, current information | ||
return self._parse_many(UserIdMsg, super()._make_request("GET", data=data, params=params).json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters