Skip to content
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
18 changes: 17 additions & 1 deletion src/FeedsV3Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ public async Task<StreamResponse<UpdateActivityResponse>> UpdateActivityAsync(st

return result;
}
public async Task<StreamResponse<RestoreActivityResponse>> RestoreActivityAsync(string id,RestoreActivityRequest request,
CancellationToken cancellationToken = default)
{
var pathParams = new Dictionary<string, string>
{
["id"] = id,
};

var result = await _client.MakeRequestAsync<RestoreActivityRequest, RestoreActivityResponse>(
"POST",
"/api/v2/feeds/activities/{id}/restore",null,request,pathParams,
cancellationToken);

return result;
}
public async Task<StreamResponse<QueryBookmarkFoldersResponse>> QueryBookmarkFoldersAsync(QueryBookmarkFoldersRequest request,
CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -1085,10 +1100,11 @@ public async Task<StreamResponse<UnfollowResponse>> UnfollowAsync(string source,
["source"] = source,
["target"] = target,
};
var queryParams = ExtractQueryParams(request);

var result = await _client.MakeRequestAsync<object, UnfollowResponse>(
"DELETE",
"/api/v2/feeds/follows/{source}/{target}",null,null,pathParams,
"/api/v2/feeds/follows/{source}/{target}",queryParams,null,pathParams,
cancellationToken);

return result;
Expand Down
86 changes: 86 additions & 0 deletions src/models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ public class ActivityRequest
public string Type { get; set; }
[JsonPropertyName("feeds")]
public List<string> Feeds { get; set; }
[JsonPropertyName("create_notification_activity")]
public bool? CreateNotificationActivity { get; set; }
[JsonPropertyName("expires_at")]
public string? ExpiresAt { get; set; }
[JsonPropertyName("id")]
Expand All @@ -501,6 +503,8 @@ public class ActivityRequest
public string? RestrictReplies { get; set; }
[JsonPropertyName("skip_enrich_url")]
public bool? SkipEnrichUrl { get; set; }
[JsonPropertyName("skip_push")]
public bool? SkipPush { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonPropertyName("user_id")]
Expand Down Expand Up @@ -595,6 +599,8 @@ public class ActivityResponse
public bool? IsWatched { get; set; }
[JsonPropertyName("moderation_action")]
public string? ModerationAction { get; set; }
[JsonPropertyName("selector_source")]
public string? SelectorSource { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonPropertyName("visibility_tag")]
Expand All @@ -613,6 +619,26 @@ public class ActivityResponse
public PollResponseData? Poll { get; set; }
}

public class ActivityRestoredEvent
{
[JsonPropertyName("created_at")]
public DateTime CreatedAt { get; set; }
[JsonPropertyName("fid")]
public string Fid { get; set; }
[JsonPropertyName("activity")]
public ActivityResponse Activity { get; set; }
[JsonPropertyName("custom")]
public object Custom { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("feed_visibility")]
public string? FeedVisibility { get; set; }
[JsonPropertyName("received_at")]
public DateTime? ReceivedAt { get; set; }
[JsonPropertyName("user")]
public UserResponseCommonFields? User { get; set; }
}

public class ActivitySelectorConfig
{
[JsonPropertyName("type")]
Expand Down Expand Up @@ -695,6 +721,8 @@ public class AddActivityRequest
public string Type { get; set; }
[JsonPropertyName("feeds")]
public List<string> Feeds { get; set; }
[JsonPropertyName("create_notification_activity")]
public bool? CreateNotificationActivity { get; set; }
[JsonPropertyName("expires_at")]
public string? ExpiresAt { get; set; }
[JsonPropertyName("id")]
Expand All @@ -707,6 +735,8 @@ public class AddActivityRequest
public string? RestrictReplies { get; set; }
[JsonPropertyName("skip_enrich_url")]
public bool? SkipEnrichUrl { get; set; }
[JsonPropertyName("skip_push")]
public bool? SkipPush { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonPropertyName("user_id")]
Expand Down Expand Up @@ -739,6 +769,8 @@ public class AddActivityResponse
public string Duration { get; set; }
[JsonPropertyName("activity")]
public ActivityResponse Activity { get; set; }
[JsonPropertyName("mention_notifications_created")]
public int? MentionNotificationsCreated { get; set; }
}

