Skip to content

Commit

Permalink
GH-85: Add support for "include_replies=only" flag in UserCommentsReq…
Browse files Browse the repository at this point in the history
…uest
  • Loading branch information
henrikfroehling committed Aug 5, 2020
1 parent 588dc2c commit f01cd1f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/Lib/Trakt.NET/Modules/TraktUsersModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public Task<TraktListResponse<ITraktCollectionShow>> GetCollectionShowsAsync(str
public Task<TraktPagedResponse<ITraktUserComment>> GetCommentsAsync(string usernameOrSlug,
TraktCommentType commentType = null,
TraktObjectType objectType = null,
bool? includeReplies = null,
TraktIncludeReplies? includeReplies = null,
TraktExtendedInfo extendedInfo = null,
TraktPagedParameters pagedParameters = null,
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TraktNet.Requests.Parameters
{
public enum TraktIncludeReplies
{
True,
False,
Only
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Enums;
using Extensions;
using Objects.Get.Users;
using Parameters;
using System;
using System.Collections.Generic;

Expand All @@ -14,7 +15,7 @@ internal sealed class UserCommentsRequest : AUsersPagedGetRequest<ITraktUserComm

internal TraktObjectType ObjectType { get; set; }

internal bool? IncludeReplies { get; set; }
internal TraktIncludeReplies? IncludeReplies { get; set; }

public override string UriTemplate => "users/{username}/comments{/comment_type}{/object_type}{?include_replies,extended,page,limit}";

Expand All @@ -31,7 +32,7 @@ public override IDictionary<string, object> GetUriPathParameters()
uriParams.Add("object_type", ObjectType.UriName);

if (IncludeReplies.HasValue)
uriParams.Add("include_replies", IncludeReplies.ToString().ToLower());
uriParams.Add("include_replies", IncludeReplies.Value.ToString().ToLower());

return uriParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class UserCommentsRequest_TestData : IEnumerable<object[]>
private static readonly TraktExtendedInfo _extendedInfo = new TraktExtendedInfo { Full = true };
private const int _page = 4;
private const int _limit = 20;
private const bool _includeReplies = true;
private const TraktIncludeReplies _includeReplies = TraktIncludeReplies.Only;

private static readonly UserCommentsRequest _request1 = new UserCommentsRequest
{
Expand Down

0 comments on commit f01cd1f

Please sign in to comment.