-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for bookmarking and favouriting statuses
- Loading branch information
Showing
4 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Skybrud.Social.Mastodon/Options/Statuses/MastodonBookmarkStatusOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Skybrud.Essentials.Common; | ||
using Skybrud.Essentials.Http; | ||
|
||
namespace Skybrud.Social.Mastodon.Options.Statuses; | ||
|
||
/// <summary> | ||
/// Class with options for favouriting a status. | ||
/// </summary> | ||
/// <see> | ||
/// <cref>https://docs.joinmastodon.org/methods/statuses/#bookmark</cref> | ||
/// </see> | ||
public class MastodonBookmarkStatusOptions : MastodonHttpRequestOptions { | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Gets or sets the ID of the status. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required string Id { get; set; } | ||
#else | ||
public string? Id { get; set; } | ||
#endif | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Initializes a new instance with default options. | ||
/// </summary> | ||
public MastodonBookmarkStatusOptions() { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance based on the specified <paramref name="id"/>. | ||
/// </summary> | ||
/// <param name="id">The ID of the status.</param> | ||
#if NET7_0_OR_GREATER | ||
[SetsRequiredMembers] | ||
#endif | ||
public MastodonBookmarkStatusOptions(string id) { | ||
Id = id; | ||
} | ||
|
||
#endregion | ||
|
||
#region Member methods | ||
|
||
/// <summary> | ||
/// Returns a new <see cref="IHttpRequest"/> instance for this options instance. | ||
/// </summary> | ||
/// <returns>An instance of <see cref="IHttpRequest"/>.</returns> | ||
public override IHttpRequest GetRequest(MastodonHttpClient client) { | ||
|
||
// Validate required properties | ||
if (string.IsNullOrWhiteSpace(Id)) throw new PropertyNotSetException(nameof(Id)); | ||
|
||
// Initialize a new HTTP request | ||
return HttpRequest.Get($"/api/v1/statuses/{Id}/bookmark"); | ||
|
||
} | ||
|
||
#endregion | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/Skybrud.Social.Mastodon/Options/Statuses/MastodonFavouriteStatusOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Skybrud.Essentials.Common; | ||
using Skybrud.Essentials.Http; | ||
|
||
namespace Skybrud.Social.Mastodon.Options.Statuses; | ||
|
||
/// <summary> | ||
/// Class with options for favouriting a status. | ||
/// </summary> | ||
/// <see> | ||
/// <cref>https://docs.joinmastodon.org/methods/statuses/#favourite</cref> | ||
/// </see> | ||
public class MastodonFavouriteStatusOptions : MastodonHttpRequestOptions { | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Gets or sets the ID of the status. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required string Id { get; set; } | ||
#else | ||
public string? Id { get; set; } | ||
#endif | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Initializes a new instance with default options. | ||
/// </summary> | ||
public MastodonFavouriteStatusOptions() { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance based on the specified <paramref name="id"/>. | ||
/// </summary> | ||
/// <param name="id">The ID of the status.</param> | ||
#if NET7_0_OR_GREATER | ||
[SetsRequiredMembers] | ||
#endif | ||
public MastodonFavouriteStatusOptions(string id) { | ||
Id = id; | ||
} | ||
|
||
#endregion | ||
|
||
#region Member methods | ||
|
||
/// <summary> | ||
/// Returns a new <see cref="IHttpRequest"/> instance for this options instance. | ||
/// </summary> | ||
/// <returns>An instance of <see cref="IHttpRequest"/>.</returns> | ||
public override IHttpRequest GetRequest(MastodonHttpClient client) { | ||
|
||
// Validate required properties | ||
if (string.IsNullOrWhiteSpace(Id)) throw new PropertyNotSetException(nameof(Id)); | ||
|
||
// Initialize a new HTTP request | ||
return HttpRequest.Get($"/api/v1/statuses/{Id}/favourite"); | ||
|
||
} | ||
|
||
#endregion | ||
|
||
} |