public class AddBookmarkRequest
Expand Down Expand Up @@ -789,6 +821,8 @@ public class AddCommentReactionResponse
public CommentResponse Comment { get; set; }
[JsonPropertyName("reaction")]
public FeedsReactionResponse Reaction { get; set; }
[JsonPropertyName("notification_created")]
public bool? NotificationCreated { get; set; }
}

public class AddCommentRequest
Expand Down Expand Up @@ -827,6 +861,10 @@ public class AddCommentResponse
public string Duration { get; set; }
[JsonPropertyName("comment")]
public CommentResponse Comment { get; set; }
[JsonPropertyName("mention_notifications_created")]
public int? MentionNotificationsCreated { get; set; }
[JsonPropertyName("notification_created")]
public bool? NotificationCreated { get; set; }
}

public class AddCommentsBatchRequest
Expand Down Expand Up @@ -877,6 +915,8 @@ public class AddReactionResponse
public ActivityResponse Activity { get; set; }
[JsonPropertyName("reaction")]
public FeedsReactionResponse Reaction { get; set; }
[JsonPropertyName("notification_created")]
public bool? NotificationCreated { get; set; }
}

public class AggregatedActivityResponse
Expand Down Expand Up @@ -1751,6 +1791,8 @@ public class CallResponse
public DateTime? EndedAt { get; set; }
[JsonPropertyName("join_ahead_time_seconds")]
public int? JoinAheadTimeSeconds { get; set; }
[JsonPropertyName("routing_number")]
public string? RoutingNumber { get; set; }
[JsonPropertyName("starts_at")]
public DateTime? StartsAt { get; set; }
[JsonPropertyName("team")]
Expand Down Expand Up @@ -2621,6 +2663,8 @@ public class CommentResponse
public double? ControversyScore { get; set; }
[JsonPropertyName("deleted_at")]
public DateTime? DeletedAt { get; set; }
[JsonPropertyName("edited_at")]
public DateTime? EditedAt { get; set; }
[JsonPropertyName("parent_id")]
public string? ParentID { get; set; }
[JsonPropertyName("text")]
Expand Down Expand Up @@ -3185,6 +3229,8 @@ public class DeleteActivitiesRequest
{
[JsonPropertyName("ids")]
public List<string> Ids { get; set; }
[JsonPropertyName("delete_notification_activity")]
public bool? DeleteNotificationActivity { get; set; }
[JsonPropertyName("hard_delete")]
public bool? HardDelete { get; set; }
[JsonPropertyName("user_id")]
Expand Down Expand Up @@ -4561,6 +4607,8 @@ public class FollowRequest
public string? PushPreference { get; set; }
[JsonPropertyName("skip_push")]
public bool? SkipPush { get; set; }
[JsonPropertyName("status")]
public string? Status { get; set; }
[JsonPropertyName("custom")]
public object Custom { get; set; }
}
Expand Down Expand Up @@ -5309,6 +5357,10 @@ public class ImportV2TaskItem

public class ImportV2TaskSettings
{
[JsonPropertyName("mode")]
public string? Mode { get; set; }
[JsonPropertyName("path")]
public string? Path { get; set; }
[JsonPropertyName("skip_references_check")]
public bool? SkipReferencesCheck { get; set; }
[JsonPropertyName("s3")]
Expand Down Expand Up @@ -7771,6 +7823,22 @@ public class RestoreActionRequest
public string? DecisionReason { get; set; }
}

public class RestoreActivityRequest
{
[JsonPropertyName("user_id")]
public string? UserID { get; set; }
[JsonPropertyName("user")]
public UserRequest? User { get; set; }
}

public class RestoreActivityResponse
{
[JsonPropertyName("duration")]
public string Duration { get; set; }
[JsonPropertyName("activity")]
public ActivityResponse Activity { get; set; }
}

public class RestoreUsersRequest
{
[JsonPropertyName("user_ids")]
Expand Down Expand Up @@ -8147,6 +8215,8 @@ public class SingleFollowResponse
public string Duration { get; set; }
[JsonPropertyName("follow")]
public FollowResponse Follow { get; set; }
[JsonPropertyName("notification_created")]
public bool? NotificationCreated { get; set; }
}

