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

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

There is a newer version: 0.5.5
Show newest version
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 details = content.toString(); return "HTTP Status Code " + httpStatusCode + " (" + httpReasonPhrase + "): " + details; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy