more cringe (#2919)
This commit is contained in:
@@ -24,7 +24,7 @@ internal class Entitlement
|
||||
public EntitlementType Type { get; set; }
|
||||
|
||||
[JsonProperty("consumed")]
|
||||
public bool IsConsumed { get; set; }
|
||||
public Optional<bool> IsConsumed { get; set; }
|
||||
|
||||
[JsonProperty("starts_at")]
|
||||
public Optional<DateTimeOffset> StartsAt { get; set; }
|
||||
|
||||
@@ -292,6 +292,11 @@ namespace Discord.Rest
|
||||
/// </summary>
|
||||
Task<IReadOnlyCollection<SKU>> IDiscordClient.GetSKUsAsync(RequestOptions options) => Task.FromResult<IReadOnlyCollection<SKU>>(Array.Empty<SKU>());
|
||||
|
||||
/// <summary>
|
||||
/// Marks a given one-time purchase entitlement for the user as consumed.
|
||||
/// </summary>
|
||||
Task IDiscordClient.ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options) => Task.CompletedTask;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,6 +446,9 @@ namespace Discord.Rest
|
||||
return models.Select(x => new SKU(x.Id, x.Type, x.ApplicationId, x.Name, x.Slug)).ToImmutableArray();
|
||||
}
|
||||
|
||||
public static Task ConsumeEntitlementAsync(BaseDiscordClient client, ulong entitlementId, RequestOptions options = null)
|
||||
=> client.ApiClient.ConsumeEntitlementAsync(entitlementId, options);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2828,6 +2828,9 @@ namespace Discord.API
|
||||
public Task<SKU[]> ListSKUsAsync(RequestOptions options = null)
|
||||
=> SendAsync<SKU[]>("GET", () => $"applications/{CurrentApplicationId}/skus", new BucketIds(), options: options);
|
||||
|
||||
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
|
||||
=> SendAsync("POST", () => $"applications/{CurrentApplicationId}/entitlements/{entitlementId}/consume", new BucketIds(), options: options);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +296,10 @@ namespace Discord.Rest
|
||||
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
|
||||
=> ClientHelper.ListSKUsAsync(this, options);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
|
||||
=> ClientHelper.ConsumeEntitlementAsync(this, entitlementId, options);
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDiscordClient
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RestEntitlement : RestEntity<ulong>, IEntitlement
|
||||
: null;
|
||||
ApplicationId = model.ApplicationId;
|
||||
Type = model.Type;
|
||||
IsConsumed = model.IsConsumed;
|
||||
IsConsumed = model.IsConsumed.GetValueOrDefault(false);
|
||||
StartsAt = model.StartsAt.IsSpecified
|
||||
? model.StartsAt.Value
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user