break;
case DELETE:
conn = createDeleteConnection(url, query, apiKey);
break;
default:
throw new APIConnectionException(
String.format(
"Unrecognized HTTP method %s. "
+ "This indicates a bug in the Stripe bindings. Please contact "
+ "support@stripe.com for assistance.",
method));
}
// trigger the request
int rCode = conn.getResponseCode();
String rBody;
Map<String, List<String>> headers;
if (rCode >= 200 && rCode < 300) {
rBody = getResponseBody(conn.getInputStream());
} else {
rBody = getResponseBody(conn.getErrorStream());
}
headers = conn.getHeaderFields();
return new StripeResponse(rCode, rBody, headers);
} catch (IOException e) {
throw new APIConnectionException(
String.format(
"IOException during API request to Stripe (%s): %s "
+ "Please check your internet connection and try again. If this problem persists,"
+ "you should check Stripe's service status at https://twitter.com/stripestatus,"
+ " or let us know at support@stripe.com.",