47
sms/config.py
Normal file
47
sms/config.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""Configuration for the voip.ms SMS client, loaded from environment.
|
||||
|
||||
Set credentials before running:
|
||||
export VOIPMS_API_USERNAME=...
|
||||
export VOIPMS_API_PASSWORD=...
|
||||
|
||||
On the voip.ms side you must also whitelist this machine's public IP under
|
||||
Main Menu -> SOAP / REST API -> API Security, and the sending DID must have
|
||||
SMS enabled.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_prefix="voipms_",
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
api_username: str = Field(..., description="voip.ms API username")
|
||||
api_password: str = Field(..., description="voip.ms API password (set in API Security)")
|
||||
|
||||
base_url: str = Field(
|
||||
"https://voip.ms/api/v1/rest.php",
|
||||
description="voip.ms REST endpoint. Avoid www.voip.ms (302 drops POST bodies).",
|
||||
)
|
||||
|
||||
dialing_mode: Literal["nanpa", "e164"] = Field(
|
||||
"nanpa",
|
||||
description="Number format. nanpa=10 digits; e164=+1 then 10 digits.",
|
||||
)
|
||||
|
||||
daily_limit: int = Field(
|
||||
100,
|
||||
description="Per-UTC-day cap on outbound sends (matches the upstream API limit).",
|
||||
ge=0,
|
||||
)
|
||||
|
||||
timeout: float = Field(30.0, description="HTTP timeout in seconds.", ge=1.0)
|
||||
Reference in New Issue
Block a user