Skip to content

Commit d28f0e7

Browse files
authored
Merge pull request #21 from zerobounce/task/update-sdk
Task/Update SDK CU-869adq005
2 parents f879414 + 83bd363 commit d28f0e7

File tree

14 files changed

+890
-28
lines changed

14 files changed

+890
-28
lines changed

README.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>");
8686
```java
8787
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", timeoutInMillis);
8888
```
89+
```java
90+
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", "<YOUR_API_BASE_URL>");
91+
```
8992

9093

9194
### Controlling SDK logging
@@ -180,6 +183,88 @@ Then you can use any of the SDK methods, for example:
180183
);
181184
```
182185
186+
* ##### Find the email formats based on a given first name and domain
187+
```java
188+
ZeroBounceSDK.getInstance().findEmail(
189+
"<FIRST_NAME_TO_TEST>"
190+
"<DOMAIN_TO_TEST>",
191+
null,
192+
null,
193+
null,
194+
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
195+
@Override
196+
public void onSuccess(ZBFindEmailResponse response) {
197+
System.out.println("findEmail response=" + response.toString());
198+
}
199+
}, new ZeroBounceSDK.OnErrorCallback() {
200+
@Override
201+
public void onError(String errorMessage) {
202+
System.out.println("findEmail error=" + errorMessage);
203+
}
204+
});
205+
);
206+
```
207+
208+
* ##### Find the email formats based on a given first name and company name
209+
```java
210+
ZeroBounceSDK.getInstance().findEmail(
211+
"<FIRST_NAME_TO_TEST>"
212+
null,
213+
"<COMPANY_NAME_TO_TEST>",
214+
null,
215+
null,
216+
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
217+
@Override
218+
public void onSuccess(ZBFindEmailResponse response) {
219+
System.out.println("findEmail response=" + response.toString());
220+
}
221+
}, new ZeroBounceSDK.OnErrorCallback() {
222+
@Override
223+
public void onError(String errorMessage) {
224+
System.out.println("findEmail error=" + errorMessage);
225+
}
226+
});
227+
);
228+
```
229+
230+
* ##### Find other domain formats based on a given domain
231+
```java
232+
ZeroBounceSDK.getInstance().findDomain(
233+
"<DOMAIN_TO_TEST>",
234+
null,
235+
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
236+
@Override
237+
public void onSuccess(ZBFindDomainResponse response) {
238+
System.out.println("findDomain response=" + response.toString());
239+
}
240+
}, new ZeroBounceSDK.OnErrorCallback() {
241+
@Override
242+
public void onError(String errorMessage) {
243+
System.out.println("findDomain error=" + errorMessage);
244+
}
245+
});
246+
);
247+
```
248+
249+
* ##### Find other domain formats based on a given company name
250+
```java
251+
ZeroBounceSDK.getInstance().findDomain(
252+
null,
253+
"COMPANY_NAME_TO_TEST",
254+
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
255+
@Override
256+
public void onSuccess(ZBFindDomainResponse response) {
257+
System.out.println("findDomain response=" + response.toString());
258+
}
259+
}, new ZeroBounceSDK.OnErrorCallback() {
260+
@Override
261+
public void onError(String errorMessage) {
262+
System.out.println("findDomain error=" + errorMessage);
263+
}
264+
});
265+
);
266+
```
267+
183268
* ##### Check how many credits you have left on your account
184269
```java
185270
ZeroBounceSDK.getInstance().getCredits(
@@ -399,6 +484,149 @@ Then you can use any of the SDK methods, for example:
399484
});
400485
```
401486
487+
## Breaking Changes:
488+
**`guessFormat`** has been deprecated. To continue using your existing code, you must migrate to **`findEmail`** or **`findDomain`** .
489+
The change is not a simple one-to-one replacement, as the functionality has been split:
490+
- **If you were finding a person's email format**, use the new **`findEmail()`** method.
491+
- **If you were only determining the domain's general email pattern**, use the new **`findDomain()`** method.
492+
### Migration Example:
493+
- #### Old (Deprecated)
494+
```java
495+
ZeroBounceSDK.getInstance().guessFormat(
496+
"<DOMAIN_TO_TEST>",
497+
null,
498+
null,
499+
null,
500+
new ZeroBounceSDK.OnSuccessCallback<ZBEmailFinderResponse>() {
501+
@Override
502+
public void onSuccess(ZBEmailFinderResponse response) {
503+
System.out.println("guessFormat response=" + response.toString());
504+
}
505+
}, new ZeroBounceSDK.OnErrorCallback() {
506+
@Override
507+
public void onError(String errorMessage) {
508+
System.out.println("guessFormat error=" + errorMessage);
509+
}
510+
});
511+
);
512+
513+
- #### New Methods
514+
- ##### Find the email formats based on a given first name and domain
515+
```java
516+
ZeroBounceSDK.getInstance().findEmail(
517+
"<FIRST_NAME_TO_TEST>"
518+
"<DOMAIN_TO_TEST>",
519+
null,
520+
null,
521+
null,
522+
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
523+
@Override
524+
public void onSuccess(ZBFindEmailResponse response) {
525+
System.out.println("findEmail response=" + response.toString());
526+
}
527+
}, new ZeroBounceSDK.OnErrorCallback() {
528+
@Override
529+
public void onError(String errorMessage) {
530+
System.out.println("findEmail error=" + errorMessage);
531+
}
532+
});
533+
);
534+
```
535+
- ##### Find the email formats based on a given first name and company name
536+
```java
537+
ZeroBounceSDK.getInstance().findEmail(
538+
"<FIRST_NAME_TO_TEST>"
539+
null,
540+
"<COMPANY_NAME_TO_TEST>",
541+
null,
542+
null,
543+
new ZeroBounceSDK.OnSuccessCallback<ZBFindEmailResponse>() {
544+
@Override
545+
public void onSuccess(ZBFindEmailResponse response) {
546+
System.out.println("findEmail response=" + response.toString());
547+
}
548+
}, new ZeroBounceSDK.OnErrorCallback() {
549+
@Override
550+
public void onError(String errorMessage) {
551+
System.out.println("findEmail error=" + errorMessage);
552+
}
553+
});
554+
);
555+
556+
- ##### Find other domain formats based on a given domain
557+
```java
558+
ZeroBounceSDK.getInstance().findDomain(
559+
"<DOMAIN_TO_TEST>",
560+
null,
561+
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
562+
@Override
563+
public void onSuccess(ZBFindDomainResponse response) {
564+
System.out.println("findDomain response=" + response.toString());
565+
}
566+
}, new ZeroBounceSDK.OnErrorCallback() {
567+
@Override
568+
public void onError(String errorMessage) {
569+
System.out.println("findDomain error=" + errorMessage);
570+
}
571+
});
572+
);
573+
```
574+
- ##### Find other domain formats based on a given company name
575+
```java
576+
ZeroBounceSDK.getInstance().findDomain(
577+
null,
578+
"COMPANY_NAME_TO_TEST",
579+
new ZeroBounceSDK.OnSuccessCallback<ZBFindDomainResponse>() {
580+
@Override
581+
public void onSuccess(ZBFindDomainResponse response) {
582+
System.out.println("findDomain response=" + response.toString());
583+
}
584+
}, new ZeroBounceSDK.OnErrorCallback() {
585+
@Override
586+
public void onError(String errorMessage) {
587+
System.out.println("findDomain error=" + errorMessage);
588+
}
589+
});
590+
);
591+
592+
## New Features and Enhancements
593+
### Custom API URL Support
594+
The `ZeroBounceSDK.initialize()` method can now accepts an `apiBaseUrl` parameter.
595+
This allows you to specify a custom base URL for the ZeroBounce API.
596+
597+
#### Migration / Usage
598+
The existing way of initializing the SDK is still valid.
599+
600+
- Default Usage (No Change Required). If you don't provide a URL, the SDK will continue to use the standard ZeroBounce API endpoint:
601+
```java
602+
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>");
603+
```
604+
```java
605+
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", timeoutInMillis);
606+
```
607+
- Initialize the SDK with your API key and URL:
608+
```java
609+
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", "<YOUR_API_BASE_URL>");
610+
```
611+
The SDK now exposes a set of predefined constants for different geographical API endpoints,
612+
allowing for more precise network routing.
613+
614+
### Available API Endpoints
615+
You can specify a custom API base URL during initialization by using the new optional `apiBaseUrl`
616+
parameter in `initialize()`. For convenience, the following constants are available in the
617+
**`ZBConstants`** class:
618+
619+
| Constant | URL Value | Description |
620+
|-------------------|------------------------------------|--------------------------------------------------------------------|
621+
| **`API_DEFAULT_URL`** | `https://api.zerobounce.net/v2/` | The global default endpoint. |
622+
| **`API_USA_URL`** | `https://api-us.zerobounce.net/v2/` | The US-specific endpoint for lower latency in the Americas. |
623+
| **`API_EU_URL`** | `https://api-eu.zerobounce.net/v2/` | The EU-specific endpoint for compliance and lower latency in Europe. |
624+
625+
### Usage Example:
626+
To use the EU endpoint for initialization:
627+
```java
628+
ZeroBounceSDK.getInstance().initialize("<YOUR_API_KEY>", ZBConstants.getInstance().API_EU_URL);
629+
```
402630
403631
## Documentation
404632
You can generate the documentation using your desired IDE or using's maven's javadoc command.
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.zerobounce.java</groupId>
6+
<artifactId>zerobouncesdk</artifactId>
7+
<version>1.3.0</version>
8+
<description>POM was created from install:install-file</description>
9+
</project>

