Skip to content

Commit a0f9cb3

Browse files
committed
Fix Typo and simple debug mode
1 parent 026f740 commit a0f9cb3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/material/DestinyAPI.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class DestinyAPI {
2828
private static String accessToken = null;
2929
private static String refreshToken = null;
3030
private static OAuthManager oam = null;
31+
private static boolean debugEnabled = false;
3132

3233
public DestinyAPI setApiKey(String apiKey) {
3334
DestinyAPI.apiKey = apiKey;
@@ -68,6 +69,18 @@ public DestinyAPI setRefreshToken(String refreshToken) {
6869
return this;
6970
}
7071

72+
public DestinyAPI enableDebugMode() {
73+
DestinyAPI.debugEnabled = true;
74+
75+
return this;
76+
}
77+
78+
public DestinyAPI disableDebugMode() {
79+
DestinyAPI.debugEnabled = false;
80+
81+
return this;
82+
}
83+
7184
/**
7285
* Set the OAuth management class
7386
* The class passed in this parameter must "extends OAuthManager"
@@ -99,7 +112,7 @@ public static BungieUser getMemberFromSteamID(String steamID) {
99112
}
100113

101114
private static BungieUser getMemberFromPlatformID(String platformName, String platformID) {
102-
JsonObject jsonObject = new HttpUtils().urlRequestGET("https://www.bungie.net/Platform/User/GetMembershipFromHardLinkedCredential/" + platformName + "/" + platformID + "/").getAsJsonObject("Responseg");
115+
JsonObject jsonObject = new HttpUtils().urlRequestGET("https://www.bungie.net/Platform/User/GetMembershipFromHardLinkedCredential/" + platformName + "/" + platformID + "/").getAsJsonObject("Response");
103116

104117
return new BungieUser(jsonObject.get("membershipId").getAsString());
105118
}
@@ -162,4 +175,6 @@ public static String getRefreshToken() {
162175
return oam.getRefreshToken();
163176
}
164177

178+
public static boolean isDebugEnabled() { return DestinyAPI.debugEnabled; }
179+
165180
}

src/main/java/utils/HttpUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public JsonObject urlRequestGET(String url) {
4545
CompletableFuture<String> response = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenApplyAsync(HttpResponse::body);
4646
JsonElement parse = null;
4747
try {
48+
if(DestinyAPI.isDebugEnabled()) {
49+
System.out.println(response.get());
50+
}
4851
parse = new JsonParser().parse(response.get()); // Parse response to JSON
4952
} catch (InterruptedException | ExecutionException e) {
5053
e.printStackTrace();

0 commit comments

Comments
 (0)