-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dolfinus
committed
Dec 27, 2018
1 parent
2301d54
commit e2634a4
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.camunda.latera.bss.apis | ||
|
||
import org.camunda.latera.bss.http.HTTPRestProcessor | ||
import org.camunda.latera.bss.logging.SimpleLogger | ||
import org.camunda.bpm.engine.delegate.DelegateExecution | ||
|
||
class HOMS { | ||
HTTPRestProcessor processor | ||
DelegateExecution execution | ||
LinkedHashMap headers | ||
SimpleLogger logger | ||
|
||
HOMS(DelegateExecution execution) { | ||
this.headers = [:] | ||
this.execution = execution | ||
this.logger = new SimpleLogger(this.execution) | ||
|
||
url = execution.getVariable("homsUrl") | ||
user = execution.getVariable("homsUser") | ||
password = execution.getVariable("homsPassword") | ||
/* | ||
token = execution.getVariable("hbwToken") | ||
this.headers = [ | ||
'Token': this.token | ||
] | ||
*/ | ||
this.processor = new HTTPRestProcessor(baseUrl: url, | ||
user: user, | ||
password: password, | ||
execution: execution) | ||
} | ||
|
||
def createOrder(String type, LinkedHashMap data) { | ||
LinkedHashMap body = [ | ||
order: [ | ||
order_type_code: type, | ||
data: data | ||
] | ||
] | ||
this.logger.info("Creating new order") | ||
def result = this.processor.sendRequest(path: '/api/orders', | ||
body: body, | ||
headers: this.headers, | ||
'post') | ||
LinkedHashMap order = result.order | ||
this.execution.setVariable("homsOrderCode", order.code) | ||
this.execution.setVariable("homsOrderId", order.id) | ||
return order | ||
} | ||
|
||
def attachFiles(List files) { | ||
Long orderId = this.execution.getVariable("homsOrderId") | ||
LinkedHashMap body = [ | ||
order_id: orderId, | ||
attachments: files | ||
] | ||
this.logger.info("Attaching files to order ${orderId}") | ||
return this.processor.sendRequest(path: '/api/attachments', | ||
body: body, | ||
headers: this.headers, | ||
'post') | ||
} | ||
} |