local-libs/com/zerobounce/java/zerobouncesdk/maven-metadata-local.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>com.zerobounce.java</groupId>
44
<artifactId>zerobouncesdk</artifactId>
55
<versioning>
6-
<release>1.2.1</release>
6+
<release>1.3.0</release>
77
<versions>
88
<version>1.1.1</version>
99
<version>1.1.3</version>
@@ -12,6 +12,7 @@
1212
<version>1.1.7</version>
1313
<version>1.2.0</version>
1414
<version>1.2.1</version>
15+
<version>1.3.0</version>
1516
</versions>
1617
<lastUpdated>20250721134252</lastUpdated>
1718
</versioning>

src/main/java/com/zerobounceexample/zerobouncejavasdksetupmaster/Controller.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class Controller {
2626
public Button validateBatchButton;
2727
public Button guessFormatButton;
2828
public Button pickFileButton;
29+
public Button findEmailButton;
30+
public Button findDomainButton;
2931

3032
public void initialize() {
3133

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

5355
activityDataButton.setOnAction(event -> getActivityData("<EMAIL_TO_TEST>"));
56+
57+
findEmailButton.setOnAction(event -> findEmail("<FIRST_NAME_TO_TEST>", "<DOMAIN_TO_TEST>"));
58+
59+
findDomainButton.setOnAction(event -> findDomain("<DOMAIN_TO_TEST>"));
5460
}
5561

5662
/**
@@ -83,6 +89,33 @@ private void validateBatch() {
8389
);
8490
}
8591

92+
/**
93+
* Calls the *find email* method of the [ZeroBounceSDK].
94+
*/
95+
private void findEmail(String firstName, String domain) {
96+
ZeroBounceSDK.getInstance().findEmail(
97+
firstName,
98+
domain,
99+
null,
100+
null,
101+
null,
102+
response -> System.out.println("Controller::guessFormat response=" + response.toString()),
103+
errorMessage -> System.out.println("Controller::guessFormat error=" + errorMessage)
104+
);
105+
}
106+
107+
/**
108+
* Calls the *find domain* method of the [ZeroBounceSDK].
109+
*/
110+
private void findDomain(String domain) {
111+
ZeroBounceSDK.getInstance().findDomain(
112+
domain,
113+
null,
114+
response -> System.out.println("Controller::guessFormat response=" + response.toString()),
115+
errorMessage -> System.out.println("Controller::guessFormat error=" + errorMessage)
116+
);
117+
}
118+
86119
/**
87120
* Calls the *guess format* method of the [ZeroBounceSDK].
88121
*/

src/main/resources/com/zerobounceexample/zerobouncejavasdksetupmaster/sample.fxml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
GridPane.rowIndex="5"/>
3131
<Button fx:id="activityDataButton" mnemonicParsing="false" text="Get Activity Data" GridPane.columnIndex="1"
3232
GridPane.rowIndex="6"/>
33+
<Button fx:id="findEmailButton" mnemonicParsing="false" text="Find Email" GridPane.columnIndex="1"
34+
GridPane.rowIndex="7"/>
35+
<Button fx:id="findDomainButton" mnemonicParsing="false" text="Find Domain" GridPane.columnIndex="1"
36+
GridPane.rowIndex="8"/>
3337

3438
<Button fx:id="pickFileButton" mnemonicParsing="false" text="Send File" GridPane.columnIndex="2"
3539
GridPane.rowIndex="1"/>

zero-bounce-sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.zerobounce.java</groupId>
66
<artifactId>zerobouncesdk</artifactId>
7-
<version>1.2.2</version>
7+
<version>1.3.0</version>
88
<packaging>jar</packaging>
99

1010
<name>ZeroBounceSDK</name>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.zerobounce;
2+
3+
/**
4+
* Defines API endpoint constants. This object is a singleton and provides
5+
* global access to the constants.
6+
*/
7+
public class ZBConstants {
8+
9+
public static final String API_DEFAULT_URL = "https://api.zerobounce.net/v2/";
10+
11+
public static final String API_USA_URL = "https://api-us.zerobounce.net/v2/";
12+
13+
public static final String API_EU_URL = "https://api-eu.zerobounce.net/v2/";
14+
}

0 commit comments

Comments
 (0)