using IWS5.Autotest.IWS5.Api.ApiEndpointFormats;
using IWS5.Autotest.IWS5.Api.Common;
using IWS5.Autotest.IWS5.Api.Common.Pashn.Autotests.Pashn.Api.Common;
using IWS5.Core.DTO;
using IWS5.Core.Models;
using IWS5.Core.Models.Request;
using Microsoft.Playwright;
using RestSharp;

namespace IWS5.Autotest.IWS5.Api.Api
{
    public class WorkItemControllerApi : BaseAppApi
    {
        private readonly SessionStorage _sessionStorage;

        public WorkItemControllerApi(SessionStorage sessionStorage) : base(ApiEndpointFormat.WorkItem.Base, sessionStorage)
        {
            _sessionStorage = sessionStorage;
        }

        public async Task<RestResponse<List<WorkItemInboxListItemDto>>> GetWorkItemsInboxForUser()
        {
            var request = CreateGetRequest(ApiEndpointFormat.WorkItem.Inbox);
            return await ExecuteRequest<List<WorkItemInboxListItemDto>>(request);
        }

        public async Task<RestResponse<Response<WorkItemListItemDTO>>> CreateWorkItem(CreateWorkItemRequest requestBody)
        {
            var request = CreatePostRequest(ApiEndpointFormat.WorkItem.Create, requestBody);
            return await ExecuteRequest<Response<WorkItemListItemDTO>>(request);
        }

        public async Task<RestResponse<Response<WorkItemListItemDTO>>> ForwardWorkItem(ForwardWorkItemRequest requestBody)
        {
            var request = CreatePatchRequest(ApiEndpointFormat.WorkItem.Forward, requestBody);
            return await ExecuteRequest<Response<WorkItemListItemDTO>>(request);
        }
    }
}