-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiles.go
76 lines (62 loc) · 1.76 KB
/
profiles.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
72
73
74
75
76
package goBungieNet
import (
"fmt"
"errors"
"time"
)
type GetProfileResponse struct {
Characters SingleCharacters
CharacterActivities SingleActivities
CharacterEquipment interface{}
CharacterInventories interface{}
CharacterKiosks interface{}
CharacterProgressions interface{}
CharacterRenderData interface{}
ItemComponents interface{}
ProfileInventory interface{}
ProfileCurrencies interface{}
Profile SingleProfile
ProfileKiosks interface{}
VendorReciepts interface{}
}
type SingleProfile struct {
Data DestinyProfile
Privacy PrivacySetting
}
type SingleCharacters struct {
Data map[int64]Character
Privacy PrivacySetting
}
type Activity struct {
}
type DestinyProfile struct {
CharacterIDs []int64
UserInfo UserInfo
DateLastPlayed time.Time
VersionsOwned DestinyVersion
}
func GetProfile(membershipID int64, networkType BungieMembershipType, components []DestinyComponentType) (*GetProfileResponse, error) {
componentString := ""
for index, component := range(components) {
if (index + 1 == len(components)) {
componentString += fmt.Sprintf("%d", component)
} else {
componentString += fmt.Sprintf("%d,", component)
}
}
url := fmt.Sprintf("/Destiny2/%d/Profile/%d/?components=%s", networkType, membershipID, componentString)
response, err := get(url)
if (err != nil) {
return nil, errors.New("Get Error: " + err.Error())
}
if response.ErrorCode.isError() {
errorString := fmt.Sprintf("Response Error: %d", response.ErrorCode)
return nil, errors.New(errorString)
}
var profileResponse GetProfileResponse
err = decode(response.Response, &profileResponse)
if err != nil {
return nil, errors.New("Could not decode response: " + err.Error())
}
return &profileResponse, nil
}