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

com.stitchdata.client.StitchResponse Maven / Gradle / Ivy

package com.stitchdata.client;
import javax.json.JsonReader;
import javax.json.Json;
import javax.json.JsonObject;

/**
 * Encapsulates a response received from Stitch.
 */
public class StitchResponse {
    private final int httpStatusCode;
    private final String httpReasonPhrase;
    private final JsonObject content;

    public StitchResponse(int httpStatusCode, String httpReasonPhrase, JsonObject content) {
        this.httpStatusCode = httpStatusCode;
        this.httpReasonPhrase = httpReasonPhrase;
        this.content = content;
    }

    /**
     * Returns true if the request succeeded.
     *
     * @return 
    *
  • true - if the request succeeded
  • *
  • false - if the request failed
  • *
*/ public boolean isOk() { return httpStatusCode < 300; } public int getHttpStatusCode() { return httpStatusCode; } public String getHttpReasonPhrase() { return httpReasonPhrase; } public JsonObject getContent() { return content; } public String toString() { String result = "HTTP Status Code " + httpStatusCode + " (" + httpReasonPhrase + ")"; if (content != null) { result += ": " + content.toString(); } return result; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy