This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
corp.go
69 lines (61 loc) · 1.44 KB
/
corp.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
package eveapi
const (
CorpContactListURL = "/corp/ContactList.xml.aspx"
CorpAccountBalanceURL = "/corp/AccountBalance.xml.aspx"
)
type Contact struct {
ID string `xml:"contactID,attr"`
Name string `xml:"contactName,attr"`
Standing int `xml:"standing,attr"`
}
type ContactSubList struct {
Name string `xml:"name,attr"`
Contacts []Contact `xml:"row"`
}
func (api API) CorpContactList() (*ContactList, error) {
output := ContactList{}
err := api.Call(CorpContactListURL, nil, &output)
if err != nil {
return nil, err
}
return &output, nil
}
type ContactList struct {
APIResult
ContactList []ContactSubList `xml:"result>rowset"`
}
func (c ContactList) Corporate() []Contact {
for _, v := range c.ContactList {
if v.Name == "corporateContactList" {
return v.Contacts
}
}
return nil
}
func (c ContactList) Alliance() []Contact {
for _, v := range c.ContactList {
if v.Name == "allianceContactList" {
return v.Contacts
}
}
return nil
}
type AccountBalance struct {
APIResult
Accounts []struct {
ID int `xml:"accountID,attr"`
Key int `xml:"accountKey,attr"`
Balance float64 `xml:"balance,attr"`
} `xml:"result>rowset>row"`
}
func (api API) CorpAccountBalances() (*AccountBalance, error) {
output := AccountBalance{}
err := api.Call(CorpAccountBalanceURL, nil, &output)
if err != nil {
return nil, err
}
if output.Error != nil {
return nil, output.Error
}
return &output, nil
}