using System;
using System.Text.Json.Serialization;
using BO.AppServer.Metadata.Enums;

namespace BO.Console.Options
{
    internal class Configuration
    {
        [JsonPropertyName("api-base-url")]
        public Uri ApiBaseUrl {get;set;}
        [JsonPropertyName("api-user")]
        public string ApiUser {get;set;}
        [JsonPropertyName("api-pwd")]
        public string ApiUserPwd {get;set;}
        [JsonPropertyName("api-magic")]
        public string ApiMagic {get;set;}
        [JsonPropertyName("api-timeout")]
        public string ApiTimeoutRaw {get;set;}
        public TimeSpan ApiTimeout => TimeSpan.Parse(ApiTimeoutRaw);

        [JsonPropertyName("default-page-size")]
        public int DefaultPageSize { get; set; }

        [JsonPropertyName("defaults")]
        public DefaultsCfg Defaults { get; set; }

        public class DefaultsCfg
        {
            [JsonPropertyName("workspace")]
            public DefaultWorkspaceCfg Workspace { get; set; }
        }


        public class DefaultWorkspaceCfg
        {
            [JsonPropertyName("api-key")]
            public string ApiKey { get; set; }
            [JsonPropertyName("api-key-password")]
            public string ApiKeyPassword { get; set; }
        }
    }
}
