Skip to main content

NotificationHubClient

com.notificationhub.sdk.NotificationHubClient

The root client. Construct it once via NotificationHubClient.Builder and share the instance across your application — it owns a shared HttpClient and ObjectMapper used by every sub-client.

NotificationHubClient.Builder

MethodDescription
apiKey(String apiKey)Sets the API key. Required.
apiSecret(String apiSecret)Sets the API secret used for HMAC signing. Required.
baseUrl(String baseUrl)Overrides the default endpoint. Throws IllegalArgumentException if the URL is http:// and not localhost. Trailing slash is stripped.
build()Returns a NotificationHubClient. Throws IllegalArgumentException if apiKey or apiSecret is null/blank.
NotificationHubClient client = new NotificationHubClient.Builder()
.apiKey("your-api-key")
.apiSecret("your-api-secret")
.baseUrl("your-base-url") // optional
.build();

Default base URL: (production endpoint) — the SDK uses NotificationHub's production endpoint by default. You only need to set baseUrl(...) if you want to point at a different environment.

Sub-client accessors

MethodReturns
notifications()NotificationApiClient
templates()TemplateApiClient
analytics()AnalyticsApiClient
projects()ProjectApiClient
providers()ProviderApiClient

Each call returns the same instance for the lifetime of the client — sub-clients are created once, in the constructor.

Throws

ExceptionWhen
IllegalArgumentExceptionapiKey/apiSecret missing at build(), or a non-HTTPS non-localhost baseUrl is set.