com.chargebee.Result Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chargebee-java Show documentation
Show all versions of chargebee-java Show documentation
Java client library for ChargeBee API
package com.chargebee;
import com.chargebee.internal.ResultBase;
import org.json.JSONObject;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static com.chargebee.IdempotencyConstants.IDEMPOTENCY_REPLAY_HEADER;
public class Result extends ResultBase implements ApiResponse {
public final int httpCode;
public Map> responseHeaders;
public Result(int httpCode, JSONObject jsonObj) {
super(jsonObj);
this.httpCode = httpCode;
}
public Result(int httpCode, JSONObject jsonObj, Map> responseHeaders) {
this(httpCode,jsonObj);
this.responseHeaders = responseHeaders;
}
public int httpCode() {
return httpCode;
}
public Map> getResponseHeaders() {
return responseHeaders;
}
public boolean isIdempotencyReplayed() {
Map> headers = responseHeaders;
Optional replayedHeader = headers.entrySet().stream()
.filter(entry -> IDEMPOTENCY_REPLAY_HEADER.equalsIgnoreCase(entry.getKey()))
.findFirst()
.flatMap(entry -> entry.getValue().stream().findFirst());
return replayedHeader.isPresent();
}
public JSONObject jsonResponse() {
return jsonObj();
}
}