-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsms.go
44 lines (35 loc) · 757 Bytes
/
sms.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
package sms
const (
LenGSM7 = 160
LenGSM7Concat = 153
LenUCS2 = 70
LenUCS2Concat = 70
)
func New(message string, options ...OptionFunc) *SMS {
sms := &SMS{
encoding: EncodingDefault,
language: LangDefault,
Message: message,
}
for _, opt := range options {
sms = opt(sms)
}
return sms
}
type SMS struct {
encoding Encoding
language Language
Message string
}
func (s SMS) Encode() (string, error) {
return Encode(s.encoding, s.language, s.Message)
}
func (s SMS) Valid() bool {
return Validate(s.encoding, s.language, s.Message)
}
func (s SMS) Len() int {
return strLen(s.encoding, s.language, s.Message)
}
func (s SMS) Segments() int {
return segmentLen(s.encoding, strLen(s.encoding, s.language, s.Message))
}