mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-05 21:11:02 +02:00
Add preliminary support for purchase history querying
This commit is contained in:
parent
6221b6dac2
commit
6ceeb68dfc
17
ecs.go
17
ecs.go
@ -30,7 +30,7 @@ const (
|
|||||||
|
|
||||||
func checkDeviceStatus(e *Envelope) {
|
func checkDeviceStatus(e *Envelope) {
|
||||||
e.AddCustomType(Balance{
|
e.AddCustomType(Balance{
|
||||||
Amount: 2018,
|
Amount: 2147483647,
|
||||||
Currency: "POINTS",
|
Currency: "POINTS",
|
||||||
})
|
})
|
||||||
e.AddKVNode("ForceSyncTime", "0")
|
e.AddKVNode("ForceSyncTime", "0")
|
||||||
@ -107,6 +107,21 @@ func purchaseTitle(e *Envelope) {
|
|||||||
e.AddKVNode("ETickets", "00000000")
|
e.AddKVNode("ETickets", "00000000")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listPurchaseHistory(e *Envelope) {
|
||||||
|
e.AddCustomType(Transactions{
|
||||||
|
TransactionId: "12345678",
|
||||||
|
Date: e.Timestamp(),
|
||||||
|
Type: "SERVICE",
|
||||||
|
TotalPaid: "7",
|
||||||
|
Currency: "POINTS",
|
||||||
|
ItemId: "17",
|
||||||
|
ItemPricing: "7",
|
||||||
|
Limits: LimitStruct(DR),
|
||||||
|
})
|
||||||
|
|
||||||
|
e.AddKVNode("ListResultTotalSize", "1")
|
||||||
|
}
|
||||||
|
|
||||||
// genServiceUrl returns a URL with the given service against a configured URL.
|
// genServiceUrl returns a URL with the given service against a configured URL.
|
||||||
// Given a baseUrl of example.com and genServiceUrl("ias", "IdentityAuthenticationSOAP"),
|
// Given a baseUrl of example.com and genServiceUrl("ias", "IdentityAuthenticationSOAP"),
|
||||||
// it would return http://ias.example.com/ias/services/ias/IdentityAuthenticationSOAP.
|
// it would return http://ias.example.com/ias/services/ias/IdentityAuthenticationSOAP.
|
||||||
|
1
main.go
1
main.go
@ -82,6 +82,7 @@ func main() {
|
|||||||
ecs.Authenticated("GetETickets", getETickets)
|
ecs.Authenticated("GetETickets", getETickets)
|
||||||
ecs.Authenticated("PurchaseTitle", purchaseTitle)
|
ecs.Authenticated("PurchaseTitle", purchaseTitle)
|
||||||
ecs.Unauthenticated("GetECConfig", getECConfig)
|
ecs.Unauthenticated("GetECConfig", getECConfig)
|
||||||
|
ecs.Authenticated("ListPurchaseHistory", listPurchaseHistory)
|
||||||
}
|
}
|
||||||
|
|
||||||
ias := r.HandleGroup("ias")
|
ias := r.HandleGroup("ias")
|
||||||
|
53
structure.go
53
structure.go
@ -98,12 +98,57 @@ type Balance struct {
|
|||||||
Currency string `xml:"Currency"`
|
Currency string `xml:"Currency"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LimitKinds int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// PR is presumably "purchased".
|
||||||
|
PR LimitKinds = 0
|
||||||
|
TR = 1
|
||||||
|
DR = 2
|
||||||
|
SR = 3
|
||||||
|
LR = 4
|
||||||
|
AT = 10000
|
||||||
|
)
|
||||||
|
|
||||||
|
// LimitStruct returns a Limits struct filled for the given kind.
|
||||||
|
func LimitStruct(kind LimitKinds) Limits {
|
||||||
|
names := map[LimitKinds]string{
|
||||||
|
PR: "PR",
|
||||||
|
TR: "TR",
|
||||||
|
DR: "DR",
|
||||||
|
SR: "SR",
|
||||||
|
LR: "LR",
|
||||||
|
AT: "AT",
|
||||||
|
}
|
||||||
|
|
||||||
|
return Limits{
|
||||||
|
Limits: kind,
|
||||||
|
LimitKind: names[kind],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limits represents a common XML structure for transaction information.
|
||||||
|
type Limits struct {
|
||||||
|
XMLName xml.Name `xml:"Limits"`
|
||||||
|
Limits LimitKinds `xml:"Limits"`
|
||||||
|
LimitKind string `xml:"LimitKind"`
|
||||||
|
}
|
||||||
|
|
||||||
// Transactions represents a common XML structure.
|
// Transactions represents a common XML structure.
|
||||||
type Transactions struct {
|
type Transactions struct {
|
||||||
XMLName xml.Name `xml:"Transactions"`
|
XMLName xml.Name `xml:"Transactions"`
|
||||||
TransactionId string `xml:"TransactionId"`
|
TransactionId string `xml:"TransactionId"`
|
||||||
Date string `xml:"Date"`
|
Date string `xml:"Date"`
|
||||||
Type string `xml:"Type"`
|
Type string `xml:"Type"`
|
||||||
|
TotalPaid string `xml:"TotalPaid"`
|
||||||
|
Currency string `xml:"Currency"`
|
||||||
|
ItemId string `xml:"ItemId"`
|
||||||
|
ItemPricing string `xml:"ItemPricing"`
|
||||||
|
Limits Limits `xml:"Limits"`
|
||||||
|
TitleId string `xml:"TitleId,omitempty"`
|
||||||
|
ItemCode int `xml:"ItemCode,omitempty"`
|
||||||
|
ReferenceId int `xml:"ReferenceId,omitempty"`
|
||||||
|
ReferenceValue string `xml:"ReferenceValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tickets represents the format to inform a console of available titles for its consumption.
|
// Tickets represents the format to inform a console of available titles for its consumption.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user