-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage_reseller_raw.go
43 lines (35 loc) · 1.1 KB
/
package_reseller_raw.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
package directadmin
import "github.com/spf13/cast"
type rawResellerPackage struct {
rawPackage
OversellEnabled string `json:"oversell" url:"oversell"`
UserQuota string `json:"nuser,omitempty" url:"nuser,omitempty"`
UserQuotaUnlimited string `json:"unusers,omitempty" url:"unusers,omitempty"` // unique unlimited field DA requires for an unlimited user quota
}
func (p *ResellerPackage) translate() (pack rawResellerPackage) {
pack = rawResellerPackage{
rawPackage: p.Package.translate(),
OversellEnabled: reverseParseOnOff(p.OversellEnabled, false),
}
if p.UserQuota == -1 {
pack.UserQuota = ""
pack.UserQuotaUnlimited = "yes"
} else {
pack.UserQuota = cast.ToString(p.UserQuota)
pack.UserQuotaUnlimited = ""
}
return pack
}
func (p *rawResellerPackage) translate() (pack ResellerPackage) {
pack = ResellerPackage{
Package: p.rawPackage.translate(),
OversellEnabled: parseOnOff(p.OversellEnabled),
UserQuota: parseNum(p.UserQuota),
}
if p.UserQuotaUnlimited == "yes" {
pack.UserQuota = -1
} else if p.UserQuota == "" {
pack.UserQuota = 0
}
return pack
}