diff --git a/cmd/sachet/config.go b/cmd/sachet/config.go index 68ecc8f..3160164 100644 --- a/cmd/sachet/config.go +++ b/cmd/sachet/config.go @@ -44,20 +44,20 @@ type ReceiverConf struct { var config struct { Providers struct { - MessageBird messagebird.MessageBirdConfig - Nexmo nexmo.NexmoConfig - Twilio twilio.TwilioConfig - Infobip infobip.InfobipConfig - Kannel kannel.KannelConfig + MessageBird messagebird.Config + Nexmo nexmo.Config + Twilio twilio.Config + Infobip infobip.Config + Kannel kannel.Config KaveNegar kavenegar.Config - Exotel exotel.ExotelConfig - CM cm.CMConfig - MailruIM mailruim.MailruIMConfig + Exotel exotel.Config + CM cm.Config + MailruIM mailruim.Config Telegram telegram.Config - Turbosms turbosms.TurbosmsConfig - Smsc smsc.SmscConfig - OTC otc.OTCConfig - MediaBurst mediaburst.MediaBurstConfig + Turbosms turbosms.Config + Smsc smsc.Config + OTC otc.Config + MediaBurst mediaburst.Config FreeMobile freemobile.Config AspSms aspsms.Config Sipgate sipgate.Config @@ -68,7 +68,7 @@ var config struct { TencentCloud tencentcloud.Config Sap sap.Config Esendex esendex.Config - Sms77 sms77.Sms77Config + Sms77 sms77.Config } Receivers []ReceiverConf diff --git a/provider/cm/cm.go b/provider/cm/cm.go index 3a69628..92c3f61 100644 --- a/provider/cm/cm.go +++ b/provider/cm/cm.go @@ -10,20 +10,20 @@ import ( "github.com/messagebird/sachet" ) -// CMConfig is the configuration struct for CM provider -type CMConfig struct { +// Config is the configuration struct for CM provider +type Config struct { ProductToken string `yaml:"producttoken"` } // CM contains the necessary values for the CM provider type CM struct { - CMConfig + Config } var cmHTTPClient = &http.Client{Timeout: time.Second * 20} // NewCM creates and returns a new CM struct -func NewCM(config CMConfig) *CM { +func NewCM(config Config) *CM { return &CM{config} } @@ -53,7 +53,7 @@ func (c *CM) Send(message sachet.Message) error { smsURL := "https://gw.cmtelecom.com/v1.0/message" payload := CMPayload{} - payload.Messages.Authentication.ProductToken = c.CMConfig.ProductToken + payload.Messages.Authentication.ProductToken = c.Config.ProductToken payload.Messages.MSG = append(payload.Messages.MSG, CMMessage{}) payload.Messages.MSG[0].From = message.From diff --git a/provider/exotel/exotel.go b/provider/exotel/exotel.go index 853bbb5..ea782f1 100644 --- a/provider/exotel/exotel.go +++ b/provider/exotel/exotel.go @@ -10,8 +10,8 @@ import ( "github.com/messagebird/sachet" ) -//ExotelConfig configuration struct for exotel Client -type ExotelConfig struct { +//Config configuration struct for exotel Client +type Config struct { AccountSID string `yaml:"account_sid"` AuthToken string `yaml:"auth_token"` } @@ -26,7 +26,7 @@ type Exotel struct { } //NewExotel creates a new -func NewExotel(config ExotelConfig) *Exotel { +func NewExotel(config Config) *Exotel { Exotel := &Exotel{AccountSid: config.AccountSID, Token: config.AuthToken} return Exotel } diff --git a/provider/infobip/infobip.go b/provider/infobip/infobip.go index a2210d2..4f3ee1c 100644 --- a/provider/infobip/infobip.go +++ b/provider/infobip/infobip.go @@ -10,8 +10,8 @@ import ( "github.com/messagebird/sachet" ) -//InfobipConfig configuration struct for Infobip Client -type InfobipConfig struct { +//Config configuration struct for Infobip Client +type Config struct { Token string `yaml:"token"` Secret string `yaml:"secret"` } @@ -21,11 +21,11 @@ const InfobipRequestTimeout = time.Second * 20 //Infobip is the exte Infobip type Infobip struct { - InfobipConfig + Config } //NewInfobip creates a new -func NewInfobip(config InfobipConfig) *Infobip { +func NewInfobip(config Config) *Infobip { Infobip := &Infobip{config} return Infobip } diff --git a/provider/kannel/kannel.go b/provider/kannel/kannel.go index 2623461..da98ff3 100644 --- a/provider/kannel/kannel.go +++ b/provider/kannel/kannel.go @@ -9,8 +9,8 @@ import ( "github.com/messagebird/sachet" ) -//KannelConfig configuration struct for Kannel Client -type KannelConfig struct { +//Config configuration struct for Kannel Client +type Config struct { URL string `yaml:"url"` User string `yaml:"username"` Pass string `yaml:"password"` @@ -21,11 +21,11 @@ const KannelRequestTimeout = time.Second * 20 //Kannel is the exte Kannel type Kannel struct { - KannelConfig + Config } //NewKannel creates a new -func NewKannel(config KannelConfig) *Kannel { +func NewKannel(config Config) *Kannel { Kannel := &Kannel{config} return Kannel } diff --git a/provider/mailruim/mailruim.go b/provider/mailruim/mailruim.go index fe9ccea..b4da8eb 100644 --- a/provider/mailruim/mailruim.go +++ b/provider/mailruim/mailruim.go @@ -5,16 +5,16 @@ import ( "github.com/messagebird/sachet" ) -type MailruIMConfig struct { +type Config struct { Token string `yaml:"token"` - Url string `yaml:"url"` + Url string `yaml:"url"` } type MailruIM struct { bot *botgolang.Bot } -func NewMailruIM(config MailruIMConfig) (*MailruIM, error) { +func NewMailruIM(config Config) (*MailruIM, error) { bot, err := botgolang.NewBot(config.Token, botgolang.BotApiURL(config.Url)) if err != nil { return nil, err @@ -32,6 +32,3 @@ func (mr *MailruIM) Send(message sachet.Message) error { } return nil } - - - diff --git a/provider/mediaburst/mediaburst.go b/provider/mediaburst/mediaburst.go index 6dceb34..6c8ce53 100644 --- a/provider/mediaburst/mediaburst.go +++ b/provider/mediaburst/mediaburst.go @@ -10,8 +10,8 @@ import ( "github.com/messagebird/sachet" ) -//MediaBurstConfig configuration struct for mediaburst Client -type MediaBurstConfig struct { +//Config configuration struct for mediaburst Client +type Config struct { APIKey string `yaml:"api_key"` } @@ -20,11 +20,11 @@ const MediaBurstRequestTimeout = time.Second * 20 //MediaBurst is the exte MediaBurst type MediaBurst struct { - MediaBurstConfig + Config } //NewMediaBurst creates a new -func NewMediaBurst(config MediaBurstConfig) *MediaBurst { +func NewMediaBurst(config Config) *MediaBurst { MediaBurst := &MediaBurst{config} return MediaBurst } diff --git a/provider/messagebird/messagebird.go b/provider/messagebird/messagebird.go index 21a23ea..b5dc528 100644 --- a/provider/messagebird/messagebird.go +++ b/provider/messagebird/messagebird.go @@ -11,7 +11,7 @@ import ( "github.com/messagebird/sachet" ) -type MessageBirdConfig struct { +type Config struct { AccessKey string `yaml:"access_key"` Gateway int `yaml:"gateway"` Debug bool `yaml:"debug"` @@ -26,7 +26,7 @@ type MessageBird struct { voiceMessageParams voicemessage.Params } -func NewMessageBird(config MessageBirdConfig) *MessageBird { +func NewMessageBird(config Config) *MessageBird { client := messagebird.New(config.AccessKey) if config.Debug { client.DebugLog = log.New(os.Stdout, "DEBUG: ", log.Lshortfile) diff --git a/provider/nexmo/nexmo.go b/provider/nexmo/nexmo.go index f135432..0b1f54f 100644 --- a/provider/nexmo/nexmo.go +++ b/provider/nexmo/nexmo.go @@ -5,7 +5,7 @@ import ( "gopkg.in/njern/gonexmo.v1" ) -type NexmoConfig struct { +type Config struct { APIKey string `yaml:"api_key"` APISecret string `yaml:"api_secret"` } @@ -14,7 +14,7 @@ type Nexmo struct { client *nexmo.Client } -func NewNexmo(config NexmoConfig) (*Nexmo, error) { +func NewNexmo(config Config) (*Nexmo, error) { client, err := nexmo.NewClientFromAPI(config.APIKey, config.APISecret) if err != nil { return nil, err diff --git a/provider/otc/otc.go b/provider/otc/otc.go index 9ea8e8d..cab3af4 100644 --- a/provider/otc/otc.go +++ b/provider/otc/otc.go @@ -12,7 +12,7 @@ import ( "time" ) -type OTCConfig struct { +type Config struct { IdentityEndpoint string `yaml:"identity_endpoint"` DomainName string `yaml:"domain_name"` ProjectName string `yaml:"project_name"` @@ -30,10 +30,10 @@ type smsRequest struct { } type OTC struct { - OTCConfig + Config } -func NewOTC(config OTCConfig) *OTC { +func NewOTC(config Config) *OTC { OTC := &OTC{config} return OTC } diff --git a/provider/sms77/sms77.go b/provider/sms77/sms77.go index 90f9d0b..8e7315b 100644 --- a/provider/sms77/sms77.go +++ b/provider/sms77/sms77.go @@ -8,8 +8,8 @@ import ( "github.com/sms77io/go-client/sms77api" ) -// Sms77Config is the configuration struct for Sms77 provider -type Sms77Config struct { +// Config is the configuration struct for Sms77 provider +type Config struct { ApiKey string `yaml:"api_key"` Debug bool `yaml:"debug"` } @@ -17,11 +17,11 @@ type Sms77Config struct { // Sms77 contains the necessary values for the Sms77 provider type Sms77 struct { client *sms77api.Sms77API - config Sms77Config + config Config } // NewSms77 creates and returns a new Sms77 struct -func NewSms77(config Sms77Config) *Sms77 { +func NewSms77(config Config) *Sms77 { client := sms77api.New(sms77api.Options{ ApiKey: config.ApiKey, Debug: config.Debug, diff --git a/provider/smsc/smsc.go b/provider/smsc/smsc.go index e697c11..f8c9382 100644 --- a/provider/smsc/smsc.go +++ b/provider/smsc/smsc.go @@ -8,7 +8,7 @@ import ( "time" ) -type SmscConfig struct { +type Config struct { Login string `yaml:"login"` Password string `yaml:"password"` } @@ -20,7 +20,7 @@ type Smsc struct { Password string } -func NewSmsc(config SmscConfig) *Smsc { +func NewSmsc(config Config) *Smsc { Smsc := &Smsc{Login: config.Login, Password: config.Password} return Smsc } diff --git a/provider/turbosms/turbosms.go b/provider/turbosms/turbosms.go index dd9e08b..4c2060a 100644 --- a/provider/turbosms/turbosms.go +++ b/provider/turbosms/turbosms.go @@ -14,7 +14,7 @@ import ( ) // sachet section -type TurbosmsConfig struct { +type Config struct { Alogin string `yaml:"login"` Apassword string `yaml:"password"` } @@ -23,7 +23,7 @@ type Turbosms struct { Password string } -func NewTurbosms(config TurbosmsConfig) *Turbosms { +func NewTurbosms(config Config) *Turbosms { Turbosms := &Turbosms{Login: config.Alogin, Password: config.Apassword} return Turbosms } diff --git a/provider/twilio/twilio.go b/provider/twilio/twilio.go index 1afcf08..d3d30a0 100644 --- a/provider/twilio/twilio.go +++ b/provider/twilio/twilio.go @@ -5,7 +5,7 @@ import ( "github.com/messagebird/sachet" ) -type TwilioConfig struct { +type Config struct { AccountSID string `yaml:"account_sid"` AuthToken string `yaml:"auth_token"` } @@ -14,7 +14,7 @@ type Twilio struct { client twiliogo.Client } -func NewTwilio(config TwilioConfig) *Twilio { +func NewTwilio(config Config) *Twilio { return &Twilio{client: twiliogo.NewClient(config.AccountSID, config.AuthToken)} }