From 94cc1cb26fd32aa3a3fbef0f9cef3d8aeffa6392 Mon Sep 17 00:00:00 2001 From: dolfinus Date: Thu, 27 Dec 2018 17:02:12 +0300 Subject: [PATCH] Add class for Imprint API --- .../camunda/latera/bss/apis/Imprint.groovy | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/org/camunda/latera/bss/apis/Imprint.groovy diff --git a/src/org/camunda/latera/bss/apis/Imprint.groovy b/src/org/camunda/latera/bss/apis/Imprint.groovy new file mode 100644 index 00000000..7d618d82 --- /dev/null +++ b/src/org/camunda/latera/bss/apis/Imprint.groovy @@ -0,0 +1,34 @@ +package org.camunda.latera.bss.apis + +import org.camunda.latera.bss.http.HTTPRestProcessor +import org.camunda.latera.bss.logging.SimpleLogger +import org.camunda.latera.bss.utils.IO +import org.camunda.bpm.engine.delegate.DelegateExecution + +class Imprint { + HTTPRestProcessor processor + LinkedHashMap headers + DelegateExecution execution + SimpleLogger logger + + Imprint(DelegateExecution execution) { + this.execution = execution + this.logger = new SimpleLogger(execution) + + def url = execution.getVariable("imprintUrl") + def version = execution.getVariable("imprintVersion") + def token = execution.getVariable("imprintToken") + this.headers = [ + 'X_IMPRINT_API_VERSION': version, + 'X_IMPRINT_API_TOKEN': token + ] + this.processor = new HTTPRestProcessor(baseUrl: url, user: user, password: password, execution: execution) + } + + def print(LinkedHashMap json) { + this.logger.info("Printing begin...") + def result = this.processor.sendRequest(path: '/api/print', body: json, headers: this.headers, requestContentType: 'application/json', 'post') + def file = IO.getBytes(result) + return file + } +} \ No newline at end of file