Code Monkey home page Code Monkey logo

fast-otp-java's Introduction

FastOTP (FastOTP-Java-Library)

FastOTP-Java-Library facilitates quick and easy development and integration of Java based applications with the FASTOTP API.

Visit FastOTP to get your api key and setup an account. FastOTP Documentation

  • Contributors: Oluwatunmise Olatunbosun

Table of Contents

Getting Started

Prerequisites

  • Java 17 or later
  • Maven (for building and testing)

Installation (Jar file)

To use Java-FastOtp in your project, follow these steps:

  1. Add the following dependency to your project's pom.xml:
<dependencies>
  /** Your Other Dependencies */
  <dependency>
    <groupId>com.oluwatunmise</groupId>
    <artifactId>java-fastotp-library-1.0</artifactId>
    <version>1.0</version>
  </dependency>
</dependencies>
  1. Configure the repository in your pom.xml:
<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>
  1. Build Project
mvn clean install
  1. Test
mvn test

Jar

Download latest Java-FastOTP Library jar file from here

Usage

Generate OTP

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

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

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());
  }
}

Response Details

The BaseResponse object provides the following information:

  • statusCode: HTTP status code received from fast otp.
  • success: Indicates whether the response falls within the 200-300 success range.
  • data: The actual data returned by fast otp.

License

The MIT License (MIT). Please see License File for more information.

Contributing

Contributions are welcome! If you find any issues or have enhancements, feel free to open a GitHub issue or submit a pull request.

fast-otp-java's People

Contributors

oluwatunmise-olat avatar

Stargazers

Michael Okoh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.