Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
operation_service.py30 linesDownload Raw Back to services
1import os2 3import requests4 5 6class OperationService:7    base_url = os.environ.get("BILLING_API_URL", "BILLING_API_URL")8    secret_key = os.environ.get("BILLING_API_SECRET_KEY", "BILLING_API_SECRET_KEY")9 10    @classmethod11    def _send_request(cls, method, endpoint, json=None, params=None):12        headers = {"Content-Type": "application/json", "Billing-Api-Secret-Key": cls.secret_key}13 14        url = f"{cls.base_url}{endpoint}"15        response = requests.request(method, url, json=json, params=params, headers=headers)16 17        return response.json()18 19    @classmethod20    def record_utm(cls, tenant_id: str, utm_info: dict):21        params = {22            "tenant_id": tenant_id,23            "utm_source": utm_info.get("utm_source", ""),24            "utm_medium": utm_info.get("utm_medium", ""),25            "utm_campaign": utm_info.get("utm_campaign", ""),26            "utm_content": utm_info.get("utm_content", ""),27            "utm_term": utm_info.get("utm_term", ""),28        }29        return cls._send_request("POST", "/tenant_utms", params=params)30