Формат вызовов API ИБП с помощью django в html

import xml.etree.ElementTree as ET
from zeep import Client, Settings
from zeep.exceptions import Fault, TransportError, XMLSyntaxError

# Set Connection
settings = Settings(strict=False, xml_huge_tree=True)
client = Client('SCHEMA-WSDLs/RateWS.wsdl', settings=settings)

# Set SOAP headers
headers = {

    'UPSSecurity': {
        'UsernameToken': {
            'Username': 'username',
            'Password': 'password'
        },

        'ServiceAccessToken': {
            'AccessLicenseNumber': 'asdasdasdasd'
        }

    }
}

# Create request dictionary
requestDictionary = {

    "RequestOption": "Shop",
    "TransactionReference": {
        "CustomerContext": "Your Customer Context"
    }
}

# Create rate request dictionary
rateRequestDictionary = {

    "Package": {
        "Dimensions": {
            "Height": "10",
            "Length": "5",
            "UnitOfMeasurement": {
                "Code": "IN",
                "Description": "inches"
            },
            "Width": "4"
        },
        "PackageWeight": {
            "UnitOfMeasurement": {
                "Code": "Lbs",
                "Description": "pounds"
            },
            "Weight": "1"
        },
        
        "PackagingType": {
            "Code": "02",
            "Description": "shop"
        }
    },
    "Service": {
        "Code": "03",#3 – Standard List Rates
        "Description": "Service Code"
    },
    "ShipFrom": {
        "Address": {
            "AddressLine": [
                "1 toronto rd",
            ],
            "City": "North York",
            "CountryCode": "CA",
            "PostalCode": "M3J1C8",
            "StateProvinceCode": "ON"
        },
        "Name": "Name"
        
    },
    "ShipTo": {
        "Address": {
            "AddressLine": "15 Hillpark Trail",
            "City": "Brampton",
            "CountryCode": "CA",
            "PostalCode": "L6S1R1",
            "StateProvinceCode": "ON"
        },
        "Name": "Name"
    },
    "Shipper": {
        "Address": {
            "AddressLine": [
                "Street Name",
            ],
            "City": "Toronto",
            "CountryCode": "CA",
            "PostalCode": "M3J1C8",
            "StateProvinceCode": "ON"
        },
        "Name": "ZTL",
        "ShipperNumber": "+66666666"
    }
}

# Try operation
try:
    response = client.service.ProcessRate(_soapheaders=headers, Request=requestDictionary,
                                         Shipment=rateRequestDictionary)
                                        
    print(response)

except Fault as error:
    print(ET.tostring(error.detail))

// как я могу получить значение тарифа из ответа... только сумму для оплаты и код, как наземный, экспресс или другие..., Я хочу сделать HTML страницу для выбора между экспресс и наземным тарифом с указанием значения, json ответ в htmlso пользователь может выбрать, затем значение доставки идет к общей стоимости в корзине...,

я только начинаю работать с json и apis call

.... //

Вернуться на верх