Package ru.loolzaaa.youkassa.client
Class ApiClientBuilder
java.lang.Object
ru.loolzaaa.youkassa.client.ApiClientBuilder
This class implement builder pattern for
ApiClient.
Compared with constructor creation of ApiClient,
this option additionally provides some sanity checks.
Usage:
ApiClient client = ApiClientBuilder.newBuilder()
.configureBasicAuth("shop_id", "secret_key")
.build();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionSets API url endpoint for client.build()CreatedApiClientinstance.configureBasicAuth(String accountId, String secretKey) Authentication configuration via Basic auth method.configureOAuth(String authToken) Authentication configuration via OAuth method.static ApiClientBuilderCreates new builder forApiClient.
-
Method Details
-
apiUrl
Sets API url endpoint for client.- Parameters:
apiUrl- api endpoint url- Returns:
- builder itself
-
configureBasicAuth
Authentication configuration via Basic auth method.Only one method (Basic/OAuth) of authentication can be configured.
- Parameters:
accountId- id of yookassa shop/accountsecretKey- secret key of yookassa shop/account- Returns:
- builder itself
- Throws:
IllegalArgumentException- if OAuth token not null
-
configureOAuth
Authentication configuration via OAuth method.Only one method (Basic/OAuth) of authentication can be configured.
- Parameters:
authToken- OAuth client token- Returns:
- builder itself
- Throws:
IllegalArgumentException- if accountId or secretKey not null
-
build
CreatedApiClientinstance.Construct authentication header value supplier based on configured authentication method.
- Returns:
- instance of
ApiClient - Throws:
IllegalArgumentException- if authentication not configured
-
newBuilder
Creates new builder forApiClient.- Returns:
- new builder instance
-