mirror of
https://github.com/status-im/spiffworkflow-connector.git
synced 2025-02-22 11:38:17 +00:00
Accept task data, pass to connectors (#8)
* Add task_data param * Missed passed one param
This commit is contained in:
parent
c94230ce27
commit
276aa4c34d
5
app.py
5
app.py
@ -125,8 +125,11 @@ def do_command(plugin_display_name, command_name):
|
||||
)
|
||||
|
||||
params = request.args.to_dict()
|
||||
raw_task_data = params.pop('spiff__task_data', '{}')
|
||||
task_data = json.loads(raw_task_data)
|
||||
|
||||
try:
|
||||
result = command(**params).execute(app.config)
|
||||
result = command(**params).execute(app.config, task_data)
|
||||
except Exception as e:
|
||||
return json_error_response(
|
||||
f"Error encountered when executing {plugin_display_name}:{command_name} {str(e)}",
|
||||
|
@ -29,7 +29,7 @@ class AddDynamoItem:
|
||||
self.table = self.dynamodb.Table(table_name)
|
||||
self.item_data = json.loads(item_data)
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
result = self.table.put_item(Item=self.item_data)
|
||||
if "ResponseMetadata" in result:
|
||||
|
@ -19,7 +19,7 @@ class QueryDynamoTable:
|
||||
self.table = self.dynamodb.Table(table_name)
|
||||
self.key = key
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
result = self.table.get_item(Key={"primaryKeyName": self.key})
|
||||
if "ResponseMetadata" in result:
|
||||
|
@ -17,7 +17,7 @@ class ScanDynamoTable:
|
||||
self.dynamodb = SimpleAuth("dynamodb", access_key, secret_key).get_resource()
|
||||
self.table = self.dynamodb.Table(table_name)
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
result = self.table.scan()
|
||||
if "ResponseMetadata" in result:
|
||||
|
@ -28,7 +28,7 @@ class UploadFileData:
|
||||
self.bucket = bucket
|
||||
self.object_name = object_name
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
# Upload the file
|
||||
try:
|
||||
|
@ -22,7 +22,7 @@ class GetPayRate:
|
||||
"""__init__."""
|
||||
self.employee_id = employee_id
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
api_key = config["BAMBOOHR_API_KEY"]
|
||||
subdomain = config["BAMBOOHR_SUBDOMAIN"]
|
||||
|
@ -15,16 +15,10 @@ class CreatePDF:
|
||||
"""__init__."""
|
||||
self.template = template
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
buf = BytesIO()
|
||||
|
||||
# TODO this will be provided in an upcoming pr
|
||||
task_data = {
|
||||
"name": "Bob",
|
||||
"amount": "123",
|
||||
}
|
||||
|
||||
html_string = markdown(self.template)
|
||||
html_template = Environment(loader=BaseLoader, autoescape=True).from_string(
|
||||
html_string
|
||||
@ -55,13 +49,13 @@ class CreatePDFAndUploadToS3:
|
||||
self.template = template
|
||||
self.aws_object_name = aws_object_name
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
aws_access_key_id = config["AWS_ACCESS_KEY_ID"]
|
||||
aws_secret_access_key = config["AWS_SECRET_ACCESS_KEY"]
|
||||
aws_bucket = config["AWS_INVOICE_S3_BUCKET"]
|
||||
|
||||
pdf_result = CreatePDF(self.template).execute(config)
|
||||
pdf_result = CreatePDF(self.template).execute(config, task_data)
|
||||
|
||||
if pdf_result["status"] != "200":
|
||||
return {
|
||||
@ -76,7 +70,7 @@ class CreatePDFAndUploadToS3:
|
||||
pdf_result["response"],
|
||||
aws_bucket,
|
||||
self.aws_object_name,
|
||||
).execute(config)
|
||||
).execute(config, task_data)
|
||||
|
||||
if aws_result["status"] != "200":
|
||||
return aws_result
|
||||
|
@ -14,7 +14,7 @@ class SendMessage:
|
||||
message_type: str
|
||||
recipient: str
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Execute."""
|
||||
url = f'{current_app.config["WAKU_PROXY_BASE_URL"]}/sendMessage'
|
||||
headers = {"Accept": "application/json", "Content-type": "application/json"}
|
||||
|
@ -159,7 +159,7 @@ class CreateInvoice:
|
||||
self.contact_email = contact_email
|
||||
self.amount = amount
|
||||
|
||||
def execute(self, config):
|
||||
def execute(self, config, task_data):
|
||||
"""Creates an invoice in xero."""
|
||||
client_id = config["XERO_CLIENT_ID"]
|
||||
client_secret = config["XERO_CLIENT_SECRET"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user