Skip to content

Commit

Permalink
feat: add monetization data classes (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Azn9 authored Mar 27, 2024
1 parent c8423a1 commit 749b114
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableCreateTestEntitlementRequest.class)
@JsonDeserialize(as = ImmutableCreateTestEntitlementRequest.class)
public interface CreateTestEntitlementRequest {

static ImmutableCreateTestEntitlementRequest.Builder builder() {
return ImmutableCreateTestEntitlementRequest.builder();
}

@JsonProperty("sku_id")
Id skuId();

@JsonProperty("owner_id")
Id ownerId();

@JsonProperty("owner_type")
int ownerType();

}
48 changes: 48 additions & 0 deletions src/main/java/discord4j/discordjson/json/EntitlementData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.possible.Possible;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableEntitlementData.class)
@JsonDeserialize(as = ImmutableEntitlementData.class)
public interface EntitlementData {

static ImmutableEntitlementData.Builder builder() {
return ImmutableEntitlementData.builder();
}

Id id();

@JsonProperty("sku_id")
Id skuId();

@JsonProperty("application_id")
Id applicationId();

@JsonProperty("user_id")
Possible<Id> userId();

int type();

boolean deleted();

@JsonProperty("guild_id")
Possible<Id> guildId();

// The following fields will not be present in test entitlements

@JsonProperty("starts_at")
Possible<String> startsAt();

@JsonProperty("ends_at")
Possible<String> endsAt();

@JsonProperty("subscription_id")
Possible<Id> subscriptionId();

}
5 changes: 5 additions & 0 deletions src/main/java/discord4j/discordjson/json/InteractionData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import discord4j.discordjson.possible.Possible;
import org.immutables.value.Value;

import java.util.List;

@Value.Immutable
@JsonSerialize(as = ImmutableInteractionData.class)
@JsonDeserialize(as = ImmutableInteractionData.class)
Expand Down Expand Up @@ -64,4 +66,7 @@ static ImmutableInteractionData.Builder builder() {

@JsonProperty("app_permissions")
Possible<String> appPermissions();

@JsonProperty("entitlements")
List<EntitlementData> entitlements();
}
30 changes: 30 additions & 0 deletions src/main/java/discord4j/discordjson/json/SkuData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSkuData.class)
@JsonDeserialize(as = ImmutableSkuData.class)
public interface SkuData {

static ImmutableSkuData.Builder builder() {
return ImmutableSkuData.builder();
}

Id id();

int type();

@JsonProperty("application_id")
Id applicationId();

String name();

String slug();

int flags();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.EntitlementData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableEntitlementCreate.class)
@JsonDeserialize(as = ImmutableEntitlementCreate.class)
public interface EntitlementCreate extends Dispatch {

static ImmutableEntitlementCreate.Builder builder() {
return ImmutableEntitlementCreate.builder();
}

@JsonUnwrapped
EntitlementData entitlement();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.EntitlementData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableEntitlementDelete.class)
@JsonDeserialize(as = ImmutableEntitlementDelete.class)
public interface EntitlementDelete extends Dispatch {

static ImmutableEntitlementDelete.Builder builder() {
return ImmutableEntitlementDelete.builder();
}

@JsonUnwrapped
EntitlementData entitlement();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.EntitlementData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableEntitlementUpdate.class)
@JsonDeserialize(as = ImmutableEntitlementUpdate.class)
public interface EntitlementUpdate extends Dispatch {

static ImmutableEntitlementUpdate.Builder builder() {
return ImmutableEntitlementUpdate.builder();
}

@JsonUnwrapped
EntitlementData entitlement();

}

0 comments on commit 749b114

Please sign in to comment.