Skip to content

Instantly share code, notes, and snippets.

@andrebaltieri
Created May 3, 2024 15:10
Show Gist options
  • Save andrebaltieri/7b9acaf3b03c556adf4e7b96c1fac6e8 to your computer and use it in GitHub Desktop.
Save andrebaltieri/7b9acaf3b03c556adf4e7b96c1fac6e8 to your computer and use it in GitHub Desktop.
using Refit;
using FinaFlow.Core.Entities;
namespace FinaFlow.Services;
public interface ICategoryService
{
[Post("/v1/categories/")]
Task CreateAsync([Body] Category category);
[Put("/v1/categories/{id}")]
Task UpdateAsync(uint id, [Body] Category category);
[Get("/v1/categories")]
Task<List<Category>> GetAsync();
[Get("/v1/categories/{id}")]
Task<Category> GetByIdAsync(uint id);
[Delete("/v1/categories/{id}")]
Task DeleteAsync(uint id);
}
public class HomePage
{
private readonly ICategoryService _api;
public HomePage(IHttpClientFactory httpClientFactory)
{
var httpClient = httpClientFactory.CreateClient(Configuration.HttpClientName);
_api = RestService.For<ICategoryService>(httpClient);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment