ggvlib.twilio
Submodules
Classes
A base client for interacting with Twilio |
|
A base client for interacting with Twilio |
|
A base client for interacting with Twilio |
|
A model for creating content via the Twilio content API |
|
Package Contents
- class ggvlib.twilio.MessagingApiClient(account_sid: str, api_key: str = None)
Bases:
Client
A base client for interacting with Twilio
- api_base_url = 'https://api.twilio.com/2010-04-01/Accounts'
- get_messages(date_sent: datetime.date = datetime.utcnow().date(), from_number: str = None, to_number: str = None, page_size: int = 1000) list[dict]
Return all message records for a given account, which is defined in the MessagingApiClient instance
- Parameters:
from_number (str) – The number the message was sent from
to_number (str) – The number the message was sent to
date_sent (date) – The date the message was sent
page_size (int) – The amount of messages to return per page
- Returns:
A list of messages
- Return type:
list[dict]
- send_content(payload: ContentSendRequest) dict
Send content via a messaging service using the Content API
- Parameters:
payload (ContentSendRequest) – A request containing information about what
send (content to)
- Raises:
Exception – If the request is not accepted
- Returns:
Information about the sent message, such as whether or not it was accepted
- Return type:
dict
- async_send_content(message_batch: List[ContentSendRequest]) List[aiohttp.ClientResponse]
A wrapper method for _async_send_content
- Parameters:
message_batch (List[ContentSendRequest]) – A list of requests containing information about what
send (content to)
- Returns:
A list of responses from the client
- Return type:
List[aiohttp.ClientResponse]
- async _async_send_content(message_batch: List[ContentSendRequest]) List[aiohttp.ClientResponse]
Send content asynchronously via a messaging service using the Content API
- Parameters:
message_batch (List[ContentSendRequest]) – A list of requests containing information about what
send (content to)
- Returns:
A list of responses from the client
- Return type:
List[aiohttp.ClientResponse]
- async _post_async(session: aiohttp.ClientSession, payload: ContentSendRequest) aiohttp.ClientResponse
_summary_
- Parameters:
session (aiohttp.ClientSession) – _description_
payload (ContentSendRequest) – _description_
- Returns:
_description_
- Return type:
aiohttp.ClientResponse
- class ggvlib.twilio.MessagingServiceApiClient(account_sid: str, api_key: str = None)
Bases:
Client
A base client for interacting with Twilio
- api_version = 1
- api_base_url
- get_all() dict
_summary_
- Returns:
_description_
- Return type:
dict
- get(service_sid: str) dict
_summary_
- Parameters:
service_sid (str) – _description_
- Returns:
_description_
- Return type:
dict
- update(payload: MessagingServiceUpdateRequest) dict
_summary_
- Parameters:
payload (MessagingServiceUpdateRequest) – _description_
- Returns:
_description_
- Return type:
dict
- class ggvlib.twilio.ContentApiClient(account_sid: str, api_key: str = None)
Bases:
Client
A base client for interacting with Twilio
- api_version = 1
- api_base_url
- check_approval_status(content_sid: str) dict
- delete_content(content_sid: str) None
- submit_content_for_approval(name: str, category: str, content_sid: str) dict
- create_content(payload: ContentCreateRequest) dict
Used for creating content with the Content API
- Parameters:
payload (ContentCreateRequest) – A content creation request
- Raises:
Exception – If the request is not accepted
- Returns:
Information about the new content, such as its content_sid
- Return type:
dict
- class ggvlib.twilio.ContentType
Bases:
pydantic.BaseModel
- category: Literal['text', 'media', 'location', 'list-picker', 'quick-reply', 'call-to-action', 'card']
- body: str
- actions: List[Dict[str, str]] | None
- items: List[Dict[str, str]] | None
- button: str | None
- content_validator(values: dict)
- to_dict() dict
- class ggvlib.twilio.ContentCreateRequest
Bases:
pydantic.BaseModel
A model for creating content via the Twilio content API
- Parameters:
friendly_name (str) – What to name the new content
variables (Dict[str, str]) – Variables in a dict format
Dict[str (types) – The type of content to create
Dict[str – The type of content to create
str]] – The type of content to create
language (str) – The content language (defaults to ‘en’)
>>> new_content = ContentCreateRequest( ... friendly_name="test", ... variables={"1": "name", "2": "11"}, ... types=[ ... ContentType( ... category="text", ... body="Hi {{1}}, Your flight will depart from gate {{2}}.", ... actions=[{"id": "test_1", "title": "action_1"}] ... ) ... ], ... language="en", ... )
- friendly_name: str
- variables: Dict[str, str]
- content_types: List[ContentType]
- language: str = 'en'
- to_dict() dict
- class ggvlib.twilio.MessagingServiceUpdateRequest
Bases:
pydantic.BaseModel
- sid: str
- friendly_name: str | None
- inbound_request_url: str | None
- inbound_method: str | None
- fallback_url: str | None
- fallback_method: str | None
- status_callback: str | None
- sticky_sender: bool | None
- mms_converter: bool | None
- smart_encoding: bool | None
- scan_message_content: bool | None
- fallback_to_long_code: bool | None
- area_code_geomatch: bool | None
- validity_period: int | None
- synchronous_validation: bool | None
- usecase: str | None
- use_inbound_webhook_on_number: bool | None
- to_dict() dict