Skip to content

Communications

The JS Communications object can be used in user customizable scripts within CYBERQUEST Data Transformation Service (DTS) and in Alerts. This Object can be called using subobjects, such as:

HttpRequest

This class is a wrapper that encapsulates the http client on specific targets (windowsagent, etc.).

All methods that send requests will return a uniform formatted response, along with the status code or potential errors.

Usage:

const request = new HttpRequest();
const response = request.get('https://api.nextgensoftware.eu/users/').asJson();

request.post('https://api.nextgensoftware.eu/users/create/', {
    name: "Test"
}, {
    headers: {
        Referer: "test"
    },
    auth: {
        username: "test",
        password: "test"
    }
});

HttpRequest.get

HttpRequest.get(url, config=null)

Returns:

  • HttpResponse

HttpRequest.post

HttpRequest.post(url, data, config=null)

Returns:

  • HttpResponse

HttpRequest.put

HttpRequest.put(url, data, config=null)

Returns:

  • HttpResponse

HttpRequest.delete

HttpRequest.delete(url, config=null)

Returns:

  • HttpResponse

HttpRequest.head

HttpRequest.head(url, config=null)

Returns:

  • HttpResponse

HttpResponse

Properties:

  • int statusCode
  • string data - The raw response body
  • Array headers - The response headers

HttpResponse.asJson()

Parses the response body as JSON.

HttpResponse.asXml()

Parses the response body as XML.

Notification.sendMessage

Parameters:

  • text - this is the message of the notification
  • type - what platform the notification is sent to (email by default, can be sent to slack or teams as well)
  • additionalParamateres (url mandatory, subjectData optional, to optional)

Taking into account the type parameter of the sendMessage method, the module will select the appropriate particular class, instantiate it under its own rules and dispatch the notification.

Usage:

CQ.Communications.sendMessage(message,platform(slak/teams/email),objectConfiguration{url:"",to:"optional",subjectData:"optional"})