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.
Prices for sending messages can be found here: Prices
Java 1.7+
- Sign up for a free account
- Get Live Api Key here
- Go through the API documentation
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>
- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations 2.8.6+
- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind 2.8.6+
- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client 2.25+
- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson 2.25+
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);
}If you encounter any difficulties or have questions regarding the use of the package, create a discussion in this repository or send an email.
You can obtain the API documentation from the source code of the package.