@@ -123,11 +123,24 @@ public TxClient(String accountId, String serviceKey, DataCenter dataCenter) {
123123 * Create an SDK client to perform Tx API calls with the account information found at https://cloud.textkernel.com/tx/console
124124 * @param accountId - The account id for your account
125125 * @param serviceKey - The service key for your account
126- * @param dataCenter - The Data Center for your account. Either {@link DataCenter#US}, {@link DataCenter#EU} or { @link DataCenter#AU}
126+ * @param dataCenter - The Data Center for your account. Either {@link DataCenter#US}, {@link DataCenter#EU}, or @link DataCenter#AU}
127127 * @param trackingTags - Optional tags to use to track API usage for your account
128128 * @throws IllegalArgumentException if the accountId, serviceKey, or dataCenter are null/empty
129129 */
130130 public TxClient (String accountId , String serviceKey , DataCenter dataCenter , List <String > trackingTags ) {
131+ this (accountId , serviceKey , dataCenter , trackingTags , 30 );
132+ }
133+
134+ /**
135+ * Create an SDK client to perform Tx API calls with the account information found at https://cloud.textkernel.com/tx/console
136+ * @param accountId - The account id for your account
137+ * @param serviceKey - The service key for your account
138+ * @param dataCenter - The Data Center for your account. Either {@link DataCenter#US}, {@link DataCenter#EU} or {@link DataCenter#AU}
139+ * @param trackingTags - Optional tags to use to track API usage for your account
140+ * @param httpTimeoutSecs - Optional override for the OkHttp client read timeout (write and connect are 10 seconds, read is 30 seconds by default)
141+ * @throws IllegalArgumentException if the accountId, serviceKey, or dataCenter are null/empty
142+ */
143+ public TxClient (String accountId , String serviceKey , DataCenter dataCenter , List <String > trackingTags , long httpTimeoutSecs ) {
131144
132145 if (accountId == null || accountId .length () == 0 ) {
133146 throw new IllegalArgumentException ("'accountId' must have a valid value" );
@@ -141,6 +154,10 @@ public TxClient(String accountId, String serviceKey, DataCenter dataCenter, List
141154 throw new IllegalArgumentException ("'dataCenter' must not be null" );
142155 }
143156
157+ if (httpTimeoutSecs <= 0 ) {
158+ throw new IllegalArgumentException ("'httpTimeoutSecs' must be greater than 0" );
159+ }
160+
144161 _endpoints = new ApiEndpoints (dataCenter );
145162
146163 final String trackingTagsHeaderValue ;//must be final to be passed into the interceptor below
@@ -184,7 +201,7 @@ public Response intercept(Interceptor.Chain chain) throws IOException {
184201 })
185202 .connectTimeout (10 , TimeUnit .SECONDS )
186203 .writeTimeout (10 , TimeUnit .SECONDS )
187- .readTimeout (30 , TimeUnit .SECONDS )
204+ .readTimeout (httpTimeoutSecs , TimeUnit .SECONDS )
188205 .build ();
189206 }
190207
0 commit comments