using GraphQL.Types;

namespace Books.Api.GraphQL.InputTypes;

public class StartBankConnectionInputType : InputObjectGraphType<StartBankConnectionInput>
{
    public StartBankConnectionInputType()
    {
        Name = "StartBankConnectionInput";
        Description = "Input for starting a bank connection";

        Field(x => x.CompanyId).Description("The company ID to connect the bank to");
        Field(x => x.AspspName).Description("The bank name (from availableBanks query)");
        Field(x => x.RedirectUrl).Description("URL to redirect back to after authorization");
        Field(x => x.PsuType, nullable: true).Description("PSU type: 'personal' or 'business' (default: personal)");
    }
}

public class StartBankConnectionInput
{
    public string CompanyId { get; set; } = string.Empty;
    public string AspspName { get; set; } = string.Empty;
    public string RedirectUrl { get; set; } = string.Empty;
    public string? PsuType { get; set; }
}

public class CompleteBankConnectionInputType : InputObjectGraphType<CompleteBankConnectionInput>
{
    public CompleteBankConnectionInputType()
    {
        Name = "CompleteBankConnectionInput";
        Description = "Input for completing a bank connection after authorization";

        Field(x => x.ConnectionId).Description("The bank connection ID from startBankConnection");
        Field(x => x.AuthorizationCode).Description("The authorization code from the bank callback");
    }
}

public class CompleteBankConnectionInput
{
    public string ConnectionId { get; set; } = string.Empty;
    public string AuthorizationCode { get; set; } = string.Empty;
}

public class LinkBankAccountInputType : InputObjectGraphType<LinkBankAccountInput>
{
    public LinkBankAccountInputType()
    {
        Name = "LinkBankAccountInput";
        Description = "Input for linking a bank account to a chart of accounts account";

        Field(x => x.ConnectionId).Description("The bank connection ID");
        Field(x => x.BankAccountId).Description("The bank account ID (from the connection's accounts list)");
        Field(x => x.LinkedAccountId).Description("The chart of accounts account ID to link to");
        Field(x => x.ImportFromDate, nullable: true).Description("Date to start importing transactions from (optional)");
    }
}

public class LinkBankAccountInput
{
    public string ConnectionId { get; set; } = string.Empty;
    public string BankAccountId { get; set; } = string.Empty;
    public string LinkedAccountId { get; set; } = string.Empty;
    public DateTime? ImportFromDate { get; set; }
}

public class ReconnectBankConnectionInputType : InputObjectGraphType<ReconnectBankConnectionInput>
{
    public ReconnectBankConnectionInputType()
    {
        Name = "ReconnectBankConnectionInput";
        Description = "Input for reconnecting an expired, failed, or disconnected bank connection";

        Field(x => x.ConnectionId).Description("The bank connection ID to reconnect");
        Field(x => x.RedirectUrl).Description("URL to redirect back to after authorization");
        Field(x => x.PsuType, nullable: true).Description("PSU type: 'personal' or 'business' (default: personal)");
    }
}

public class ReconnectBankConnectionInput
{
    public string ConnectionId { get; set; } = string.Empty;
    public string RedirectUrl { get; set; } = string.Empty;
    public string? PsuType { get; set; }
}
