Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external http client as EosioJavaRpcProviderImpl constructor parameter #14

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ public EosioJavaRpcProviderImpl(@NotNull String baseURL, boolean enableDebug) th
this.rpcProviderApi = this.retrofit.create(IEosioJavaRpcProviderApi.class);
}

/**
* Construct a new RPC provider instance given the base URL to use for building requests.
* @param baseURL Base URL to use for building requests.
* @param okHttpClient external OkHttpClient client.
* @throws EosioJavaRpcProviderInitializerError thrown if the base URL passed in is null.
*/
public EosioJavaRpcProviderImpl(@NotNull String baseURL, @NotNull OkHttpClient okHttpClient) throws EosioJavaRpcProviderInitializerError {
if(baseURL == null || baseURL.isEmpty()) {
throw new EosioJavaRpcProviderInitializerError(EosioJavaRpcErrorConstants.RPC_PROVIDER_BASE_URL_EMPTY);
}

this.baseURL = baseURL;

this.retrofit = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build();

this.rpcProviderApi = this.retrofit.create(IEosioJavaRpcProviderApi.class);
}

/**
* Process a retrofit call, setting arguments, checking responses and decoding responses and errors
* as necessary.
Expand Down