//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Ajuna.NetApi.Model.Types.Base;
using Ajuna.ServiceLayer.Attributes;
using Ajuna.ServiceLayer.Storage;
using System.Collections.Generic;
using System.Threading.Tasks;


namespace Bajun.Network.NET.RestService.Generated.Storage
{
    
    
    /// <summary>
    /// IVestingStorage interface definition.
    /// </summary>
    public interface IVestingStorage : IStorage
    {
        
        /// <summary>
        /// >> VestingSchedules
        ///  Vesting schedules of an account.
        /// 
        ///  VestingSchedules: map AccountId => Vec<VestingSchedule>
        /// </summary>
        Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22 GetVestingSchedules(string key);
    }
    
    /// <summary>
    /// VestingStorage class definition.
    /// </summary>
    public sealed class VestingStorage : IVestingStorage
    {
        
        /// <summary>
        /// _vestingSchedulesTypedStorage typed storage field
        /// </summary>
        private TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22> _vestingSchedulesTypedStorage;
        
        /// <summary>
        /// VestingStorage constructor.
        /// </summary>
        public VestingStorage(IStorageDataProvider storageDataProvider, List<IStorageChangeDelegate> storageChangeDelegates)
        {
            this.VestingSchedulesTypedStorage = new TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22>("Vesting.VestingSchedules", storageDataProvider, storageChangeDelegates);
        }
        
        /// <summary>
        /// _vestingSchedulesTypedStorage property
        /// </summary>
        public TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22> VestingSchedulesTypedStorage
        {
            get
            {
                return _vestingSchedulesTypedStorage;
            }
            set
            {
                _vestingSchedulesTypedStorage = value;
            }
        }
        
        /// <summary>
        /// Connects to all storages and initializes the change subscription handling.
        /// </summary>
        public async Task InitializeAsync(Ajuna.ServiceLayer.Storage.IStorageDataProvider dataProvider)
        {
            await VestingSchedulesTypedStorage.InitializeAsync("Vesting", "VestingSchedules");
        }
        
        /// <summary>
        /// Implements any storage change for Vesting.VestingSchedules
        /// </summary>
        [StorageChange("Vesting", "VestingSchedules")]
        public void OnUpdateVestingSchedules(string key, string data)
        {
            VestingSchedulesTypedStorage.Update(key, data);
        }
        
        /// <summary>
        /// >> VestingSchedules
        ///  Vesting schedules of an account.
        /// 
        ///  VestingSchedules: map AccountId => Vec<VestingSchedule>
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22 GetVestingSchedules(string key)
        {
            if ((key == null))
            {
                return null;
            }
            if (VestingSchedulesTypedStorage.Dictionary.TryGetValue(key, out Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT22 result))
            {
                return result;
            }
            else
            {
                return null;
            }
        }
    }
}
