|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from rsb.models.base_model import BaseModel |
| 4 | +from rsb.models.field import Field |
| 5 | + |
| 6 | + |
| 7 | +class TwilioAPIConfig(BaseModel): |
| 8 | + """Configuration for Twilio WhatsApp API.""" |
| 9 | + |
| 10 | + account_sid: str = Field(description="Twilio Account SID") |
| 11 | + auth_token: str = Field(description="Twilio Auth Token") |
| 12 | + whatsapp_number: str = Field( |
| 13 | + description="Your Twilio WhatsApp number (e.g., 'whatsapp:+14155238886')" |
| 14 | + ) |
| 15 | + webhook_url: str | None = Field( |
| 16 | + default=None, description="Webhook URL for receiving messages" |
| 17 | + ) |
| 18 | + timeout: int = Field(default=30, description="Request timeout in seconds") |
| 19 | + status_callback_url: str | None = Field( |
| 20 | + default=None, description="URL for message status callbacks" |
| 21 | + ) |
| 22 | + |
| 23 | + def clone( |
| 24 | + self, |
| 25 | + new_account_sid: str | None = None, |
| 26 | + new_auth_token: str | None = None, |
| 27 | + new_whatsapp_number: str | None = None, |
| 28 | + new_webhook_url: str | None = None, |
| 29 | + new_timeout: int | None = None, |
| 30 | + new_status_callback_url: str | None = None, |
| 31 | + ) -> TwilioAPIConfig: |
| 32 | + """Clone the configuration with optional new values.""" |
| 33 | + return TwilioAPIConfig( |
| 34 | + account_sid=new_account_sid or self.account_sid, |
| 35 | + auth_token=new_auth_token or self.auth_token, |
| 36 | + whatsapp_number=new_whatsapp_number or self.whatsapp_number, |
| 37 | + webhook_url=new_webhook_url or self.webhook_url, |
| 38 | + timeout=new_timeout or self.timeout, |
| 39 | + status_callback_url=new_status_callback_url or self.status_callback_url, |
| 40 | + ) |
0 commit comments