Add test ListItems response

Not currently functional, but parses succesfully.
This commit is contained in:
Spotlight 2021-05-24 14:12:00 -05:00
parent 50bf68ed8b
commit 8291cff180
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
3 changed files with 93 additions and 0 deletions

41
cas.go Normal file
View File

@ -0,0 +1,41 @@
package main
func listItems(e *Envelope) {
titleId, err := getKey(e.doc, "TitleId")
if err != nil {
e.Error(9, "Unable to obtain title.", err)
}
e.AddKVNode("ListResultTotalSize", "1")
e.AddCustomType(Items{
TitleId: titleId,
Contents: ContentsMetadata{
TitleIncluded: false,
ContentIndex: 1,
},
Attributes: []Attributes{
{
Name: "MaxUserInodes",
Value: "10",
},
{
Name: "itemComment",
Value: "Does not catch on fire.",
},
},
Ratings: Ratings{
Name: "Testing",
Rating: 1,
Age: 13,
},
Prices: Prices{
ItemId: 0,
Price: Price{
Amount: 1,
Currency: "POINTS",
},
Limits: LimitStruct(PR),
LicenseKind: "PERMANENT",
},
})
}

View File

@ -96,6 +96,11 @@ func main() {
ias.Unauthenticated("Register", register)
ias.Authenticated("Unregister", unregister)
}
cas := r.HandleGroup("cas")
{
cas.Authenticated("ListItems", listItems)
}
log.Fatal(http.ListenAndServe(readConfig.Address, r.Handle()))
// From here on out, all special cool things should go into their respective handler function.

View File

@ -163,3 +163,50 @@ type Tickets struct {
MigrateCount int `xml:"MigrateCount"`
MigrateLimit int `xml:"MigrateLimit"`
}
// Attributes represents a common structure of the same name.
type Attributes struct {
XMLName xml.Name `xml:"Attributes"`
Name string `xml:"Name"`
Value string `xml:"Value"`
}
// ContentsMetadata describes data about contents within a title.
type ContentsMetadata struct {
XMLName xml.Name `xml:"Contents"`
TitleIncluded bool `xml:"TitleIncluded"`
ContentIndex int `xml:"ContentIndex"`
}
// Price holds the price for a title.
type Price struct {
XMLName xml.Name `xml:"Price"`
Amount int `xml:"Amount"`
Currency string `xml:"Currency"`
}
// Prices describes a common structure for listing prices within a title.
type Prices struct {
ItemId int `xml:"ItemId"`
Price Price
Limits Limits `xml:"Limits"`
LicenseKind string `xml:"LicenseKind"`
}
// Items allows specifying an overview of a title's contents.
type Items struct {
XMLName xml.Name `xml:"Items"`
TitleId string `xml:"TitleId"`
Contents ContentsMetadata `xml:"Contents"`
Attributes []Attributes `xml:"Attribute,omitempty"`
Ratings Ratings `xml:"Ratings,omitempty"`
Prices Prices `xml:"Prices,omitempty"`
}
// Ratings allows specifying the rating of an item across multiple properties.
type Ratings struct {
XMLName xml.Name `xml:"Ratings"`
Name string `xml:"Name"`
Rating int `xml:"Rating"`
Age int `xml:"Age"`
}