summaryrefslogtreecommitdiffhomepage
path: root/esi.go
blob: bd3b0fee6fbf97908839b328246dbbd5ff24793e (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func GetKillmail(id int32, hash string) (EsiKillmail, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/killmails/%d/%s/", id, hash))
	if err != nil {
		return EsiKillmail{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiKillmail
	if err := decoder.Decode(&details); err != nil {
		return EsiKillmail{}, err
	}

	return details, nil
}

func GetType(id int32) (EsiType, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/universe/types/%d/", id))
	if err != nil {
		return EsiType{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiType
	if err := decoder.Decode(&details); err != nil {
		return EsiType{}, err
	}

	return details, nil
}

func GetGroup(id int32) (EsiGroup, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/universe/groups/%d/", id))
	if err != nil {
		return EsiGroup{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiGroup
	if err := decoder.Decode(&details); err != nil {
		return EsiGroup{}, err
	}

	return details, nil
}

func GetSolarSystem(id int32) (EsiUniverseSystem, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/universe/systems/%d/", id))
	if err != nil {
		return EsiUniverseSystem{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiUniverseSystem
	if err := decoder.Decode(&details); err != nil {
		return EsiUniverseSystem{}, err
	}

	return details, nil
}

func GetConstellation(id int32) (EsiUniverseConstellation, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/universe/constellations/%d/", id))
	if err != nil {
		return EsiUniverseConstellation{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiUniverseConstellation
	if err := decoder.Decode(&details); err != nil {
		return EsiUniverseConstellation{}, err
	}

	return details, nil
}

func GetRegion(id int32) (EsiUniverseRegion, error) {
	r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/universe/regions/%d/", id))
	if err != nil {
		return EsiUniverseRegion{}, err
	}
	decoder := json.NewDecoder(r.Body)
	var details EsiUniverseRegion
	if err := decoder.Decode(&details); err != nil {
		return EsiUniverseRegion{}, err
	}

	return details, nil
}