SalesforceResponse.java 1.53 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.JSONObject
 */
package com.adobe.cq.mcm.salesforce;

import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

public class SalesforceResponse {
    private String body;
    private Integer code;
    private Boolean accessTokenUpdated = false;

    public SalesforceResponse(Integer code, String body) {
        this.body = body;
        this.code = code;
    }

    public SalesforceResponse() {
    }

    public String getBody() {
        return this.body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Boolean getAccessTokenUpdated() {
        return this.accessTokenUpdated;
    }

    public void setAccessTokenUpdated(Boolean accessTokenUpdated) {
        this.accessTokenUpdated = accessTokenUpdated;
    }

    public JSONObject getBodyAsJSON() throws JSONException {
        if (this.getBody() != null) {
            if (this.getBody().charAt(0) == '[' && this.getBody().charAt(this.getBody().length() - 1) == ']') {
                String responseBody = this.getBody().substring(1, this.getBody().length() - 1);
                return new JSONObject(responseBody);
            }
            return new JSONObject(this.getBody());
        }
        return null;
    }
}