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
9 changes: 1 addition & 8 deletions LinkAce.sln
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
27 changes: 0 additions & 27 deletions src/LinkAce.Api/LinkAce.Api.csproj

This file was deleted.

12 changes: 0 additions & 12 deletions src/LinkAce.Api/Meta.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/LinkAce.Api/Responses/SearchLinkResponse.cs

This file was deleted.

60 changes: 60 additions & 0 deletions src/LinkAce.NET/ApiResponses/SearchLinkResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using JetBrains.Annotations;
using LinkAce.NET.Entites;

namespace LinkAce.NET.ApiResponses;

/// <summary>
/// Represents the response from a search query for links.
/// </summary>
[PublicAPI]
public class SearchLinkResponse
{
/// <summary>
/// Gets or sets the current page number.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the list of links returned by the search.
/// </summary>
public List<Link>? Data { get; set; }
/// <summary>
/// Gets or sets the URL of the first page.
/// </summary>
public string? FirstPageUrl { get; set; }
/// <summary>
/// Gets or sets the starting record number on the current page.
/// </summary>
public int? From { get; set; }
/// <summary>
/// Gets or sets the last page number.
/// </summary>
public int LastPage { get; set; }
/// <summary>
/// Gets or sets the URL of the last page.
/// </summary>
public string? LastPageUrl { get; set; }
/// <summary>
/// Gets or sets the URL of the next page.
/// </summary>
public string? NextPageUrl { get; set; }
/// <summary>
/// Gets or sets the path of the search query.
/// </summary>
public string Path { get; set; }
/// <summary>
/// Gets or sets the number of records per page.
/// </summary>
public string PerPage { get; set; }
/// <summary>
/// Gets or sets the URL of the previous page.
/// </summary>
public string? PreviousPageUrl { get; set; }
/// <summary>
/// Gets or sets the ending record number on the current page.
/// </summary>
public int? To { get; set; }
/// <summary>
/// Gets or sets the total number of records found.
/// </summary>
public int Total { get; set; }
}
63 changes: 63 additions & 0 deletions src/LinkAce.NET/Entites/Link.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using JetBrains.Annotations;

namespace LinkAce.NET.Entites;

/// <summary>
/// Represents a link entity with various properties such as URL, title, description, and status.
/// </summary>
[PublicAPI]
public class Link
{
/// <summary>
/// Gets or sets a value indicating whether the link check is disabled.
/// </summary>
public bool CheckDisabled { get; set; }
/// <summary>
/// Gets or sets the date and time when the link was created.
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// Gets or sets the date and time when the link was deleted, if applicable.
/// </summary>
public DateTime? DeletedAt { get; set; }
/// <summary>
/// Gets or sets the description of the link.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Gets or sets the icon associated with the link.
/// </summary>
public string? Icon { get; set; }
/// <summary>
/// Gets or sets the unique identifier for the link.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the link is private.
/// </summary>
public bool IsPrivate { get; set; }
/// <summary>
/// Gets or sets the status of the link.
/// </summary>
public int Status { get; set; }
/// <summary>
/// Gets or sets the tags associated with the link.
/// </summary>
public string[]? Tags { get; set; }
/// <summary>
/// Gets or sets the title of the link.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the date and time when the link was last updated.
/// </summary>
public DateTime UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the URL of the link.
/// </summary>
public string Url { get; set; }
/// <summary>
/// Gets or sets the user identifier associated with the link.
/// </summary>
public int UserId { get; set; }
}
37 changes: 37 additions & 0 deletions src/LinkAce.NET/LinkAce.NET.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.3</Version>
<Title>LinkAce.NET</Title>
<Authors>prplecake</Authors>
<PackageProjectUrl>https://github.com/prplecake/LinkAce.NET</PackageProjectUrl>
<RepositoryUrl>https://github.com/prplecake/LinkAce.NET</RepositoryUrl>
<Description>A C# library for interacting with the LinkAce API.</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>api, LinkAce, LinkAceAPI, C#, bookmarks, bookmarking</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Client for interacting with the LinkAce.NET API.
/// </summary>
[PublicAPI]
public class LinkAceClient
{
private static string? _apiUrl;
private static HttpClient _client = new();
/// <summary>
/// Initializes a new instance of the <see cref="LinkAceClient" /> class with the specified URL and HTTP client.
/// </summary>
/// <param name="linkAceUrl">The base URL of the LinkAce.NET instance.</param>
/// <param name="httpClient">The HTTP client to use for requests.</param>
public LinkAceClient(string linkAceUrl, HttpClient httpClient)
{
_apiUrl = $"{linkAceUrl}/api/v1";
_client = httpClient;
}
/// <summary>
/// Initializes a new instance of the <see cref="LinkAceClient" /> class with the specified URL and API token.
/// </summary>
/// <param name="linkAceUrl">The base URL of the LinkAce.NET instance.</param>
/// <param name="apiToken">The API token for authentication.</param>
public LinkAceClient(string linkAceUrl, string apiToken)
{
_apiUrl = $"{linkAceUrl}/api/v1";
Expand All @@ -25,13 +40,23 @@ public LinkAceClient(string linkAceUrl, string apiToken)
_client.DefaultRequestHeaders.UserAgent.Add(Meta.UserAgent);
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);
}
/// <summary>
/// Creates a new link.
/// </summary>
/// <param name="link">The link to create.</param>
/// <returns>The HTTP response message.</returns>
public async Task<HttpResponseMessage?> CreateLink(Link link)
{
var response = await _client.PostAsync($"{_apiUrl}/links",
new StringContent(JsonConvert.SerializeObject(link), Encoding.UTF8,
MediaTypeNames.Application.Json));
return response;
}
/// <summary>
/// Searches for links by URL.
/// </summary>
/// <param name="url">The URL to search for.</param>
/// <returns>The search response containing the links.</returns>
public async Task<SearchLinkResponse?> SearchLinksByUrl(string url)
{
var uriBuilder = new UriBuilder($"{_apiUrl}/search/links");
Expand All @@ -43,6 +68,12 @@ public LinkAceClient(string linkAceUrl, string apiToken)
await response.Content.ReadAsStringAsync());
return obj;
}
/// <summary>
/// Updates a link by its ID.
/// </summary>
/// <param name="id">The ID of the link to update.</param>
/// <param name="link">The updated link data.</param>
/// <returns>The HTTP response message.</returns>
public async Task<HttpResponseMessage?> UpdateLinkById(int id, Link link)
{
var response = await _client.PatchAsync($"{_apiUrl}/links/{id}",
Expand Down
17 changes: 17 additions & 0 deletions src/LinkAce.NET/Meta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Net.Http.Headers;
using System.Reflection;

namespace LinkAce.NET;

/// <summary>
/// Provides metadata information about the LinkAce.NET package.
/// </summary>
public static class Meta
{
private const string Name = "LinkAce.NET";
private static readonly string AssemblyVersion = Assembly.GetEntryAssembly()!.GetName().Version!.ToString();
/// <summary>
/// The user agent information for HTTP requests.
/// </summary>
public static readonly ProductInfoHeaderValue UserAgent = new(Name, AssemblyVersion);
}
18 changes: 0 additions & 18 deletions src/LinkAce/Entites/Link.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/LinkAce/LinkAce.csproj

This file was deleted.

2 changes: 1 addition & 1 deletion src/TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LinkAce.Api;
using LinkAce.NET;
using Microsoft.Extensions.Configuration;
Console.WriteLine("Hello, World!");

Expand Down
Loading