Search in sources :

Example 1 with StripeObject

use of com.stripe.model.StripeObject in project stripe-java by stripe.

the class LiveStripeResponseGetter method staticRequest.

private static <T> T staticRequest(APIResource.RequestMethod method, String url, Map<String, Object> params, Class<T> clazz, APIResource.RequestType type, RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException {
    StripeResponse response = rawRequest(method, url, params, type, options);
    int responseCode = response.code();
    String responseBody = response.body();
    String requestId = response.requestId();
    if (responseCode < 200 || responseCode >= 300) {
        handleAPIError(responseBody, responseCode, requestId);
    }
    T resource = APIResource.GSON.fromJson(responseBody, clazz);
    if (resource instanceof StripeObject) {
        StripeObject obj = (StripeObject) resource;
        obj.setLastResponse(response);
    }
    return resource;
}
Also used : StripeObject(com.stripe.model.StripeObject)

Aggregations

StripeObject (com.stripe.model.StripeObject)1