Skip to content

Commit f60092d

Browse files
committed
GetInvitedMembers, Group Chat Administration
1 parent 1c6c6b8 commit f60092d

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.dec4234.javadestinyapi.material.clan;
2+
3+
public enum ClanChatSecuritySetting {
4+
5+
GROUP(0),
6+
ADMINS(1);
7+
8+
private int setting;
9+
10+
private ClanChatSecuritySetting(int setting) {
11+
this.setting = setting;
12+
}
13+
14+
public int getSetting() {
15+
return setting;
16+
}
17+
}

src/main/java/net/dec4234/javadestinyapi/material/clan/ClanManagement.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.google.gson.JsonArray;
1212
import com.google.gson.JsonElement;
13+
import com.google.gson.JsonObject;
1314
import net.dec4234.javadestinyapi.material.DestinyAPI;
1415
import net.dec4234.javadestinyapi.material.user.BungieUser;
1516
import net.dec4234.javadestinyapi.utils.HttpUtils;
@@ -99,6 +100,37 @@ public void abdicateFoundership(BungieUser bungieUser) {
99100
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Admin/AbdicateFoundership/" + bungieUser.getMembershipType() + "/" + bungieUser.getID() + "/", "");
100101
}
101102

103+
/**
104+
* Adds a new optional conversation to the clan
105+
*
106+
* @param chatName The name of the chat
107+
* @param clanChatSecuritySetting The security setting of the chat
108+
*/
109+
public void addOptionalConversation(String chatName, ClanChatSecuritySetting clanChatSecuritySetting) {
110+
JsonObject jsonObject = new JsonObject();
111+
jsonObject.addProperty("chatName", chatName);
112+
jsonObject.addProperty("chatSecurity", clanChatSecuritySetting.getSetting());
113+
114+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Admin/OptionalConversations/Add/", jsonObject.toString());
115+
}
116+
117+
/**
118+
* Edits an optional conversation
119+
*
120+
* @param conversationID The ID of the conversation
121+
* @param chatEnabled Whether or not the chat is enabled
122+
* @param chatName The name of the chat
123+
* @param clanChatSecuritySetting The security setting of the chat
124+
*/
125+
public void editOptionalConversation(String conversationID, boolean chatEnabled, String chatName, ClanChatSecuritySetting clanChatSecuritySetting) {
126+
JsonObject jsonObject = new JsonObject();
127+
jsonObject.addProperty("chatName", chatName);
128+
jsonObject.addProperty("chatSecurity", clanChatSecuritySetting.getSetting());
129+
jsonObject.addProperty("chatEnabled", chatEnabled);
130+
131+
hu.urlRequestPOSTOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Admin/OptionalConversations/" + conversationID + "/Edit/", jsonObject.toString());
132+
}
133+
102134
/**
103135
* Gets a list of members who have been banned from the clan
104136
*
@@ -130,6 +162,25 @@ public List<BungieUser> getPendingMembers() {
130162
return temp;
131163
}
132164

165+
/**
166+
* Returns a list of members who have been invited to the clan
167+
*
168+
* Has pagination feature that is not implemented because what clan would have more than 50 invited users?
169+
*
170+
* @return The list of invited users
171+
*/
172+
public List<BungieUser> getInvitedMembers() {
173+
List<BungieUser> temp = new ArrayList<>();
174+
175+
JsonArray ja = hu.urlRequestGETOauth("https://www.bungie.net/Platform/GroupV2/" + clan.getClanID() + "/Members/Invited/?components=200").getAsJsonObject("Response").getAsJsonArray("results");
176+
177+
for(JsonElement je : ja) {
178+
temp.add(new BungieUser(je.getAsJsonObject().getAsJsonObject("destinyUserInfo").get("membershipId").getAsString()));
179+
}
180+
181+
return temp;
182+
}
183+
133184
/**
134185
* Check if a BungieUser is a pending applicant without the performance overhead of creating multiple BungieUsers
135186
*/

0 commit comments

Comments
 (0)