Added some more Structs.

This commit is contained in:
CornierKhan1 2018-09-06 13:56:04 +10:00 committed by GitHub
parent aa7ed5361f
commit 17784f045d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

55
main.go
View File

@ -24,6 +24,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"time"
) )
const ( const (
@ -60,6 +61,20 @@ type LET struct {
DeviceId string `xml:"Body>ListETickets>DeviceId"` DeviceId string `xml:"Body>ListETickets>DeviceId"`
MessageId string `xml:"Body>ListETickets>MessageId"` MessageId string `xml:"Body>ListETickets>MessageId"`
} }
// PurchaseTitle
type PT struct {
XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>PurchaseTitle>Version"`
DeviceId string `xml:"Body>PurchaseTitle>DeviceId"`
MessageId string `xml:"Body>PurchaseTitle>MessageId"`
}
// CheckRegistration
type CR struct {
XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>CheckRegistration>Version"`
DeviceId string `xml:"Body>CheckRegistration>DeviceId"`
MessageId string `xml:"Body>CheckRegistration>MessageId"`
}
func main() { func main() {
fmt.Println("Starting HTTP connection (Port 8000)...") fmt.Println("Starting HTTP connection (Port 8000)...")
@ -184,6 +199,46 @@ func handler(w http.ResponseWriter, r *http.Request) {
} else { } else {
if bytes.Contains(body, []byte("PurchaseTitle")){ if bytes.Contains(body, []byte("PurchaseTitle")){
fmt.Println("PT")
PT := PT{}
err = xml.Unmarshal([]byte(body), &PT)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(PT)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, `<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<PurchaseTitleResponse xmlns="urn:ecs.wsapi.broadon.com">
<Version>` + PT.Version + `</Version>
<DeviceId>` + PT.DeviceId + `</DeviceId>
<MessageId>` + PT.MessageId + `</MessageId>
<TimeStamp>00000000</TimeStamp>
<ErrorCode>0</ErrorCode>
<ServiceStandbyMode>false</ServiceStandbyMode>
<Balance>
<Amount>2018</Amount>
<Currency>POINTS</Currency>
</Balance>
<Transactions>
<TransactionId>00000000</TransactionId>
<Date>` + time.RFC3339 + `</Date>
<Type>PURCHGAME</Type>
</Transactions>
<SyncTime>00000000</SyncTime>
<ETickets>00000000</ETickets>
<Certs>00000000</Certs>
<Certs>00000000</Certs>
<TitleId>00000000</TitleId>
</PurchaseTitleResponse>
</soapenv:Body>
</soapenv:Envelope>`)
} else { } else {