Updated on 2024-10-10 GMT+08:00

APIConnectResponse

Path

com.roma.apic.livedata.provider.v1.APIConnectResponse

Description

This class is used to specify the HTTP status code, header, and body to be returned after a function API is called. To achieve this, the class object must be returned in the execute function.

Example

1
2
3
4
importClass(com.roma.apic.livedata.provider.v1.APIConnectResponse);
function execute(data) {
    return new APIConnectResponse(401, {"X-Type":"Demo"}, "unauthorized", false);
}

In this example, the HTTP status code returned when the function API is called is 401, the response header contains "X-Type: Demo", and the response body is "unauthorized".

Constructor Details

  • public APIConnectResponse(Integer statusCode)

    Constructs an APIConnectResponse.

    Parameter: statusCode indicates the response status code.

  • public APIConnectResponse(Integer statusCode, Map<String,String> headers)

    Constructs an APIConnectResponse.

    Parameters: statusCode indicates the response status code, and headers indicates the response header.

  • public APIConnectResponse(Integer statusCode, Map<String,String> headers, Object body)

    Constructs an APIConnectResponse.

    Parameters: statusCode indicates the response status code, headers indicates the response header, and body indicates the response body.

  • public APIConnectResponse(Integer statusCode, Map<String,String> headers, String body, Boolean base64Encoded)

    Constructs an APIConnectResponse.

    Parameters: statusCode indicates the response status code, headers indicates the response header, body indicates the response body, and base64Encoded indicates whether the body is encoded using Base64.

Method List

Returned Type

Method and Description

Object

getBody()

Obtain the response body.

Map<String,String>

getHeaders()

Obtain the response header.

Integer

getStatusCode()

Obtain the response status code.

Boolean

isBase64Encoded()

Check whether the body is encoded using Base64.

void

setBase64Encoded(Boolean base64Encoded)

Set whether the body is encoded using Base64.

void

setBody(Object body)

Set the response body.

void

setHeaders(Map<String,String> headers)

Set the response header.

void

setStatusCode(Integer statusCode)

Set the response status code.

Method Details

  • public Object getBody()

    Obtain the response body.

    Returns

    Response body.

  • public Map<String,String> getHeaders()

    Obtain the response header.

    Returns

    Map set of the request header.

  • public Integer getStatusCode()

    Obtain the response status code.

    Returns

    Response status code.

  • public Boolean isBase64Encoded()

    Check whether the body is encoded using Base64.

    Returns

    • true: Base64 encoding has been performed.
    • false: Base64 encoding is not performed.
  • public void setBase64Encoded(Boolean base64Encoded)

    Set whether the body is encoded using Base64.

    Input Parameter

    base64Encoded: If the value is true, Base64 encoding has been performed. If the value is false, Base64 encoding is not performed.

  • public void setBody(Object body)

    Set the response body.

    Input Parameter

    body indicates the body object.

  • public void setHeaders(Map<String,String> headers)

    Set the response header.

    Input Parameter

    headers indicates the map set of headers.

  • public void setStatusCode(Integer statusCode)

    Set the response status code.

    Input Parameter

    statusCode indicates the status code.