Skip to content

Commit

Permalink
Merge pull request #351 from TwitchLib/remove_get_code_status_and_red…
Browse files Browse the repository at this point in the history
…eem_code

remove Entitlements/GetCodeStatus and Entitlements/RedeemCode
  • Loading branch information
Syzuna authored Apr 7, 2023
2 parents b2e69e7 + 5ca26f5 commit 146343a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 80 deletions.

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

}
}

0 comments on commit 146343a

Please sign in to comment.