Files
StorefrontUtility/main.py

67 lines
2.8 KiB
Python

import requests
from lxml import etree
def Obtain_Ticket(URL, HOST):
GetTicket = """<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ObtainUserTicket xmlns="http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111">
<username>ddembinski</username>
<password>mond@y</password>
<ident>string</ident>
</ObtainUserTicket>
</soap12:Body>
</soap12:Envelope>"""
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
response = requests.post(url=URL, data=GetTicket, headers=headers).text
# print(response)
temp1 = response.split('<ObtainUserTicketResult>')
temp2 = temp1[1].split('</ObtainUserTicketResult>')
ticket = temp2[0]
# print("got ticket: " + ticket)
return ticket
def Release_Ticket(ticket, URL, HOST):
ReleaseTicket = """<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ReleaseTicket xmlns="http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111">
<ticket>"""+ticket+""""</ticket>
</ReleaseTicket>
</soap12:Body>
</soap12:Envelope>"""
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
# print("released ticket "+ticket)
def Run_Report(ticket, URL, HOST):
send = """<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetReport xmlns="http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111">
<token>"""+ticket+"""</token>
<reportName>Orders</reportName>
<columnNames>
<string>Order ID</string>
<string>Order Price</string>
</columnNames>
</GetReport>
</soap12:Body>
</soap12:Envelope>"""
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
response = requests.post(url=URL, data=send, headers=headers).text
print(response)
def main():
URL = 'http://soprema.gli.us.com/Store/storefrontapi.asmx'
HOST = 'soprema.gli.us.com'
ticket = Obtain_Ticket(URL, HOST)
Run_Report(ticket, URL, HOST)
Release_Ticket(ticket, URL, HOST)
main()