Filled in more of the templates...

This commit is contained in:
CornierKhan1 2018-09-06 16:38:06 +10:00
parent 6ed1f051c2
commit eb65089272

122
main.go
View File

@ -54,33 +54,45 @@ type NETS struct {
DeviceId string `xml:"Body>NotifiedETicketsSynced>DeviceId"` DeviceId string `xml:"Body>NotifiedETicketsSynced>DeviceId"`
MessageId string `xml:"Body>NotifiedETicketsSynced>MessageId"` MessageId string `xml:"Body>NotifiedETicketsSynced>MessageId"`
} }
// ListETickets // ListETickets
type LET struct { type LET struct {
XMLName xml.Name `xml:"Envelope"` XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>ListETickets>Version"` Version string `xml:"Body>ListETickets>Version"`
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 // PurchaseTitle
type PT struct { type PT struct {
XMLName xml.Name `xml:"Envelope"` XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>PurchaseTitle>Version"` Version string `xml:"Body>PurchaseTitle>Version"`
DeviceId string `xml:"Body>PurchaseTitle>DeviceId"` DeviceId string `xml:"Body>PurchaseTitle>DeviceId"`
MessageId string `xml:"Body>PurchaseTitle>MessageId"` MessageId string `xml:"Body>PurchaseTitle>MessageId"`
} }
// CheckRegistration // CheckRegistration
type CR struct { type CR struct {
XMLName xml.Name `xml:"Envelope"` XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>CheckRegistration>Version"` Version string `xml:"Body>CheckRegistration>Version"`
DeviceId string `xml:"Body>CheckRegistration>DeviceId"` DeviceId string `xml:"Body>CheckRegistration>DeviceId"`
MessageId string `xml:"Body>CheckRegistration>MessageId"` MessageId string `xml:"Body>CheckRegistration>MessageId"`
} }
// GetRegistrationInfo // GetRegistrationInfo
type GRI struct { type GRI struct {
XMLName xml.Name `xml:"Envelope"` XMLName xml.Name `xml:"Envelope"`
Version string `xml:"Body>GetRegistrationInfo>Version"` Version string `xml:"Body>GetRegistrationInfo>Version"`
DeviceId string `xml:"Body>GetRegistrationInfo>DeviceId"` DeviceId string `xml:"Body>GetRegistrationInfo>DeviceId"`
MessageId string `xml:"Body>GetRegistrationInfo>MessageId"` MessageId string `xml:"Body>GetRegistrationInfo>MessageId"`
}
// Register
type REG struct {
}
// Unregister
type UNR struct {
} }
func main() { func main() {
@ -158,9 +170,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body> <soapenv:Body>
<NotifyETicketsSyncedResponse xmlns="urn:ecs.wsapi.broadon.com"> <NotifyETicketsSyncedResponse xmlns="urn:ecs.wsapi.broadon.com">
<Version>` + NETS.Version + `</Version> <Version>`+NETS.Version+`</Version>
<DeviceId>` + NETS.DeviceId + `</DeviceId> <DeviceId>`+NETS.DeviceId+`</DeviceId>
<MessageId>` + NETS.MessageId + `</MessageId> <MessageId>`+NETS.MessageId+`</MessageId>
<TimeStamp>00000000</TimeStamp> <TimeStamp>00000000</TimeStamp>
<ErrorCode>0</ErrorCode> <ErrorCode>0</ErrorCode>
<ServiceStandbyMode>false</ServiceStandbyMode> <ServiceStandbyMode>false</ServiceStandbyMode>
@ -190,9 +202,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body> <soapenv:Body>
<ListETicketsResponse xmlns="urn:ecs.wsapi.broadon.com"> <ListETicketsResponse xmlns="urn:ecs.wsapi.broadon.com">
<Version>` + LET.Version + `</Version> <Version>`+LET.Version+`</Version>
<DeviceId>` + LET.DeviceId + `</DeviceId> <DeviceId>`+LET.DeviceId+`</DeviceId>
<MessageId>` + LET.MessageId + `</MessageId> <MessageId>`+LET.MessageId+`</MessageId>
<TimeStamp>00000000</TimeStamp> <TimeStamp>00000000</TimeStamp>
<ErrorCode>0</ErrorCode> <ErrorCode>0</ErrorCode>
<ServiceStandbyMode>false</ServiceStandbyMode> <ServiceStandbyMode>false</ServiceStandbyMode>
@ -205,7 +217,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Delivered response!") fmt.Println("Delivered response!")
} else { } else {
if bytes.Contains(body, []byte("PurchaseTitle")){ if bytes.Contains(body, []byte("PurchaseTitle")) {
fmt.Println("PT") fmt.Println("PT")
PT := PT{} PT := PT{}
err = xml.Unmarshal([]byte(body), &PT) err = xml.Unmarshal([]byte(body), &PT)
@ -223,9 +235,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body> <soapenv:Body>
<PurchaseTitleResponse xmlns="urn:ecs.wsapi.broadon.com"> <PurchaseTitleResponse xmlns="urn:ecs.wsapi.broadon.com">
<Version>` + PT.Version + `</Version> <Version>`+PT.Version+`</Version>
<DeviceId>` + PT.DeviceId + `</DeviceId> <DeviceId>`+PT.DeviceId+`</DeviceId>
<MessageId>` + PT.MessageId + `</MessageId> <MessageId>`+PT.MessageId+`</MessageId>
<TimeStamp>00000000</TimeStamp> <TimeStamp>00000000</TimeStamp>
<ErrorCode>0</ErrorCode> <ErrorCode>0</ErrorCode>
<ServiceStandbyMode>false</ServiceStandbyMode> <ServiceStandbyMode>false</ServiceStandbyMode>
@ -235,7 +247,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
</Balance> </Balance>
<Transactions> <Transactions>
<TransactionId>00000000</TransactionId> <TransactionId>00000000</TransactionId>
<Date>` + time.RFC3339 + `</Date> <Date>`+time.RFC3339+`</Date>
<Type>PURCHGAME</Type> <Type>PURCHGAME</Type>
</Transactions> </Transactions>
<SyncTime>00000000</SyncTime> <SyncTime>00000000</SyncTime>
@ -251,19 +263,67 @@ func handler(w http.ResponseWriter, r *http.Request) {
// IDENTITY AUTHENTICATION SOAP // IDENTITY AUTHENTICATION SOAP
if bytes.Contains(body, []byte("CheckRegistration")){ if bytes.Contains(body, []byte("CheckRegistration")) {
fmt.Println("CR.")
CR := CR{}
err = xml.Unmarshal([]byte(body), &CR)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "not good enough for me. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(CR)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else { } else {
if bytes.Contains(body, []byte("GetRegistrationInfo")){ if bytes.Contains(body, []byte("GetRegistrationInfo")) {
fmt.Println("GRI.")
GRI := GRI{}
err = xml.Unmarshal([]byte(body), &GRI)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "how dirty. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(GRI)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else { } else {
if bytes.Contains(body, []byte("Register")){ if bytes.Contains(body, []byte("Register")) {
fmt.Println("REG.")
REG := REG{}
err = xml.Unmarshal([]byte(body), &REG)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "disgustingly invalid. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(REG)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else { } else {
if bytes.Contains(body, []byte("Unregister")){ if bytes.Contains(body, []byte("Unregister")) {
fmt.Println("UNR.")
UNR := UNR{}
err = xml.Unmarshal([]byte(body), &UNR)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "how abnormal... ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(UNR)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else { } else {
fmt.Println("Nothing sent?") fmt.Println("Nothing sent?")