-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
54 lines (41 loc) · 1.74 KB
/
forms.py
File metadata and controls
54 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncManagedResourceMixin,
CollectionMixin,
ManagedResourceMixin,
)
from mpt_api_client.models import Model, ResourceData
class Form(Model):
"""Helpdesk Form resource."""
class FormsServiceConfig:
"""Helpdesk Forms service configuration."""
_endpoint = "/public/v1/helpdesk/forms"
_model_class = Form
_collection_key = "data"
class FormsService(
ManagedResourceMixin[Form],
CollectionMixin[Form],
Service[Form],
FormsServiceConfig,
):
"""Helpdesk Forms service."""
def publish(self, resource_id: str, resource_data: ResourceData | None = None) -> Form:
"""Switch form to published state."""
return self._resource_action(resource_id, "POST", "publish", json=resource_data)
def unpublish(self, resource_id: str, resource_data: ResourceData | None = None) -> Form:
"""Switch form to unpublished state."""
return self._resource_action(resource_id, "POST", "unpublish", json=resource_data)
class AsyncFormsService(
AsyncManagedResourceMixin[Form],
AsyncCollectionMixin[Form],
AsyncService[Form],
FormsServiceConfig,
):
"""Async Helpdesk Forms service."""
async def publish(self, resource_id: str, resource_data: ResourceData | None = None) -> Form:
"""Switch form to published state."""
return await self._resource_action(resource_id, "POST", "publish", json=resource_data)
async def unpublish(self, resource_id: str, resource_data: ResourceData | None = None) -> Form:
"""Switch form to unpublished state."""
return await self._resource_action(resource_id, "POST", "unpublish", json=resource_data)