diff --git a/src/tech/avroid/eva/Eva.groovy b/src/tech/avroid/eva/Eva.groovy index 6f4ed00..06b2f93 100644 --- a/src/tech/avroid/eva/Eva.groovy +++ b/src/tech/avroid/eva/Eva.groovy @@ -69,11 +69,12 @@ class Eva implements Serializable { } /** - * Getting Eva task information + * Getting Eva task information @Deprecated use getTaskInfo * @param filterValue String - value for search task * @param filterParam String - type of filter for search task. Default value - "code" * @return String - id of task */ + @Deprecated private String getTask(String filterValue, String filterParam = "code") { Map body = [ jsonrpc: "1.2", @@ -93,4 +94,30 @@ class Eva implements Serializable { ).content.toString() } } + + /** + * Getting Eva task information + * @param filterValue String - value for search task + * @param filterParam String - type of filter for search task. Default value - "code" + * @return Map - fields' task + */ + public Map getTaskInfo(String filterValue, String filterParam = "code") { + Map body = [ + jsonrpc: "1.2", + method: "CmfTask.get", + kwargs: [ + filter: [filterParam, "==", filterValue], + ]] + + script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) { + return script.readJSON( text: script.httpRequest( + url: "$host/api/", + contentType: 'APPLICATION_JSON', + httpMode: 'POST', + customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]], + validResponseCodes: '200', + requestBody: JsonOutput.toJson(body) + ).content.toString())['result'] + } + } }