All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io._57blocks.sms.SmsServiceTwilioImpl Maven / Gradle / Ivy

Go to download

sms-spring-boot provide a convenient approach to integrate sms service by pre-defined configuration. It supports templating with resource bundle.

There is a newer version: 0.1.2
Show newest version
package io._57blocks.sms;

import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import java.util.Locale;
import org.springframework.context.support.ResourceBundleMessageSource;

public class SmsServiceTwilioImpl implements SmsService {

  private ResourceBundleMessageSource messageSource;

  public SmsServiceTwilioImpl(ResourceBundleMessageSource smsMessageSource) {
    this.messageSource = smsMessageSource;
  }

  public Object send(String from, String to, String template, Locale locale, Object[] args) {
    String body = messageSource.getMessage(template, args, locale);

    Message message = Message.creator(new PhoneNumber(to), new PhoneNumber(from), body).create();
    return message.getSid();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy