63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
import requests
|
|
from bs4 import BeautifulSoup as bs
|
|
from datetime import datetime, timedelta
|
|
import time
|
|
|
|
def client_Specific_Tabs(option, wb, ticket, HOST, URL):
|
|
print("Client Specific")
|
|
if option == "Westfield":
|
|
Westfield()
|
|
elif option == "CCM":
|
|
CCM(wb, ticket, HOST, URL)
|
|
else:
|
|
return
|
|
|
|
|
|
def Westfield():
|
|
return
|
|
|
|
def CCM(wb, ticket, HOST, URL):
|
|
|
|
print("CCM is starting")
|
|
|
|
REPORT_FIELDS = '<string>Order ID</string>, <string>Order Status</string>'
|
|
|
|
now = datetime.now()
|
|
first = now.replace(day=1)
|
|
lastMonth = first - timedelta(days=1)
|
|
previous = lastMonth.strftime("%m/01/%Y")
|
|
now = now.strftime("%m/%d/%Y")
|
|
|
|
ws4 = wb.create_sheet("Downloaded Items")
|
|
|
|
report_filter = """ <filterNameOrXml><?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Date/Time Created" query="IsBetweenDate" minValue=""" + '"' + previous + ' 00:00"' + """ maxValue=""" + '"' + now + ' 00:00"' """/> <PFWebFilter:Step publicFieldName="PrintingFreeDownloadOnly" query="ExactEquals" minValue="download" maxValue="" /> </PFWebFilter:UserFilter></filterNameOrXml>
|
|
"""
|
|
|
|
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>Items</reportName>
|
|
<archived>false</archived>
|
|
""" + report_filter + """
|
|
<columnNames>""" + REPORT_FIELDS + """</columnNames>
|
|
</GetReport>
|
|
</soap12:Body>
|
|
</soap12:Envelope>"""
|
|
|
|
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length',
|
|
'SOAPAction': 'http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111/GetReport'}
|
|
response = requests.post(url=URL, data=send, headers=headers).text
|
|
|
|
temp1 = response.split('</GetReportResult>')
|
|
temp2 = temp1[1].split('<error />')
|
|
report = (temp2[0])
|
|
|
|
y = bs(report, "lxml")
|
|
|
|
ws4.append(report)
|
|
|
|
return
|