Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

BSG REST API. Free SMS API - Java com.bsg.rest

The library enables working with the BSG REST service. It supports automatic serialization/deserialization into Java objects The BSG API enables to send mass SMS campaigns, send single transactional SMS, Viber campaigns, and verify phone numbers using HLR requests. There are no charges for API usage, you only pay fors for the messages sent.

Pricing

Prices for sending messages can be found here: Prices

Requirements

Java 1.7+

How to use API

Installation

This library is accompanied by a pom.xml file, which allows using Maven to install it into the local repository.

mvn install:install-file -Dfile=RestClient-1.0.jar You can also install it by downloading the package's source code as a Zip archive or cloning this repository. All components of this library automatically download dependencies.

To use the library, you need to add dependencies to your pom.xml file.

 <dependency>
<groupId>com.bsg</groupId>
<artifactId>RestClient</artifactId>
<version>1.0</version>
</dependency>

Dependencies

Example

try (SmsClientsmsClient = newSmsClient("YOUR_API_KEY")) {
//Log responsesmsClient.getJerseyClient().register(newLoggingFilter());
//Sms pricesPricesDatasmsPrices = smsClient.getSmsPrices(9);
//Multiple smsMultipleSmsRequestmultipleSmsRequest = newMultipleSmsRequest();
multipleSmsRequest.setBody("Some text");
multipleSmsRequest.setOriginator("me");
multipleSmsRequest.setTariff(null);
multipleSmsRequest.setValidity(1);
List<Phone> phones = newArrayList();
phones.add(newPhone("79991234567", UUID.randomUUID().toString().substring(0, 13)));
phones.add(newPhone("79991234568", UUID.randomUUID().toString().substring(0, 13)));
multipleSmsRequest.setPhones(phones);
MultipleSmsDatadata = smsClient.createSms(multipleSmsRequest);
//Sms info by task idSmsTaskInfosmsTaskInfo = smsClient.getSmsTaskInfo(data.getTaskId());
//Sms info by idMessageInfosmsInfo = smsClient.getSmsInfo(data.getSmses().get(0).getId());
//Sms info by external idMessageInfosmsInfo2 = smsClient.getSmsInfoByReference(data.getSmses().get(0).getReference());
//Single smsSingleSmsDatasingleSms = smsClient.createSms("me", "Some text", "79991234567", UUID.randomUUID().toString().substring(0, 13), 1, null);
}
try (ViberClientviberClient = newViberClient("YOUR_API_KEY")) {
//Log responseviberClient.getJerseyClient().register(newLoggingFilter());
//Viber pricesPricesDataviberPrices = viberClient.getViberPrices(9);
//Viber messageViberMessageRequestviberMessageRequest = newViberMessageRequest();
viberMessageRequest.setTariff(null);
viberMessageRequest.setValidity(1);
Messagemessage = newMessage();
List<Message> messages = newArrayList<>();
viberMessageRequest.setMessages(messages);
message.setAlphaName("BSG");
message.setIsPromotional(false);
message.setText("111");
message.setOptions(newOptions(newSenderViber("1", "1", "1")));
messages.add(message);
List<Recipient> recipients = newArrayList<>();
Recipientrecipient = newRecipient("79991234567", UUID.randomUUID().toString().substring(0, 13));
recipients.add(recipient);
message.setRecipients(recipients);
ViberMessageDatacreateViberMessage = viberClient.createViberMessage(viberMessageRequest);
//Viber info by idMessageInfoviberMessageInfo = viberClient.getViberMessageInfo(createViberMessage.getViberMessages().get(0).getId());
//Viber info by external idMessageInfoviberMessageInfo1 = viberClient.getViberMessageInfoByReference(createViberMessage.getViberMessages().get(0).getReference());
}
try (HlrClientrestClient = newHlrClient("YOUR_API_KEY")) {
//Log responserestClient.getJerseyClient().register(newLoggingFilter());
//BalanceBalancebalance = restClient.getBalance();
//Hlr pricesPricesDatahlrPrices = restClient.getHlrPrices(9);
//Create HLRHlrDatahlr = restClient.createHlr("380972920000", UUID.randomUUID().toString().substring(0, 13), null, "http://someurl.com/callback");
//Hlr info by IDHlrInfohlrInfo = restClient.getHlrInfo(hlr.getHlrs().get(0).getId());
//Hlr info by external IDHlrInfohlrInfo2 = restClient.getHlrInfoByReference(hlr.getHlrs().get(0).getReference());
//Hlr batchList<HlrRequest> hlrRequests = newArrayList<>();
hlrRequests.add(newHlrRequest("380972920001", UUID.randomUUID().toString().substring(0, 13), null, "http://someurl.com/callback"));
hlrRequests.add(newHlrRequest("380972920001", UUID.randomUUID().toString().substring(0, 13), null, "http://someurl.com/callback"));
HlrDatacreateHlr = restClient.createHlr(hlrRequests);
}

Support

If you encounter any difficulties or have questions regarding the use of the package, create a discussion in this repository or send an email.

Documentation

You can obtain the API documentation from the source code of the package.

About

This repository contains the open source Java client for BSG's REST API. SMS, Viber and HLR.

Topics

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages