Fix bug in cas where if Limit was PR, the LimitStruct would omit a node.

This commit is contained in:
Sketch 2022-10-17 07:24:36 -04:00
parent 24976315d4
commit a943188958
4 changed files with 21 additions and 8 deletions

8
cas.go
View File

@ -31,12 +31,12 @@ func listItems(e *Envelope) {
Prices: Prices{
ItemId: 0,
Price: Price{
Amount: 100,
// Not sure about WSC, but must match the price for the title you are purchasing in Wii no Ma.
Amount: 0,
Currency: "POINTS",
},
// Literally every Limit except for PR works
Limits: LimitStruct(TR),
LicenseKind: "RENTAL",
Limits: LimitStruct(DR),
LicenseKind: RENTAL,
},
})
}

View File

@ -13,6 +13,18 @@ const (
AT = 10000
)
// LicenceKinds represents the various rights a user has to a title.
type LicenceKinds string
const (
PERMANENT LicenceKinds = "PERMANENT"
DEMO LicenceKinds = "DEMO"
TRIAL LicenceKinds = "TRIAL"
RENTAL LicenceKinds = "RENTAL"
SUBSCRIPT LicenceKinds = "SUBSCRIPT"
SERVICE LicenceKinds = "SERVICE"
)
// LimitStruct returns a Limits struct filled for the given kind.
func LimitStruct(kind LimitKinds) Limits {
names := map[LimitKinds]string{

View File

@ -104,7 +104,7 @@ type Balance struct {
// Limits represents a common XML structure for transaction information.
type Limits struct {
XMLName xml.Name `xml:"Limits"`
Limits LimitKinds `xml:"Limits,omitempty"`
Limits LimitKinds `xml:"Limits"`
LimitKind string `xml:"LimitKind,omitempty"`
}
@ -161,8 +161,8 @@ type Price struct {
type Prices struct {
ItemId int `xml:"ItemId"`
Price Price
Limits Limits `xml:"Limits"`
LicenseKind string `xml:"LicenseKind"`
Limits Limits `xml:"Limits"`
LicenseKind LicenceKinds `xml:"LicenseKind"`
}
// Items allows specifying an overview of a title's contents.
@ -181,4 +181,5 @@ type Ratings struct {
Name string `xml:"Name"`
Rating int `xml:"Rating"`
Age int `xml:"Age"`
// There is also a `Descriptors` field
}

View File

@ -35,7 +35,7 @@ import (
var namespaceParse = regexp.MustCompile(`^urn:(.{3})\.wsapi\.broadon\.com/(.*)$`)
// parseAction interprets contents along the lines of "urn:ecs.wsapi.broadon.com/CheckDeviceStatus",
//where "CheckDeviceStatus" is the action to be performed.
// where "CheckDeviceStatus" is the action to be performed.
func parseAction(original string) (string, string) {
// Intended to return the original string, the service's name and the name of the action.
matches := namespaceParse.FindStringSubmatch(original)