Skip to content

Commit

Permalink
check interface for each provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dzyanis committed Mar 16, 2022
1 parent deb1b0d commit 70964ec
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/sachet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func providerByName(name string) (sachet.Provider, error) {
case "ovh":
return ovh.NewOvh(config.Providers.OVH)
case "tencentcloud":
return tencentcloud.NewTencentCloud(config.Providers.TencentCloud)
return tencentcloud.NewTencentCloud(config.Providers.TencentCloud), nil
case "sap":
return sap.NewSap(config.Providers.Sap), nil
case "esendex":
Expand Down
2 changes: 2 additions & 0 deletions provider/aliyun/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Config struct {
TemplateParamKey string `yaml:"template_param_key"`
}

var _ (sachet.Provider) = (*Aliyun)(nil)

type Aliyun struct {
client *dysmsapi.Client
config *Config
Expand Down
2 changes: 2 additions & 0 deletions provider/aspsms/aspsms.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Config struct {
Password string `yaml:"password"`
}

var _ (sachet.Provider) = (*AspSms)(nil)

// AspSms contains the necessary values for the AspSms provider.
type AspSms struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/cm/cm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
ProductToken string `yaml:"producttoken"`
}

var _ (sachet.Provider) = (*CM)(nil)

// CM contains the necessary values for the CM provider.
type CM struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/esendex/esendex.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Config struct {
AccountReference string `yaml:"account_reference"`
}

var _ (sachet.Provider) = (*Esendex)(nil)

type Esendex struct {
Config
httpClient *http.Client
Expand Down
2 changes: 2 additions & 0 deletions provider/exotel/exotel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Config struct {
// ExotelRequestTimeout is the timeout for http request to exotel.
const ExotelRequestTimeout = time.Second * 20

var _ (sachet.Provider) = (*Exotel)(nil)

// Exotel is the exte Exotel.
type Exotel struct {
AccountSid string
Expand Down
2 changes: 2 additions & 0 deletions provider/freemobile/freemobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Config struct {
URL string `yaml:"url"`
}

var _ (sachet.Provider) = (*FreeMobile)(nil)

// FreeMobile contains the necessary values for the FreeMobile provider.
type FreeMobile struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/ghasedak/ghasedak.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Config struct {
APIToken string `yaml:"api_token"`
}

var _ (sachet.Provider) = (*Ghasedak)(nil)

// Creating the KaveNegar to contain provider data.
type Ghasedak struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/infobip/infobip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Config struct {
// InfobipRequestTimeout is the timeout for http request to Infobip.
const InfobipRequestTimeout = time.Second * 20

var _ (sachet.Provider) = (*Infobip)(nil)

// Infobip is the exte Infobip.
type Infobip struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/kannel/kannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Config struct {
// KannelRequestTimeout is the timeout for http request to Kannel.
const KannelRequestTimeout = time.Second * 20

var _ (sachet.Provider) = (*Kannel)(nil)

// Kannel is the exte Kannel.
type Kannel struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/kavenegar/kavenegar.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Config struct {
PhoneNumbers []string `yaml:"phone_numbers"`
}

var _ (sachet.Provider) = (*KaveNegar)(nil)

// Creating the KaveNegar to contain provider data.
type KaveNegar struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/mailruim/mailruim.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Config struct {
Url string `yaml:"url"`
}

var _ (sachet.Provider) = (*MailruIM)(nil)

type MailruIM struct {
bot *botgolang.Bot
}
Expand Down
2 changes: 2 additions & 0 deletions provider/mediaburst/mediaburst.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Config struct {
// MediaBurstRequestTimeout is the timeout for http request to mediaburst.
const MediaBurstRequestTimeout = time.Second * 20

var _ (sachet.Provider) = (*MediaBurst)(nil)

// MediaBurst is the exte MediaBurst.
type MediaBurst struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/messagebird/messagebird.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Config struct {
Repeat int `yaml:"repeat"`
}

var _ (sachet.Provider) = (*MessageBird)(nil)

type MessageBird struct {
client *messagebird.Client
messageParams sms.Params
Expand Down
2 changes: 2 additions & 0 deletions provider/nexmo/nexmo.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Config struct {
APISecret string `yaml:"api_secret"`
}

var _ (sachet.Provider) = (*Nexmo)(nil)

type Nexmo struct {
client *nexmo.Client
}
Expand Down
2 changes: 2 additions & 0 deletions provider/nowsms/nowsms.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Config struct {
PhoneNumbers []string `yaml:"phone_numbers"`
}

var _ (sachet.Provider) = (*NowSms)(nil)

// NowSms contains the necessary values for the NowSms provider.
type NowSms struct {
Config
Expand Down
3 changes: 1 addition & 2 deletions provider/otc/otc.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ func (c *OTC) SendRequest(method, resource string, payload *smsRequest, attempts
c.Token = ""
if attempts--; attempts > 0 {
return c.SendRequest(method, resource, payload, attempts)
} else {
return nil, err
}
return nil, err
} else if resp.StatusCode >= http.StatusBadRequest {
return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode)
}
Expand Down
2 changes: 2 additions & 0 deletions provider/ovh/ovh.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Config struct {
Priority string `yaml:"priority"`
}

var _ (sachet.Provider) = (*Ovh)(nil)

type Ovh struct {
client *ovh.Client
config *Config
Expand Down
2 changes: 2 additions & 0 deletions provider/pushbullet/pushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Config struct {
AccessToken string `yaml:"access_token"`
}

var _ (sachet.Provider) = (*Pushbullet)(nil)

// Pushbullet contains the necessary values for the Pushbullet provider.
type Pushbullet struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/sap/sap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
AuthHash string `yaml:"auth_hash"`
}

var _ (sachet.Provider) = (*Sap)(nil)

// Sap contains the necessary values for the Sap provider.
type Sap struct {
Config
Expand Down
2 changes: 2 additions & 0 deletions provider/sipgate/sipgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Config struct {
Password string `yaml:"password"`
}

var _ (sachet.Provider) = (*Sipgate)(nil)

// Sipgate contains the necessary values for the Sipgate provider.
type Sipgate struct {
Config
Expand Down
6 changes: 4 additions & 2 deletions provider/tencentcloud/tencentcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ type Config struct {
Truncate bool `yaml:"truncate"`
}

var _ (sachet.Provider) = (*TencentCloud)(nil)

type TencentCloud struct {
client *sms.Client
config *Config
}

func NewTencentCloud(config Config) (*TencentCloud, error) {
func NewTencentCloud(config Config) *TencentCloud {
credential := common.NewCredential(
config.SecretId,
config.SecretKey,
Expand All @@ -42,7 +44,7 @@ func NewTencentCloud(config Config) (*TencentCloud, error) {
return &TencentCloud{
client: client,
config: &config,
}, nil
}
}

func truncateString(str string, num int) string {
Expand Down
2 changes: 2 additions & 0 deletions provider/twilio/twilio.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Config struct {
AuthToken string `yaml:"auth_token"`
}

var _ (sachet.Provider) = (*Twilio)(nil)

type Twilio struct {
client twiliogo.Client
}
Expand Down

0 comments on commit 70964ec

Please sign in to comment.