Skip to content

Commit

Permalink
Add class for HOMS API
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Dec 27, 2018
1 parent 2301d54 commit e2634a4
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/org/camunda/latera/bss/apis/HOMS.groovy
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')
}
}

0 comments on commit e2634a4

Please sign in to comment.