summaryrefslogtreecommitdiffhomepage
path: root/esi.go
blob: f50eb4d04fb853a79b9022fefbf511a4270f71ef (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
package main

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

func GetKillmail(id uint64, 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 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
}