Package com.whatsapp.api
Class WhatsappApiServiceGenerator
java.lang.Object
com.whatsapp.api.WhatsappApiServiceGenerator
The type Whatsapp api service generator.
-
Method Summary
Modifier and TypeMethodDescriptionstatic okhttp3.OkHttpClient
static <S> S
createService
(Class<S> serviceClass, String token) Create service s.static <S> S
createService
(Class<S> serviceClass, String token, String baseUrl) Create service s.static <T> MediaFile
executeDownloadSync
(retrofit2.Call<T> call) Execute sync file downloadstatic <T> T
executeSync
(retrofit2.Call<T> call) Execute sync t.static okhttp3.OkHttpClient
Gets shared client.static WhatsappApiError
getWhatsappApiError
(retrofit2.Response<?> response) Gets whatsapp api error.static void
setHttpProxy
(String host, int port, String username, String pwd) Sets http proxy for the shared client.
-
Method Details
-
createDefaultHttpClient
public static okhttp3.OkHttpClient createDefaultHttpClient() -
setHttpProxy
Sets http proxy for the shared client.If you need to use a proxy to connect to the internet, you can use this method to set it.
- If you want to use a proxy that requires authentication,
you can pass the username and password as parameters.
- If you want to use a proxy that does not require authentication,
you can pass
null
as parameters forusername
andpwd
.
- Parameters:
host
- the host (Not null)port
- the portusername
- the usernamepwd
- the pwd- See Also:
- If you want to use a proxy that requires authentication,
you can pass the username and password as parameters.
-
createService
Create service s.- Type Parameters:
S
- the type parameter- Parameters:
serviceClass
- the service classtoken
- the tokenbaseUrl
- the base url- Returns:
- the s
-
createService
Create service s.- Type Parameters:
S
- the type parameter- Parameters:
serviceClass
- the service classtoken
- the token- Returns:
- the s
-
executeSync
public static <T> T executeSync(retrofit2.Call<T> call) Execute sync t.- Type Parameters:
T
- the type parameter- Parameters:
call
- the call- Returns:
- the t
-
executeDownloadSync
Execute sync file download- Type Parameters:
T
- the type parameter- Parameters:
call
- the call- Returns:
- the t
-
getWhatsappApiError
public static WhatsappApiError getWhatsappApiError(retrofit2.Response<?> response) throws WhatsappApiException, IOException Gets whatsapp api error.- Parameters:
response
- the response- Returns:
- the whatsapp api error
- Throws:
WhatsappApiException
- the whatsapp api exceptionIOException
- the io exception
-