-
Notifications
You must be signed in to change notification settings - Fork 1
/
smitego.go
71 lines (64 loc) · 1.74 KB
/
smitego.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package smitego
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
// Returns ping information for the Smite API endpoint server.
func Ping() string {
url := "http://api.smitegame.com/smiteapi.svc/pingJson"
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
return string(contents[:])
}
}
return "Ping service not available."
}
// TODO: Create struct and find out why Request Error is
// happening on correct API call.
func GetQueueStats(playerName string, queueId int) string {
timestamp := time.Now().UTC().Format("20060102150405")
hash := getMD5Hash(DevID + "getqueuestats" + AuthKey + timestamp)
url := "http://api.smitegame.com/smiteapi.svc/getqueuestatsJson/" + DevID + "/" + hash + "/" + SessionID + "/" + timestamp + "/" + playerName + "/" + string(queueId)
fmt.Println(url)
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
return string(contents)
}
}
return ""
}
//TO-DO: Service Endpoint not found.
func GetTopRanked(queueId int) string {
timestamp := time.Now().UTC().Format("20060102150405")
hash := getMD5Hash(DevID + "gettopranked" + AuthKey + timestamp)
url := "http://api.smitegame.com/smiteapi.svc/gettoprankedJson/" + DevID + "/" + hash + "/" + SessionID + "/" + timestamp + "/" + string(queueId)
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
return string(contents)
}
}
return ""
}