Skip to content
Merged
Show file tree
Hide file tree
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
228 changes: 228 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>");
```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", timeoutInMillis);
```
```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", "<YOUR_API_BASE_URL>");
```


### Controlling SDK logging
Expand Down Expand Up @@ -180,6 +183,88 @@ Then you can use any of the SDK methods, for example:
);
```

* ##### Find the email formats based on a given first name and domain
```java
ZeroBounceSDK.getInstance().findEmail(
"<FIRST_NAME_TO_TEST>"
"<DOMAIN_TO_TEST>",
null,
null,
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
@Override
public void onSuccess(ZBFindEmailResponse response) {
System.out.println("findEmail response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findEmail error=" + errorMessage);
}
});
);
```

* ##### Find the email formats based on a given first name and company name
```java
ZeroBounceSDK.getInstance().findEmail(
"<FIRST_NAME_TO_TEST>"
null,
"<COMPANY_NAME_TO_TEST>",
null,
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
@Override
public void onSuccess(ZBFindEmailResponse response) {
System.out.println("findEmail response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findEmail error=" + errorMessage);
}
});
);
```

* ##### Find other domain formats based on a given domain
```java
ZeroBounceSDK.getInstance().findDomain(
"<DOMAIN_TO_TEST>",
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
@Override
public void onSuccess(ZBFindDomainResponse response) {
System.out.println("findDomain response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findDomain error=" + errorMessage);
}
});
);
```

* ##### Find other domain formats based on a given company name
```java
ZeroBounceSDK.getInstance().findDomain(
null,
"COMPANY_NAME_TO_TEST",
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
@Override
public void onSuccess(ZBFindDomainResponse response) {
System.out.println("findDomain response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findDomain error=" + errorMessage);
}
});
);
```

* ##### Check how many credits you have left on your account
```java
ZeroBounceSDK.getInstance().getCredits(
Expand Down Expand Up @@ -399,6 +484,149 @@ Then you can use any of the SDK methods, for example:
});
```

## Breaking Changes:
**`guessFormat`** has been deprecated. To continue using your existing code, you must migrate to **`findEmail`** or **`findDomain`** .
The change is not a simple one-to-one replacement, as the functionality has been split:
- **If you were finding a person's email format**, use the new **`findEmail()`** method.
- **If you were only determining the domain's general email pattern**, use the new **`findDomain()`** method.
### Migration Example:
- #### Old (Deprecated)
```java
ZeroBounceSDK.getInstance().guessFormat(
"<DOMAIN_TO_TEST>",
null,
null,
null,
new ZeroBounceSDK.OnSuccessCallback<ZBEmailFinderResponse>() {
@Override
public void onSuccess(ZBEmailFinderResponse response) {
System.out.println("guessFormat response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("guessFormat error=" + errorMessage);
}
});
);

- #### New Methods
- ##### Find the email formats based on a given first name and domain
```java
ZeroBounceSDK.getInstance().findEmail(
"<FIRST_NAME_TO_TEST>"
"<DOMAIN_TO_TEST>",
null,
null,
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
@Override
public void onSuccess(ZBFindEmailResponse response) {
System.out.println("findEmail response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findEmail error=" + errorMessage);
}
});
);
```
- ##### Find the email formats based on a given first name and company name
```java
ZeroBounceSDK.getInstance().findEmail(
"<FIRST_NAME_TO_TEST>"
null,
"<COMPANY_NAME_TO_TEST>",
null,
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
@Override
public void onSuccess(ZBFindEmailResponse response) {
System.out.println("findEmail response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findEmail error=" + errorMessage);
}
});
);

- ##### Find other domain formats based on a given domain
```java
ZeroBounceSDK.getInstance().findDomain(
"<DOMAIN_TO_TEST>",
null,
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
@Override
public void onSuccess(ZBFindDomainResponse response) {
System.out.println("findDomain response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findDomain error=" + errorMessage);
}
});
);
```
- ##### Find other domain formats based on a given company name
```java
ZeroBounceSDK.getInstance().findDomain(
null,
"COMPANY_NAME_TO_TEST",
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
@Override
public void onSuccess(ZBFindDomainResponse response) {
System.out.println("findDomain response=" + response.toString());
}
}, new ZeroBounceSDK.OnErrorCallback() {
@Override
public void onError(String errorMessage) {
System.out.println("findDomain error=" + errorMessage);
}
});
);

## New Features and Enhancements
### Custom API URL Support
The `ZeroBounceSDK.initialize()` method can now accepts an `apiBaseUrl` parameter.
This allows you to specify a custom base URL for the ZeroBounce API.

#### Migration / Usage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Migration / Usage
#### Migration / Usage

The existing way of initializing the SDK is still valid.

- Default Usage (No Change Required). If you don't provide a URL, the SDK will continue to use the standard ZeroBounce API endpoint:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Default Usage (No Change Required). If you don't provide a URL, the SDK will continue to use the standard ZeroBounce API endpoint:
- Default Usage (No Change Required). If you don't provide a URL, the SDK will continue to use the standard ZeroBounce API endpoint:

