Skip to content

Commit

Permalink
Merge pull request messagebird#105 from BDelacour/master
Browse files Browse the repository at this point in the history
rename every ProviderConfig to Config
  • Loading branch information
marcel corso gonzalez committed Nov 18, 2021
2 parents edf8d3e + 87d45c6 commit 6575a24
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 56 deletions.
26 changes: 13 additions & 13 deletions cmd/sachet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +68,7 @@ var config struct {
TencentCloud tencentcloud.Config
Sap sap.Config
Esendex esendex.Config
Sms77 sms77.Sms77Config
Sms77 sms77.Config
}

Receivers []ReceiverConf
Expand Down
10 changes: 5 additions & 5 deletions provider/cm/cm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions provider/exotel/exotel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions provider/infobip/infobip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions provider/kannel/kannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
}
Expand Down
9 changes: 3 additions & 6 deletions provider/mailruim/mailruim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +32,3 @@ func (mr *MailruIM) Send(message sachet.Message) error {
}
return nil
}



8 changes: 4 additions & 4 deletions provider/mediaburst/mediaburst.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions provider/messagebird/messagebird.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions provider/nexmo/nexmo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions provider/otc/otc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions provider/sms77/sms77.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ 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"`
}

// 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,
Expand Down
4 changes: 2 additions & 2 deletions provider/smsc/smsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"
)

type SmscConfig struct {
type Config struct {
Login string `yaml:"login"`
Password string `yaml:"password"`
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions provider/turbosms/turbosms.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// sachet section
type TurbosmsConfig struct {
type Config struct {
Alogin string `yaml:"login"`
Apassword string `yaml:"password"`
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions provider/twilio/twilio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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)}
}

Expand Down

0 comments on commit 6575a24

Please sign in to comment.