diff --git a/LinkAce.sln b/LinkAce.sln index a1c88fe..8c2681b 100644 --- a/LinkAce.sln +++ b/LinkAce.sln @@ -1,7 +1,5 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinkAce", "src\LinkAce\LinkAce.csproj", "{AC6F279B-A91D-49FB-BB47-79A3B4E289E4}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{22C844A6-ACCE-4473-9C7B-D53D613DA802}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{66EB4E20-E8C9-43B5-9B51-B3BB962AEEF2}" @@ -17,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI Workflows", "CI Workflow .github\workflows\dotnet.yml = .github\workflows\dotnet.yml EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinkAce.Api", "src\LinkAce.Api\LinkAce.Api.csproj", "{6C83B6FB-E141-46BA-A446-8346BB11A7E3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinkAce.NET", "src\LinkAce.NET\LinkAce.NET.csproj", "{6C83B6FB-E141-46BA-A446-8346BB11A7E3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "src\TestApp\TestApp.csproj", "{97052387-BAA1-40E8-A861-C412B373FBDC}" EndProject @@ -27,10 +25,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AC6F279B-A91D-49FB-BB47-79A3B4E289E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC6F279B-A91D-49FB-BB47-79A3B4E289E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC6F279B-A91D-49FB-BB47-79A3B4E289E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC6F279B-A91D-49FB-BB47-79A3B4E289E4}.Release|Any CPU.Build.0 = Release|Any CPU {6C83B6FB-E141-46BA-A446-8346BB11A7E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C83B6FB-E141-46BA-A446-8346BB11A7E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C83B6FB-E141-46BA-A446-8346BB11A7E3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -42,7 +36,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {7E05B1B4-5625-4A84-A2B2-4D66C8059904} = {E1115509-DC42-44D8-A031-A207EF90073F} - {AC6F279B-A91D-49FB-BB47-79A3B4E289E4} = {22C844A6-ACCE-4473-9C7B-D53D613DA802} {6C83B6FB-E141-46BA-A446-8346BB11A7E3} = {22C844A6-ACCE-4473-9C7B-D53D613DA802} {97052387-BAA1-40E8-A861-C412B373FBDC} = {22C844A6-ACCE-4473-9C7B-D53D613DA802} EndGlobalSection diff --git a/src/LinkAce.Api/LinkAce.Api.csproj b/src/LinkAce.Api/LinkAce.Api.csproj deleted file mode 100644 index a561714..0000000 --- a/src/LinkAce.Api/LinkAce.Api.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - net7.0 - enable - enable - 0.0.3 - LinkAce.Api - prplecake - https://github.com/prplecake/LinkAce.NET - https://github.com/prplecake/LinkAce.NET/blob/master/LICENSE - https://github.com/prplecake/LinkAce.NET - - - - none - - - - - - - - - - - diff --git a/src/LinkAce.Api/Meta.cs b/src/LinkAce.Api/Meta.cs deleted file mode 100644 index 2b49e40..0000000 --- a/src/LinkAce.Api/Meta.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Net.Http.Headers; -using System.Reflection; - -namespace LinkAce.Api; - -public class Meta -{ - private const string - Name = "LinkAce.NET"; - public static readonly string AssemblyVersion = Assembly.GetEntryAssembly()!.GetName().Version!.ToString(); - public static readonly ProductInfoHeaderValue UserAgent = new(Name, AssemblyVersion); -} diff --git a/src/LinkAce.Api/Responses/SearchLinkResponse.cs b/src/LinkAce.Api/Responses/SearchLinkResponse.cs deleted file mode 100644 index b12c2d1..0000000 --- a/src/LinkAce.Api/Responses/SearchLinkResponse.cs +++ /dev/null @@ -1,19 +0,0 @@ -using LinkAce.Entites; - -namespace LinkAce.Api.Responses; - -public class SearchLinkResponse -{ - public int CurrentPage { get; set; } - public List? Data { get; set; } - public string? FirstPageUrl { get; set; } - public int? From { get; set; } - public int LastPage { get; set; } - public string? LastPageUrl { get; set; } - public string? NextPageUrl { get; set; } - public string Path { get; set; } - public string PerPage { get; set; } - public string? PreviousPageUrl { get; set; } - public int? To { get; set; } - public int Total { get; set; } -} diff --git a/src/LinkAce.NET/ApiResponses/SearchLinkResponse.cs b/src/LinkAce.NET/ApiResponses/SearchLinkResponse.cs new file mode 100644 index 0000000..db5b108 --- /dev/null +++ b/src/LinkAce.NET/ApiResponses/SearchLinkResponse.cs @@ -0,0 +1,60 @@ +using JetBrains.Annotations; +using LinkAce.NET.Entites; + +namespace LinkAce.NET.ApiResponses; + +/// +/// Represents the response from a search query for links. +/// +[PublicAPI] +public class SearchLinkResponse +{ + /// + /// Gets or sets the current page number. + /// + public int CurrentPage { get; set; } + /// + /// Gets or sets the list of links returned by the search. + /// + public List? Data { get; set; } + /// + /// Gets or sets the URL of the first page. + /// + public string? FirstPageUrl { get; set; } + /// + /// Gets or sets the starting record number on the current page. + /// + public int? From { get; set; } + /// + /// Gets or sets the last page number. + /// + public int LastPage { get; set; } + /// + /// Gets or sets the URL of the last page. + /// + public string? LastPageUrl { get; set; } + /// + /// Gets or sets the URL of the next page. + /// + public string? NextPageUrl { get; set; } + /// + /// Gets or sets the path of the search query. + /// + public string Path { get; set; } + /// + /// Gets or sets the number of records per page. + /// + public string PerPage { get; set; } + /// + /// Gets or sets the URL of the previous page. + /// + public string? PreviousPageUrl { get; set; } + /// + /// Gets or sets the ending record number on the current page. + /// + public int? To { get; set; } + /// + /// Gets or sets the total number of records found. + /// + public int Total { get; set; } +} diff --git a/src/LinkAce.NET/Entites/Link.cs b/src/LinkAce.NET/Entites/Link.cs new file mode 100644 index 0000000..25c7aaf --- /dev/null +++ b/src/LinkAce.NET/Entites/Link.cs @@ -0,0 +1,63 @@ +using JetBrains.Annotations; + +namespace LinkAce.NET.Entites; + +/// +/// Represents a link entity with various properties such as URL, title, description, and status. +/// +[PublicAPI] +public class Link +{ + /// + /// 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; } +} diff --git a/src/LinkAce.NET/LinkAce.NET.csproj b/src/LinkAce.NET/LinkAce.NET.csproj new file mode 100644 index 0000000..684cde6 --- /dev/null +++ b/src/LinkAce.NET/LinkAce.NET.csproj @@ -0,0 +1,37 @@ + + + + net7.0;net8.0 + enable + enable + 0.0.3 + LinkAce.NET + prplecake + https://github.com/prplecake/LinkAce.NET + https://github.com/prplecake/LinkAce.NET + A C# library for interacting with the LinkAce API. + LICENSE + README.md + api, LinkAce, LinkAceAPI, C#, bookmarks, bookmarking + true + + + + embedded + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/src/LinkAce.Api/LinkAceClient.cs b/src/LinkAce.NET/LinkAceClient.cs similarity index 56% rename from src/LinkAce.Api/LinkAceClient.cs rename to src/LinkAce.NET/LinkAceClient.cs index f560c18..cbf222d 100644 --- a/src/LinkAce.Api/LinkAceClient.cs +++ b/src/LinkAce.NET/LinkAceClient.cs @@ -2,21 +2,36 @@ using System.Net.Mime; using System.Text; using System.Web; -using LinkAce.Api.Responses; -using LinkAce.Entites; +using JetBrains.Annotations; +using LinkAce.NET.ApiResponses; +using LinkAce.NET.Entites; using Newtonsoft.Json; -namespace LinkAce.Api; +namespace LinkAce.NET; +/// +/// Client for interacting with the LinkAce.NET API. +/// +[PublicAPI] public class LinkAceClient { private static string? _apiUrl; private static HttpClient _client = new(); + /// + /// Initializes a new instance of the class with the specified URL and HTTP client. + /// + /// The base URL of the LinkAce.NET instance. + /// The HTTP client to use for requests. public LinkAceClient(string linkAceUrl, HttpClient httpClient) { _apiUrl = $"{linkAceUrl}/api/v1"; _client = httpClient; } + /// + /// Initializes a new instance of the class with the specified URL and API token. + /// + /// The base URL of the LinkAce.NET instance. + /// The API token for authentication. public LinkAceClient(string linkAceUrl, string apiToken) { _apiUrl = $"{linkAceUrl}/api/v1"; @@ -25,6 +40,11 @@ public LinkAceClient(string linkAceUrl, string apiToken) _client.DefaultRequestHeaders.UserAgent.Add(Meta.UserAgent); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken); } + /// + /// Creates a new link. + /// + /// The link to create. + /// The HTTP response message. public async Task CreateLink(Link link) { var response = await _client.PostAsync($"{_apiUrl}/links", @@ -32,6 +52,11 @@ public LinkAceClient(string linkAceUrl, string apiToken) MediaTypeNames.Application.Json)); return response; } + /// + /// Searches for links by URL. + /// + /// The URL to search for. + /// The search response containing the links. public async Task SearchLinksByUrl(string url) { var uriBuilder = new UriBuilder($"{_apiUrl}/search/links"); @@ -43,6 +68,12 @@ public LinkAceClient(string linkAceUrl, string apiToken) await response.Content.ReadAsStringAsync()); return obj; } + /// + /// Updates a link by its ID. + /// + /// The ID of the link to update. + /// The updated link data. + /// The HTTP response message. public async Task UpdateLinkById(int id, Link link) { var response = await _client.PatchAsync($"{_apiUrl}/links/{id}", diff --git a/src/LinkAce.NET/Meta.cs b/src/LinkAce.NET/Meta.cs new file mode 100644 index 0000000..b3cab01 --- /dev/null +++ b/src/LinkAce.NET/Meta.cs @@ -0,0 +1,17 @@ +using System.Net.Http.Headers; +using System.Reflection; + +namespace LinkAce.NET; + +/// +/// Provides metadata information about the LinkAce.NET package. +/// +public static class Meta +{ + private const string Name = "LinkAce.NET"; + private static readonly string AssemblyVersion = Assembly.GetEntryAssembly()!.GetName().Version!.ToString(); + /// + /// The user agent information for HTTP requests. + /// + public static readonly ProductInfoHeaderValue UserAgent = new(Name, AssemblyVersion); +} diff --git a/src/LinkAce/Entites/Link.cs b/src/LinkAce/Entites/Link.cs deleted file mode 100644 index c188049..0000000 --- a/src/LinkAce/Entites/Link.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace LinkAce.Entites; - -public class Link -{ - public bool CheckDisabled { get; set; } - public DateTime CreatedAt { get; set; } - public DateTime? DeletedAt { get; set; } - public string? Description { get; set; } - public string? Icon { get; set; } - public int Id { get; set; } - public bool IsPrivate { get; set; } - public int Status { get; set; } - public string? Title { get; set; } - public DateTime UpdatedAt { get; set; } - public string Url { get; set; } - public int UserId { get; set; } - public string[]? Tags { get; set; } -} diff --git a/src/LinkAce/LinkAce.csproj b/src/LinkAce/LinkAce.csproj deleted file mode 100644 index 074c6aa..0000000 --- a/src/LinkAce/LinkAce.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net7.0 - enable - enable - 0.0.4 - LinkAce - https://github.com/prplecake/LinkAce.NET - https://github.com/prplecake/LinkAce.NET/blob/master/LICENSE - https://github.com/prplecake/LinkAce.NET - git - - - - none - - - diff --git a/src/TestApp/Program.cs b/src/TestApp/Program.cs index 6a5fecf..bd9ef1a 100644 --- a/src/TestApp/Program.cs +++ b/src/TestApp/Program.cs @@ -1,4 +1,4 @@ -using LinkAce.Api; +using LinkAce.NET; using Microsoft.Extensions.Configuration; Console.WriteLine("Hello, World!"); diff --git a/src/TestApp/TestApp.csproj b/src/TestApp/TestApp.csproj index 15888db..fbf65d6 100644 --- a/src/TestApp/TestApp.csproj +++ b/src/TestApp/TestApp.csproj @@ -20,7 +20,7 @@ - +