Skip to content

Commit

Permalink
add user timeline SOBotics#2
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticEcho committed Jul 27, 2018
1 parent f90dc92 commit 41b23d0
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 2 deletions.
26 changes: 26 additions & 0 deletions SharpExchange/Api/2.2/Endpoints/UserTimelines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using SharpExchange.Api.V22.Types;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace SharpExchange.Api.V22.Endpoints
{
public static class UserTimelines
{
/// <summary>
/// Gets a subset of the actions of that have been taken by
/// the users identified by a set of ids.
/// </summary>
public static Task<Result<UserTimeline[]>> GetByIdsAsync(IEnumerable<int> userIds, QueryOptions options = null)
{
userIds.ThrowIfNullOrEmpty(nameof(userIds));
options = options.GetDefaultIfNull();

var idsStr = userIds.ToDelimitedList();
var endpoint = $"{Constants.BaseApiUrl}/users/{idsStr}/timeline";

return ApiRequestScheduler.ScheduleRequestAsync<UserTimeline[]>(endpoint, options);
}
}
}
2 changes: 1 addition & 1 deletion SharpExchange/Api/2.2/Types/QuestionTimeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class QuestionTimeline
public string RevisionGuid { get; internal set; }

[JsonProperty("timeline_type")]
public TimelineType? EntryType { get; internal set; }
public QuestionTimelineType? TimelineType { get; internal set; }

[JsonProperty("up_vote_count")]
public int? UpVoteCount { get; internal set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SharpExchange.Api.V22.Types
{
public enum TimelineType
public enum QuestionTimelineType
{
[EnumMember(Value = "question")]
Question,
Expand Down
45 changes: 45 additions & 0 deletions SharpExchange/Api/2.2/Types/UserTimeline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text;

namespace SharpExchange.Api.V22.Types
{
public class UserTimeline
{
[JsonProperty("badge_id")]
public int? BadgeId { get; internal set; }

[JsonProperty("comment_id")]
public int? CommentId { get; internal set; }

[JsonProperty("creation_date")]
[JsonConverter(typeof(UnixDateTimeConverter))]
public DateTime? CreatedOn { get; internal set; }

[JsonProperty("detail")]
public string Details { get; internal set; }

[JsonProperty("link")]
public string Link { get; internal set; }

[JsonProperty("post_id")]
public int? PostId { get; internal set; }

[JsonProperty("post_type")]
public PostType PostType { get; internal set; }

[JsonProperty("suggested_edit_id")]
public int? SuggestedEditid { get; internal set; }

[JsonProperty("timeline_type")]
public UserTimelineType? TimelineType { get; internal set; }

[JsonProperty("title")]
public string Title { get; internal set; }

[JsonProperty("user_id")]
public int? UserId { get; internal set; }
}
}
31 changes: 31 additions & 0 deletions SharpExchange/Api/2.2/Types/UserTimelineType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Runtime.Serialization;

namespace SharpExchange.Api.V22.Types
{
public enum UserTimelineType
{
[EnumMember(Value = "commented")]
Commented,

[EnumMember(Value = "asked")]
Asked,

[EnumMember(Value = "answered")]
Answered,

[EnumMember(Value = "badge")]
Badge,

[EnumMember(Value = "revision")]
Revision,

[EnumMember(Value = "accepted")]
Accepted,

[EnumMember(Value = "reviewed")]
Reviewed,

[EnumMember(Value = "suggested")]
Suggested
}
}

0 comments on commit 41b23d0

Please sign in to comment.