57 lines
3.2 KiB
Text
57 lines
3.2 KiB
Text
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
||
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||
|
|
|
||
|
|
export module Nostro.App:Banks;
|
||
|
|
|
||
|
|
import std;
|
||
|
|
|
||
|
|
// The banks the app can connect, and what is a bank's own: its name, the ways a connection to it is made, and what
|
||
|
|
// each way lets a connection do. The settings are built from this: adding a connection lists the banks, a bank lists
|
||
|
|
// its ways, and each way has a form of its own (bunq's are in Nostro.App-Bunq.cpp). Nothing else in the app names a
|
||
|
|
// bank or a way: every other screen says "your bank", and asks here what a connection can do. A bank and a way are
|
||
|
|
// found by what nostrod calls them, and one that nostrod has and this app does not know is shown by that name.
|
||
|
|
|
||
|
|
export namespace Nostro::App {
|
||
|
|
// The form a way is filled in on. One for each way of each bank: what a bank asks for is its own.
|
||
|
|
enum class ConnectForm : std::uint8_t {
|
||
|
|
BunqKey,
|
||
|
|
BunqOAuth
|
||
|
|
};
|
||
|
|
|
||
|
|
// One way to connect to a bank.
|
||
|
|
struct Way {
|
||
|
|
std::string_view key; // names it in a route and a region: "key"
|
||
|
|
std::string_view auth; // what nostrod calls a connection made this way (ConnectorSummary::auth): "api key"
|
||
|
|
std::string_view title; // "API key"
|
||
|
|
std::string_view about; // what it gives and what it takes, in a line for under its title
|
||
|
|
std::string_view revoke; // what stays valid at the bank once a connection is removed, and where it is revoked
|
||
|
|
ConnectForm form = ConnectForm::BunqKey;
|
||
|
|
// A connection made this way pays between the user's own accounts and nobody else. What it cannot pay it can
|
||
|
|
// save as a draft, so this is for a bank that has drafts.
|
||
|
|
bool ownAccountsOnly = false;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct Bank {
|
||
|
|
std::string_view id; // what nostrod calls it (ConnectorSummary::bank): "bunq"
|
||
|
|
std::string_view name; // as the bank writes its own name
|
||
|
|
std::span<const Way> ways;
|
||
|
|
};
|
||
|
|
|
||
|
|
// The banks the app can connect, in the order they are offered.
|
||
|
|
std::span<const Bank> Banks() noexcept;
|
||
|
|
// The bank nostrod calls `id`; null for one this app does not know.
|
||
|
|
const Bank* FindBank(std::string_view id) noexcept;
|
||
|
|
// The way a connection to that bank was made, by what nostrod calls the bank and the way; null for one this app
|
||
|
|
// does not know.
|
||
|
|
const Way* FindWay(std::string_view bank, std::string_view auth) noexcept;
|
||
|
|
|
||
|
|
// A bank's name as it writes it, and what nostrod calls it for one this app does not know.
|
||
|
|
std::string BankName(std::string_view id);
|
||
|
|
// How a connection was made, in words: "API key", and what nostrod calls it for a way this app does not know.
|
||
|
|
std::string WayName(std::string_view bank, std::string_view auth);
|
||
|
|
// Whether a connection made that way pays between the user's own accounts only. Not that the app knows of, for a
|
||
|
|
// way it does not know: nostrod refuses what such a connection cannot do.
|
||
|
|
bool OwnAccountsOnly(std::string_view bank, std::string_view auth) noexcept;
|
||
|
|
// What a connection was made with stays valid at the bank when the connection is removed: where to revoke it.
|
||
|
|
std::string Revoking(std::string_view bank, std::string_view auth);
|
||
|
|
}
|