HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_forms/buyercall/buyercall/integrations/ams_prequalify.py
import os
import logging
import xml.etree.ElementTree as ET
from flask import current_app as app
import requests
import xml.etree.ElementTree as ET
import xmltodict
import json
log = logging.getLogger(__name__)

class AMSPreQualify(object):
    def __init__(self, url, client_id):
        self.base_url = url
        self.client_id = client_id
    
    def post(self, data):
        data["clientId"] = self.client_id
        headers = {'Content-Type': 'application/json'}
        r = requests.post(self.base_url, json=data, headers=headers) 
        if r.status_code == 200:
            try:
                response_data = r.json()
                return r.status_code, response_data
            except json.JSONDecodeError:
                log.error(f'Failed to decode JSON response: {r.text}')
                return r.status_code, 'Error posting form lead.', ''
        else:
            log.error(f'Response: {r.text}')
            return r.status_code, 'Error posting form lead.', ''