What are the steps to install the Java FDK Client in a Maven project? What are some sample usage scenarios?
To install the Java FDK Client from Fynd in a Maven project, follow these steps:
- Create a new Maven project, or use an existing one.
- Open the project’s
pom.xml
file and add the following dependency to the<dependencies>
section:
<dependency>
<groupId>com.github.gofynd</groupId>
<artifactId>fdk-client-java</artifactId>
<version>v1.0.6</version>
</dependency>
Note: Make sure to check the available version list on jitpack and use the appropriate version number.
3. Add the Jitpack repository to your project’s pom.xml
file.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
After installation, you can start integrating Java FDK Clients into your application. Here are two sample usage scenarios using ApplicationClient
and PlatformClient
classes.
For ApplicationClient
:
ApplicationConfig applicationConfig = null;
try {
applicationConfig = new ApplicationConfig(
"YOUR_APPLICATION_ID",
"YOUR_APPLICATION_TOKEN"
);
if(Objects.nonNull(applicationConfig)) {
ApplicationClient applicationClient = new ApplicationClient(applicationConfig);
return applicationClient.catalog.getProductDetailBySlug("product-slug");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
For PlatformClient
:
PlatformConfig platformConfig = null;
try {
platformConfig = new PlatformConfig(
"COMPANY_ID",
"API_KEY",
"API_SECRET",
"DOMAIN"
);
if(Objects.nonNull(platformConfig)) {
PlatformClient platformClient = new PlatformClient(platformConfig);
return platformClient.catalog.getCompanyDetail("COMPANY_ID");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
For more details, refer to the documentation.