namespace Csob.Client;

/// <summary>
/// Central registry of ČSOB PSD2 resource path templates (relative to <c>CSOB_API_BASE_URL</c>).
///
/// Paths follow the Czech Open Banking Standard (COBS) as implemented by ČSOB. The account-scoped
/// AISP paths and the PISP <c>/my/payments/.../sign/{signId}</c> authorization flow are confirmed
/// against the ČSOB developer portal; the remaining COBS resources use the same <c>/my/</c> prefix.
/// Keep every path here so a portal-specific correction is a single-file change.
/// </summary>
public static class CsobApiPaths
{
    // ----- AISP (Account Information) -----
    public const string Accounts = "/my/accounts";
    public static string Account(string id) => $"/my/accounts/{Esc(id)}";
    public static string Balance(string accountId) => $"/my/accounts/{Esc(accountId)}/balance";
    public static string Transactions(string accountId) => $"/my/accounts/{Esc(accountId)}/transactions";
    public static string AwaitingTransactions(string accountId) => $"/my/accounts/{Esc(accountId)}/transactions/awaiting";
    public static string AccountStandingOrders(string accountId) => $"/my/accounts/{Esc(accountId)}/standingorders";
    public static string AccountStandingOrder(string accountId, string standingOrderId) => $"/my/accounts/{Esc(accountId)}/standingorders/{Esc(standingOrderId)}";
    public static string AccountDirectDebits(string accountId) => $"/my/accounts/{Esc(accountId)}/directdebits";

    // ----- PISP (Payment Initiation) -----
    public const string Payments = "/my/payments";
    public static string Payment(string id) => $"/my/payments/{Esc(id)}";
    public static string PaymentStatus(string id) => $"/my/payments/{Esc(id)}/status";
    public static string PaymentSign(string id, string signId) => $"/my/payments/{Esc(id)}/sign/{Esc(signId)}";

    public const string StandingOrders = "/my/standingorders";
    public static string StandingOrder(string id) => $"/my/standingorders/{Esc(id)}";
    public static string StandingOrderStatus(string id) => $"/my/standingorders/{Esc(id)}/status";
    public static string StandingOrderSign(string id, string signId) => $"/my/standingorders/{Esc(id)}/sign/{Esc(signId)}";

    public const string DirectDebits = "/my/directdebits";
    public static string DirectDebit(string id) => $"/my/directdebits/{Esc(id)}";
    public static string DirectDebitStatus(string id) => $"/my/directdebits/{Esc(id)}/status";
    public static string DirectDebitSign(string id, string signId) => $"/my/directdebits/{Esc(id)}/sign/{Esc(signId)}";

    // ----- Common (Consents) -----
    public const string Consents = "/consents";
    public static string Consent(string id) => $"/consents/{Esc(id)}";

    private static string Esc(string segment) => Uri.EscapeDataString(segment);
}
