Add voxtelesys_integration/doctype/voxtelesys_settings/voxtelesys_settings.py
This commit is contained in:
parent
f62ae072d9
commit
9a17384cd2
1 changed files with 49 additions and 0 deletions
|
|
@ -0,0 +1,49 @@
|
||||||
|
"""
|
||||||
|
Voxtelesys Settings - Single DocType controller.
|
||||||
|
"""
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class VoxtelesysSettings(Document):
|
||||||
|
def validate(self):
|
||||||
|
self._set_webhook_url_display()
|
||||||
|
|
||||||
|
def _set_webhook_url_display(self):
|
||||||
|
base = (self.voxml_base_url or "").rstrip("/")
|
||||||
|
if not base:
|
||||||
|
base = frappe.utils.get_url()
|
||||||
|
self.webhook_url_display = (
|
||||||
|
f"{base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call"
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_enabled() -> bool:
|
||||||
|
return bool(frappe.db.get_single_value("Voxtelesys Settings", "enabled"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_api_token() -> str:
|
||||||
|
token = frappe.db.get_single_value("Voxtelesys Settings", "api_token")
|
||||||
|
if not token:
|
||||||
|
frappe.throw(
|
||||||
|
"Voxtelesys API Token is not configured. Please set it in Voxtelesys Settings.",
|
||||||
|
title="Voxtelesys Not Configured",
|
||||||
|
)
|
||||||
|
return token
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_caller_id() -> str:
|
||||||
|
return frappe.db.get_single_value("Voxtelesys Settings", "caller_id") or ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_trunk_group() -> str:
|
||||||
|
return frappe.db.get_single_value("Voxtelesys Settings", "outbound_trunk_group") or ""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_recording_enabled() -> bool:
|
||||||
|
return bool(frappe.db.get_single_value("Voxtelesys Settings", "recording_enabled"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_voxml_base_url() -> str:
|
||||||
|
base = frappe.db.get_single_value("Voxtelesys Settings", "voxml_base_url") or ""
|
||||||
|
return base.rstrip("/") or frappe.utils.get_url().rstrip("/")
|
||||||
Loading…
Reference in a new issue