Package com.stripe.net
Class HttpClient
- java.lang.Object
-
- com.stripe.net.HttpClient
-
- Direct Known Subclasses:
HttpURLConnectionClient
public abstract class HttpClient extends java.lang.ObjectBase abstract class for HTTP clients used to send requests to Stripe's API.
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.DurationmaxNetworkRetriesDelayMaximum sleep time between tries to send HTTP requests after network failure.static java.time.DurationminNetworkRetriesDelayMinimum sleep time between tries to send HTTP requests after network failure.
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpClient()Initializes a new instance of theHttpClientclass.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringbuildUserAgentString()Builds the value of theUser-Agentheader.protected static java.lang.StringbuildXStripeClientUserAgentString()Builds the value of theX-Stripe-Client-User-Agentheader.abstract StripeResponserequest(StripeRequest request)Sends the given request to Stripe's API.StripeResponserequestWithRetries(StripeRequest request)Sends the given request to Stripe's API, retrying the request in cases of intermittent problems.StripeResponserequestWithTelemetry(StripeRequest request)Sends the given request to Stripe's API, handling telemetry if not disabled.
-
-
-
Field Detail
-
maxNetworkRetriesDelay
public static final java.time.Duration maxNetworkRetriesDelay
Maximum sleep time between tries to send HTTP requests after network failure.
-
minNetworkRetriesDelay
public static final java.time.Duration minNetworkRetriesDelay
Minimum sleep time between tries to send HTTP requests after network failure.
-
-
Constructor Detail
-
HttpClient
protected HttpClient()
Initializes a new instance of theHttpClientclass.
-
-
Method Detail
-
request
public abstract StripeResponse request(StripeRequest request) throws StripeException
Sends the given request to Stripe's API.- Parameters:
request- the request- Returns:
- the response
- Throws:
StripeException- If the request fails for any reason
-
requestWithTelemetry
public StripeResponse requestWithTelemetry(StripeRequest request) throws StripeException
Sends the given request to Stripe's API, handling telemetry if not disabled.- Parameters:
request- the request- Returns:
- the response
- Throws:
StripeException- If the request fails for any reason
-
requestWithRetries
public StripeResponse requestWithRetries(StripeRequest request) throws StripeException
Sends the given request to Stripe's API, retrying the request in cases of intermittent problems.- Parameters:
request- the request- Returns:
- the response
- Throws:
StripeException- If the request fails for any reason
-
buildUserAgentString
protected static java.lang.String buildUserAgentString()
Builds the value of theUser-Agentheader.- Returns:
- a string containing the value of the
User-Agentheader
-
buildXStripeClientUserAgentString
protected static java.lang.String buildXStripeClientUserAgentString()
Builds the value of theX-Stripe-Client-User-Agentheader.- Returns:
- a string containing the value of the
X-Stripe-Client-User-Agentheader
-
-