-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for subscriptions.
- Loading branch information
Showing
12 changed files
with
442 additions
and
1 deletion.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
Backend/Remora.Discord.API.Abstractions/API/Objects/Monetization/ISubscription.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// ISubscription.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a user's recurrent payment for at least one SKU. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface ISubscription | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the subscription. | ||
/// </summary> | ||
Snowflake ID { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the subscribed user. | ||
/// </summary> | ||
Snowflake UserID { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of SKUs the user is subscribed to. | ||
/// </summary> | ||
IReadOnlyList<Snowflake> SKUIDs { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of entitlements granted for this subscription. | ||
/// </summary> | ||
IReadOnlyList<Snowflake> EntitlementIDs { get; } | ||
|
||
/// <summary> | ||
/// Gets the list of SKUs that this user will be subscribed to at renewal. | ||
/// </summary> | ||
IReadOnlyList<Snowflake>? RenewalSKUIDs { get; } | ||
|
||
/// <summary> | ||
/// Gets the time at which the current subscription period started. | ||
/// </summary> | ||
DateTimeOffset CurrentPeriodStart { get; } | ||
|
||
/// <summary> | ||
/// Gets the time at which the current subscription period ends. | ||
/// </summary> | ||
DateTimeOffset CurrentPeriodEnd { get; } | ||
|
||
/// <summary> | ||
/// Gets the status of the subscription. | ||
/// </summary> | ||
SubscriptionStatus Status { get; } | ||
|
||
/// <summary> | ||
/// Gets the time at which the subscription was canceled. | ||
/// </summary> | ||
DateTimeOffset? CanceledAt { get; } | ||
|
||
/// <summary> | ||
/// Gets the ISO3166-1-alpha-2 country code of the payment source used to purchase the subscription. | ||
/// </summary> | ||
Optional<string> Country { get; } | ||
} |
47 changes: 47 additions & 0 deletions
47
Backend/Remora.Discord.API.Abstractions/API/Objects/Monetization/SubscriptionStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// SubscriptionStatus.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Enumerates various statuses a subscription can have. | ||
/// </summary> | ||
[PublicAPI] | ||
public enum SubscriptionStatus | ||
{ | ||
/// <summary> | ||
/// The subscription is active and scheduled to renew. | ||
/// </summary> | ||
Active = 0, | ||
|
||
/// <summary> | ||
/// The subscription is active but will not renew. | ||
/// </summary> | ||
Ending = 1, | ||
|
||
/// <summary> | ||
/// The subscription is inactive and is not being charged. | ||
/// </summary> | ||
Inactive = 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Backend/Remora.Discord.API/API/Objects/Monetization/Subscription.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Subscription.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Objects; | ||
|
||
/// <inheritdoc /> | ||
[PublicAPI] | ||
public record Subscription | ||
( | ||
Snowflake ID, | ||
Snowflake UserID, | ||
IReadOnlyList<Snowflake> SKUIDs, | ||
IReadOnlyList<Snowflake> EntitlementIDs, | ||
IReadOnlyList<Snowflake>? RenewalSKUIDs, | ||
DateTimeOffset CurrentPeriodStart, | ||
DateTimeOffset CurrentPeriodEnd, | ||
SubscriptionStatus Status, | ||
DateTimeOffset? CanceledAt, | ||
Optional<string> Country | ||
) : ISubscription; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Tests/Remora.Discord.API.Tests/API/Objects/Monetization/SubscriptionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// SubscriptionTests.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Discord.API.Tests.TestBases; | ||
|
||
namespace Remora.Discord.API.Tests.Objects; | ||
|
||
/// <inheritdoc /> | ||
public class SubscriptionTests : ObjectTestBase<ISubscription> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SubscriptionTests"/> class. | ||
/// </summary> | ||
/// <param name="fixture">The test fixture.</param> | ||
public SubscriptionTests(JsonBackedTypeTestFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
} |
Oops, something went wrong.