Use Refit for APIs, make data/API stack async

This commit is contained in:
Neil Brommer 2021-11-28 22:32:21 -08:00
parent 9c4f01ab13
commit b00158daa7
17 changed files with 196 additions and 124 deletions

View file

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Refit;
namespace Start.Shared.Api {
public interface IBookmarkContainersApi {
[Get("/")]
Task<ApiResponse<IEnumerable<BookmarkContainerDto>>> GetAllBookmarkContainers();
[Get("/{bookmarkContainerId}")]
Task<ApiResponse<BookmarkContainerDto?>> GetBookmarkContainer(int bookmarkContainerId);
[Post("/Create")]
Task<ApiResponse<BookmarkContainerDto?>> CreateBookmarkContainer(
[Body(BodySerializationMethod.Serialized)] string title);
[Delete("/Delete/{bookmarkContainerId}")]
Task<HttpResponseMessage> DeleteBookmarkContainer(int bookmarkContainerId);
}
}

View file

@ -0,0 +1,15 @@
using System.Threading.Tasks;
using Refit;
namespace Start.Shared.Api {
public interface IBookmarksApi {
[Get("{bookmarkId}")]
Task<BookmarkDto?> GetBookmark(int bookmarkId);
[Post("/Create")]
Task CreateBookmark(string title, string url, string? notes, int bookmarkGroupId);
[Delete("/Delete/{bookmarkId}")]
Task DeleteBookmark(int bookmarkId);
}
}

View file

@ -9,4 +9,14 @@
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<None Remove="Refit" />
<None Remove="Api\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Api\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Refit" Version="6.1.15" />
</ItemGroup>
</Project>