|
1 | 1 | import { _get } from "../../lib/bungie_api/BungieApiClient";
|
2 | 2 | import { getTokens } from "../../lib/bungie_api/TokensStore";
|
3 | 3 |
|
4 |
| -export interface DestinyCharacter { |
5 |
| - membershipId: string; |
6 |
| - membershipType: number; |
7 |
| - characterId: string; |
8 |
| - dateLastPlayed: string; |
9 |
| - classType: number; |
10 |
| - classHash: number; |
11 |
| - emblemPath: string; |
12 |
| - emblemHash: number; |
13 |
| - emblemBackgroundPath: string; |
| 4 | +export interface DestinyArmor { |
| 5 | + intellect: number; |
| 6 | + discipline: number; |
| 7 | + resilience: number; |
| 8 | + mobility: number; |
| 9 | + strength: number; |
| 10 | + recovery: number; |
| 11 | + instanceHash: string; |
| 12 | + itemHash: string; |
| 13 | + artifice: boolean; |
| 14 | + masterwork: boolean; |
| 15 | + exotic: boolean; |
| 16 | + class: string; |
| 17 | + type: string; |
| 18 | + socket: string; |
14 | 19 | }
|
15 | 20 |
|
16 |
| -export function getProfile(destinyMembershipId: string) { |
17 |
| - const accessToken = getTokens()?.accessToken; |
| 21 | +const IS_ARMOR = 3897883278; |
18 | 22 |
|
19 |
| - _get( |
20 |
| - `/Platform/Destiny2/1/Profile/${destinyMembershipId}/?components=102,200`, |
| 23 | +export async function getProfile(destinyMembershipId: string) { |
| 24 | + const accessToken = getTokens()?.accessToken.value; |
| 25 | + |
| 26 | + const response = await _get( |
| 27 | + `/Platform/Destiny2/1/Profile/${destinyMembershipId}/?components=102,201,300,205,302,304,305`, |
21 | 28 | {
|
22 | 29 | headers: {
|
23 |
| - Authorization: `Bearer ${accessToken}}`, |
| 30 | + Authorization: `Bearer ${accessToken}`, |
24 | 31 | },
|
25 | 32 | }
|
26 |
| - ).then((response) => { |
27 |
| - if (response.data.Response) { |
28 |
| - var characters = response.data.Response.characters.data; |
29 |
| - for (const key in characters) { |
30 |
| - const character: DestinyCharacter = { |
31 |
| - membershipId: characters[key].membershipId, |
32 |
| - membershipType: characters[key].membershipType, |
33 |
| - characterId: characters[key].characterId, |
34 |
| - dateLastPlayed: characters[key].dateLastPlayed, |
35 |
| - classType: characters[key].classType, |
36 |
| - classHash: characters[key].classHash, |
37 |
| - emblemPath: characters[key].emblemPath, |
38 |
| - emblemHash: characters[key].emblemHash, |
39 |
| - emblemBackgroundPath: characters[key].emblemBackgroundPath, |
40 |
| - }; |
| 33 | + ); |
| 34 | + |
| 35 | + if (response.data.Response) { |
| 36 | + var responseData = response.data.Response.itemComponents; |
| 37 | + |
| 38 | + var armorHashes = []; |
| 39 | + |
| 40 | + for (const key in responseData.instances.data) { |
| 41 | + if ( |
| 42 | + responseData.instances.data[key].primaryStat !== undefined && |
| 43 | + responseData.instances.data[key].primaryStat.statHash === IS_ARMOR |
| 44 | + ) { |
| 45 | + armorHashes.push(key); |
41 | 46 | }
|
| 47 | + } |
| 48 | + |
| 49 | + console.log(armorHashes); |
| 50 | + |
| 51 | + for (const key in responseData.stats.data) { |
| 52 | + } |
| 53 | + |
| 54 | + for (const key in responseData.sockets.data) { |
| 55 | + } |
42 | 56 |
|
43 |
| - return true; |
44 |
| - } else { |
45 |
| - console.log("Could not get response"); |
46 |
| - return false; |
| 57 | + for (const key in responseData.perks.data) { |
47 | 58 | }
|
48 |
| - }); |
| 59 | + } else { |
| 60 | + console.log("Could not get response"); |
| 61 | + } |
49 | 62 | }
|
0 commit comments