From c63b4e53f5d844fbdc3c2a247f8e76c6320484bb Mon Sep 17 00:00:00 2001 From: Peter Annabel Date: Wed, 30 Jul 2025 18:42:07 -0500 Subject: [PATCH] Implemented endpoints --- .gitignore | 1 + src/pysimplesat/clients/simplesat_client.py | 62 ++++++------- .../endpoints/siem/AgentsIdEndpoint.py | 72 ---------------- .../siem/BillingreportsIdEndpoint.py | 72 ---------------- .../siem/IncidentreportsIdEndpoint.py | 72 ---------------- .../endpoints/siem/ReportsIdEndpoint.py | 72 ---------------- .../endpoints/siem/SignalsIdEndpoint.py | 72 ---------------- .../endpoints/simplesat/AccountEndpoint.py | 37 -------- .../endpoints/simplesat/ActorEndpoint.py | 37 -------- .../endpoints/simplesat/AgentsEndpoint.py | 86 ------------------- .../endpoints/simplesat/AgentsIdEndpoint.py | 72 ---------------- .../endpoints/simplesat/AnswersEndpoint.py | 24 ++++++ .../endpoints/simplesat/AnswersIdEndpoint.py | 59 +++++++++++++ .../simplesat/AnswersSearchEndpoint.py | 32 +++++++ .../simplesat/BillingreportsEndpoint.py | 86 ------------------- .../simplesat/BillingreportsIdEndpoint.py | 72 ---------------- .../simplesat/CustomersBulkEndpoint.py | 31 +++++++ .../endpoints/simplesat/CustomersEndpoint.py | 46 ++++++++++ .../simplesat/CustomersIdEndpoint.py | 59 +++++++++++++ .../simplesat/IncidentreportsEndpoint.py | 86 ------------------- .../simplesat/IncidentreportsIdEndpoint.py | 72 ---------------- .../simplesat/OrganizationsEndpoint.py | 86 ------------------- .../QuestionsEndpoint.py} | 23 ++--- .../endpoints/simplesat/ReportsEndpoint.py | 86 ------------------- .../endpoints/simplesat/ReportsIdEndpoint.py | 72 ---------------- .../ResponsesCreateOrUpdateEndpoint.py | 31 +++++++ .../endpoints/simplesat/ResponsesEndpoint.py | 26 ++++++ ...nsIdEndpoint.py => ResponsesIdEndpoint.py} | 16 ++-- .../ResponsesIdUpdateEndpoint.py} | 24 +++--- .../simplesat/ResponsesSearchEndpoint.py | 32 +++++++ .../endpoints/simplesat/SignalsEndpoint.py | 86 ------------------- .../endpoints/simplesat/SignalsIdEndpoint.py | 72 ---------------- .../endpoints/simplesat/SurveysEndpoint.py | 52 +++++++++++ .../simplesat/SurveysIdEmailEndpoint.py | 31 +++++++ .../endpoints/simplesat/SurveysIdEndpoint.py | 10 +++ .../simplesat/TeamMembersEndpoint.py | 44 ++++++++++ .../TeamMembersIdEndpoint.py} | 16 ++-- src/pysimplesat/models/simplesat/__init__.py | 17 +++- 38 files changed, 558 insertions(+), 1388 deletions(-) delete mode 100644 src/pysimplesat/endpoints/siem/AgentsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/siem/BillingreportsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/siem/IncidentreportsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/siem/ReportsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/siem/SignalsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/AccountEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/ActorEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/AgentsEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/AgentsIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/BillingreportsEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/BillingreportsIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/IncidentreportsEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/IncidentreportsIdEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/OrganizationsEndpoint.py rename src/pysimplesat/endpoints/{siem/AccountEndpoint.py => simplesat/QuestionsEndpoint.py} (58%) delete mode 100644 src/pysimplesat/endpoints/simplesat/ReportsEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/ReportsIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/ResponsesCreateOrUpdateEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py rename src/pysimplesat/endpoints/simplesat/{OrganizationsIdEndpoint.py => ResponsesIdEndpoint.py} (71%) rename src/pysimplesat/endpoints/{siem/ActorEndpoint.py => simplesat/ResponsesIdUpdateEndpoint.py} (55%) create mode 100644 src/pysimplesat/endpoints/simplesat/ResponsesSearchEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/SignalsEndpoint.py delete mode 100644 src/pysimplesat/endpoints/simplesat/SignalsIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/SurveysIdEmailEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py create mode 100644 src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py rename src/pysimplesat/endpoints/{siem/OrganizationsIdEndpoint.py => simplesat/TeamMembersIdEndpoint.py} (71%) diff --git a/.gitignore b/.gitignore index b7faf40..6b0f26a 100644 --- a/.gitignore +++ b/.gitignore @@ -205,3 +205,4 @@ cython_debug/ marimo/_static/ marimo/_lsp/ __marimo__/ +src/simplesat_scratchpad.py diff --git a/src/pysimplesat/clients/simplesat_client.py b/src/pysimplesat/clients/simplesat_client.py index b34c16b..83e3af5 100644 --- a/src/pysimplesat/clients/simplesat_client.py +++ b/src/pysimplesat/clients/simplesat_client.py @@ -1,19 +1,16 @@ import typing from datetime import datetime, timezone -import base64 from pysimplesat.clients.base_client import SimpleSatClient from pysimplesat.config import Config if typing.TYPE_CHECKING: - from pysimplesat.endpoints.simplesat.AccountEndpoint import AccountEndpoint - from pysimplesat.endpoints.simplesat.ActorEndpoint import ActorEndpoint - from pysimplesat.endpoints.simplesat.AgentsEndpoint import AgentsEndpoint - from pysimplesat.endpoints.simplesat.BillingreportsEndpoint import BillingreportsEndpoint - from pysimplesat.endpoints.simplesat.IncidentreportsEndpoint import IncidentreportsEndpoint - from pysimplesat.endpoints.simplesat.OrganizationsEndpoint import OrganizationsEndpoint - from pysimplesat.endpoints.simplesat.ReportsEndpoint import ReportsEndpoint - from pysimplesat.endpoints.simplesat.SignalsEndpoint import SignalsEndpoint + from pysimplesat.endpoints.simplesat.SurveysEndpoint import SurveysEndpoint + from pysimplesat.endpoints.simplesat.AnswersEndpoint import AnswersEndpoint + from pysimplesat.endpoints.simplesat.CustomersEndpoint import CustomersEndpoint + from pysimplesat.endpoints.simplesat.QuestionsEndpoint import QuestionsEndpoint + from pysimplesat.endpoints.simplesat.TeamMembersEndpoint import TeamMembersEndpoint + from pysimplesat.endpoints.simplesat.ResponsesEndpoint import ResponsesEndpoint class SimpleSatAPIClient(SimpleSatClient): @@ -37,52 +34,41 @@ class SimpleSatAPIClient(SimpleSatClient): # Initializing endpoints @property - def account(self) -> "AccountEndpoint": - from pysimplesat.endpoints.simplesat.AccountEndpoint import AccountEndpoint + def surveys(self) -> "SurveysEndpoint": + from pysimplesat.endpoints.simplesat.SurveysEndpoint import SurveysEndpoint - return AccountEndpoint(self) + return SurveysEndpoint(self) @property - def actor(self) -> "ActorEndpoint": - from pysimplesat.endpoints.simplesat.ActorEndpoint import ActorEndpoint + def answers(self) -> "AnswersEndpoint": + from pysimplesat.endpoints.simplesat.AnswersEndpoint import AnswersEndpoint - return ActorEndpoint(self) + return AnswersEndpoint(self) @property - def agents(self) -> "AgentsEndpoint": - from pysimplesat.endpoints.simplesat.AgentsEndpoint import AgentsEndpoint + def customers(self) -> "CustomersEndpoint": + from pysimplesat.endpoints.simplesat.CustomersEndpoint import CustomersEndpoint - return AgentsEndpoint(self) + return CustomersEndpoint(self) @property - def billing_reports(self) -> "BillingreportsEndpoint": - from pysimplesat.endpoints.simplesat.BillingreportsEndpoint import BillingreportsEndpoint + def questions(self) -> "QuestionsEndpoint": + from pysimplesat.endpoints.simplesat.QuestionsEndpoint import QuestionsEndpoint - return BillingreportsEndpoint(self) + return QuestionsEndpoint(self) @property - def incident_reports(self) -> "IncidentreportsEndpoint": - from pysimplesat.endpoints.simplesat.IncidentreportsEndpoint import IncidentreportsEndpoint + def team_members(self) -> "TeamMembersEndpoint": + from pysimplesat.endpoints.simplesat.TeamMembersEndpoint import TeamMembersEndpoint - return IncidentreportsEndpoint(self) + return TeamMembersEndpoint(self) @property - def organizations(self) -> "OrganizationsEndpoint": - from pysimplesat.endpoints.simplesat.OrganizationsEndpoint import OrganizationsEndpoint + def responses(self) -> "ResponsesEndpoint": + from pysimplesat.endpoints.simplesat.ResponsesEndpoint import ResponsesEndpoint - return OrganizationsEndpoint(self) + return ResponsesEndpoint(self) - @property - def reports(self) -> "ReportsEndpoint": - from pysimplesat.endpoints.simplesat.ReportsEndpoint import ReportsEndpoint - - return ReportsEndpoint(self) - - @property - def signals(self) -> "SignalsEndpoint": - from pysimplesat.endpoints.simplesat.SignalsEndpoint import SignalsEndpoint - - return SignalsEndpoint(self) def _get_url(self) -> str: """ diff --git a/src/pysimplesat/endpoints/siem/AgentsIdEndpoint.py b/src/pysimplesat/endpoints/siem/AgentsIdEndpoint.py deleted file mode 100644 index 3b4bb54..0000000 --- a/src/pysimplesat/endpoints/siem/AgentsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Agents -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class AgentsIdEndpoint( - SimpleSatEndpoint, - IGettable[Agents, SimpleSatRequestParams], - IPaginateable[Agents, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Agents) - IPaginateable.__init__(self, Agents) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Agents]: - """ - Performs a GET request against the /agents endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Agents]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Agents, - self, - "agents", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Agents: - """ - Performs a GET request against the /agents 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Agents, - super()._make_request("GET", data=data, params=params).json().get('agent', {}), - ) diff --git a/src/pysimplesat/endpoints/siem/BillingreportsIdEndpoint.py b/src/pysimplesat/endpoints/siem/BillingreportsIdEndpoint.py deleted file mode 100644 index 9fc9775..0000000 --- a/src/pysimplesat/endpoints/siem/BillingreportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import BillingReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class BillingIdreportsEndpoint( - SimpleSatEndpoint, - IGettable[BillingReports, SimpleSatRequestParams], - IPaginateable[BillingReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, BillingReports) - IPaginateable.__init__(self, BillingReports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[BillingReports]: - """ - Performs a GET request against the /billing_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[BillingReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - BillingReports, - self, - "billing_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> BillingReports: - """ - Performs a GET request against the /billing_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - BillingReports, - super()._make_request("GET", data=data, params=params).json().get('billing_report', {}), - ) diff --git a/src/pysimplesat/endpoints/siem/IncidentreportsIdEndpoint.py b/src/pysimplesat/endpoints/siem/IncidentreportsIdEndpoint.py deleted file mode 100644 index 5a3c3f0..0000000 --- a/src/pysimplesat/endpoints/siem/IncidentreportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import IncidentReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class IncidentreportsIdEndpoint( - SimpleSatEndpoint, - IGettable[IncidentReports, SimpleSatRequestParams], - IPaginateable[IncidentReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, IncidentReports) - IPaginateable.__init__(self, IncidentReports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[IncidentReports]: - """ - Performs a GET request against the /incident_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[IncidentReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - IncidentReports, - self, - "incident_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> IncidentReports: - """ - Performs a GET request against the /incident_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - IncidentReports, - super()._make_request("GET", data=data, params=params).json().get('incident_report', {}), - ) diff --git a/src/pysimplesat/endpoints/siem/ReportsIdEndpoint.py b/src/pysimplesat/endpoints/siem/ReportsIdEndpoint.py deleted file mode 100644 index 97f59da..0000000 --- a/src/pysimplesat/endpoints/siem/ReportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Reports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class ReportsIdEndpoint( - SimpleSatEndpoint, - IGettable[Reports, SimpleSatRequestParams], - IPaginateable[Reports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Reports) - IPaginateable.__init__(self, Reports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Reports]: - """ - Performs a GET request against the /reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Reports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Reports, - self, - "reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Reports: - """ - Performs a GET request against the /reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Reports, - super()._make_request("GET", data=data, params=params).json().get('report', {}), - ) diff --git a/src/pysimplesat/endpoints/siem/SignalsIdEndpoint.py b/src/pysimplesat/endpoints/siem/SignalsIdEndpoint.py deleted file mode 100644 index e3075e7..0000000 --- a/src/pysimplesat/endpoints/siem/SignalsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Signals -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class SignalsIdEndpoint( - SimpleSatEndpoint, - IGettable[Signals, SimpleSatRequestParams], - IPaginateable[Signals, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Signals) - IPaginateable.__init__(self, Signals) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Signals]: - """ - Performs a GET request against the /signals endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Signals]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Signals, - self, - "signals", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Signals: - """ - Performs a GET request against the /signals 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Signals, - super()._make_request("GET", data=data, params=params).json().get('signal', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/AccountEndpoint.py b/src/pysimplesat/endpoints/simplesat/AccountEndpoint.py deleted file mode 100644 index 034e9fe..0000000 --- a/src/pysimplesat/endpoints/simplesat/AccountEndpoint.py +++ /dev/null @@ -1,37 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import BaseEndpoint -from pysimplesat.interfaces import ( - IGettable, -) -from pysimplesat.models.simplesat import Account -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class AccountEndpoint( - SimpleSatEndpoint, - IGettable[Account, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "account", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Account) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Account: - """ - Performs a GET request against the /account 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Account, - super()._make_request("GET", data=data, params=params).json().get('account', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/ActorEndpoint.py b/src/pysimplesat/endpoints/simplesat/ActorEndpoint.py deleted file mode 100644 index 7c841c7..0000000 --- a/src/pysimplesat/endpoints/simplesat/ActorEndpoint.py +++ /dev/null @@ -1,37 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, -) -from pysimplesat.models.simplesat import ActorResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class ActorEndpoint( - SimpleSatEndpoint, - IGettable[ActorResponse, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "actor", parent_endpoint=parent_endpoint) - IGettable.__init__(self, ActorResponse) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> ActorResponse: - """ - Performs a GET request against the /Actor 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - ActorResponse, - super()._make_request("GET", data=data, params=params).json(), - ) diff --git a/src/pysimplesat/endpoints/simplesat/AgentsEndpoint.py b/src/pysimplesat/endpoints/simplesat/AgentsEndpoint.py deleted file mode 100644 index 2ed7914..0000000 --- a/src/pysimplesat/endpoints/simplesat/AgentsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.AgentsIdEndpoint import AgentsIdEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Agents -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class AgentsEndpoint( - SimpleSatEndpoint, - IGettable[Agents, SimpleSatRequestParams], - IPaginateable[Agents, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "agents", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Agents) - IPaginateable.__init__(self, Agents) - - def id(self, id: int) -> AgentsIdEndpoint: - """ - Sets the ID for this endpoint and returns an initialized AgentsIdEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - AgentsIdEndpoint: The initialized AgentsIdEndpoint object. - """ - child = AgentsIdEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Agents]: - """ - Performs a GET request against the /agents endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Agents]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Agents, - self, - "agents", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Agents: - """ - Performs a GET request against the /agents 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - Agents, - super()._make_request("GET", data=data, params=params).json().get('agents', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/AgentsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/AgentsIdEndpoint.py deleted file mode 100644 index 3b4bb54..0000000 --- a/src/pysimplesat/endpoints/simplesat/AgentsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Agents -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class AgentsIdEndpoint( - SimpleSatEndpoint, - IGettable[Agents, SimpleSatRequestParams], - IPaginateable[Agents, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Agents) - IPaginateable.__init__(self, Agents) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Agents]: - """ - Performs a GET request against the /agents endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Agents]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Agents, - self, - "agents", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Agents: - """ - Performs a GET request against the /agents 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Agents, - super()._make_request("GET", data=data, params=params).json().get('agent', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py b/src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py new file mode 100644 index 0000000..4d3311a --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py @@ -0,0 +1,24 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.AnswersIdEndpoint import AnswersIdEndpoint +from pysimplesat.endpoints.simplesat.AnswersSearchEndpoint import AnswersSearchEndpoint + + +class AnswersEndpoint( + SimpleSatEndpoint, +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "answers", parent_endpoint=parent_endpoint) + self.search = self._register_child_endpoint(AnswersSearchEndpoint(client, parent_endpoint=self)) + + def id(self, id: int) -> AnswersIdEndpoint: + """ + Sets the ID for this endpoint and returns an initialized AnswersIdEndpoint object to move down the chain. + + Parameters: + id (int): The ID to set. + Returns: + AnswersIdEndpoint: The initialized AnswersIdEndpoint object. + """ + child = AnswersIdEndpoint(self.client, parent_endpoint=self) + child._id = id + return child diff --git a/src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py new file mode 100644 index 0000000..d119800 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py @@ -0,0 +1,59 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IGettable, + IPuttable +) +from pysimplesat.models.simplesat import Answer +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class AnswersIdEndpoint( + SimpleSatEndpoint, + IGettable[Answer, SimpleSatRequestParams], + IPuttable[Answer, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) + IGettable.__init__(self, Answer) + IPuttable.__init__(self, Answer) + + def get( + self, + data: JSON | None = None, + params: SimpleSatRequestParams | None = None, + ) -> Answer: + """ + Performs a GET request against the /answers/{id} 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: + AuthInformation: The parsed response data. + """ + return self._parse_one( + Answer, + super()._make_request("GET", data=data, params=params).json(), + ) + + def put( + self, + data: JSON | None = None, + params: SimpleSatRequestParams | None = None, + ) -> Answer: + """ + Performs a PUT request against the /answers/{id} 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: + Answer: The parsed response data. + """ + return self._parse_one( + Answer, + super()._make_request("PUT", data=data, params=params).json(), + ) diff --git a/src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py b/src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py new file mode 100644 index 0000000..c9371c3 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py @@ -0,0 +1,32 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import Answer +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class AnswersSearchEndpoint( + SimpleSatEndpoint, + IPostable[Answer, SimpleSatRequestParams], + +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "search", parent_endpoint=parent_endpoint) + IPostable.__init__(self, Answer) + + #TODO: How do I paginate a post? + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> Answer: + """ + Performs a POST request against the /answers/search 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: + Survey: The parsed response data. + """ + return self._parse_many(Answer, super()._make_request("POST", data=data, params=params).json().get('answers', {})) diff --git a/src/pysimplesat/endpoints/simplesat/BillingreportsEndpoint.py b/src/pysimplesat/endpoints/simplesat/BillingreportsEndpoint.py deleted file mode 100644 index 9ed9509..0000000 --- a/src/pysimplesat/endpoints/simplesat/BillingreportsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.BillingreportsIdEndpoint import BillingIdreportsEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import BillingReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class BillingreportsEndpoint( - SimpleSatEndpoint, - IGettable[BillingReports, SimpleSatRequestParams], - IPaginateable[BillingReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "billing_reports", parent_endpoint=parent_endpoint) - IGettable.__init__(self, BillingReports) - IPaginateable.__init__(self, BillingReports) - - def id(self, id: int) -> BillingIdreportsEndpoint: - """ - Sets the ID for this endpoint and returns an initialized BillingIdreportsEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - BillingIdreportsEndpoint: The initialized BillingIdreportsEndpoint object. - """ - child = BillingIdreportsEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[BillingReports]: - """ - Performs a GET request against the /billing_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[BillingReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - BillingReports, - self, - "billing_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> BillingReports: - """ - Performs a GET request against the /billing_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - BillingReports, - super()._make_request("GET", data=data, params=params).json().get('billing_reports', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/BillingreportsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/BillingreportsIdEndpoint.py deleted file mode 100644 index 9fc9775..0000000 --- a/src/pysimplesat/endpoints/simplesat/BillingreportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import BillingReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class BillingIdreportsEndpoint( - SimpleSatEndpoint, - IGettable[BillingReports, SimpleSatRequestParams], - IPaginateable[BillingReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, BillingReports) - IPaginateable.__init__(self, BillingReports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[BillingReports]: - """ - Performs a GET request against the /billing_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[BillingReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - BillingReports, - self, - "billing_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> BillingReports: - """ - Performs a GET request against the /billing_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - BillingReports, - super()._make_request("GET", data=data, params=params).json().get('billing_report', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py b/src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py new file mode 100644 index 0000000..7923cb5 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py @@ -0,0 +1,31 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import CustomerBulk +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class CustomersBulkEndpoint( + SimpleSatEndpoint, + IPostable[CustomerBulk, SimpleSatRequestParams], + +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "bulk", parent_endpoint=parent_endpoint) + IPostable.__init__(self, CustomerBulk) + + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> CustomerBulk: + """ + Performs a POST request against the /customers/bulk 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: + Survey: The parsed response data. + """ + return self._parse_one(CustomerBulk, super()._make_request("POST", data=data, params=params).json()) diff --git a/src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py b/src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py new file mode 100644 index 0000000..ddb11b7 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py @@ -0,0 +1,46 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.CustomersIdEndpoint import CustomersIdEndpoint +from pysimplesat.endpoints.simplesat.CustomersBulkEndpoint import CustomersBulkEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import Customer +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class CustomersEndpoint( + SimpleSatEndpoint, + IPostable[Customer, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "customers", parent_endpoint=parent_endpoint) + IPostable.__init__(self, Customer) + self.bulk = self._register_child_endpoint(CustomersBulkEndpoint(client, parent_endpoint=self)) + + def id(self, id: int) -> CustomersIdEndpoint: + """ + Sets the ID for this endpoint and returns an initialized CustomersIdEndpoint object to move down the chain. + + Parameters: + id (int): The ID to set. + Returns: + CustomersIdEndpoint: The initialized CustomersIdEndpoint object. + """ + child = CustomersIdEndpoint(self.client, parent_endpoint=self) + child._id = id + return child + + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> Customer: + """ + Performs a POST request against the /customers 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: + Customer: The parsed response data. + """ + return self._parse_one(Customer, super()._make_request("POST", data=data, params=params).json()) diff --git a/src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py new file mode 100644 index 0000000..725246c --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py @@ -0,0 +1,59 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IGettable, + IPuttable +) +from pysimplesat.models.simplesat import Customer +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class CustomersIdEndpoint( + SimpleSatEndpoint, + IGettable[Customer, SimpleSatRequestParams], + IPuttable[Customer, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) + IGettable.__init__(self, Customer) + IPuttable.__init__(self, Customer) + + def get( + self, + data: JSON | None = None, + params: SimpleSatRequestParams | None = None, + ) -> Customer: + """ + Performs a GET request against the /customers/{id} 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: + AuthInformation: The parsed response data. + """ + return self._parse_one( + Customer, + super()._make_request("GET", data=data, params=params).json(), + ) + + def put( + self, + data: JSON | None = None, + params: SimpleSatRequestParams | None = None, + ) -> Customer: + """ + Performs a PUT request against the /customers/{id} 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: + Customer: The parsed response data. + """ + return self._parse_one( + Customer, + super()._make_request("PUT", data=data, params=params).json(), + ) diff --git a/src/pysimplesat/endpoints/simplesat/IncidentreportsEndpoint.py b/src/pysimplesat/endpoints/simplesat/IncidentreportsEndpoint.py deleted file mode 100644 index c15af96..0000000 --- a/src/pysimplesat/endpoints/simplesat/IncidentreportsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.IncidentreportsIdEndpoint import IncidentreportsIdEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import IncidentReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class IncidentreportsEndpoint( - SimpleSatEndpoint, - IGettable[IncidentReports, SimpleSatRequestParams], - IPaginateable[IncidentReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "incident_reports", parent_endpoint=parent_endpoint) - IGettable.__init__(self, IncidentReports) - IPaginateable.__init__(self, IncidentReports) - - def id(self, id: int) -> IncidentreportsIdEndpoint: - """ - Sets the ID for this endpoint and returns an initialized IncidentreportsIdEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - IncidentreportsIdEndpoint: The initialized IncidentreportsIdEndpoint object. - """ - child = IncidentreportsIdEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[IncidentReports]: - """ - Performs a GET request against the /incident_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[IncidentReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - IncidentReports, - self, - "incident_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> IncidentReports: - """ - Performs a GET request against the /incident_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - IncidentReports, - super()._make_request("GET", data=data, params=params).json().get('incident_reports', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/IncidentreportsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/IncidentreportsIdEndpoint.py deleted file mode 100644 index 5a3c3f0..0000000 --- a/src/pysimplesat/endpoints/simplesat/IncidentreportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import IncidentReports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class IncidentreportsIdEndpoint( - SimpleSatEndpoint, - IGettable[IncidentReports, SimpleSatRequestParams], - IPaginateable[IncidentReports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, IncidentReports) - IPaginateable.__init__(self, IncidentReports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[IncidentReports]: - """ - Performs a GET request against the /incident_reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[IncidentReports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - IncidentReports, - self, - "incident_reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> IncidentReports: - """ - Performs a GET request against the /incident_reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - IncidentReports, - super()._make_request("GET", data=data, params=params).json().get('incident_report', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/OrganizationsEndpoint.py b/src/pysimplesat/endpoints/simplesat/OrganizationsEndpoint.py deleted file mode 100644 index 643b00c..0000000 --- a/src/pysimplesat/endpoints/simplesat/OrganizationsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.OrganizationsIdEndpoint import OrganizationsIdEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Organizations -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class OrganizationsEndpoint( - SimpleSatEndpoint, - IGettable[Organizations, SimpleSatRequestParams], - IPaginateable[Organizations, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "organizations", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Organizations) - IPaginateable.__init__(self, Organizations) - - def id(self, id: int) -> OrganizationsIdEndpoint: - """ - Sets the ID for this endpoint and returns an initialized OrganizationsIdEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - OrganizationsIdEndpoint: The initialized OrganizationsIdEndpoint object. - """ - child = OrganizationsIdEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Organizations]: - """ - Performs a GET request against the /organizations endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Organizations]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Organizations, - self, - "organizations", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Organizations: - """ - Performs a GET request against the /Organizations 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - Organizations, - super()._make_request("GET", data=data, params=params).json().get('organizations', {}), - ) diff --git a/src/pysimplesat/endpoints/siem/AccountEndpoint.py b/src/pysimplesat/endpoints/simplesat/QuestionsEndpoint.py similarity index 58% rename from src/pysimplesat/endpoints/siem/AccountEndpoint.py rename to src/pysimplesat/endpoints/simplesat/QuestionsEndpoint.py index 542e2f9..a5ae50b 100644 --- a/src/pysimplesat/endpoints/siem/AccountEndpoint.py +++ b/src/pysimplesat/endpoints/simplesat/QuestionsEndpoint.py @@ -2,36 +2,37 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint from pysimplesat.interfaces import ( IGettable, ) -from pysimplesat.models.simplesat import Account +from pysimplesat.models.simplesat import Question from pysimplesat.types import ( JSON, SimpleSatRequestParams, ) -class AccountEndpoint( +class QuestionsEndpoint( SimpleSatEndpoint, - IGettable[Account, SimpleSatRequestParams], + IGettable[Question, SimpleSatRequestParams], ): def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "account", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Account) + SimpleSatEndpoint.__init__(self, client, "questions", parent_endpoint=parent_endpoint) + IGettable.__init__(self, Question) def get( self, data: JSON | None = None, params: SimpleSatRequestParams | None = None, - ) -> Account: + ) -> Question: """ - Performs a GET request against the /account endpoint. + Performs a GET request against the /questions 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: - AuthInformation: The parsed response data. + Question: The parsed response data. """ - return self._parse_one( - Account, - super()._make_request("GET", data=data, params=params).json().get('account', {}), + print("get") + return self._parse_many( + Question, + super()._make_request("GET", data=data, params=params).json().get('questions', {}), ) diff --git a/src/pysimplesat/endpoints/simplesat/ReportsEndpoint.py b/src/pysimplesat/endpoints/simplesat/ReportsEndpoint.py deleted file mode 100644 index d0b4439..0000000 --- a/src/pysimplesat/endpoints/simplesat/ReportsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.ReportsIdEndpoint import ReportsIdEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Reports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class ReportsEndpoint( - SimpleSatEndpoint, - IGettable[Reports, SimpleSatRequestParams], - IPaginateable[Reports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "reports", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Reports) - IPaginateable.__init__(self, Reports) - - def id(self, id: int) -> ReportsIdEndpoint: - """ - Sets the ID for this endpoint and returns an initialized ReportsIdEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - ReportsIdEndpoint: The initialized ReportsIdEndpoint object. - """ - child = ReportsIdEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Reports]: - """ - Performs a GET request against the /reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Reports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Reports, - self, - "reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Reports: - """ - Performs a GET request against the /reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - Reports, - super()._make_request("GET", data=data, params=params).json().get('reports', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/ReportsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/ReportsIdEndpoint.py deleted file mode 100644 index 97f59da..0000000 --- a/src/pysimplesat/endpoints/simplesat/ReportsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Reports -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class ReportsIdEndpoint( - SimpleSatEndpoint, - IGettable[Reports, SimpleSatRequestParams], - IPaginateable[Reports, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Reports) - IPaginateable.__init__(self, Reports) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Reports]: - """ - Performs a GET request against the /reports endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Reports]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Reports, - self, - "reports", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Reports: - """ - Performs a GET request against the /reports 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Reports, - super()._make_request("GET", data=data, params=params).json().get('report', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/ResponsesCreateOrUpdateEndpoint.py b/src/pysimplesat/endpoints/simplesat/ResponsesCreateOrUpdateEndpoint.py new file mode 100644 index 0000000..8d2665e --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/ResponsesCreateOrUpdateEndpoint.py @@ -0,0 +1,31 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import Response +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class ResponsesCreateOrUpdateEndpoint( + SimpleSatEndpoint, + IPostable[Response, SimpleSatRequestParams], + +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "create-or-update", parent_endpoint=parent_endpoint) + IPostable.__init__(self, Response) + + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> Response: + """ + Performs a POST request against the /responses/create-or-update 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: + Survey: The parsed response data. + """ + return self._parse_one(Response, super()._make_request("POST", data=data, params=params).json()) diff --git a/src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py b/src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py new file mode 100644 index 0000000..5ab1416 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py @@ -0,0 +1,26 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.ResponsesIdEndpoint import ResponsesIdEndpoint +from pysimplesat.endpoints.simplesat.ResponsesSearchEndpoint import ResponsesSearchEndpoint +from pysimplesat.endpoints.simplesat.ResponsesCreateOrUpdateEndpoint import ResponsesCreateOrUpdateEndpoint + + +class ResponsesEndpoint( + SimpleSatEndpoint, +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "responses", parent_endpoint=parent_endpoint) + self.search = self._register_child_endpoint(ResponsesSearchEndpoint(client, parent_endpoint=self)) + self.createorupdate = self._register_child_endpoint(ResponsesCreateOrUpdateEndpoint(client, parent_endpoint=self)) + + def id(self, id: int) -> ResponsesIdEndpoint: + """ + Sets the ID for this endpoint and returns an initialized ResponsesIdEndpoint object to move down the chain. + + Parameters: + id (int): The ID to set. + Returns: + ResponsesIdEndpoint: The initialized ResponsesIdEndpoint object. + """ + child = ResponsesIdEndpoint(self.client, parent_endpoint=self) + child._id = id + return child diff --git a/src/pysimplesat/endpoints/simplesat/OrganizationsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/ResponsesIdEndpoint.py similarity index 71% rename from src/pysimplesat/endpoints/simplesat/OrganizationsIdEndpoint.py rename to src/pysimplesat/endpoints/simplesat/ResponsesIdEndpoint.py index 19b480a..ed990fa 100644 --- a/src/pysimplesat/endpoints/simplesat/OrganizationsIdEndpoint.py +++ b/src/pysimplesat/endpoints/simplesat/ResponsesIdEndpoint.py @@ -2,28 +2,28 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint from pysimplesat.interfaces import ( IGettable, ) -from pysimplesat.models.simplesat import Organizations +from pysimplesat.models.simplesat import Response from pysimplesat.types import ( JSON, SimpleSatRequestParams, ) -class OrganizationsIdEndpoint( +class ResponsesIdEndpoint( SimpleSatEndpoint, - IGettable[Organizations, SimpleSatRequestParams], + IGettable[Response, SimpleSatRequestParams], ): def __init__(self, client, parent_endpoint=None) -> None: SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Organizations) + IGettable.__init__(self, Response) def get( self, data: JSON | None = None, params: SimpleSatRequestParams | None = None, - ) -> Organizations: + ) -> Response: """ - Performs a GET request against the /organizations/{id} endpoint. + Performs a GET request against the /responses/{id} endpoint. Parameters: data (dict[str, Any]): The data to send in the request body. @@ -32,6 +32,6 @@ class OrganizationsIdEndpoint( AuthInformation: The parsed response data. """ return self._parse_one( - Organizations, - super()._make_request("GET", data=data, params=params).json().get('organization', {}), + Response, + super()._make_request("GET", data=data, params=params).json(), ) diff --git a/src/pysimplesat/endpoints/siem/ActorEndpoint.py b/src/pysimplesat/endpoints/simplesat/ResponsesIdUpdateEndpoint.py similarity index 55% rename from src/pysimplesat/endpoints/siem/ActorEndpoint.py rename to src/pysimplesat/endpoints/simplesat/ResponsesIdUpdateEndpoint.py index 7c841c7..aa1a31f 100644 --- a/src/pysimplesat/endpoints/siem/ActorEndpoint.py +++ b/src/pysimplesat/endpoints/simplesat/ResponsesIdUpdateEndpoint.py @@ -1,37 +1,37 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint from pysimplesat.interfaces import ( - IGettable, + IPuttable, ) -from pysimplesat.models.simplesat import ActorResponse +from pysimplesat.models.simplesat import Response from pysimplesat.types import ( JSON, SimpleSatRequestParams, ) -class ActorEndpoint( +class ResponsesIdUpdateEndpoint( SimpleSatEndpoint, - IGettable[ActorResponse, SimpleSatRequestParams], + IPuttable[Response, SimpleSatRequestParams], ): def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "actor", parent_endpoint=parent_endpoint) - IGettable.__init__(self, ActorResponse) + SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) + IPuttable.__init__(self, Response) - def get( + def put( self, data: JSON | None = None, params: SimpleSatRequestParams | None = None, - ) -> ActorResponse: + ) -> Response: """ - Performs a GET request against the /Actor endpoint. + Performs a PUT request against the /responses/{id}/update 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: - AuthInformation: The parsed response data. + Response: The parsed response data. """ return self._parse_one( - ActorResponse, - super()._make_request("GET", data=data, params=params).json(), + Response, + super()._make_request("PUT", data=data, params=params).json(), ) diff --git a/src/pysimplesat/endpoints/simplesat/ResponsesSearchEndpoint.py b/src/pysimplesat/endpoints/simplesat/ResponsesSearchEndpoint.py new file mode 100644 index 0000000..2b51879 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/ResponsesSearchEndpoint.py @@ -0,0 +1,32 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import Response +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class ResponsesSearchEndpoint( + SimpleSatEndpoint, + IPostable[Response, SimpleSatRequestParams], + +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "search", parent_endpoint=parent_endpoint) + IPostable.__init__(self, Response) + + #TODO: How do I paginate a post? + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> Response: + """ + Performs a POST request against the /responses/search 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: + Survey: The parsed response data. + """ + return self._parse_many(Response, super()._make_request("POST", data=data, params=params).json().get('responses', {})) diff --git a/src/pysimplesat/endpoints/simplesat/SignalsEndpoint.py b/src/pysimplesat/endpoints/simplesat/SignalsEndpoint.py deleted file mode 100644 index 125bae9..0000000 --- a/src/pysimplesat/endpoints/simplesat/SignalsEndpoint.py +++ /dev/null @@ -1,86 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.endpoints.simplesat.SignalsIdEndpoint import SignalsIdEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Signals -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class SignalsEndpoint( - SimpleSatEndpoint, - IGettable[Signals, SimpleSatRequestParams], - IPaginateable[Signals, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "signals", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Signals) - IPaginateable.__init__(self, Signals) - - def id(self, id: int) -> SignalsIdEndpoint: - """ - Sets the ID for this endpoint and returns an initialized SignalsIdEndpoint object to move down the chain. - - Parameters: - id (int): The ID to set. - Returns: - SignalsIdEndpoint: The initialized SignalsIdEndpoint object. - """ - child = SignalsIdEndpoint(self.client, parent_endpoint=self) - child._id = id - return child - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Signals]: - """ - Performs a GET request against the /signals endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Signals]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Signals, - self, - "signals", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Signals: - """ - Performs a GET request against the /signals 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: - AuthInformation: The parsed response data. - """ - return self._parse_many( - Signals, - super()._make_request("GET", data=data, params=params).json().get('signals', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/SignalsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/SignalsIdEndpoint.py deleted file mode 100644 index e3075e7..0000000 --- a/src/pysimplesat/endpoints/simplesat/SignalsIdEndpoint.py +++ /dev/null @@ -1,72 +0,0 @@ -from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint -from pysimplesat.interfaces import ( - IGettable, - IPaginateable, -) -from pysimplesat.models.simplesat import Signals -from pysimplesat.responses.paginated_response import PaginatedResponse -from pysimplesat.types import ( - JSON, - SimpleSatRequestParams, -) - - -class SignalsIdEndpoint( - SimpleSatEndpoint, - IGettable[Signals, SimpleSatRequestParams], - IPaginateable[Signals, SimpleSatRequestParams], -): - def __init__(self, client, parent_endpoint=None) -> None: - SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Signals) - IPaginateable.__init__(self, Signals) - - def paginated( - self, - page: int, - limit: int, - params: SimpleSatRequestParams | None = None, - ) -> PaginatedResponse[Signals]: - """ - Performs a GET request against the /signals endpoint and returns an initialized PaginatedResponse object. - - Parameters: - page (int): The page number to request. - limit (int): The number of results to return per page. - params (dict[str, int | str]): The parameters to send in the request query string. - Returns: - PaginatedResponse[Signals]: The initialized PaginatedResponse object. - """ - if params: - params["page"] = page - params["limit"] = limit - else: - params = {"page": page, "limit": limit} - return PaginatedResponse( - super()._make_request("GET", params=params), - Signals, - self, - "signals", - page, - limit, - params, - ) - - def get( - self, - data: JSON | None = None, - params: SimpleSatRequestParams | None = None, - ) -> Signals: - """ - Performs a GET request against the /signals 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: - AuthInformation: The parsed response data. - """ - return self._parse_one( - Signals, - super()._make_request("GET", data=data, params=params).json().get('signal', {}), - ) diff --git a/src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py b/src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py new file mode 100644 index 0000000..8016b21 --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py @@ -0,0 +1,52 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.SurveysIdEndpoint import SurveysIdEndpoint +from pysimplesat.interfaces import ( + IGettable, +) +from pysimplesat.models.simplesat import Survey +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class SurveysEndpoint( + SimpleSatEndpoint, + IGettable[Survey, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "surveys", parent_endpoint=parent_endpoint) + IGettable.__init__(self, Survey) + + def id(self, id: int) -> SurveysIdEndpoint: + """ + Sets the ID for this endpoint and returns an initialized SurveysIdEndpoint object to move down the chain. + + Parameters: + id (int): The ID to set. + Returns: + SurveysIdEndpoint: The initialized SurveysIdEndpoint object. + """ + child = SurveysIdEndpoint(self.client, parent_endpoint=self) + child._id = id + return child + + def get( + self, + data: JSON | None = None, + params: SimpleSatRequestParams | None = None, + ) -> Survey: + """ + Performs a GET request against the /surveys 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: + Survey: The parsed response data. + """ + print("get") + return self._parse_many( + Survey, + super()._make_request("GET", data=data, params=params).json().get('surveys', {}), + ) diff --git a/src/pysimplesat/endpoints/simplesat/SurveysIdEmailEndpoint.py b/src/pysimplesat/endpoints/simplesat/SurveysIdEmailEndpoint.py new file mode 100644 index 0000000..2122bee --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/SurveysIdEmailEndpoint.py @@ -0,0 +1,31 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import SurveyEmail +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class SurveysIdEmailEndpoint( + SimpleSatEndpoint, + IPostable[SurveyEmail, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "email", parent_endpoint=parent_endpoint) + IPostable.__init__(self, SurveyEmail) + + + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> SurveyEmail: + """ + Performs a POST request against the /surveys/{id}/email 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: + SurveyEmail: The parsed response data. + """ + return self._parse_one(SurveyEmail, super()._make_request("POST", data=data, params=params).json()) diff --git a/src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py new file mode 100644 index 0000000..37cab5d --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py @@ -0,0 +1,10 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.SurveysIdEmailEndpoint import SurveysIdEmailEndpoint + + +class SurveysIdEndpoint( + SimpleSatEndpoint, +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) + self.email = self._register_child_endpoint(SurveysIdEmailEndpoint(client, parent_endpoint=self)) diff --git a/src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py b/src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py new file mode 100644 index 0000000..c29608d --- /dev/null +++ b/src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py @@ -0,0 +1,44 @@ +from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint +from pysimplesat.endpoints.simplesat.TeamMembersIdEndpoint import TeamMembersIdEndpoint +from pysimplesat.interfaces import ( + IPostable, +) +from pysimplesat.models.simplesat import TeamMember +from pysimplesat.types import ( + JSON, + SimpleSatRequestParams, +) + + +class TeamMembersEndpoint( + SimpleSatEndpoint, + IPostable[TeamMember, SimpleSatRequestParams], +): + def __init__(self, client, parent_endpoint=None) -> None: + SimpleSatEndpoint.__init__(self, client, "team-members", parent_endpoint=parent_endpoint) + IPostable.__init__(self, TeamMember) + + def id(self, id: int) -> TeamMembersIdEndpoint: + """ + Sets the ID for this endpoint and returns an initialized TeamMembersIdEndpoint object to move down the chain. + + Parameters: + id (int): The ID to set. + Returns: + TeamMembersIdEndpoint: The initialized TeamMembersIdEndpoint object. + """ + child = TeamMembersIdEndpoint(self.client, parent_endpoint=self) + child._id = id + return child + + def post(self, data: JSON | None = None, params: SimpleSatRequestParams | None = None) -> TeamMember: + """ + Performs a POST request against the /team-members 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: + TeamMember: The parsed response data. + """ + return self._parse_one(TeamMember, super()._make_request("POST", data=data, params=params).json()) diff --git a/src/pysimplesat/endpoints/siem/OrganizationsIdEndpoint.py b/src/pysimplesat/endpoints/simplesat/TeamMembersIdEndpoint.py similarity index 71% rename from src/pysimplesat/endpoints/siem/OrganizationsIdEndpoint.py rename to src/pysimplesat/endpoints/simplesat/TeamMembersIdEndpoint.py index 19b480a..10b30f1 100644 --- a/src/pysimplesat/endpoints/siem/OrganizationsIdEndpoint.py +++ b/src/pysimplesat/endpoints/simplesat/TeamMembersIdEndpoint.py @@ -2,28 +2,28 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint from pysimplesat.interfaces import ( IGettable, ) -from pysimplesat.models.simplesat import Organizations +from pysimplesat.models.simplesat import TeamMember from pysimplesat.types import ( JSON, SimpleSatRequestParams, ) -class OrganizationsIdEndpoint( +class TeamMembersIdEndpoint( SimpleSatEndpoint, - IGettable[Organizations, SimpleSatRequestParams], + IGettable[TeamMember, SimpleSatRequestParams], ): def __init__(self, client, parent_endpoint=None) -> None: SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint) - IGettable.__init__(self, Organizations) + IGettable.__init__(self, TeamMember) def get( self, data: JSON | None = None, params: SimpleSatRequestParams | None = None, - ) -> Organizations: + ) -> TeamMember: """ - Performs a GET request against the /organizations/{id} endpoint. + Performs a GET request against the /team-members/{id} endpoint. Parameters: data (dict[str, Any]): The data to send in the request body. @@ -32,6 +32,6 @@ class OrganizationsIdEndpoint( AuthInformation: The parsed response data. """ return self._parse_one( - Organizations, - super()._make_request("GET", data=data, params=params).json().get('organization', {}), + TeamMember, + super()._make_request("GET", data=data, params=params).json(), ) diff --git a/src/pysimplesat/models/simplesat/__init__.py b/src/pysimplesat/models/simplesat/__init__.py index ada6e18..157d296 100644 --- a/src/pysimplesat/models/simplesat/__init__.py +++ b/src/pysimplesat/models/simplesat/__init__.py @@ -33,7 +33,7 @@ class Answer(SimpleSatModel): published_as_testimonial: bool | None = Field(default=None, alias="PublishedAsTestimonial") response_id: int | None = Field(default=None, alias="ResponseId") -class Answer(SimpleSatModel): +class Customer(SimpleSatModel): id: int | None = Field(default=None, alias="Id") external_id: str | None = Field(default=None, alias="ExternalId") created: datetime | None = Field(default=None, alias="Created") @@ -59,3 +59,18 @@ class Response(SimpleSatModel): team_members: dict[str, Any] | None = Field(default=None, alias="TeamMembers") ticket: dict[str, Any] | None = Field(default=None, alias="Ticket") customer: dict[str, Any] | None = Field(default=None, alias="Customer") + +class Survey(SimpleSatModel): + id: int | None = Field(default=None, alias="Id") + name: str | None = Field(default=None, alias="Name") + metric: str | None = Field(default=None, alias="Metric") + survey_token: str | None = Field(default=None, alias="SurveyToken") + survey_type: str | None = Field(default=None, alias="SurveyType") + brand_name: str | None = Field(default=None, alias="BrandName") + +class CustomerBulk(SimpleSatModel): + request_id: str | None = Field(default=None, alias="RequestId") + detail: str | None = Field(default=None, alias="Detail") + +class SurveyEmail(SimpleSatModel): + detail: str | None = Field(default=None, alias="Detail")