mirror of
https://github.com/brygphilomena/pysimplesat.git
synced 2025-11-04 08:47:29 +00:00
Implemented endpoints
This commit is contained in:
parent
56ce6105ea
commit
c63b4e53f5
1
.gitignore
vendored
1
.gitignore
vendored
@ -205,3 +205,4 @@ cython_debug/
|
|||||||
marimo/_static/
|
marimo/_static/
|
||||||
marimo/_lsp/
|
marimo/_lsp/
|
||||||
__marimo__/
|
__marimo__/
|
||||||
|
src/simplesat_scratchpad.py
|
||||||
|
|||||||
@ -1,19 +1,16 @@
|
|||||||
import typing
|
import typing
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
import base64
|
|
||||||
|
|
||||||
from pysimplesat.clients.base_client import SimpleSatClient
|
from pysimplesat.clients.base_client import SimpleSatClient
|
||||||
from pysimplesat.config import Config
|
from pysimplesat.config import Config
|
||||||
|
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
from pysimplesat.endpoints.simplesat.AccountEndpoint import AccountEndpoint
|
from pysimplesat.endpoints.simplesat.SurveysEndpoint import SurveysEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.ActorEndpoint import ActorEndpoint
|
from pysimplesat.endpoints.simplesat.AnswersEndpoint import AnswersEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.AgentsEndpoint import AgentsEndpoint
|
from pysimplesat.endpoints.simplesat.CustomersEndpoint import CustomersEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.BillingreportsEndpoint import BillingreportsEndpoint
|
from pysimplesat.endpoints.simplesat.QuestionsEndpoint import QuestionsEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.IncidentreportsEndpoint import IncidentreportsEndpoint
|
from pysimplesat.endpoints.simplesat.TeamMembersEndpoint import TeamMembersEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.OrganizationsEndpoint import OrganizationsEndpoint
|
from pysimplesat.endpoints.simplesat.ResponsesEndpoint import ResponsesEndpoint
|
||||||
from pysimplesat.endpoints.simplesat.ReportsEndpoint import ReportsEndpoint
|
|
||||||
from pysimplesat.endpoints.simplesat.SignalsEndpoint import SignalsEndpoint
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleSatAPIClient(SimpleSatClient):
|
class SimpleSatAPIClient(SimpleSatClient):
|
||||||
@ -37,52 +34,41 @@ class SimpleSatAPIClient(SimpleSatClient):
|
|||||||
|
|
||||||
# Initializing endpoints
|
# Initializing endpoints
|
||||||
@property
|
@property
|
||||||
def account(self) -> "AccountEndpoint":
|
def surveys(self) -> "SurveysEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.AccountEndpoint import AccountEndpoint
|
from pysimplesat.endpoints.simplesat.SurveysEndpoint import SurveysEndpoint
|
||||||
|
|
||||||
return AccountEndpoint(self)
|
return SurveysEndpoint(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def actor(self) -> "ActorEndpoint":
|
def answers(self) -> "AnswersEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.ActorEndpoint import ActorEndpoint
|
from pysimplesat.endpoints.simplesat.AnswersEndpoint import AnswersEndpoint
|
||||||
|
|
||||||
return ActorEndpoint(self)
|
return AnswersEndpoint(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def agents(self) -> "AgentsEndpoint":
|
def customers(self) -> "CustomersEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.AgentsEndpoint import AgentsEndpoint
|
from pysimplesat.endpoints.simplesat.CustomersEndpoint import CustomersEndpoint
|
||||||
|
|
||||||
return AgentsEndpoint(self)
|
return CustomersEndpoint(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def billing_reports(self) -> "BillingreportsEndpoint":
|
def questions(self) -> "QuestionsEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.BillingreportsEndpoint import BillingreportsEndpoint
|
from pysimplesat.endpoints.simplesat.QuestionsEndpoint import QuestionsEndpoint
|
||||||
|
|
||||||
return BillingreportsEndpoint(self)
|
return QuestionsEndpoint(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def incident_reports(self) -> "IncidentreportsEndpoint":
|
def team_members(self) -> "TeamMembersEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.IncidentreportsEndpoint import IncidentreportsEndpoint
|
from pysimplesat.endpoints.simplesat.TeamMembersEndpoint import TeamMembersEndpoint
|
||||||
|
|
||||||
return IncidentreportsEndpoint(self)
|
return TeamMembersEndpoint(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def organizations(self) -> "OrganizationsEndpoint":
|
def responses(self) -> "ResponsesEndpoint":
|
||||||
from pysimplesat.endpoints.simplesat.OrganizationsEndpoint import OrganizationsEndpoint
|
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:
|
def _get_url(self) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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(),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
24
src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py
Normal file
24
src/pysimplesat/endpoints/simplesat/AnswersEndpoint.py
Normal file
@ -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
|
||||||
59
src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py
Normal file
59
src/pysimplesat/endpoints/simplesat/AnswersIdEndpoint.py
Normal file
@ -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(),
|
||||||
|
)
|
||||||
32
src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py
Normal file
32
src/pysimplesat/endpoints/simplesat/AnswersSearchEndpoint.py
Normal file
@ -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', {}))
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
31
src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py
Normal file
31
src/pysimplesat/endpoints/simplesat/CustomersBulkEndpoint.py
Normal file
@ -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())
|
||||||
46
src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py
Normal file
46
src/pysimplesat/endpoints/simplesat/CustomersEndpoint.py
Normal file
@ -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())
|
||||||
59
src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py
Normal file
59
src/pysimplesat/endpoints/simplesat/CustomersIdEndpoint.py
Normal file
@ -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(),
|
||||||
|
)
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -2,36 +2,37 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
|||||||
from pysimplesat.interfaces import (
|
from pysimplesat.interfaces import (
|
||||||
IGettable,
|
IGettable,
|
||||||
)
|
)
|
||||||
from pysimplesat.models.simplesat import Account
|
from pysimplesat.models.simplesat import Question
|
||||||
from pysimplesat.types import (
|
from pysimplesat.types import (
|
||||||
JSON,
|
JSON,
|
||||||
SimpleSatRequestParams,
|
SimpleSatRequestParams,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AccountEndpoint(
|
class QuestionsEndpoint(
|
||||||
SimpleSatEndpoint,
|
SimpleSatEndpoint,
|
||||||
IGettable[Account, SimpleSatRequestParams],
|
IGettable[Question, SimpleSatRequestParams],
|
||||||
):
|
):
|
||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
SimpleSatEndpoint.__init__(self, client, "account", parent_endpoint=parent_endpoint)
|
SimpleSatEndpoint.__init__(self, client, "questions", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, Account)
|
IGettable.__init__(self, Question)
|
||||||
|
|
||||||
def get(
|
def get(
|
||||||
self,
|
self,
|
||||||
data: JSON | None = None,
|
data: JSON | None = None,
|
||||||
params: SimpleSatRequestParams | 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:
|
Parameters:
|
||||||
data (dict[str, Any]): The data to send in the request body.
|
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.
|
params (dict[str, int | str]): The parameters to send in the request query string.
|
||||||
Returns:
|
Returns:
|
||||||
AuthInformation: The parsed response data.
|
Question: The parsed response data.
|
||||||
"""
|
"""
|
||||||
return self._parse_one(
|
print("get")
|
||||||
Account,
|
return self._parse_many(
|
||||||
super()._make_request("GET", data=data, params=params).json().get('account', {}),
|
Question,
|
||||||
|
super()._make_request("GET", data=data, params=params).json().get('questions', {}),
|
||||||
)
|
)
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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())
|
||||||
26
src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py
Normal file
26
src/pysimplesat/endpoints/simplesat/ResponsesEndpoint.py
Normal file
@ -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
|
||||||
@ -2,28 +2,28 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
|||||||
from pysimplesat.interfaces import (
|
from pysimplesat.interfaces import (
|
||||||
IGettable,
|
IGettable,
|
||||||
)
|
)
|
||||||
from pysimplesat.models.simplesat import Organizations
|
from pysimplesat.models.simplesat import Response
|
||||||
from pysimplesat.types import (
|
from pysimplesat.types import (
|
||||||
JSON,
|
JSON,
|
||||||
SimpleSatRequestParams,
|
SimpleSatRequestParams,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class OrganizationsIdEndpoint(
|
class ResponsesIdEndpoint(
|
||||||
SimpleSatEndpoint,
|
SimpleSatEndpoint,
|
||||||
IGettable[Organizations, SimpleSatRequestParams],
|
IGettable[Response, SimpleSatRequestParams],
|
||||||
):
|
):
|
||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
|
SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, Organizations)
|
IGettable.__init__(self, Response)
|
||||||
|
|
||||||
def get(
|
def get(
|
||||||
self,
|
self,
|
||||||
data: JSON | None = None,
|
data: JSON | None = None,
|
||||||
params: SimpleSatRequestParams | 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:
|
Parameters:
|
||||||
data (dict[str, Any]): The data to send in the request body.
|
data (dict[str, Any]): The data to send in the request body.
|
||||||
@ -32,6 +32,6 @@ class OrganizationsIdEndpoint(
|
|||||||
AuthInformation: The parsed response data.
|
AuthInformation: The parsed response data.
|
||||||
"""
|
"""
|
||||||
return self._parse_one(
|
return self._parse_one(
|
||||||
Organizations,
|
Response,
|
||||||
super()._make_request("GET", data=data, params=params).json().get('organization', {}),
|
super()._make_request("GET", data=data, params=params).json(),
|
||||||
)
|
)
|
||||||
@ -1,37 +1,37 @@
|
|||||||
from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
||||||
from pysimplesat.interfaces import (
|
from pysimplesat.interfaces import (
|
||||||
IGettable,
|
IPuttable,
|
||||||
)
|
)
|
||||||
from pysimplesat.models.simplesat import ActorResponse
|
from pysimplesat.models.simplesat import Response
|
||||||
from pysimplesat.types import (
|
from pysimplesat.types import (
|
||||||
JSON,
|
JSON,
|
||||||
SimpleSatRequestParams,
|
SimpleSatRequestParams,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ActorEndpoint(
|
class ResponsesIdUpdateEndpoint(
|
||||||
SimpleSatEndpoint,
|
SimpleSatEndpoint,
|
||||||
IGettable[ActorResponse, SimpleSatRequestParams],
|
IPuttable[Response, SimpleSatRequestParams],
|
||||||
):
|
):
|
||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
SimpleSatEndpoint.__init__(self, client, "actor", parent_endpoint=parent_endpoint)
|
SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, ActorResponse)
|
IPuttable.__init__(self, Response)
|
||||||
|
|
||||||
def get(
|
def put(
|
||||||
self,
|
self,
|
||||||
data: JSON | None = None,
|
data: JSON | None = None,
|
||||||
params: SimpleSatRequestParams | 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:
|
Parameters:
|
||||||
data (dict[str, Any]): The data to send in the request body.
|
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.
|
params (dict[str, int | str]): The parameters to send in the request query string.
|
||||||
Returns:
|
Returns:
|
||||||
AuthInformation: The parsed response data.
|
Response: The parsed response data.
|
||||||
"""
|
"""
|
||||||
return self._parse_one(
|
return self._parse_one(
|
||||||
ActorResponse,
|
Response,
|
||||||
super()._make_request("GET", data=data, params=params).json(),
|
super()._make_request("PUT", data=data, params=params).json(),
|
||||||
)
|
)
|
||||||
@ -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', {}))
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
@ -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', {}),
|
|
||||||
)
|
|
||||||
52
src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py
Normal file
52
src/pysimplesat/endpoints/simplesat/SurveysEndpoint.py
Normal file
@ -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', {}),
|
||||||
|
)
|
||||||
@ -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())
|
||||||
10
src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py
Normal file
10
src/pysimplesat/endpoints/simplesat/SurveysIdEndpoint.py
Normal file
@ -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))
|
||||||
44
src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py
Normal file
44
src/pysimplesat/endpoints/simplesat/TeamMembersEndpoint.py
Normal file
@ -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())
|
||||||
@ -2,28 +2,28 @@ from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
|||||||
from pysimplesat.interfaces import (
|
from pysimplesat.interfaces import (
|
||||||
IGettable,
|
IGettable,
|
||||||
)
|
)
|
||||||
from pysimplesat.models.simplesat import Organizations
|
from pysimplesat.models.simplesat import TeamMember
|
||||||
from pysimplesat.types import (
|
from pysimplesat.types import (
|
||||||
JSON,
|
JSON,
|
||||||
SimpleSatRequestParams,
|
SimpleSatRequestParams,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class OrganizationsIdEndpoint(
|
class TeamMembersIdEndpoint(
|
||||||
SimpleSatEndpoint,
|
SimpleSatEndpoint,
|
||||||
IGettable[Organizations, SimpleSatRequestParams],
|
IGettable[TeamMember, SimpleSatRequestParams],
|
||||||
):
|
):
|
||||||
def __init__(self, client, parent_endpoint=None) -> None:
|
def __init__(self, client, parent_endpoint=None) -> None:
|
||||||
SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
|
SimpleSatEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
|
||||||
IGettable.__init__(self, Organizations)
|
IGettable.__init__(self, TeamMember)
|
||||||
|
|
||||||
def get(
|
def get(
|
||||||
self,
|
self,
|
||||||
data: JSON | None = None,
|
data: JSON | None = None,
|
||||||
params: SimpleSatRequestParams | 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:
|
Parameters:
|
||||||
data (dict[str, Any]): The data to send in the request body.
|
data (dict[str, Any]): The data to send in the request body.
|
||||||
@ -32,6 +32,6 @@ class OrganizationsIdEndpoint(
|
|||||||
AuthInformation: The parsed response data.
|
AuthInformation: The parsed response data.
|
||||||
"""
|
"""
|
||||||
return self._parse_one(
|
return self._parse_one(
|
||||||
Organizations,
|
TeamMember,
|
||||||
super()._make_request("GET", data=data, params=params).json().get('organization', {}),
|
super()._make_request("GET", data=data, params=params).json(),
|
||||||
)
|
)
|
||||||
@ -33,7 +33,7 @@ class Answer(SimpleSatModel):
|
|||||||
published_as_testimonial: bool | None = Field(default=None, alias="PublishedAsTestimonial")
|
published_as_testimonial: bool | None = Field(default=None, alias="PublishedAsTestimonial")
|
||||||
response_id: int | None = Field(default=None, alias="ResponseId")
|
response_id: int | None = Field(default=None, alias="ResponseId")
|
||||||
|
|
||||||
class Answer(SimpleSatModel):
|
class Customer(SimpleSatModel):
|
||||||
id: int | None = Field(default=None, alias="Id")
|
id: int | None = Field(default=None, alias="Id")
|
||||||
external_id: str | None = Field(default=None, alias="ExternalId")
|
external_id: str | None = Field(default=None, alias="ExternalId")
|
||||||
created: datetime | None = Field(default=None, alias="Created")
|
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")
|
team_members: dict[str, Any] | None = Field(default=None, alias="TeamMembers")
|
||||||
ticket: dict[str, Any] | None = Field(default=None, alias="Ticket")
|
ticket: dict[str, Any] | None = Field(default=None, alias="Ticket")
|
||||||
customer: dict[str, Any] | None = Field(default=None, alias="Customer")
|
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")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user