using Managing.Core;
using Managing.Domain.Candles;
using Managing.Infrastructure.Databases.InfluxDb.Models;
using static Managing.Common.Enums;

namespace Managing.Infrastructure.Databases.InfluxDb;

public static class PriceHelpers
{
    public static PriceDto Map(Candle candle)
    {
        var price = new PriceDto
        {
            Exchange = candle.Exchange.ToString(),
            Ticker = candle.Ticker,
            OpenTime = candle.OpenTime,
            Open = candle.Open,
            Close = candle.Close,
            CloseTime = candle.Date,
            High = candle.High,
            Low = candle.Low,
            Timeframe = candle.Timeframe.ToString()
        };

        return price;
    }

    public static Candle Map(PriceDto dto)
    {
        return new Candle
        {
            Exchange = MiscExtensions.ParseEnum<TradingExchanges>(dto.Exchange),
            Ticker = dto.Ticker,
            OpenTime = dto.OpenTime,
            Open = dto.Open,
            Close = dto.Close,
            Date = dto.CloseTime,
            High = dto.High,
            Low = dto.Low,
            Timeframe = MiscExtensions.ParseEnum<Timeframe>(dto.Timeframe)
        };
    }
}