Skip to content

Commit

Permalink
invites api (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweisz authored and Taz03 committed Apr 17, 2024
1 parent 61bcc3c commit 5cd97b1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
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));
}
}
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);
}
}

0 comments on commit 5cd97b1

Please sign in to comment.