-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
50 lines (37 loc) · 1.84 KB
/
config.py
File metadata and controls
50 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional
class ManyChatConfig(BaseSettings):
"""Configuration for ManyChat API integration.
Loads configuration from environment variables with the prefix 'MANYCHAT_'.
"""
model_config = SettingsConfigDict(env_prefix="MANYCHAT_", env_file=".env", extra="ignore")
# Required configuration
api_key: str = Field(..., description="API key for ManyChat authentication")
api_version: str = Field("v1", description="API version to use")
base_url: str = Field("https://api.manychat.com/fb",
description="Base URL for ManyChat API endpoints")
# Optional configuration with defaults
timeout: int = Field(30, description="Request timeout in seconds")
max_retries: int = Field(3, description="Maximum number of retries for failed requests")
retry_delay: float = Field(1.0, description="Delay between retries in seconds")
# Rate limiting
rate_limit: int = Field(100, description="Maximum requests per minute")
rate_window: int = Field(60, description="Rate limit window in seconds")
# Logging and debugging
log_level: str = Field("INFO", description="Logging level")
debug: bool = Field(False, description="Enable debug mode for additional logging")
# Webhook configuration
webhook_secret: Optional[str] = Field(
None,
description="Secret for webhook signature verification"
)
# Cache settings
cache_ttl: int = Field(300, description="Default cache TTL in seconds")
@property
def api_url(self) -> str:
"""Get the full base API URL with version."""
return f"{self.base_url}/{self.api_version}"
# Create a singleton instance
config = ManyChatConfig()
__all__ = ["config", "ManyChatConfig"]