namespace Hims.Api.Controllers
{
    using System.Threading.Tasks;
    using Domain.Services;
    using Microsoft.AspNetCore.Authorization;
    using Microsoft.AspNetCore.Mvc;
    using Shared.EntityModels;
    using Shared.UserModels.Filters;
    using Utilities;

    /// <summary>
    /// The doctor device details controller.
    /// </summary>
    [Authorize]
    [Route("api/doctor-device-details")]
    [Consumes("application/json")]
    [Produces("application/json")]
    public class DoctorDeviceDetailsController : BaseController
    {
        /// <summary>
        /// The doctor device details services.
        /// </summary>
        private readonly IDoctorDeviceDetailsService doctorDeviceDetailsServices;

        /// <inheritdoc />
        public DoctorDeviceDetailsController(IDoctorDeviceDetailsService doctorDeviceDetailsServices) => this.doctorDeviceDetailsServices = doctorDeviceDetailsServices;

        /// <summary>
        /// The fetch all.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <remarks>
        /// ### REMARKS ###
        /// The following codes are returned
        /// - 200 - List.
        /// - 500 - Problem with Server side code.
        /// </remarks>
        [HttpPost]
        [Route("fetch")]
        [ProducesResponseType(typeof(string), 200)]
        [ProducesResponseType(500)]
        public async Task<ActionResult> FetchAsync([FromBody] VideoCallHistoryFilterModel model)
        {
            var response = await this.doctorDeviceDetailsServices.FetchAsync(model.AppointmentId);

            return this.Success(response);
        }

        /// <summary>
        /// The add async.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <remarks>
        /// ### REMARKS ###
        /// The following codes are returned
        /// - 200 - added.
        /// - 500 - Problem with Server side code.
        /// </remarks>
        [HttpPost]
        [Route("add")]
        [ProducesResponseType(typeof(string), 200)]
        [ProducesResponseType(500)]
        public async Task<ActionResult> AddAsync([FromBody] DoctorDeviceDetailsModel model)
        {
            var response = await this.doctorDeviceDetailsServices.InsertAsync(model);
            return this.Success(response);
        }
    }
}