mirror of
https://github.com/brygphilomena/pysimplesat.git
synced 2025-11-04 08:47:29 +00:00
Fixed Questions Endpoint. Added pagination and added missing model
This commit is contained in:
parent
3339dbddc8
commit
0eba968c11
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pysimplesat"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = [
|
||||
{ name="Peter Annabel", email="peter.annabel@gmail.com" },
|
||||
]
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
from pysimplesat.endpoints.base.base_endpoint import SimpleSatEndpoint
|
||||
from pysimplesat.interfaces import (
|
||||
IGettable,
|
||||
IPaginateable,
|
||||
)
|
||||
from pysimplesat.models.simplesat import Question
|
||||
from pysimplesat.responses.paginated_response import PaginatedResponse
|
||||
from pysimplesat.types import (
|
||||
JSON,
|
||||
SimpleSatRequestParams,
|
||||
@ -12,10 +14,43 @@ from pysimplesat.types import (
|
||||
class QuestionsEndpoint(
|
||||
SimpleSatEndpoint,
|
||||
IGettable[Question, SimpleSatRequestParams],
|
||||
IPaginateable[Question, SimpleSatRequestParams],
|
||||
):
|
||||
def __init__(self, client, parent_endpoint=None) -> None:
|
||||
SimpleSatEndpoint.__init__(self, client, "questions", parent_endpoint=parent_endpoint)
|
||||
IGettable.__init__(self, Question)
|
||||
IPaginateable.__init__(self, Question)
|
||||
|
||||
def paginated(
|
||||
self,
|
||||
page: int,
|
||||
limit: int,
|
||||
params: SimpleSatRequestParams | None = None,
|
||||
) -> PaginatedResponse[Question]:
|
||||
"""
|
||||
Performs a GET request against the /questions 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[Question]: The initialized PaginatedResponse object.
|
||||
"""
|
||||
if params:
|
||||
params["page[number]"] = page
|
||||
params["page[size]"] = limit
|
||||
else:
|
||||
params = {"page[number]": page, "page[size]": limit}
|
||||
return PaginatedResponse(
|
||||
super()._make_request("GET", params=params),
|
||||
Question,
|
||||
self,
|
||||
"questions",
|
||||
page,
|
||||
limit,
|
||||
params,
|
||||
)
|
||||
|
||||
def get(
|
||||
self,
|
||||
|
||||
@ -68,6 +68,17 @@ class Survey(SimpleSatModel):
|
||||
survey_type: str | None = Field(default=None, alias="SurveyType")
|
||||
brand_name: str | None = Field(default=None, alias="BrandName")
|
||||
|
||||
class Question(SimpleSatModel):
|
||||
id: int | None = Field(default=None, alias="Id")
|
||||
survey: dict[str, int | str] | None = Field(default=None, alias="Survey")
|
||||
order: int | None = Field(default=None, alias="Order")
|
||||
metric: str | None = Field(default=None, alias="Metric")
|
||||
text: str | None = Field(default=None, alias="Text")
|
||||
rating_scale: bool | None = Field(default=None, alias="RatingScale")
|
||||
required: bool | None = Field(default=None, alias="Required")
|
||||
choices: list[str] | None = Field(default=None, alias="Choices")
|
||||
rules: dict[str, Any] | None = Field(default=None, alias="Rules")
|
||||
|
||||
class CustomerBulk(SimpleSatModel):
|
||||
request_id: str | None = Field(default=None, alias="RequestId")
|
||||
detail: str | None = Field(default=None, alias="Detail")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user