Skip to content

Commit

Permalink
Update monetization (discord/discord-api-docs#6477)
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaZ2 committed Oct 14, 2023
1 parent ddb9564 commit d4094e0
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 18 deletions.
34 changes: 29 additions & 5 deletions NetCord/Entitlement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,43 @@ public Entitlement(JsonModels.JsonEntitlement jsonModel)

public override ulong Id => _jsonModel.Id;

/// <summary>
/// Id of the SKU.
/// </summary>
public ulong SkuId => _jsonModel.SkuId;

public ulong? UserId => _jsonModel.UserId;

public ulong? GuildId => _jsonModel.GuildId;

/// <summary>
/// Id of the parent application.
/// </summary>
public ulong ApplicationId => _jsonModel.ApplicationId;

/// <summary>
/// Id of the user that is granted access to the entitlement's SKU.
/// </summary>
public ulong? UserId => _jsonModel.UserId;

/// <summary>
/// Type of the entitlement.
/// </summary>
public EntitlementType Type => _jsonModel.Type;

public bool Consumed => _jsonModel.Consumed;
/// <summary>
/// Indicates whether the entitlement was deleted.
/// </summary>
public bool Deleted => _jsonModel.Deleted;

/// <summary>
/// Start date at which the entitlement is valid. Not present when using test entitlements.
/// </summary>
public DateTimeOffset? StartsAt => _jsonModel.StartsAt;

/// <summary>
/// Date at which the entitlement is no longer valid. Not present when using test entitlements.
/// </summary>
public DateTimeOffset? EndsAt => _jsonModel.EndsAt;

/// <summary>
/// Id of the guild that is granted access to the entitlement's SKU.
/// </summary>
public ulong? GuildId => _jsonModel.GuildId;
}
16 changes: 8 additions & 8 deletions NetCord/JsonModels/JsonEntitlement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ public partial class JsonEntitlement : JsonEntity
[JsonPropertyName("sku_id")]
public ulong SkuId { get; set; }

[JsonPropertyName("user_id")]
public ulong? UserId { get; set; }

[JsonPropertyName("guild_id")]
public ulong? GuildId { get; set; }

[JsonPropertyName("application_id")]
public ulong ApplicationId { get; set; }

[JsonPropertyName("user_id")]
public ulong? UserId { get; set; }

[JsonPropertyName("type")]
public EntitlementType Type { get; set; }

[JsonPropertyName("consumed")]
public bool Consumed { get; set; }
[JsonPropertyName("deleted")]
public bool Deleted { get; set; }

[JsonPropertyName("starts_at")]
public DateTimeOffset? StartsAt { get; set; }

[JsonPropertyName("ends_at")]
public DateTimeOffset? EndsAt { get; set; }

[JsonPropertyName("guild_id")]
public ulong? GuildId { get; set; }

[JsonSerializable(typeof(JsonEntitlement))]
public partial class JsonEntitlementSerializerContext : JsonSerializerContext
{
Expand Down
6 changes: 3 additions & 3 deletions NetCord/Rest/JsonModels/JsonSku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public partial class JsonSku : JsonEntity
[JsonPropertyName("type")]
public SkuType Type { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("application_id")]
public ulong ApplicationId { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("slug")]
public string Slug { get; set; }

Expand Down
19 changes: 17 additions & 2 deletions NetCord/Rest/Sku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,28 @@ public Sku(JsonModels.JsonSku jsonModel)

public override ulong Id => _jsonModel.Id;

/// <summary>
/// Type of the SKU.
/// </summary>
public SkuType Type => _jsonModel.Type;

public string Name => _jsonModel.Name;

/// <summary>
/// Id of the parent application.
/// </summary>
public ulong ApplicationId => _jsonModel.ApplicationId;

/// <summary>
/// Customer-facing name of your premium offering.
/// </summary>
public string Name => _jsonModel.Name;

/// <summary>
/// System-generated URL slug based on the SKU's name.
/// </summary>
public string Slug => _jsonModel.Slug;

/// <summary>
/// Flags of the SKU.
/// </summary>
public SkuFlags Flags => _jsonModel.Flags;
}
12 changes: 12 additions & 0 deletions NetCord/Rest/SkuFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
[Flags]
public enum SkuFlags
{
/// <summary>
/// SKU is available for purchase.
/// </summary>
Available = 1 << 2,

/// <summary>
/// Recurring SKU that can be purchased by a user and applied to a single server. Grants access to every user in that server.
/// </summary>
GuildSubscription = 1 << 7,

/// <summary>
/// Recurring SKU purchased by a user for themselves. Grants access to the purchasing user in every server.
/// </summary>
UserSubscription = 1 << 8,
}

0 comments on commit d4094e0

Please sign in to comment.