All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.trimble.id.Response Maven / Gradle / Ivy

Go to download

Trimble Identity OAuth Client library holds the client classes that are used for communicating with Trimble Identity Service

The newest version!
package com.trimble.id;

import java.util.List;
import java.util.Map;

/**
 * Represents the response from an HTTP request.
 */
public class Response {

    private int statusCode;

    private Map> headers;

    private T data;

    private String errorMessage;

    private String requestId;

    private String apiEndpoint;

    private long responseTime;

    public Response(int statusCode, Map> headers, T data, String requestId, String errorMessage) {
        this.statusCode = statusCode;
        this.headers = headers;
        this.data = data;
        this.errorMessage = errorMessage;
        this.requestId = requestId;
    }

    public Response(int statusCode, Map> headers, T data, String requestId, String apiEndpoint, long responseTime) {
        this.responseTime = responseTime;
        this.apiEndpoint = apiEndpoint;
        this.statusCode = statusCode;
        this.headers = headers;
        this.data = data;
        this.requestId = requestId;
    }

    /**
     * Get the status code of the response.
     * 
     * @return The status code of the response.
     */
    public int getStatusCode() {
        return statusCode;
    }

    /**
     * Get the headers of the response.
     * 
     * @return The headers of the response.
     */
    public Map> getHeaders() {
        return headers;
    }

    /**
     * Get the data of the response.
     * 
     * @return The data of the response.
     */
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /**
     * Get the error message
     * 
     * @return The error message
     */
    public String getErrorMessage() {
        return errorMessage;
    }

    /**
     * Get the TCP request id
     * 
     * @return The TCP request id
     */
    public String getRequestId() {
        return requestId;
    }

    /**
     * Get the apiEndpoint of the request
     * 
     * @return The apiEndpoint of the request
     */
    public String getApiEndpoint() {
        return apiEndpoint;
    }

    /**
     * Get the response time of the request in milliseconds
     * 
     * @return The response time of the request in milliseconds
     */
    public long getResponseTime() {
        return responseTime;
    }

    /**
     * Set the response time of the request in milliseconds
     * 
     * @param responseTime The response time of the request in milliseconds
     */
    public void setResponseTime(long responseTime) {
        this.responseTime = responseTime;
    }

    /**
     * Set the apiEndpoint of the request
     * 
     * @param apiEndpoint The apiEndpoint of the request
     */
    public void setApiEndpoint(String apiEndpoint) {
        this.apiEndpoint = apiEndpoint;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Response{");
        sb.append("statusCode=").append(statusCode);
        sb.append(", headers=").append(headers);
        sb.append(", data=").append(data);
        sb.append(", errorMessage='").append(errorMessage).append('\'');
        sb.append(", requestId='").append(requestId).append('\'');
        sb.append(", apiEndpoint='").append(apiEndpoint).append('\'');
        sb.append(", responseTime=").append(responseTime);
        sb.append('}');
        return sb.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy