-
Notifications
You must be signed in to change notification settings - Fork 10
/
x15.go
98 lines (86 loc) · 2.51 KB
/
x15.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
89
90
91
92
93
94
95
96
97
98
// Copyright (c) 2016 The Constantin Karataev. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd.
//
// desc
// https://wiki.wmtransfer.com/projects/webmoney/wiki/Interface_X15
package webmoney
import (
"encoding/xml"
)
type TrustList struct {
XMLName xml.Name `xml:"gettrustlist"`
Wmid string `xml:"wmid"`
}
func (t TrustList) GetSignSource(reqn string) (string, error) {
return t.Wmid + reqn, nil
}
type TrustListResponse struct {
XMLName xml.Name `xml:"trustlist"`
Cnt string `xml:"cnt,attr"`
TrustList []Trust `xml:"trastlist"`
}
type Trust struct {
XMLName xml.Name `xml:"trast"`
Id string `xml:"id,attr"`
Inv string `xml:"inv,attr"`
Trast string `xml:"trans,attr"`
PurseAttr string `xml:"purse,attr"`
TransHist string `xml:"transhist"`
Master string `xml:"master"`
Purse string `xml:"purse"`
DayLimit string `xml:"daylimit"`
DLimit string `xml:"dlimit"`
WLimit string `xml:"wlimit"`
MLimit string `xml:"mlimit"`
DSum string `xml:"dsum"`
WSum string `xml:"wsum"`
MSum string `xml:"msum"`
LastSumDate string `xml:"lastsumdate"`
}
type TrustSave struct {
XMLName xml.Name `xml:"trust"`
Inv string `xml:"inv,attr"`
Trans string `xml:"trans,attr"`
PurseAttr string `xml:"purse,attr"`
TransHist string `xml:"transhist"`
MasterWmid string `xml:"masterwmid"`
SlaveWmid string `xml:"slavewmid"`
Purse string `xml:"purse"`
Limit string `xml:"limit"`
DayLimit string `xml:"daylimit"`
WeekLimit string `xml:"weeklimit"`
MonthLimit string `xml:"monthlimit"`
}
func (t TrustSave) GetSignSource(reqn string) (string, error) {
return t.Purse + t.MasterWmid + reqn, nil
}
//func GetTrastList
func (w *WmClient) GetTrustList(t TrustList) (TrustListResponse, error) {
var InterfaceName string
if w.Wmid != t.Wmid {
InterfaceName = "TrustList2"
} else {
InterfaceName = "TrustList"
}
X := W3s{
Interface: XInterface{Name: InterfaceName, Type: "w3s"},
Request: t,
Client: w,
}
result := TrustListResponse{}
err := X.getResult(&result)
return result, err
}
func (w *WmClient) SetTrust(t TrustSave) (Trust, error) {
X := W3s{
Interface: XInterface{Name: "TrustSave2", Type: "w3s"},
Request: t,
Client: w,
}
result := Trust{}
err := X.getResult(&result)
return result, err
}