mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-13 08:15:21 +02:00
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
"""Telnyx telephony provider package."""
|
|
|
|
from typing import Any, Dict
|
|
|
|
from api.services.telephony.registry import (
|
|
ProviderSpec,
|
|
ProviderUIField,
|
|
ProviderUIMetadata,
|
|
register,
|
|
)
|
|
|
|
from .config import TelnyxConfigurationRequest, TelnyxConfigurationResponse
|
|
from .provider import TelnyxProvider
|
|
from .transport import create_transport
|
|
|
|
|
|
def _config_loader(value: Dict[str, Any]) -> Dict[str, Any]:
|
|
return {
|
|
"provider": "telnyx",
|
|
"api_key": value.get("api_key"),
|
|
"connection_id": value.get("connection_id"),
|
|
"from_numbers": value.get("from_numbers", []),
|
|
}
|
|
|
|
|
|
_UI_METADATA = ProviderUIMetadata(
|
|
display_name="Telnyx",
|
|
docs_url="https://docs.dograh.com/integrations/telephony/telnyx",
|
|
fields=[
|
|
ProviderUIField(
|
|
name="api_key", label="API Key", type="password", sensitive=True
|
|
),
|
|
ProviderUIField(
|
|
name="connection_id",
|
|
label="Call Control App ID",
|
|
type="text",
|
|
description="Telnyx Call Control Application ID (connection_id)",
|
|
),
|
|
ProviderUIField(
|
|
name="from_numbers",
|
|
label="Phone Numbers",
|
|
type="string-array",
|
|
description="E.164-formatted Telnyx phone numbers",
|
|
),
|
|
],
|
|
)
|
|
|
|
|
|
SPEC = ProviderSpec(
|
|
name="telnyx",
|
|
provider_cls=TelnyxProvider,
|
|
config_loader=_config_loader,
|
|
transport_factory=create_transport,
|
|
transport_sample_rate=8000,
|
|
config_request_cls=TelnyxConfigurationRequest,
|
|
ui_metadata=_UI_METADATA,
|
|
config_response_cls=TelnyxConfigurationResponse,
|
|
account_id_credential_field="connection_id",
|
|
)
|
|
|
|
|
|
register(SPEC)
|
|
|
|
|
|
__all__ = [
|
|
"SPEC",
|
|
"TelnyxConfigurationRequest",
|
|
"TelnyxConfigurationResponse",
|
|
"TelnyxProvider",
|
|
"create_transport",
|
|
]
|