public class SortParam
Expand Down Expand Up @@ -8341,6 +8411,8 @@ public class ThreadedCommentResponse
public double? ControversyScore { get; set; }
[JsonPropertyName("deleted_at")]
public DateTime? DeletedAt { get; set; }
[JsonPropertyName("edited_at")]
public DateTime? EditedAt { get; set; }
[JsonPropertyName("parent_id")]
public string? ParentID { get; set; }
[JsonPropertyName("text")]
Expand Down Expand Up @@ -8487,6 +8559,8 @@ public class UnfollowBatchRequest
{
[JsonPropertyName("follows")]
public List<FollowPair> Follows { get; set; }
[JsonPropertyName("delete_notification_activity")]
public bool? DeleteNotificationActivity { get; set; }
}

public class UnfollowBatchResponse
Expand Down Expand Up @@ -8537,6 +8611,8 @@ public class UnpinActivityResponse

public class UpdateActivityPartialRequest
{
[JsonPropertyName("handle_mention_notifications")]
public bool? HandleMentionNotifications { get; set; }
[JsonPropertyName("user_id")]
public string? UserID { get; set; }
[JsonPropertyName("unset")]
Expand All @@ -8559,6 +8635,8 @@ public class UpdateActivityRequest
{
[JsonPropertyName("expires_at")]
public DateTime? ExpiresAt { get; set; }
[JsonPropertyName("handle_mention_notifications")]
public bool? HandleMentionNotifications { get; set; }
[JsonPropertyName("poll_id")]
public string? PollID { get; set; }
[JsonPropertyName("restrict_replies")]
Expand Down Expand Up @@ -8795,6 +8873,8 @@ public class UpdateCommentRequest
{
[JsonPropertyName("comment")]
public string? Comment { get; set; }
[JsonPropertyName("handle_mention_notifications")]
public bool? HandleMentionNotifications { get; set; }
[JsonPropertyName("skip_enrich_url")]
public bool? SkipEnrichUrl { get; set; }
[JsonPropertyName("skip_push")]
Expand All @@ -8803,6 +8883,8 @@ public class UpdateCommentRequest
public string? UserID { get; set; }
[JsonPropertyName("attachments")]
public List<Attachment> Attachments { get; set; }
[JsonPropertyName("mentioned_user_ids")]
public List<string> MentionedUserIds { get; set; }
[JsonPropertyName("custom")]
public object Custom { get; set; }
[JsonPropertyName("user")]
Expand Down Expand Up @@ -8971,6 +9053,8 @@ public class UpdateFollowRequest
public string? PushPreference { get; set; }
[JsonPropertyName("skip_push")]
public bool? SkipPush { get; set; }
[JsonPropertyName("status")]
public string? Status { get; set; }
[JsonPropertyName("custom")]
public object Custom { get; set; }
}
Expand Down Expand Up @@ -9117,6 +9201,8 @@ public class UpsertActivitiesResponse
public string Duration { get; set; }
[JsonPropertyName("activities")]
public List<ActivityResponse> Activities { get; set; }
[JsonPropertyName("mention_notifications_created")]
public int? MentionNotificationsCreated { get; set; }
}

public class UpsertCollectionsRequest
Expand Down
36 changes: 36 additions & 0 deletions tests/FeedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,42 @@ public async Task UpdateActivityAsync_ShouldCallCorrectEndpoint()
It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task RestoreActivityAsync_ShouldCallCorrectEndpoint()
{
// Arrange
var request = new RestoreActivityRequest();
var id = "test-id";

var expectedResponse = new StreamResponse<RestoreActivityResponse>
{
Data = new RestoreActivityResponse()
};

_mockClient.Setup(x => x.MakeRequestAsync<RestoreActivityRequest, RestoreActivityResponse>(
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<RestoreActivityRequest>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(expectedResponse);

// Act
var result = await _client.RestoreActivityAsync(id,request);

// Assert
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.EqualTo(expectedResponse));

_mockClient.Verify(x => x.MakeRequestAsync<RestoreActivityRequest, RestoreActivityResponse>(
"POST",
"/api/v2/feeds/activities/{id}/restore",
It.IsAny<Dictionary<string, string>>(),
It.IsAny<RestoreActivityRequest>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task QueryBookmarkFoldersAsync_ShouldCallCorrectEndpoint()
{
// Arrange
Expand Down
Loading