Source code for isodata.pjm.query.QueryUpToTransactionResults
"""QueryUpToTransactionResults - This message is used to query for up to transactions results. This is a private report.
Optional. The ID of the Up To Transaction to query.
"""
# pylint:disable=duplicate-code
from ...pjm import constants as C
[docs]
def prepare(token, **kwargs):
"""prepare and return all the components of the requests call."""
transaction_filter = ''
if 'transaction_id' in kwargs:
transaction_filter = ' TransactionID="%s"' % kwargs['transaction_id']
try:
xml = "".join([
'<?xml version="1.0" encoding="UTF-8"?>',
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="%s" xmlns:SOAP-ENV="%s">' % (C.SOAP_ENCCODING, C.SOAP_ENVELOPE),
'<SOAP-ENV:Body>',
'<QueryRequest xmlns="%s">' % C.PJM_EMKT_XMLNS,
'<QueryUpToTransactionResults day="%s" %s/>' % (kwargs['market_day'].strftime("%Y-%m-%d"), transaction_filter),
'</QueryRequest>',
'</SOAP-ENV:Body>',
'</SOAP-ENV:Envelope>',
])
except KeyError as err:
raise TypeError('[%s] Missing required field: %s for query.' % (kwargs['report'], err)) from err
return {
'xml': xml,
'headers': {
**C.PJM_BASE_HEADERS,
'Cookie': 'pjmauth=' + token,
'Content-length': str(len(xml))
},
'url': C.PJM_EMKT_URL_QUERY
}