func New(jsonCfg []byte) (interface{}, error) {
	var c *cfg
	if err := json.Unmarshal(jsonCfg, &c); err != nil {
		return nil, err
	}
	if c.AppID == "" {
		return nil, errors.New("invalid AppID")
	}
	if c.AWSRegion == "" {
		return nil, errors.New("invalid AWSRegion")
	}
	if c.AWSAccessKey == "" {
		return nil, errors.New("invalid AWSAccessKey")
	}
	if c.AWSSecretKey == "" {
		return nil, errors.New("invalid AWSSecretKey")
	}
	sess := session.Must(session.NewSession())
	svc := pinpoint.New(sess,
		aws.NewConfig().
			WithCredentials(credentials.NewStaticCredentials(c.AWSAccessKey, c.AWSSecretKey, "")).
			WithRegion(c.AWSRegion),
	)
	return &sms{
		cfg: c,
		p:   svc}, nil
}
New returns an instance of the SMS package. cfg is configuration
represented as a JSON string. Supported options are.
{
AppID: "", // Application ID for amazon pinpoint service,
AWSAccessKey: "", // AWS access key,
AWSSecretKey: "", // AWS secret key,
AWSRegion: "", // AWS region name,
MessageType: "", // MessageType to signify if it is transactional sms,
SenderID: "" // Unique sender id
}
package main
import (
	"encoding/json"
	"errors"
	"fmt"
	"regexp"
	"strings"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/pinpoint"
	"github.com/knadh/otpgateway/models"
)
const (
	providerID    = "pinpoint"
	channelName   = "SMS"
	addressName   = "Mobile number"
	maxAddresslen = 10
	maxOTPlen     = 6
)
var (
	channelType = "SMS"
)
var reNum = regexp.MustCompile(`\+?([0-9]){8,15}`)
type sms struct {
	cfg *cfg
	p   *pinpoint.Pinpoint
}
type cfg struct {
	AppID        string `json:"AppID"`
	AWSAccessKey string `json:"AWSAccessKey"`
	AWSSecretKey string `json:"AWSSecretKey"`
	AWSRegion    string `json:"AWSRegion"`
	MessageType  string `json:"MessageType"`
	SenderID     string `json:"SenderID"`
}