-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
69 lines (62 loc) · 1.99 KB
/
types.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
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/M2MGateway/go-smpp/pdu"
)
type Configuration struct {
Hook string `json:"hook"`
HookMode string `json:"hook_mode"`
Devices []*Device `json:"devices"`
}
//goland:noinspection ALL
type Device struct {
SMSC string `json:"smsc"`
SystemID string `json:"system_id"`
Password string `json:"password"`
SystemType string `json:"system_type"`
Version pdu.InterfaceVersion `json:"version"`
BindMode string `json:"bind_mode"`
Owner string `json:"owner"`
Phone string `json:"phone"`
Extra json.RawMessage `json:"extra"`
Workaround string `json:"workaround"`
KeepAliveTick time.Duration `json:"keepalive_tick"`
KeepAliveTimeout time.Duration `json:"keepalive_timeout"`
}
func (d *Device) String() string {
return fmt.Sprintf("%s @ %s", d.SMSC, d.SystemID)
}
func (d *Device) Binder() pdu.Responsable {
switch d.BindMode {
case "receiver":
return &pdu.BindReceiver{
SystemID: d.SystemID,
Password: d.Password,
SystemType: d.SystemType,
Version: d.Version,
}
case "transceiver":
return &pdu.BindTransceiver{
SystemID: d.SystemID,
Password: d.Password,
SystemType: d.SystemType,
Version: d.Version,
}
}
return nil
}
//goland:noinspection ALL
type Payload struct {
SMSC string `json:"smsc"`
SystemID string `json:"system_id"`
SystemType string `json:"system_type"`
Source string `json:"source,omitempty"`
Target string `json:"target,omitempty"`
Message string `json:"message"`
DeliverTime time.Time `json:"deliver_time"`
Owner string `json:"owner,omitempty"`
Phone string `json:"phone,omitempty"`
Extra json.RawMessage `json:"extra,omitempty"`
}