Coder Social home page Coder Social logo

swahid / infobip-api-java-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infobip/infobip-api-java-client

0.0 2.0 0.0 141 KB

Infobip API client library in Java.

Home Page: http://dev.infobip.com

License: Apache License 2.0

Java 100.00%

infobip-api-java-client's Introduction

Infobip API Java client

Prerequisites

You have installed Java (minimal required version is Java 7).

Installation

It is recommended that you use a dependency management system to get started with using Infobip Java API client in your project. You can choose between Maven and Gradle. Depending on your choice find the appropriate configuration below.

Maven configuration

For using the API client in your maven project add the following snippet to the <dependencies> section of your pom.xml file:

<dependency>
    <groupId>com.infobip</groupId>
    <artifactId>infobip-api-java-client</artifactId>
    <version>2.1.0</version>
</dependency>

Gradle configuration

For adding the API client to your gradle project add the following line to the dependencies section of your build.gradle file:

compile "com.infobip:infobip-api-java-client:2.1.0"

Manual dependency management

If you choose not to use any tool for dependency management you can still use the Infobip API client. A .jar with the API client and all of its dependencies can be found at maven central repository.
From the list there click on jar-with-dependencies.jar link to download the .jar file that you can manually integrate into your project.

Running examples

First, setup your username and password in infobip.examples.Example. Then, you can run provided examples in infobip.examples package

Basic messaging example

First, initialize the messaging client using your username and password:

SendSingleTextualSms client = new SendSingleTextualSms(new BasicAuthConfiguration(USERNAME, PASSWORD));

Prepare the message:

SMSTextualRequest requestBody = new SMSTextualRequest();
requestBody.setFrom(FROM);
requestBody.setTo(Arrays.asList("xxxxxxxx", "yyyyyyyy"));
requestBody.setText("This is an example message");

Send the message:

SMSResponse response = client.execute(requestBody);

Later you can query for the delivery status of the message:

 GetSentSmsDeliveryReports client = new GetSentSmsDeliveryReports(new BasicAuthConfiguration(USERNAME, PASSWORD));
 SMSReportResponse response = client.execute(BULK_ID, MESSAGE_ID, LIMIT);

Messaging with delivery report push to notification URL example

Similar to standard messaging example, but when preparing your message, use SMSAdvancedTextualRequest:

SendMultipleTextualSmsAdvanced client = new SendMultipleTextualSmsAdvanced(new BasicAuthConfiguration(USERNAME, PASSWORD));

Destination destination = new Destination();
destination.setTo("xxxxxxxx");

Message message = new Message();
message.setFrom(FROM);
message.setDestinations(Collections.singletonList(destination));
message.setText(MESSAGE_TEXT);
message.setNotifyUrl("NOTIFY_URL");

SMSAdvancedTextualRequest requestBody = new SMSAdvancedTextualRequest();
requestBody.setMessages(Collections.singletonList(message));

SMSResponse response = client.execute(requestBody);

When the delivery notification is pushed to your server as a HTTP POST request, you can process the body of the message with the following code:

SMSReportResponse smsReportResponse = gson.fromJson(requestBody, SMSReportResponse.class);

License

This library is licensed under the Apache License, Version 2.0

infobip-api-java-client's People

Contributors

anamarjanovic avatar cesljasdavor avatar hkozacinski-ib avatar mbruncic avatar nmenkovic-ib avatar pducic avatar

Watchers

 avatar  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.