forked from casdoor/go-sms-sender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.go
88 lines (83 loc) · 2.97 KB
/
basic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package go_sms_sender
import "fmt"
const (
Twilio = "Twilio SMS"
AmazonSNS = "Amazon SNS"
AzureACS = "Azure ACS"
Msg91 = "Msg91 SMS"
GCCPAY = "GCCPAY SMS"
Infobip = "Infobip SMS"
SUBMAIL = "SUBMAIL SMS"
SmsBao = "SmsBao SMS"
Aliyun = "Aliyun SMS"
TencentCloud = "Tencent Cloud SMS"
BaiduCloud = "Baidu Cloud SMS"
VolcEngine = "Volc Engine SMS"
HuaweiCloud = "Huawei Cloud SMS"
UCloud = "UCloud SMS"
Huyi = "Huyi SMS"
MockSms = "Mock SMS"
Netgsm = "Netgsm SMS"
OsonSms = "OSON SMS"
QuanmSms = "Quanm SMS"
)
type SmsClient interface {
SendMessage(param map[string]string, targetPhoneNumber ...string) error
}
func NewSmsClient(provider string, accessId string, accessKey string, sign string, template string, other ...string) (SmsClient, error) {
switch provider {
case Twilio:
return GetTwilioClient(accessId, accessKey, template)
case AmazonSNS:
return GetAmazonSNSClient(accessId, accessKey, template, other)
case AzureACS:
return GetACSClient(accessKey, template, other)
case Msg91:
return GetMsg91Client(accessId, accessKey, template)
case GCCPAY:
return GetGCCPAYClient(accessId, accessKey, template)
case Infobip:
return GetInfobipClient(accessId, accessKey, template, other)
case SUBMAIL:
return GetSubmailClient(accessId, accessKey, template)
case SmsBao:
return GetSmsbaoClient(accessId, accessKey, sign, template, other)
case Aliyun:
return GetAliyunClient(accessId, accessKey, sign, template)
case TencentCloud:
return GetTencentClient(accessId, accessKey, sign, template, other)
case BaiduCloud:
return GetBceClient(accessId, accessKey, sign, template, other)
case VolcEngine:
return GetVolcClient(accessId, accessKey, sign, template, other)
case HuaweiCloud:
return GetHuaweiClient(accessId, accessKey, sign, template, other)
case UCloud:
return GetUcloudClient(accessId, accessKey, sign, template, other)
case Huyi:
return GetHuyiClient(accessId, accessKey, template)
case Netgsm:
return GetNetgsmClient(accessId, accessKey, sign, template)
case MockSms:
return NewMocker(accessId, accessKey, sign, template, other)
case OsonSms:
return GetOsonClient(accessId, accessKey, sign, template)
case QuanmSms:
return GetQuanmSMSClient(accessId, accessKey, template)
default:
return nil, fmt.Errorf("unsupported provider: %s", provider)
}
}