diff --git a/src/LinkAce.NET/Entites/CreateLinkRequest.cs b/src/LinkAce.NET/Entites/CreateLinkRequest.cs
new file mode 100644
index 0000000..fb24461
--- /dev/null
+++ b/src/LinkAce.NET/Entites/CreateLinkRequest.cs
@@ -0,0 +1,83 @@
+using JetBrains.Annotations;
+
+namespace LinkAce.NET.Entites;
+
+///
+/// Represents a link entity with various properties such as URL, title, description, and status.
+///
+[PublicAPI]
+public class CreateLinkRequest
+{
+ ///
+ /// Gets or sets a value indicating whether the link check is disabled.
+ ///
+ public bool CheckDisabled { get; set; }
+ ///
+ /// Gets or sets the date and time when the link was created.
+ ///
+ public DateTime CreatedAt { get; set; }
+ ///
+ /// Gets or sets the date and time when the link was deleted, if applicable.
+ ///
+ public DateTime? DeletedAt { get; set; }
+ ///
+ /// Gets or sets the description of the link.
+ ///
+ public string? Description { get; set; }
+ ///
+ /// Gets or sets the icon associated with the link.
+ ///
+ public string? Icon { get; set; }
+ ///
+ /// Gets or sets the unique identifier for the link.
+ ///
+ public int Id { get; set; }
+ ///
+ /// Gets or sets a value indicating whether the link is private.
+ ///
+ public bool IsPrivate { get; set; }
+ ///
+ /// Gets or sets the status of the link.
+ ///
+ public int Status { get; set; }
+ ///
+ /// Gets or sets the tags associated with the link.
+ ///
+ public string[]? Tags { get; set; }
+ ///
+ /// Gets or sets the title of the link.
+ ///
+ public string? Title { get; set; }
+ ///
+ /// Gets or sets the date and time when the link was last updated.
+ ///
+ public DateTime UpdatedAt { get; set; }
+ ///
+ /// Gets or sets the URL of the link.
+ ///
+ public string Url { get; set; }
+ ///
+ /// Gets or sets the user identifier associated with the link.
+ ///
+ public int UserId { get; set; }
+
+ public static implicit operator CreateLinkRequest(Link link)
+ {
+ return new CreateLinkRequest
+ {
+ CheckDisabled = link.CheckDisabled,
+ CreatedAt = link.CreatedAt,
+ DeletedAt = link.DeletedAt,
+ Description = link.Description,
+ Icon = link.Icon,
+ Id = link.Id,
+ IsPrivate = link.IsPrivate,
+ Status = link.Status,
+ Tags = link.Tags?.Select(tag => tag.Name).ToArray(),
+ Title = link.Title,
+ UpdatedAt = link.UpdatedAt,
+ Url = link.Url,
+ UserId = link.UserId
+ };
+ }
+}
diff --git a/src/LinkAce.NET/LinkAce.NET.csproj b/src/LinkAce.NET/LinkAce.NET.csproj
index 48c25b5..a64470b 100644
--- a/src/LinkAce.NET/LinkAce.NET.csproj
+++ b/src/LinkAce.NET/LinkAce.NET.csproj
@@ -1,7 +1,7 @@
- net7.0;net8.0
+ net8.0
enable
enable
0.0.3
diff --git a/src/LinkAce.NET/LinkAceClient.cs b/src/LinkAce.NET/LinkAceClient.cs
index fd466a7..30205f7 100644
--- a/src/LinkAce.NET/LinkAceClient.cs
+++ b/src/LinkAce.NET/LinkAceClient.cs
@@ -17,6 +17,9 @@ public class LinkAceClient
{
private static string? _apiUrl;
private static HttpClient _client;
+ private JsonSerializerOptions _serializationOptions = new(JsonSerializerDefaults.Web){
+ PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
+ };
///
/// Initializes a new instance of the class with the specified URL and HTTP client.
///
@@ -46,12 +49,12 @@ public LinkAceClient(string linkAceUrl, string apiToken, HttpClient? client = nu
///
/// Creates a new link.
///
- /// The link to create.
+ /// The request to create a link.
/// The HTTP response message.
- public async Task CreateLink(Link link)
+ public async Task CreateLink(CreateLinkRequest createLinkRequest)
{
var response = await _client.PostAsync($"{_apiUrl}/links",
- new StringContent(JsonSerializer.Serialize(link), Encoding.UTF8,
+ new StringContent(JsonSerializer.Serialize(createLinkRequest, _serializationOptions), Encoding.UTF8,
MediaTypeNames.Application.Json));
return response;
}
@@ -80,7 +83,7 @@ public LinkAceClient(string linkAceUrl, string apiToken, HttpClient? client = nu
public async Task UpdateLinkById(int id, Link link)
{
var response = await _client.PatchAsync($"{_apiUrl}/links/{id}",
- new StringContent(JsonSerializer.Serialize(link), Encoding.UTF8,
+ new StringContent(JsonSerializer.Serialize(link, _serializationOptions), Encoding.UTF8,
MediaTypeNames.Application.Json));
return response;
}