-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Stage Requests
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/javadiscord/jdi/internal/api/impl/stage/CreateStageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.javadiscord.jdi.internal.api.impl.stage; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public record CreateStageRequest( | ||
long channelId, | ||
String topic, | ||
int privacyLevel, | ||
Optional<Boolean> sendStartNotification, | ||
Optional<Long> guildScheduledEventId) | ||
implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
// all of these except get supports X-Audit-Log-Reason header, not sure how we are handling | ||
// so I will leave out for now | ||
Map<String, Object> body = new HashMap<>(); | ||
body.put("channel_id", channelId); | ||
body.put("topic", topic); | ||
body.put("privacy_level", privacyLevel); | ||
sendStartNotification.ifPresent(val -> body.put("send_start_notification", val)); | ||
guildScheduledEventId.ifPresent(val -> body.put("guild_scheduled_event_id", val)); | ||
|
||
return new DiscordRequestBuilder().post().path("/stage-instances").body(body); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/javadiscord/jdi/internal/api/impl/stage/DeleteStageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.javadiscord.jdi.internal.api.impl.stage; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record DeleteStageRequest(String channelId) implements DiscordRequest { | ||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder() | ||
.delete() | ||
.path("/stage-instances/%s".formatted(channelId)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/javadiscord/jdi/internal/api/impl/stage/GetStageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.javadiscord.jdi.internal.api.impl.stage; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record GetStageRequest(String channelId) implements DiscordRequest { | ||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder().get().path("/stage-instances/%s".formatted(channelId)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/javadiscord/jdi/internal/api/impl/stage/ModifyStageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.javadiscord.jdi.internal.api.impl.stage; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public record ModifyStageRequest( | ||
String channelId, Optional<String> topic, Optional<Integer> privacyLevel) | ||
implements DiscordRequest { | ||
@Override | ||
public DiscordRequestBuilder create() { | ||
Map<String, Object> body = new HashMap<>(); | ||
topic.ifPresent(val -> body.put("topic", val)); | ||
privacyLevel.ifPresent(val -> body.put("privacy_level", privacyLevel)); | ||
return new DiscordRequestBuilder() | ||
.patch() | ||
.path("/stage-instances/%s".formatted(channelId)) | ||
.body(body); | ||
} | ||
} |