"""Job-scoped SMS operations — swagger tag ``JobSms`` (4 routes).
Exposed as ``api.jobs.sms``. Old names on
:class:`~ab.api.endpoints.jobs.JobsEndpoint` remain as deprecation shims.
Method renames (``_sms`` suffix dropped):
* :meth:`list` (was ``list_sms``)
* :meth:`send` (was ``send_sms``)
* :meth:`mark_read` (was ``mark_sms_read``)
* :meth:`get_template` (was ``get_sms_template``)
"""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ab.api.models.jobs import MarkSmsAsReadModel, SendSMSModel
from ab.api.base import BaseEndpoint
from ab.api.route import Route
_LIST = Route("GET", "/job/{jobDisplayId}/sms")
_SEND = Route("POST", "/job/{jobDisplayId}/sms", request_model="SendSMSModel")
_MARK_READ = Route("POST", "/job/{jobDisplayId}/sms/read", request_model="MarkSmsAsReadModel")
_GET_TEMPLATE = Route("GET", "/job/{jobDisplayId}/sms/templatebased/{templateId}")
[docs]
class JobSmsEndpoint(BaseEndpoint):
"""Job-scoped SMS operations (ACPortal API)."""
[docs]
def list(self, job_display_id: int) -> None:
"""``GET /job/{jobDisplayId}/sms``
Docs: https://ab-sdk.readthedocs.io/en/latest/api/jobs/sms.list.html
"""
return self._request(_LIST.bind(jobDisplayId=job_display_id))
[docs]
def send(self, job_display_id: int, *, data: SendSMSModel | dict) -> None:
"""``POST /job/{jobDisplayId}/sms``
Docs: https://ab-sdk.readthedocs.io/en/latest/api/jobs/sms.send.html
Request model: SendSMSModel
"""
return self._request(_SEND.bind(jobDisplayId=job_display_id), json=data)
[docs]
def mark_read(self, job_display_id: int, *, data: MarkSmsAsReadModel | dict) -> None:
"""``POST /job/{jobDisplayId}/sms/read``
Docs: https://ab-sdk.readthedocs.io/en/latest/api/jobs/sms.mark_read.html
Request model: MarkSmsAsReadModel
"""
return self._request(_MARK_READ.bind(jobDisplayId=job_display_id), json=data)
[docs]
def get_template(self, job_display_id: int, template_id: str) -> None:
"""``GET /job/{jobDisplayId}/sms/templatebased/{templateId}``
Docs: https://ab-sdk.readthedocs.io/en/latest/api/jobs/sms.get_template.html
"""
return self._request(
_GET_TEMPLATE.bind(jobDisplayId=job_display_id, templateId=template_id),
)