-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTUG_2022_GetPONo.json
1 lines (1 loc) · 2.54 KB
/
TUG_2022_GetPONo.json
1
[{"name":"TUG_2022_GetPONo","description":"","scriptCode":"####### Build an IDM api request Payload #######\n#\n# Author: Rob Thayer\n# Date: Arpil 1 2022\n#\n#################################################\n\nimport xml.etree.ElementTree as ET\nimport json\nfrom typing import List\n\nclass DataInput:\n def __init__(self):\n self.entity = \"Purchase_Order\"\n self.keyattr = \"Purchase_Order_Number\"\n self.operator = \"=\"\n self.textSearch = False\n self.logicalType = \"\"\n\n def getPO(self):\n root = ET.fromstring(INPUT)\n ns = {'xs': 'http://schema.infor.com/InforOAGIS/2'}\n poNo = root.find(\".//xs:DataArea/xs:PurchaseOrder/xs:PurchaseOrderHeader/xs:DocumentID/xs:ID\", ns)\n if poNo is not None:\n pono = poNo.text[:-3] \n else:\n pono = poNo.text\n return pono \n\nclass Query(object):\n def __init__(self, query: str):\n self.query = query \n\nclass Queries(object):\n def __init__(self, queries: List[Query]):\n self.queries = queries\n\nclass QueryKeys(object):\n def __init__(self,entities: str, useTextSearch: str, arguments: str):\n self.entities = entities\n self.useTextSearch = useTextSearch\n self.arguments = arguments\n\nclass ArgumentKeys(object):\n def __init__(self, key: str, operator: str, value: str, logicalType: str): \n self.key = key\n self.operator = operator\n self.value = value\n self.logicalType = logicalType\n\nclass ArgumentsArg(object):\n def __init__(self, argument: List[ArgumentKeys]):\n self.argument = argument \n\nclass Request:\n def payload():\n params = DataInput()\n argKeys = ArgumentKeys(key=params.keyattr,operator=params.operator,value=params.getPO(),logicalType=params.logicalType)\n argsArg = ArgumentsArg([argKeys])\n queryKeys = QueryKeys(entities=params.entity,useTextSearch=params.textSearch, arguments=argsArg)\n query = Query(query=[queryKeys])\n result = Queries(queries=query)\n return result\n\ndef getIDMItem(result: str):\n result = json.dumps(result, default=lambda o: o.__dict__, indent=4)\n return result\n\nOUTPUT = getIDMItem(Request.payload()) \n\n\n","documentation":"","usedLibraries":[],"inputVariables":[],"outputVariables":[],"variables":[{"name":"OUTPUT","fileName":"","description":"","dataType":"STRING","type":"OUTPUT","content":null},{"name":"INPUT","fileName":"","description":"","dataType":"STRING","type":"INPUT","content":null}]}]