# validation_rest_min.py
# A minimal Python program to test the FirmaSAT Validation REST API
import requests
import json

# 1. Define some XML content as a string
# As a test, send some well-formed XML that is not a valid SAT CFDi document
# This should return a status "partialsuccess" with an xml-error
# "XML file is not a supported document."
xml_content = """<?xml version="1.0"?><data><item>value</item></data>"""

# 2. Create the payload: a dictionary where the XML is an encoded string value
payload = {
    "api-token": "YOUR_API_TOKEN_HERE",  # Replace with your own api-token
    "xmldata": xml_content,
}

# 3. Define the target URL and headers
url = "https://di-mgt.com.au/cryptosys/api/fsa_validation"
headers = {
    "Content-Type": "application/json"
}

# 4. Send the POST request using the json= parameter
# The requests library automatically serializes the dictionary to JSON
response = requests.post(url, json=payload, headers=headers)

# 5. Check the response
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")