Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Entitlements/GetCodeStatus and Entitlements/RedeemCode #351

Merged
merged 1 commit into from
Apr 7, 2023
Merged
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

This file was deleted.

This file was deleted.

60 changes: 0 additions & 60 deletions TwitchLib.Api.Helix/Entitlements.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TwitchLib.Api.Core;
using TwitchLib.Api.Core.Enums;
using TwitchLib.Api.Core.Exceptions;
using TwitchLib.Api.Core.Interfaces;
using TwitchLib.Api.Helix.Models.Entitlements.GetCodeStatus;
using TwitchLib.Api.Helix.Models.Entitlements.GetDropsEntitlements;
using TwitchLib.Api.Helix.Models.Entitlements.RedeemCode;
using TwitchLib.Api.Helix.Models.Entitlements.UpdateDropsEntitlements;

namespace TwitchLib.Api.Helix
Expand All @@ -22,39 +18,6 @@ public Entitlements(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHa
{
}

#region GetCodeStatus
/// <summary>
/// Gets the status of one or more provided codes.
/// <para>This API requires that the caller is an authenticated Twitch user.</para>
/// <para>The API is throttled to one request per second per authenticated user.</para>
/// </summary>
/// <param name="codes">
/// The codes to get the status of.
/// <para>1-20 code parameters are allowed.</para>
/// </param>
/// <param name="userId">The user account which is going to receive the entitlement associated with the code.</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetCodeStatusResponse"></returns>
/// <exception cref="BadParameterException"></exception>
public Task<GetCodeStatusResponse> GetCodeStatusAsync(List<string> codes, string userId, string accessToken = null)
{
if (codes == null || codes.Count == 0 || codes.Count > 20)
throw new BadParameterException("codes cannot be null and must have between 1 and 20 items");

if (userId == null)
throw new BadParameterException("userId cannot be null");

var getParams = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("user_id", userId)
};

getParams.AddRange(codes.Select(code => new KeyValuePair<string, string>("code", code)));

return TwitchPostGenericAsync<GetCodeStatusResponse>("/entitlements/codes", ApiVersion.Helix, null, getParams, accessToken);
}
#endregion

#region GetDropsEntitlements
/// <summary>
/// Gets a list of entitlements for a given organization that have been granted to a game, user, or both.
Expand Down Expand Up @@ -120,28 +83,5 @@ public Task<UpdateDropsEntitlementsResponse> UpdateDropsEntitlementsAsync(string

#endregion

#region RedeemCode
/// <summary>
/// Redeems one or more redemption codes.
/// <para>Redeeming a code credits the user’s account with the entitlement associated with the code.</para>
/// <para>For example, a Bits reward earned when playing a game.</para>
/// <para>Rate limit: You may send at most one request per second per user.</para>
/// <para>Only client IDs approved by Twitch may redeem codes on behalf of any Twitch user account.</para>
/// </summary>
/// <param name="codes">The redemption codes to redeem. You may specify a maximum of 20 codes.</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="RedeemCodeResponse"></returns>
/// <exception cref="BadParameterException"></exception>
public Task<RedeemCodeResponse> RedeemCodeAsync(List<string> codes, string accessToken = null)
{
if (codes == null || codes.Count == 0 || codes.Count > 20)
throw new BadParameterException("codes cannot be null and must have between 1 and 20 items");

var getParams = codes.Select(code => new KeyValuePair<string, string>("code", code)).ToList();

return TwitchPostGenericAsync<RedeemCodeResponse>("/entitlements/codes", ApiVersion.Helix, null, getParams, accessToken);
}
#endregion

}
}