-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the axis-saksham-client-java wiki!
Welcome to the documentation for the Axis Saksham Java Client SDK. This SDK provides a convenient way to integrate with Axis Bank's Saksham API in your Java applications. This guide will walk you through the steps to get started with the SDK, including how to add it as a dependency and sample code for calling the APIs.
- Adding SDK as a Maven Dependency
- Adding SDK as a Gradle Dependency
- Logging Configuration
- API Usage
- Exception Handling
To use the Axis Saksham Java Client SDK in your Maven project, add the following dependency to your pom.xml
file:
<dependency>
<groupId>com.eclatian.oss</groupId>
<artifactId>saksham-rest-client</artifactId>
<version>1.0.0</version>
</dependency>
To add the SDK as a dependency in your Gradle project, add the following line to your build.gradle
file:
implementation 'com.eclatian.oss:saksham-rest-client:1.0.0'
The Axis Saksham Java Client SDK uses SLF4J for logging, allowing you to configure logging based on your preferences and environment. To enable logging, you can add the SLF4J binding of your choice to your project's dependencies. Here's an example configuration using the Logback binding:
Add the Logback dependency to your project:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.5</version>
</dependency>
Configure your logging in a logback.xml file. Place the file in your project's resources directory with the following content:
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
This example configuration logs messages to the console with a timestamp, log level, logger name, and message.
You can customize the logging configuration as per your requirements and use different logging implementations supported by SLF4J.
The first step to start with the SDK is to initialize the client:
InitializationOptions pOptions = null;
try {
pOptions = new InitializationOptions.Builder()
.env(SakshamEnv.UAT)
.corpCode(corpCode)
.channelId(channelId)
.clientId(clientId)
.clientSecret(secret)
.key(key)
.certFileStream(new FileInputStream(certPath))
.certPassPhrase(certPassPhrase)
.autoPopulateSubHeader(true) //Default is true. If you make it false, you will have to populate manually.
.hideRequestRawJson(false) //Default is true. Make it false only for debug purpose.
.build();
} catch (FileNotFoundException ex) {
logger.error("Cert file not found.", ex);
}
SakshamManager.INSTANCE.initialize(pOptions);
Know that corpCode
, channelId
, clientId
, secret
and key
will be given by Axis Bank. You will also get the certificate file and documentation which would create .p12
file and the certPassPhrase
.
Once the initialization is done, you are ready to make the API calls by creating right request objects and using the right service classes. As per the Axis Bank API documentation, ensure that you populate required information for every request. Not doing that will make the SDK through a validation exception.
BeneficiaryRegistrationRequest beneficiaryRegistrationRequest = new BeneficiaryRegistrationRequest();
ArrayList<BeneInsert> beneinsert = new ArrayList<>();
beneficiaryRegistrationRequest.setBeneinsert(beneinsert);
BeneInsert e = new BeneInsert();
e.setBeneAccNum("12344567");
e.setBeneCode("qwerty");
e.setBeneIfscCode("DLEN004658");
e.setBeneName("ABC");
beneinsert.add(e);
// Make the service call
BeneRegistrationService beneRegistrationService = new BeneRegistrationService();
BeneficiaryRegistrationResponse actualResponse = beneRegistrationService
.trigger(beneficiaryRegistrationRequest);
BeneficiaryEnquiryRequest r = new BeneficiaryEnquiryRequest();
r.setEmailId("abc@xyz.com");
r.setStatus(BeneStatus.All);
ArrayList<String> beneCode = new ArrayList<>();
beneCode.add("qwerty");
r.setBeneCode(beneCode);
// Make the service call
BeneficiaryEnquiryService service = new BeneficiaryEnquiryService();
BeneficiaryEnquiryResponse actualResponse = service
.trigger(r);
Additionally the SDK works for transfer-payment
and get-status
APIs as well.
The Axis Saksham Java Client SDK wraps all exceptions in the SakshamClientException class. This ensures that any errors that occur during API calls are caught and handled in a consistent manner. You can catch SakshamClientException to handle any exceptions that may occur during the SDK usage.
It's recommended to wrap your API calls with try-catch blocks to handle exceptions gracefully and provide meaningful error messages to your users.
try {
// Call the API and get the response
// ...
} catch (SakshamClientException e) {
// Handle the exception
logger.error("An error occurred during API call: " + e.getMessage());
}
By handling SakshamClientException, you can gracefully handle errors, log them, and provide appropriate feedback to your users.
That's it! You're now equipped with the information you need to use the Axis Saksham Java Client SDK in your projects. If you have any questions or need further assistance, please don't hesitate to reach out.