```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>");
```
```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", timeoutInMillis);
```
- Initialize the SDK with your API key and URL:
```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", "<YOUR_API_BASE_URL>");
```
The SDK now exposes a set of predefined constants for different geographical API endpoints,
allowing for more precise network routing.

### Available API Endpoints
You can specify a custom API base URL during initialization by using the new optional `apiBaseUrl`
parameter in `initialize()`. For convenience, the following constants are available in the
**`ZBConstants`** class:

| Constant | URL Value | Description |
|-------------------|------------------------------------|--------------------------------------------------------------------|
| **`API_DEFAULT_URL`** | `https://api.zerobounce.net/v2/` | The global default endpoint. |
| **`API_USA_URL`** | `https://api-us.zerobounce.net/v2/` | The US-specific endpoint for lower latency in the Americas. |
| **`API_EU_URL`** | `https://api-eu.zerobounce.net/v2/` | The EU-specific endpoint for compliance and lower latency in Europe. |

### Usage Example:
To use the EU endpoint for initialization:
```java
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", ZBConstants.getInstance().API_EU_URL);
```

## Documentation
You can generate the documentation using your desired IDE or using's maven's javadoc command.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zerobounce.java</groupId>
<artifactId>zerobouncesdk</artifactId>
<version>1.3.0</version>
<description>POM was created from install:install-file</description>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>com.zerobounce.java</groupId>
<artifactId>zerobouncesdk</artifactId>
<versioning>
<release>1.2.1</release>
<release>1.3.0</release>
<versions>
<version>1.1.1</version>
<version>1.1.3</version>
Expand All @@ -12,6 +12,7 @@
<version>1.1.7</version>
<version>1.2.0</version>
<version>1.2.1</version>
<version>1.3.0</version>
</versions>
<lastUpdated>20250721134252</lastUpdated>
</versioning>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Controller {
public Button validateBatchButton;
public Button guessFormatButton;
public Button pickFileButton;
public Button findEmailButton;
public Button findDomainButton;

public void initialize() {

Expand All @@ -51,6 +53,10 @@ public void initialize() {
deleteFileButton.setOnAction(event -> deleteFile("<YOUR_FILE_ID>"));

activityDataButton.setOnAction(event -> getActivityData("<EMAIL_TO_TEST>"));

findEmailButton.setOnAction(event -> findEmail("<FIRST_NAME_TO_TEST>", "<DOMAIN_TO_TEST>"));

findDomainButton.setOnAction(event -> findDomain("<DOMAIN_TO_TEST>"));
}

/**
Expand Down Expand Up @@ -83,6 +89,33 @@ private void validateBatch() {
);
}

/**
* Calls the *find email* method of the [ZeroBounceSDK].
*/
private void findEmail(String firstName, String domain) {
ZeroBounceSDK.getInstance().findEmail(
firstName,
domain,
null,
null,
null,
response -> System.out.println("Controller::guessFormat response=" + response.toString()),
errorMessage -> System.out.println("Controller::guessFormat error=" + errorMessage)
);
}

/**
* Calls the *find domain* method of the [ZeroBounceSDK].
*/
private void findDomain(String domain) {
ZeroBounceSDK.getInstance().findDomain(
domain,
null,
response -> System.out.println("Controller::guessFormat response=" + response.toString()),
errorMessage -> System.out.println("Controller::guessFormat error=" + errorMessage)
);
}

/**
* Calls the *guess format* method of the [ZeroBounceSDK].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
GridPane.rowIndex="5"/>
<Button fx:id="activityDataButton" mnemonicParsing="false" text="Get Activity Data" GridPane.columnIndex="1"
GridPane.rowIndex="6"/>
<Button fx:id="findEmailButton" mnemonicParsing="false" text="Find Email" GridPane.columnIndex="1"
GridPane.rowIndex="7"/>
<Button fx:id="findDomainButton" mnemonicParsing="false" text="Find Domain" GridPane.columnIndex="1"
GridPane.rowIndex="8"/>

<Button fx:id="pickFileButton" mnemonicParsing="false" text="Send File" GridPane.columnIndex="2"
GridPane.rowIndex="1"/>
Expand Down
2 changes: 1 addition & 1 deletion zero-bounce-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.zerobounce.java</groupId>
<artifactId>zerobouncesdk</artifactId>
<version>1.2.2</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<name>ZeroBounceSDK</name>
Expand Down
14 changes: 14 additions & 0 deletions zero-bounce-sdk/src/main/java/com/zerobounce/ZBConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.zerobounce;

/**
* Defines API endpoint constants. This object is a singleton and provides
* global access to the constants.
*/
public class ZBConstants {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class ZBConstants {
/**
* Defines API endpoint constants. This object is a singleton and provides
* global access to the constants.
*/
public class ZBConstants {


public static final String API_DEFAULT_URL = "https://api.zerobounce.net/v2/";

public static final String API_USA_URL = "https://api-us.zerobounce.net/v2/";

public static final String API_EU_URL = "https://api-eu.zerobounce.net/v2/";
}
Loading