-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathx6.go
51 lines (41 loc) · 1.09 KB
/
x6.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
package webmoney
import (
"encoding/xml"
"strings"
)
type SendMsg struct {
XMLName xml.Name `xml:"message"`
ReceiverWmid string `xml:"receiverwmid"`
MsgSubj string `xml:"msgsubj"`
MsgText string `xml:"msgtext"`
OnlyAuth int `xml:"onlyauth"`
}
func (s SendMsg) GetSignSource(reqn string) (string, error) {
subject, err := Utf8ToWin(strings.Trim(s.MsgSubj, " "))
if err != nil {
return "", err
}
text, err := Utf8ToWin(strings.Trim(s.MsgText, " "))
if err != nil {
return "", err
}
return s.ReceiverWmid + reqn + text + subject, nil
}
type SendMsgResponse struct {
XMLName xml.Name `xml:"message"`
MessageId int `xml:"id,attr"`
ReceiverWmid string `xml:"receiverwmid"`
MsgSubj string `xml:"msgsubj"`
MsgText string `xml:"msgtext"`
DateCrt string `xml:"datecrt"`
}
func (w *WmClient) SendMessage(s SendMsg) (SendMsgResponse, error) {
X := W3s{
Request: s,
Interface: XInterface{Name: "SendMsg", Type: "w3s"},
Client: w,
}
result := SendMsgResponse{}
err := X.getResult(&result)
return result, err
}