Twizo Library

Java library for the Twizo api

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.twizo
ArtifactId

ArtifactId

lib-api-java
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

Twizo Library
Java library for the Twizo api
Project URL

Project URL

https://github.com/twizoapi/lib-api-java
Source Code Management

Source Code Management

https://github.com/twizoapi/lib-api-java

Download lib-api-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.twizo/lib-api-java/ -->
<dependency>
    <groupId>com.twizo</groupId>
    <artifactId>lib-api-java</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.twizo/lib-api-java/
implementation 'com.twizo:lib-api-java:0.3.0'
// https://jarcasting.com/artifacts/com.twizo/lib-api-java/
implementation ("com.twizo:lib-api-java:0.3.0")
'com.twizo:lib-api-java:jar:0.3.0'
<dependency org="com.twizo" name="lib-api-java" rev="0.3.0">
  <artifact name="lib-api-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.twizo', module='lib-api-java', version='0.3.0')
)
libraryDependencies += "com.twizo" % "lib-api-java" % "0.3.0"
[com.twizo/lib-api-java "0.3.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.8.0
junit : junit jar 4.12
org.mockito : mockito-core pom 2.2.0

Project Modules

There are no modules declared in this project.

Twizo

Twizo Java API

Connect to the Twizo API using Java. This API includes functions to send verifications (2FA), SMS and Number Lookup.

Requirements

  • Java >= 8
  • Maven

Get application secret and api host

To use the Twizo API client, the following things are required:

Installation

At this moment there are 2 options to use the Twizo Java library (IntelliJ)

Maven

  1. Add Maven Framework to your project by right clicking the project folder -> Add Framework Support -> Maven
  2. Add the lib-api-java module module to your project
  3. Add the module as a dependency to your pom.xml file
<dependency>
    <groupId>com.twizo</groupId>
    <artifactId>lib-api-java</artifactId>
    <version>0.1.0</version>
</dependency>
  1. Make sure to mark the src folder as source directory to be able to use the Twizo classes
  2. Reimport (or enable auto-import) Maven

Jar file

  1. Put the lib-api-java.jar file in your lib folder
  2. Add the library to the project in the Project Structure -> Libraries menu

In the near future this library will be available from the Maven Central Repository

Getting started

Initializing the Twizo Api using your api secret and api host

import com.twizo.TwizoFactory;
import com.twizo.Twizo;

class MyClass {

    private static void main(String[] args) {
        Twizo twizo = new TwizoFactory("your-api-key", Node.ASIA);
    }
    
}

Send a sms

SmsController smsController = twizo.getSmsController();

// parameters = recipient phone number - message - sender phone number
smsController.sendSimple("60123456789", "Hello World", "60987654321");

Create a new NumberLookup

NumberLookupController numberLookupController = twizo.getNumberLookupController();

// parameter = phone number to look up
numberLookupController.createSimpleNumberLookup("60123456789");

Create a new Verification

VerificationController verificationController = twizo.getVerificationController();

// parameter = phone number to receive token
verificationController.createSimpleVerification("60123456789");

Verify a token

VerificationController verificationController = twizo.getVerificationController();

// parameter = token to verify
verificationController.verifyToken("012345");

Examples

In the examples directory you can find a collection of cli examples of how to use the api. When first running an example you will be asked for a host name and apiKey; this will be written to a properties file.

Testing

To run the Unit Tests provided with this code, you have to enter your API key in the TestSetup class in the tests directory.

License

The MIT License. Copyright (c) 2017 Twizo

Support

Contact: www.twizo.com[email protected]

com.twizo

Twizo

Versions

Version
0.3.0