﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShoperRestApiClient.Entities;
using ShoperRestApiClient.Entities.FilterEntities;

namespace ShoperRestApiClient.Factories
{
    public class ProductStocksFactory : BaseFactory, IFactory<Entities.productStock, Entities.FilterEntities.productStock>
    {
        public ProductStocksFactory(Authorization.Context context, Configurations.Client configuration = null)
            : base(context, configuration)
        {
        }

        public int Create(Entities.productStock entity)
        {
            return Execute<int>("product-stocks", RestSharp.Method.POST, entity);
        }

        public bool Delete(int id)
        {
            return Execute<bool>("product-stocks/" + id, RestSharp.Method.DELETE);
        }

        public List<Entities.productStock> GetAll(Entities.FilterEntities.productStock filter)
        {
            List<RestSharp.Parameter> parameters = null;
            if (filter != null)
            {
                parameters = new List<RestSharp.Parameter>();
                parameters.Add(new RestSharp.Parameter
                {
                    Name = "filters",
                    Value = filter,
                    Type = RestSharp.ParameterType.QueryString
                });
            }

            return ExecuteGetList<Entities.productStock>("product-stocks", RestSharp.Method.GET, null, parameters);
        }

        public List<Entities.productStock> GetAll()
        {
            return GetAll(null);
        }

        public Entities.productStock GetById(int id)
        {
            return Execute<Entities.productStock>("product-stocks/" + id, RestSharp.Method.GET);
        }

        public bool Update(int id, Entities.productStock entity)
        {
            return Execute<bool>("product-stocks/" + id, RestSharp.Method.PUT, entity);
        }
    }
}
