﻿using Service.Balances.Domain.Models;

namespace Service.Balances.Postgres
{
    public class BalanceEntity : WalletBalance
    {
        public string WalletId { get; set; }

        public static BalanceEntity Create(string walletId, WalletBalance balance)
        {
            return new BalanceEntity()
            {
                WalletId = walletId,
                AssetId = balance.AssetId
            }.Apply(balance);
        }

        public BalanceEntity Apply(WalletBalance balance)
        {
            Balance = balance.Balance;
            Reserve = balance.Reserve;
            LastUpdate = balance.LastUpdate;
            SequenceId = balance.SequenceId;

            return this;
        }
    }
}