﻿namespace Stove.StoveSDK
{
    using System;
    using System.Collections.Generic;
    using MiniJSON;

    /**
     * Push's settings.
     * @param enabledDay Whether receive push during the day.
     * @param enabledNight Whether receive push during the night.
     * @since 2.0.0
     */
    public class PushSettings
    {
        /**
         * Whether receive push during the day.
         * Set to BOOL type.
         * @since 2.0.0
         */
        public bool? EnabledDay { get; }

        /**
         * Whether receive push during the night.
         * Set to BOOL type.
         * @since 2.0.0
         */
        public bool? EnabledNight { get; }

        public PushSettings(bool? enabledDay, bool? enabledNight)
        {
            EnabledDay = enabledDay;
            EnabledNight = enabledNight;
        }

        /**
         * Dictionary serialization.
         * @since 2.0.0
         */
        public PushSettings(Dictionary<string, object> dictionary)
        {
            if (dictionary.ContainsKey("enabledDay"))
            {
                EnabledDay = Convert.ToBoolean(dictionary["enabledDay"]);
            }

            if (dictionary.ContainsKey("enabledNight"))
            {
                EnabledNight = Convert.ToBoolean(dictionary["enabledNight"]);
            }
        }

        /**
         * Dictionary deserialization.
         * @since 2.0.0
         */
        public Dictionary<string, object> ToDictionary()
        {
            Dictionary<string, object> dictionary = new Dictionary<string, object>();

            if (EnabledDay != null)
            {
                dictionary.Add("enabledDay", EnabledDay);
            }

            if (EnabledNight != null)
            {
                dictionary.Add("enabledNight", EnabledNight);
            }

            return dictionary;
        }

        /**
         * JSON serialization.
         * @since 2.0.0
         */
        public string ToJSONString()
        {
            Dictionary<string, object> dictionary = ToDictionary();

            return Json.Serialize(dictionary);
        }

        public override string ToString()
        {
            return "PushSettings(EnabledDay=" + EnabledDay + ", EnabledNight=" + EnabledNight + ")";
        }
    }
}
