diff --git a/ET4 b/ET4 new file mode 100644 index 0000000..e69de29 diff --git a/core/apirequest/__pycache__/path.cpython-314.pyc b/core/apirequest/__pycache__/path.cpython-314.pyc new file mode 100644 index 0000000..f96d797 Binary files /dev/null and b/core/apirequest/__pycache__/path.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/request.cpython-314.pyc b/core/apirequest/__pycache__/request.cpython-314.pyc index d4b42c7..b34ea5d 100644 Binary files a/core/apirequest/__pycache__/request.cpython-314.pyc and b/core/apirequest/__pycache__/request.cpython-314.pyc differ diff --git a/core/apirequest/path.py b/core/apirequest/path.py new file mode 100644 index 0000000..e78cf94 --- /dev/null +++ b/core/apirequest/path.py @@ -0,0 +1,18 @@ +def buildPath(path, outputs): + if isinstance(path, str): + return path + + result = "" + + for part in path: + if isinstance(part, dict): + value = outputs[part["output"]] + + for key in part.get("keys", []): + value = value[key] + + result += str(value) + else: + result += part + + return result diff --git a/core/apirequest/request.py b/core/apirequest/request.py index 11648a6..7d1b726 100644 --- a/core/apirequest/request.py +++ b/core/apirequest/request.py @@ -1,9 +1,12 @@ from .object import buildObject +from .path import buildPath def buildRequest(definition, outputs): + path = buildPath(definition.path, outputs) + request = { "method": definition.method, - "path": definition.path, + "path": path, } if hasattr(definition, "keys"): @@ -25,4 +28,6 @@ def buildRequest(definition, outputs): request["headers"] = headers + print(path) + return request, outputs diff --git a/core/runtime/__init__.py b/core/runtime/__init__.py index 9d915dd..20db262 100644 --- a/core/runtime/__init__.py +++ b/core/runtime/__init__.py @@ -2,6 +2,7 @@ #from . import outputs #from . import managefailure #from . import savedata +from .select import buildSelect, buildSelect2 from .outputs import buildOutput from .savedata import buildSave, loadSave from .logs import buildLog diff --git a/core/runtime/__pycache__/__init__.cpython-314.pyc b/core/runtime/__pycache__/__init__.cpython-314.pyc index 9203522..744a8e0 100644 Binary files a/core/runtime/__pycache__/__init__.cpython-314.pyc and b/core/runtime/__pycache__/__init__.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/logs.cpython-314.pyc b/core/runtime/__pycache__/logs.cpython-314.pyc index 82e7e07..cdb2449 100644 Binary files a/core/runtime/__pycache__/logs.cpython-314.pyc and b/core/runtime/__pycache__/logs.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/outputs.cpython-314.pyc b/core/runtime/__pycache__/outputs.cpython-314.pyc index df59b73..a9bdf97 100644 Binary files a/core/runtime/__pycache__/outputs.cpython-314.pyc and b/core/runtime/__pycache__/outputs.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/runtimecontract.cpython-314.pyc b/core/runtime/__pycache__/runtimecontract.cpython-314.pyc index b3c6ef1..0a08fb6 100644 Binary files a/core/runtime/__pycache__/runtimecontract.cpython-314.pyc and b/core/runtime/__pycache__/runtimecontract.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/select.cpython-314.pyc b/core/runtime/__pycache__/select.cpython-314.pyc new file mode 100644 index 0000000..8b3120b Binary files /dev/null and b/core/runtime/__pycache__/select.cpython-314.pyc differ diff --git a/core/runtime/logs.py b/core/runtime/logs.py index a7b2539..3d4bce0 100644 --- a/core/runtime/logs.py +++ b/core/runtime/logs.py @@ -1,6 +1,6 @@ import logging -def buildLog (action, outputs): +def buildLog (action, outputs, response): #if response.status_code == 200: #print(f"{action.name} successful") try: diff --git a/core/runtime/outputs.py b/core/runtime/outputs.py index ac21762..eb7818e 100644 --- a/core/runtime/outputs.py +++ b/core/runtime/outputs.py @@ -1,5 +1,9 @@ -def buildOutput(response, action, outputs): - +def buildOutput(response, action, outputs):#, select_data): + #if select_data != "not applied": + #response_data = select_data + #else: + #response_data = response.json() + response_data = response.json() response_objects = [response_data] @@ -17,3 +21,5 @@ def buildOutput(response, action, outputs): return outputs + + diff --git a/core/runtime/runtimecontract.py b/core/runtime/runtimecontract.py index cc2ef8d..57e43e4 100644 --- a/core/runtime/runtimecontract.py +++ b/core/runtime/runtimecontract.py @@ -1,10 +1,21 @@ -from core.runtime import buildOutput, buildSave, buildLog +from core.runtime import buildSelect, buildSelect2, buildOutput, buildSave, buildLog + +#select_data = {} def buildRuntimeAttr(action, outputs, response): + #select_data = {} + #response_data = response.json() + + #if hasattr(action, "select"): + #select_data, action, outputs = buildSelect(response, action, outputs) + #else: + #select_data = "not applied" #print("BEFORE buildOutput:", type(outputs)) if hasattr(action, "outputs"): - outputs = buildOutput(response, action, outputs) - + outputs = buildOutput(response, action, outputs)#, select_data) + + if hasattr(action, "select"): + select_data, action, outputs = buildSelect2(action, outputs) #print("AFTER buildOutput:", type(outputs)) #print("DEBUG buildSave") #print("outputs type:", type(outputs)) @@ -15,7 +26,7 @@ def buildRuntimeAttr(action, outputs, response): buildSave(outputs, action) if hasattr(action, "prints"): - buildLog(action, outputs) + buildLog(action, outputs, response) #if hasattr(action, "conversion"): #conversions = action.conversion.items() @@ -26,5 +37,5 @@ def buildRuntimeAttr(action, outputs, response): if action.showstatus is True and response.status_code == 200: print(f"{action.name} successful") - + return outputs, response diff --git a/core/runtime/select.py b/core/runtime/select.py new file mode 100644 index 0000000..2f5e32d --- /dev/null +++ b/core/runtime/select.py @@ -0,0 +1,45 @@ +def buildSelect(response, action, outputs): + #if hasattr(action, "select"): + + response_data = response.json() + #selection = action.select + #print(response_data) + + select_data ={} + for item, index in action.select.items(): + select_data[item] = response_data[item][index] + + print(select_data) + + #if select_data == None: + # selection = "not applied" + #else: + selection = select_data + + return selection, action, outputs + +def buildSelect2(action, outputs): + #print(outputs) + select_data = [] + target = outputs[action.select["source"]] + selectmethod = action.select["selectmethod"] + targetkey = action.select["key"] + targetvalue = action.select["value"] + #for item in target: + for item in target: + #print (item) + for key, value in item.items(): + if selectmethod == "exclude": + if targetkey == key and item[key] != targetvalue: + select_data.append(item) + #print(item) + if selectmethod == "include": + if targetkey == key and item[key] == targetvalue: + select_data.append(item) + #print(item) + print(select_data) + return select_data, action, outputs + #for item in outputs[output_name]: + #for key, value in action.select.include.items(): + #if key in item and item[key] == value: + #select_data.append(item) diff --git a/plugins/rmass/actions/__init__.py b/plugins/rmass/actions/__init__.py index 2d020a5..e3ba84f 100644 --- a/plugins/rmass/actions/__init__.py +++ b/plugins/rmass/actions/__init__.py @@ -1 +1 @@ -from . import login, getcsrf, refresh_tokens, checkavailable, setavailable, setunavailable, setnotset +from . import login, getcsrf, refresh_tokens, checkavailable, setavailable, setunavailable, setnotset, getmessage diff --git a/plugins/rmass/actions/__pycache__/__init__.cpython-314.pyc b/plugins/rmass/actions/__pycache__/__init__.cpython-314.pyc index c382f1a..f8bd970 100644 Binary files a/plugins/rmass/actions/__pycache__/__init__.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/__init__.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc new file mode 100644 index 0000000..d06a256 Binary files /dev/null and b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc new file mode 100644 index 0000000..289ddf3 Binary files /dev/null and b/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc differ diff --git a/plugins/rmass/actions/getmessage.py b/plugins/rmass/actions/getmessage.py new file mode 100644 index 0000000..b13a967 --- /dev/null +++ b/plugins/rmass/actions/getmessage.py @@ -0,0 +1,63 @@ +import os + +name = "Get message" + +kind = "action" + +#id = "getmessage" + +showstatus = True + +#skipstep = { +# "checkavailable": "validTo >= 3600" +#} + +#availabletime = int(os.environ.get("AVAILABLE_DURATION",3)) + +#duration = availabletime - 1 + +#keys = [ +# { +# "keytitle": "option", +# "keyvalue": 1, +# }, +# { +# "keytitle": "duration", +# "keyvalue": duration, +# }, +#] + +method = "GET" + +#messageid = 49971192 + +#path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}" +#path = [ +# "https://rentmasseur.com/api/v1/mailbox/", +# {"output": "[messageid][0].id"} +#] + +path = [ + "https://rentmasseur.com/api/v1/mailbox/", + { + "output": "messageid", + "keys": [0, "id"] + } +] + +#path = os.path.join(baseurl.messageid) + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +outputs = { + "conversation": "messages" +} + +#prints = { +# "message": "messages" +#} diff --git a/plugins/rmass/actions/pullmessagelist.py b/plugins/rmass/actions/pullmessagelist.py new file mode 100644 index 0000000..ced788b --- /dev/null +++ b/plugins/rmass/actions/pullmessagelist.py @@ -0,0 +1,52 @@ +name = "Get message list" + +kind = "action" + +id = "getmessagelist" + +showstatus = True + +#skipstep = { +# "checkavailable": "validTo >= 3600" +#} + +#availabletime = int(os.environ.get("AVAILABLE_DURATION",3)) + +#duration = availabletime - 1 + +#keys = [ +# { +# "keytitle": "option", +# "keyvalue": 1, +# }, +# { +# "keytitle": "duration", +# "keyvalue": duration, +# }, +#] + +method = "GET" + +#path = "https://rentmasseur.com/api/v1/mailbox?page=1&folder=1&sort=1" +path = "https://rentmasseur.com/api/v1/mailbox" +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +select = { + "source": "emails", + "selectmethod": "exclude", + "key": "unread", + "value": 0, +} + +outputs = { + "emails": "emails" +} + +#prints = { +# "messageid": "id" +#} diff --git a/plugins/rmass/operations/__init__.py b/plugins/rmass/operations/__init__.py index c6042c6..0366f92 100644 --- a/plugins/rmass/operations/__init__.py +++ b/plugins/rmass/operations/__init__.py @@ -1,2 +1,2 @@ -from . import login, checkavailable, setavailable +from . import login, checkavailable, setavailable, pullmessagelist diff --git a/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc b/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc index 1646f66..20211af 100644 Binary files a/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc and b/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc differ diff --git a/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc new file mode 100644 index 0000000..83b2248 Binary files /dev/null and b/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc differ diff --git a/plugins/rmass/operations/pullmessagelist.py b/plugins/rmass/operations/pullmessagelist.py new file mode 100644 index 0000000..2b32993 --- /dev/null +++ b/plugins/rmass/operations/pullmessagelist.py @@ -0,0 +1,26 @@ +from plugins.rmass.actions import pullmessagelist, refresh_tokens, getmessage + +name = "Get Message List" + +kind = "operation" + +actions = [ + refresh_tokens, + pullmessagelist, + #getmessage, + #setavailable, +] + +#sleeptime = 10 + +#skipstep = { +# setavailable: { +# "output": "validTo", +# "operator": ">=", +# "value": 3600, +# } +#} + +#role = "activate" + +#sleeptime = 180 diff --git a/pullmessagelist (Copy).py b/pullmessagelist (Copy).py new file mode 100644 index 0000000..07a469e --- /dev/null +++ b/pullmessagelist (Copy).py @@ -0,0 +1,28 @@ +import time +from plugins import rmass +from core.execution.operation import buildOperation + +outputs = buildOperation(rmass.operations.pullmessagelist) + +#print(outputs) +user_list = [] +for item in outputs["message_list"]: + sender = item["userCard"] + user_list.append(sender["id"]) +print(user_list) + +conversations = [] +for item in outputs["message_list"]: + conversation = item["id"] + conversations.append(conversation) + +print(conversations) +#for messageid in user_list + #outputs = buildOperation(rmass.operations.getmessage) +#id_list = [] +#for user in user_list +# id_list.append +# print + + +#ime.sleep(rmass.operations.setavailable.sleeptime) diff --git a/pullmessagelist.py b/pullmessagelist.py new file mode 100644 index 0000000..08fb56f --- /dev/null +++ b/pullmessagelist.py @@ -0,0 +1,38 @@ +import time +from plugins import rmass +from core.execution.operation import buildOperation +from core.execution.action import buildAction +#from plugins.rmass.actions.getmessage import getmessageaction + +outputs = buildOperation(rmass.operations.pullmessagelist) + +#print(outputs) +#print(messageid) +#user_list = [] +#for item in outputs["message_list"]: +# sender = item["userCard"] +# user_list.append(sender["id"]) +#print(user_list) + +#conversations = [] +#for item in outputs["message_list"]: +# conversation = item["id"] +# conversations.append(conversation) + +#print(conversations) + +#for messageid in conversations: +#outputs = buildAction(rmass.actions.getmessage, outputs) + +#print(outputs) + + +#for messageid in user_list + #outputs = buildOperation(rmass.operations.getmessage) +#id_list = [] +#for user in user_list +# id_list.append +# print + + +#ime.sleep(rmass.operations.setavailable.sleeptime) diff --git a/tokens.json b/tokens.json index 4d2c043..c6b3d6b 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE2NzQzMzAsIm5iZiI6MTc5MTY3NDE1MCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTY3NDIxMH0.HcqR4crgZkqdaSKpY3EiC8aejvlgQppKZbV_El8MeCPzoRSHssJcDtj5dmDXjP3VhjseIbgPvCqDxKC2jb3Qdg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQyNjYyMTAsIm5iZiI6MTc5MTY3NDE1MCwianRpIjoiZTJRY3FUYnNBSjRpZWNSQ0JEWUdXY2pvYkxDREkrS05mRUwzQUU1OEk3az0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTY3NDIxMCwic3ViIjoiMjM4MzAyIn0.ExbPr-h99AVPpB0RTZs_3h15rY1clue95tGb0Cq0qrqkhaWloB8G6v7vmCFqJcpVyW1YHLrw45zOjPv9uZ25oA"} \ No newline at end of file +{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE4MTU5NzksIm5iZiI6MTc5MTgxNTc5OSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTgxNTg1OX0.oxYvEJrX9lQRiHtaOndLLv8bZGo1AVboC6xjKljnrHmXSJe52-urHrQsTyc1XlJV08a5z_1ctYR8yGmYejwjeQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ0MDc4NTksIm5iZiI6MTc5MTgxNTc5OSwianRpIjoiK25FQmd1VGxlN1g2N1V3NXBEUXRMMXRQTzZYMEdHcGZYMW1vaXNNYVNxRT0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTgxNTg1OSwic3ViIjoiMjM4MzAyIn0.hTff0wNuOgBQTTYdt9DpVjVwyxj5oA4C7SBWwmY0Uaf5M2kfhI_YWCJRJL9oGrDfHt32N3_PEsfPRWQZBcZJdw"} \ No newline at end of file