using AbrBlazorTools;
using System.Net.Http;
using System.Threading.Tasks;

namespace Panel.ApiUtils
{
    public class PlantsUtils : IPlantsUtils
    {
        private readonly IHttpClientWithLoginToken _client;

        public PlantsUtils(IHttpClientWithLoginToken client)
        {
            _client = client;
        }

        public Task<HttpResponseMessage> List()
        {
            return _client.HttpGet("/api/Plants/List");
        }

        public Task<HttpResponseMessage> Add(object plantModel)
        {
            return _client.HttpPost("/api/Plants/Add", plantModel);
        }

        public Task<HttpResponseMessage> Update(object plantModel)
        {
            return _client.HttpPut("/api/Plants/Update", plantModel);
        }

        public Task<HttpResponseMessage> Delete(Guid id)
        {
            return _client.HttpDelete($"/api/Plants/Delete/{id}");
        }
    }

    public interface IPlantsUtils
    {
        Task<HttpResponseMessage> List();
        Task<HttpResponseMessage> Add(object plantModel);
        Task<HttpResponseMessage> Update(object plantModel);
        Task<HttpResponseMessage> Delete(Guid id);
    }
}
