-
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.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/com/javadiscord/jdi/internal/api/impl/invite/DeleteInviteRequest.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.invite; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record DeleteInviteRequest(String inviteCode) implements DiscordRequest { | ||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder().delete().path("/invites/%s".formatted(inviteCode)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/javadiscord/jdi/internal/api/impl/invite/GetInviteRequest.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,28 @@ | ||
package com.javadiscord.jdi.internal.api.impl.invite; | ||
|
||
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 GetInviteRequest( | ||
String inviteCode, | ||
Optional<Boolean> withCounts, | ||
Optional<Boolean> withExpiration, | ||
Optional<Long> guildScheduledEventId) | ||
implements DiscordRequest { | ||
@Override | ||
public DiscordRequestBuilder create() { | ||
Map<String, Object> body = new HashMap<>(); | ||
withCounts.ifPresent(val -> body.put("with_counts", val)); | ||
withExpiration.ifPresent(val -> body.put("with_expiration", val)); | ||
guildScheduledEventId.ifPresent(val -> body.put("guild_schedulede_event_id", val)); | ||
|
||
return new DiscordRequestBuilder() | ||
.get() | ||
.path("/invites/%s".formatted(inviteCode)) | ||
.body(body); | ||
} | ||
} |