Skip to content

Commit

Permalink
chore: update readme file on usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Oluwatunmise-olat committed Jan 28, 2024
1 parent e9ae9f0 commit edc0055
Showing 1 changed file with 94 additions and 14 deletions.
108 changes: 94 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# FastOTP (FastOTP-Java-Library)
FastOTP-Java-Library facilitates quick and easy development and integration of Java based applications with the [FASTOTP API](https://fastotp.co/).

Visit [FastOTP](https://fastotp.co/) to get your api key and setup an account.

- **Contributors:** **Oluwatunmise Olatunbosun**

## Table of Contents

- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation-jar-file)
- [Usage](#usuage)
- [Usage](#usage)
- [Generate OTP](#generate-otp)
- [Validate OTP](#validate-otp)
- [Get OTP](#get-otp)
Expand All @@ -26,21 +28,24 @@ FastOTP-Java-Library facilitates quick and easy development and integration of J
To use Java-FastOtp in your project, follow these steps:
1. Add the following dependency to your project's `pom.xml`:
```xml
<dependency>
<groupId>com.oluwatunmise.Java-FastOtp-Library-1.0</groupId>
<artifactId>java-fastotp-library-1.0</artifactId>
<version>1.0</version>
</dependency>
<dependencies>
/** Your Other Dependencies */
<dependency>
<groupId>com.oluwatunmise</groupId>
<artifactId>java-fastotp-library-1.0</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
```
2. Make sure you have the necessary repositories configured in your pom.xml:
```xml
<repositories>
<repository>
<id>github</id>
<name>Github Oluwatunmise-olat FastOtp Library</name>
<url>https://maven.pkg.github.com/Oluwatunmise-olat/fast-otp-java</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>github</id>
<name>Github Oluwatunmise-olat FastOtp Library</name>
<url>https://maven.pkg.github.com/Oluwatunmise-olat/fast-otp-java</url>
</repository>
</distributionManagement>
```
3. Build Project
```shell
Expand All @@ -54,11 +59,86 @@ mvn test
### Jar
Download latest Java-FastOTP Library jar file from [here](https://github.com/Oluwatunmise-olat/fast-otp-java/releases/latest)

### Usuage
### Usage

### Generate OTP
```java
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.*;

public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);

OTPDelivery otpDelivery = new OTPDelivery("[email protected]");
GenerateOTP generateOTP = new GenerateOTP(
10,
6,
"alpha_numeric",
"java_test",
otpDelivery
);
BaseResponse baseResponse = fastOTP.GenerateOTP(generateOTP);

if (baseResponse.getSuccess()) {
BaseSuccessResponse baseSuccessResponse = (BaseSuccessResponse) baseResponse.getData();
System.out.println(baseSuccessResponse.getOtp().getDeliveryDetails());
System.out.println(baseSuccessResponse.getOtp().getIdentifier());
}else {
BaseErrorResponse baseErrorResponse = (BaseErrorResponse) baseResponse.getData();
System.out.println(baseErrorResponse.getErrors());
System.out.println(baseErrorResponse.getMessage());
}
}
}
```
### Validate OTP
```java
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.BaseErrorResponse;
import com.oluwatunmise.external.BaseResponse;
import com.oluwatunmise.external.BaseSuccessResponse;
import com.oluwatunmise.external.ValidateOTP;

public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);

ValidateOTP validateOTP = new ValidateOTP("your_identifier", "4567");
BaseResponse baseResponse = fastOTP.ValidateOTP(validateOTP);

if (baseResponse.getSuccess()) {
BaseSuccessResponse baseSuccessResponse = (BaseSuccessResponse) baseResponse.getData();
System.out.println(baseSuccessResponse.getOtp().getDeliveryDetails());
System.out.println(baseSuccessResponse.getOtp().getIdentifier());
}else {
BaseErrorResponse baseErrorResponse = (BaseErrorResponse) baseResponse.getData();
System.out.println(baseErrorResponse.getErrors());
System.out.println(baseErrorResponse.getMessage());
}
}
}
```
### Get OTP
```java
import com.oluwatunmise.FastOTP;
import com.oluwatunmise.external.BaseResponse;

public class Main {
public static void main(String[] args) throws Exception {
String apiKey = "xxx_xxx";
FastOTP fastOTP = new FastOTP(apiKey);
BaseResponse baseResponse = fastOTP.GetOTP("matrix");

System.out.println(baseResponse);
System.out.println(baseResponse.getStatusCode());
System.out.println(baseResponse.getData());
System.out.println(baseResponse.getSuccess());
}
}
```

## License

Expand Down

0 comments on commit edc0055

Please sign in to comment.