Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions core/src/main/java/gg/eventalerts/sdk/object/EAEventPreset.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package gg.eventalerts.sdk.object;

import com.google.gson.annotations.SerializedName;
import gg.eventalerts.sdk.ExampleUtility;
import org.bson.types.ObjectId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;


public class EAEventPreset extends EAObject {
@NotNull public static final String KEY_ID = "id";
@NotNull public static final String KEY_USER = "user";
@NotNull public static final String KEY_NAME = "name";
@NotNull public static final String KEY_DESCRIPTION = "description";
@NotNull public static final String KEY_LAST_USED = "lastUsed";
@NotNull public static final String KEY_DATA = "data";

@SerializedName(KEY_ID) @Nullable public ObjectId id;
@SerializedName(KEY_USER) @Nullable public Long user;
@SerializedName(KEY_NAME) @Nullable public String name;
@SerializedName(KEY_DESCRIPTION) @Nullable public String description;
@SerializedName(KEY_LAST_USED) @Nullable public Date lastUsed;
@SerializedName(KEY_DATA) @Nullable public Data data;

public EAEventPreset() {}

public EAEventPreset(@Nullable ObjectId id, @Nullable Long user, @Nullable String name, @Nullable String description, @Nullable Date lastUsed, @Nullable Data data) {
this.id = id;
this.user = user;
this.name = name;
this.description = description;
this.lastUsed = lastUsed;
this.data = data;
}

@NotNull
public static EAEventPreset getExample() {
return new EAEventPreset(
new ObjectId(),
ExampleUtility.User.SRNYX_ID,
"Example Preset",
"This is an example preset.",
new Date(),
Data.getExample());
}

public static class Data {
@NotNull public static final String KEY_TITLE = "title";
@NotNull public static final String KEY_ROLES = "roles";
@NotNull public static final String KEY_DESCRIPTION = "description";
@NotNull public static final String KEY_TIME = "time";
@NotNull public static final String KEY_PRIZE = "prize";
@NotNull public static final String KEY_IP = "ip";
@NotNull public static final String KEY_PLATFORMS = "platforms";
@NotNull public static final String KEY_VERSION = "version";
@NotNull public static final String KEY_MAX_PLAYERS = "maxPlayers";
@NotNull public static final String KEY_MEDIA = "media";

@SerializedName(KEY_TITLE) @Nullable public String title;
@SerializedName(KEY_ROLES) @Nullable public Set<EAEvent.PingRole> roles;
@SerializedName(KEY_DESCRIPTION) @Nullable public String description;
@SerializedName(KEY_TIME) @Nullable public String time;
@SerializedName(KEY_PRIZE) @Nullable public String prize;
@SerializedName(KEY_IP) @Nullable public String ip;
@SerializedName(KEY_PLATFORMS) @Nullable public Set<EAEvent.Platform> platforms;
@SerializedName(KEY_VERSION) @Nullable public String version;
@SerializedName(KEY_MAX_PLAYERS) @Nullable public Integer maxPlayers;
@SerializedName(KEY_MEDIA) @Nullable public EAEvent.Media media;

public Data() {}

public Data(@Nullable String title, @Nullable Collection<EAEvent.PingRole> roles, @Nullable String description, @Nullable String time, @Nullable String prize, @Nullable String ip, @Nullable Collection<EAEvent.Platform> platforms, @Nullable String version, @Nullable Integer maxPlayers, @Nullable EAEvent.Media media) {
this.title = title;
this.roles = roles == null ? null : new HashSet<>(roles);
this.description = description;
this.time = time;
this.prize = prize;
this.ip = ip;
this.platforms = platforms == null ? null : new HashSet<>(platforms);
this.version = version;
this.maxPlayers = maxPlayers;
this.media = media;
}

@NotNull
public static Data getExample() {
return new Data(
"Example Event",
Collections.singleton(EAEvent.PingRole.PARTNER),
"This is an example event description.",
"30m",
"Example Prize",
"example.com",
Collections.singleton(EAEvent.Platform.JAVA),
"1.21.11",
100,
EAEvent.Media.getExample());
}
}
}
7 changes: 2 additions & 5 deletions http/src/main/java/gg/eventalerts/sdk/http/EAHTTP.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package gg.eventalerts.sdk.http;

import gg.eventalerts.sdk.EventAlertsSDK;
import gg.eventalerts.sdk.http.endpoint.EACrossBans;
import gg.eventalerts.sdk.http.endpoint.EAEvents;
import gg.eventalerts.sdk.http.endpoint.EAPartnerServers;
import gg.eventalerts.sdk.http.endpoint.EAPlayers;
import gg.eventalerts.sdk.http.endpoint.EAServerApplications;
import gg.eventalerts.sdk.http.endpoint.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -23,6 +19,7 @@ public class EAHTTP {
@NotNull public final EAPartnerServers partnerServers = new EAPartnerServers(this);
@NotNull public final EAPlayers players = new EAPlayers(this);
@NotNull public final EAServerApplications serverApplications = new EAServerApplications(this);
@NotNull public final EAEventPresets eventPresets = new EAEventPresets(this);

private EAHTTP(@NotNull String url, @NotNull String userAgent, @NotNull Map<String, String> headers) {
this.url = url;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gg.eventalerts.sdk.http.endpoint;

import gg.eventalerts.sdk.http.EAHTTP;
import gg.eventalerts.sdk.http.action.EAAction;
import gg.eventalerts.sdk.http.response.PaginatedResponse;
import gg.eventalerts.sdk.object.EAEventPreset;
import org.bson.types.ObjectId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Map;


public class EAEventPresets extends EAEndpoint {
public EAEventPresets(@NotNull EAHTTP http) {
super(http, "event_presets");
}

@NotNull
public EAAction<PaginatedResponse<EAEventPreset>> retrievePage(@Nullable Integer page, @Nullable Integer limit, @Nullable Map<String, Object> queryParams) {
return super.retrievePage(EAEventPreset.class, "data", page, limit, queryParams);
}

@NotNull
public EAAction<List<EAEventPreset>> retrieveMany(int count, @Nullable Integer startPage, @Nullable Map<String, Object> queryParams) {
return super.retrieveMany(EAEventPreset.class, "data", count, startPage, queryParams);
}

@NotNull
public EAAction<List<EAEventPreset>> retrieveAll(@Nullable Map<String, Object> queryParams) {
return super.retrieveAll(EAEventPreset.class, "data", queryParams);
}

@NotNull
public EAAction<EAEventPreset> retrieveOne(@NotNull String... pathSegments) {
return super.retrieveOne(EAEventPreset.class, "data", pathSegments);
}

@NotNull
public EAAction<EAEventPreset> retrieveOneById(@NotNull ObjectId id) {
return retrieveOne("id", id.toHexString());
}
}