Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webexinteract

Use WebExInteract to send bulk SMS online. Instantly reach out to your customers with personalized SMS marketing messages, updates, alerts, OTPs, SMS attachments & more.

The Upstream API is still in it's infancy and so subsequently is this API! 😞

What we and upstream can do however is:

SendSms.send()
Accounts.read()
Senders.read()
Senders.list()
Senders.delete()

Enjoy 😃

Note: We use a 4 point versioning system: (Semantic Versioning 2.0.0 + 1) W.X.Y.Z
W: The Upstream API version that is being targetted
X: MAJOR version when we make incompatible API changes
Y: MINOR version when we add functionality in a backward compatible manner
Z: PATCH version when we make backward compatible bug fixes

Installation

<dependency>
    <groupId>uk.co.twinn.api</groupId>
    <artifactId>webexinteract-api-client</artifactId>
    <version>1.1.0.0</version>
</dependency>

Authentication

Create a file in user home ~ named /.webexinteract-api/config.json Set contents as below. Change the secret.

{
  "website" : "api.webexinteract.com", 
  "secret": "abc_1234567890abcdef1234567890abcdef"
}

Account

private void accounts() {

    Read<Account> read = Accounts.read().getResponse();

    if (read.isSuccess()) {

        System.out.println(
            new JacksonObjectMapper().toJson(read.getResult())
        );

    } else {

        System.out.println(
            new JacksonObjectMapper().toJson(read.getError())
        );

    }

}

Send SMS

private void sendSms(String phoneNumber){

    //you can add a list of recipients or a single recipient
    //you can also add a list of phoneNumbers under the Recipient
    Created<Sms> created =
        SendSms
            .send(MY_MESSAGE, MY_SENDERNAME)
            .addTo(new Recipient().countryCode("GB").phone(phoneNumber)) //set GB as country use 'normal' 07000123456 format
            //.addTo(new Recipient().phone(e164phoneNumber)) //use the +4470000123456 format
            //.setScheduleAt(ZonedDateTime.now().minusDays(2)) //cause in the past error
            //.setScheduleAt(ZonedDateTime.now().plusYears(2)) //cause too far in the future error
            .setSkipOptOutCheck(true)
            .getResponse();

    if (created.isSuccess()){
        //if we enter an incorrect phone number we receive response 200
        //but getErrors is not empty
        //so if we enter lots of numbers we have a list of messages that succeed
        //and a list of those that failed
        System.out.println(
            new JacksonObjectMapper().toJson(created.getResult())
        );

        for (SmsTransaction success : created.getResult().getMessages()){
            System.out.println("Success to " + success.getTo());
        }
        for (SmsTransaction success : created.getResult().getErrors()){
            System.out.println("Failure to " + success.getTo());
        }

        if (created.getResult().getErrors().isEmpty()){

            System.out.println("Success Success!");

        }else{

            System.out.println("Success with Error(s)!");

        }

    }else{

        System.out.println("FAILURE");
        System.out.println(
            new JacksonObjectMapper().toJson(created.getError())
        );

    }

}

Senders

List

private void sendersList() {

    Listed<Sender> listed = Senders.list().getResponse();

    if (listed.isSuccess()) {

        System.out.println("SUCCESS");

        System.out.println(
            new JacksonObjectMapper().toJson(
                listed.getResult()
            )
        );

        System.out.println(
            new JacksonObjectMapper().toJson(
                listed.getResult().getPaging()
            )
        );

        for (Sender sender : listed.getResult().getItems()) {
            System.out.println(
                    new JacksonObjectMapper().toJson(sender)
            );

            Read<Sender> read = Senders.read(sender.getId()).getResponse();
            
            if (read.isSuccess()) {
                System.out.println(
                    "READ IT BACK" + new JacksonObjectMapper().toJson(read.getResult())
                );
            }

        }

        //There is an API option to delete. but NOT create.
        //We do not have a sandbox so for now I have not implemented delete

    } else {

        System.out.println("FAILURE");
        System.out.println(
            new JacksonObjectMapper().toJson(listed.getError())
        );

    }
}

Delete

private void senderDelete() {

    Deleted<Sender> delete = Senders.delete("ssd_3XXXXXXXXXXXXXXXXXXXXX").getResponse();

    if (delete.isSuccess()){
        System.out.println("Success");
    }else{
        System.out.println("Error");
        System.out.println(
            new JacksonObjectMapper().toJson(delete.getError())
        );
    }

}    

About

Use WebExInteract to send bulk SMS online. Instantly reach out to your customers with personalized SMS marketing messages, updates, alerts, OTPs, SMS attachments & more.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages