feat(app): add the Nostro app, a window for phones and desktops

Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.

- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
  from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
  Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
  nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
  with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
  net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
  Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
  look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
  --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.

The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
  without asking the bank. The app searches with it; before, every search was
  a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
  a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
  as DEACTIVATED however well it pays, and leaves it as it is when asked,
  without an error.

The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.

Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.

Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-19 12:27:14 +01:00
commit 5b4037955b
106 changed files with 17804 additions and 289 deletions

View file

@ -13,6 +13,7 @@ import :Account;
import :Bunq;
import :Currency;
import :Transaction;
import :Utils;
using namespace Nostro;
using namespace Nostro::Bus;
@ -32,46 +33,149 @@ Client Client::System(std::chrono::seconds timeout) {
Client::Client(BusPtr bus) : bus(std::move(bus)) {
}
void Client::Attach(sd_event* event) {
ThrowOnSdBus(sd_bus_attach_event(bus.get(), event, SD_EVENT_PRIORITY_NORMAL), "attach to an event loop");
}
bool Client::Connected() const {
return sd_bus_is_open(bus.get()) > 0;
}
namespace {
// nostrod's error, as an exception: input it refused as std::invalid_argument, the rest as a DaemonError.
// One method of nostrod's interface: its member, whether it changes anything (for what a lost answer means), and
// how its answer is read.
template<typename R>
struct MethodCall {
std::string_view member;
bool changes = false;
R (*read)(sd_bus_message*) = nullptr;
};
// What an asynchronous call keeps until its answer, freed with the call's slot.
struct Waiting {
bool answered = false;
virtual ~Waiting() = default;
};
template<typename R>
struct WaitingFor : Waiting {
MethodCall<R> call;
Client::Then<R> then;
};
// nostrod's error, as an exception: input it refused as std::invalid_argument, the rest as a DaemonError, and what
// may or may not have happened as OutcomeUnknown.
[[noreturn]] void Throw(const sd_bus_error& error, bool changes) {
const std::string name = ErrorName(error);
const std::string message = ErrorMessage(error);
if(name == SD_BUS_ERROR_SERVICE_UNKNOWN) {
throw std::runtime_error(std::format("nostrod is not running, and the system bus cannot start it: is it installed? ({})", message));
throw DaemonMissing(std::format("nostrod is not running, and the system bus cannot start it: is it installed? ({})", message));
}
if(name == errorInvalidArgument) {
throw std::invalid_argument(message);
}
if(changes && (name == SD_BUS_ERROR_NO_REPLY || name == SD_BUS_ERROR_TIMEOUT)) {
throw std::runtime_error(std::format("nostrod did not answer in time ({}): what you asked for may have been carried out, check before trying again", message));
throw OutcomeUnknown(std::format("nostrod did not answer in time ({}): what you asked for may have been carried out, check before trying again", message));
}
// bunq's error to a write that may have gone through all the same says so at its end, as the checkout's
// published interface documents for net.catcrafts.Nostro1.Error.Bank.
if(changes && name == errorBank && message.ends_with(BunqError::maybeCarriedOut)) {
throw OutcomeUnknown(message);
}
throw DaemonError(name, message);
}
// Calls `member` with what `append` appends, reads the answer with `read`, and keeps the notes that end it.
// `changes` says whether the call moves money or changes anything, for what a lost answer means.
template<typename AppendArguments, typename ReadAnswer>
auto Call(sd_bus* bus, std::vector<std::string>& notes, std::string_view member, bool changes, AppendArguments&& append, ReadAnswer&& read) {
std::exception_ptr ErrorOf(const sd_bus_error& error, bool changes) {
try {
Throw(error, changes);
} catch(...) {
return std::current_exception();
}
}
MessagePtr NewCall(sd_bus* bus, std::string_view member) {
sd_bus_message* raw = nullptr;
ThrowOnSdBus(sd_bus_message_new_method_call(bus, &raw, busName.data(), objectPath.data(), interfaceName.data(), std::string(member).c_str()), "call nostrod");
const MessagePtr call(raw);
MessagePtr call(raw);
if(IsSensitive(member)) {
ThrowOnSdBus(sd_bus_message_sensitive(raw), "call nostrod");
}
append(raw);
return call;
}
// Calls `call` with what `append` appends and waits for the answer, keeping the notes that end it.
template<typename R, typename Append>
R Run(sd_bus* bus, std::vector<std::string>& notes, const MethodCall<R>& call, Append&& append) {
const MessagePtr message = NewCall(bus, call.member);
append(message.get());
Error error;
sd_bus_message* answer = nullptr;
if(sd_bus_call(bus, raw, 0, &error.error, &answer) < 0) {
Throw(error.error, changes);
if(sd_bus_call(bus, message.get(), 0, &error.error, &answer) < 0) {
Throw(error.error, call.changes);
}
const MessagePtr reply(answer);
auto result = read(answer);
R result = call.read(answer);
const std::vector<std::string> more = Read<std::vector<std::string>>(answer);
notes.insert(notes.end(), more.begin(), more.end());
return result;
}
template<typename R>
Answer<R> Failure(std::exception_ptr error) {
return Answer<R>{std::variant<R, std::exception_ptr>(std::in_place_index<1>, std::move(error)), {}};
}
// An answer to an asynchronous call, read and handed to its `then`. It never throws: sd-bus calls it from C.
template<typename R>
std::int32_t OnReply(sd_bus_message* reply, void* userdata, sd_bus_error*) {
WaitingFor<R>& waiting = *static_cast<WaitingFor<R>*>(userdata);
waiting.answered = true;
Answer<R> answer = [&waiting, reply] {
try {
if(sd_bus_message_is_method_error(reply, nullptr)) {
return Failure<R>(ErrorOf(*sd_bus_message_get_error(reply), waiting.call.changes));
}
R result = waiting.call.read(reply);
std::vector<std::string> notes = Read<std::vector<std::string>>(reply);
return Answer<R>{std::variant<R, std::exception_ptr>(std::in_place_index<0>, std::move(result)), std::move(notes)};
} catch(...) {
return Failure<R>(std::current_exception());
}
}();
// sd-bus holds the slot while this runs, so `then` may cancel its own Pending.
try {
waiting.then(std::move(answer));
} catch(const std::exception& e) {
Note(std::format("nostrod's answer to {} could not be handled: {}", waiting.call.member, e.what()));
} catch(...) {
Note(std::format("nostrod's answer to {} could not be handled", waiting.call.member));
}
return 0;
}
void DeleteWaiting(void* userdata) {
delete static_cast<Waiting*>(userdata);
}
// Sends `call` with what `append` appends, and returns the slot that waits for its answer.
template<typename R, typename Append>
sd_bus_slot* Start(sd_bus* bus, const MethodCall<R>& call, Append&& append, Client::Then<R>&& then) {
if(sd_bus_get_event(bus) == nullptr) {
throw std::logic_error(std::format("nostrod's {} was called to answer later, but the client is attached to no event loop: call Attach first", call.member));
}
const MessagePtr message = NewCall(bus, call.member);
append(message.get());
std::unique_ptr<WaitingFor<R>> waiting = std::make_unique<WaitingFor<R>>();
waiting->call = call;
waiting->then = std::move(then);
sd_bus_slot* slot = nullptr;
ThrowOnSdBus(sd_bus_call_async(bus, &slot, message.get(), OnReply<R>, waiting.get(), 0), "call nostrod");
// The slot frees what waits for the answer when it goes: once its Pending is destroyed or cancelled.
sd_bus_slot_set_destroy_callback(slot, DeleteWaiting);
waiting.release();
return slot;
}
void Nothing(sd_bus_message*) {
}
@ -95,6 +199,34 @@ namespace {
return created;
}
template<typename T>
T ReadAs(sd_bus_message* reply) {
return Read<T>(reply);
}
constexpr MethodCall<std::vector<ConnectorSummary>> connectorsCall{"Connectors", false, ReadAs<std::vector<ConnectorSummary>>};
constexpr MethodCall<AddedConnector> addBunqCall{"AddBunq", true, ReadAdded};
constexpr MethodCall<AddedConnector> addBunqOAuthCall{"AddBunqOAuth", true, ReadAdded};
constexpr MethodCall<std::string> removeConnectorCall{"RemoveConnector", true, ReadAs<std::string>};
constexpr MethodCall<std::vector<ConnectorAccounts>> accountsCall{"Accounts", false, ReadAs<std::vector<ConnectorAccounts>>};
constexpr MethodCall<std::vector<Transaction>> transactionsCall{"Transactions", false, ReadAs<std::vector<Transaction>>};
constexpr MethodCall<Created> sendCall{"Send", true, ReadCreated};
constexpr MethodCall<Created> scheduleCall{"Schedule", true, ReadCreated};
constexpr MethodCall<Created> draftCall{"Draft", true, ReadCreated};
constexpr MethodCall<BunqPaymentRequest> requestCall{"Request", true, ReadAs<BunqPaymentRequest>};
constexpr MethodCall<std::vector<BunqPaymentRequest>> requestsCall{"Requests", false, ReadAs<std::vector<BunqPaymentRequest>>};
constexpr MethodCall<std::monostate> revokeRequestCall{"RevokeRequest", true, NoAnswer};
constexpr MethodCall<std::vector<BunqIncomingRequest>> incomingRequestsCall{"IncomingRequests", false, ReadAs<std::vector<BunqIncomingRequest>>};
constexpr MethodCall<std::monostate> respondToRequestCall{"RespondToRequest", true, NoAnswer};
constexpr MethodCall<std::vector<BunqScheduledPayment>> scheduledPaymentsCall{"ScheduledPayments", false, ReadAs<std::vector<BunqScheduledPayment>>};
constexpr MethodCall<std::monostate> cancelScheduledPaymentCall{"CancelScheduledPayment", true, NoAnswer};
constexpr MethodCall<std::vector<BunqDraftPayment>> draftPaymentsCall{"DraftPayments", false, ReadAs<std::vector<BunqDraftPayment>>};
constexpr MethodCall<std::monostate> respondToDraftPaymentCall{"RespondToDraftPayment", true, NoAnswer};
constexpr MethodCall<std::vector<ConnectorCards>> cardsCall{"Cards", false, ReadAs<std::vector<ConnectorCards>>};
constexpr MethodCall<BunqCard> setCardStatusCall{"SetCardStatus", true, ReadAs<BunqCard>};
constexpr MethodCall<std::optional<Account>> defaultCheckoutAccountCall{"DefaultCheckoutAccount", false, ReadAs<std::optional<Account>>};
constexpr MethodCall<Account> setDefaultCheckoutAccountCall{"SetDefaultCheckoutAccount", true, ReadAs<Account>};
// The arguments a payment, a draft, a schedule and a request share.
auto PaymentArguments(std::string_view account, std::string_view counterparty, std::string_view name, std::int64_t amount, std::string_view description) {
return [=](sd_bus_message* call) {
@ -106,6 +238,13 @@ namespace {
};
}
auto ScheduleArguments(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description, const BunqSchedule& schedule) {
return [payment = PaymentArguments(account, to, name, amount, description), &schedule](sd_bus_message* call) {
payment(call);
Append(call, schedule);
};
}
auto AccountArgument(std::string_view account) {
return [account](sd_bus_message* call) {
Append(call, std::string(account));
@ -119,126 +258,247 @@ namespace {
};
}
template<typename T>
T ReadAs(sd_bus_message* reply) {
return Read<T>(reply);
auto ResponseArguments(std::string_view account, std::uint64_t id, bool accept) {
return [account, id, accept](sd_bus_message* call) {
Append(call, std::string(account));
Append(call, id);
Append(call, accept);
};
}
auto BunqKeyArguments(std::string_view apiKey, std::string_view allowedIps, std::string_view environment) {
return [=](sd_bus_message* call) {
Append(call, std::string(apiKey));
Append(call, std::string(allowedIps));
Append(call, std::string(environment));
};
}
auto OAuthArguments(std::string_view environment, std::string_view clientId, std::string_view clientSecret, std::string_view redirectUri, std::string_view code) {
return [=](sd_bus_message* call) {
Append(call, std::string(environment));
Append(call, std::string(clientId));
Append(call, std::string(clientSecret));
Append(call, std::string(redirectUri));
Append(call, std::string(code));
};
}
auto TransactionArguments(std::string_view account, const TransactionQuery& query) {
return [account, &query](sd_bus_message* call) {
Append(call, std::string(account));
AppendQuery(call, query);
};
}
auto CardArguments(std::uint64_t card, std::string_view status) {
return [card, status](sd_bus_message* call) {
Append(call, card);
Append(call, std::string(status));
};
}
}
Client::Pending::Pending(sd_bus_slot* slot) : slot(slot) {
}
Client::Pending::Pending(Pending&& other) noexcept : slot(std::exchange(other.slot, nullptr)) {
}
Client::Pending& Client::Pending::operator=(Pending&& other) noexcept {
// What this waited for is dropped with `moved`.
Pending moved(std::move(other));
std::swap(slot, moved.slot);
return *this;
}
Client::Pending::~Pending() {
Cancel();
}
void Client::Pending::Cancel() {
// Freeing the slot takes the answer's callback off the bus, and frees what waited for it.
slot = sd_bus_slot_unref(slot);
}
bool Client::Pending::Active() const {
return slot != nullptr && !static_cast<const Waiting*>(sd_bus_slot_get_userdata(slot))->answered;
}
std::vector<ConnectorSummary> Client::Connectors() {
return Call(bus.get(), notes, "Connectors", false, Nothing, ReadAs<std::vector<ConnectorSummary>>);
return Run(bus.get(), notes, connectorsCall, Nothing);
}
Client::Pending Client::Connectors(Then<std::vector<ConnectorSummary>> then) {
return Pending(Start(bus.get(), connectorsCall, Nothing, std::move(then)));
}
AddedConnector Client::AddBunq(std::string_view apiKey, std::string_view allowedIps, std::string_view environment) {
return Call(bus.get(), notes, "AddBunq", true, [=](sd_bus_message* call) {
Append(call, std::string(apiKey));
Append(call, std::string(allowedIps));
Append(call, std::string(environment));
}, ReadAdded);
return Run(bus.get(), notes, addBunqCall, BunqKeyArguments(apiKey, allowedIps, environment));
}
Client::Pending Client::AddBunq(std::string_view apiKey, std::string_view allowedIps, std::string_view environment, Then<AddedConnector> then) {
return Pending(Start(bus.get(), addBunqCall, BunqKeyArguments(apiKey, allowedIps, environment), std::move(then)));
}
AddedConnector Client::AddBunqOAuth(std::string_view environment, std::string_view clientId, std::string_view clientSecret, std::string_view redirectUri, std::string_view code) {
return Call(bus.get(), notes, "AddBunqOAuth", true, [=](sd_bus_message* call) {
Append(call, std::string(environment));
Append(call, std::string(clientId));
Append(call, std::string(clientSecret));
Append(call, std::string(redirectUri));
Append(call, std::string(code));
}, ReadAdded);
return Run(bus.get(), notes, addBunqOAuthCall, OAuthArguments(environment, clientId, clientSecret, redirectUri, code));
}
Client::Pending Client::AddBunqOAuth(std::string_view environment, std::string_view clientId, std::string_view clientSecret, std::string_view redirectUri, std::string_view code, Then<AddedConnector> then) {
return Pending(Start(bus.get(), addBunqOAuthCall, OAuthArguments(environment, clientId, clientSecret, redirectUri, code), std::move(then)));
}
std::string Client::RemoveConnector(std::string_view connector) {
return Call(bus.get(), notes, "RemoveConnector", true, AccountArgument(connector), ReadAs<std::string>);
return Run(bus.get(), notes, removeConnectorCall, AccountArgument(connector));
}
Client::Pending Client::RemoveConnector(std::string_view connector, Then<std::string> then) {
return Pending(Start(bus.get(), removeConnectorCall, AccountArgument(connector), std::move(then)));
}
std::vector<ConnectorAccounts> Client::Accounts() {
return Call(bus.get(), notes, "Accounts", false, Nothing, ReadAs<std::vector<ConnectorAccounts>>);
return Run(bus.get(), notes, accountsCall, Nothing);
}
Client::Pending Client::Accounts(Then<std::vector<ConnectorAccounts>> then) {
return Pending(Start(bus.get(), accountsCall, Nothing, std::move(then)));
}
std::vector<Transaction> Client::Transactions(std::string_view account, const TransactionQuery& query) {
return Call(bus.get(), notes, "Transactions", false, [account, &query](sd_bus_message* call) {
Append(call, std::string(account));
AppendQuery(call, query);
}, ReadAs<std::vector<Transaction>>);
return Run(bus.get(), notes, transactionsCall, TransactionArguments(account, query));
}
Client::Pending Client::Transactions(std::string_view account, const TransactionQuery& query, Then<std::vector<Transaction>> then) {
return Pending(Start(bus.get(), transactionsCall, TransactionArguments(account, query), std::move(then)));
}
Created Client::Send(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description) {
return Call(bus.get(), notes, "Send", true, PaymentArguments(account, to, name, amount, description), ReadCreated);
return Run(bus.get(), notes, sendCall, PaymentArguments(account, to, name, amount, description));
}
Client::Pending Client::Send(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description, Then<Created> then) {
return Pending(Start(bus.get(), sendCall, PaymentArguments(account, to, name, amount, description), std::move(then)));
}
Created Client::Schedule(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description, const BunqSchedule& schedule) {
const auto payment = PaymentArguments(account, to, name, amount, description);
return Call(bus.get(), notes, "Schedule", true, [&payment, &schedule](sd_bus_message* call) {
payment(call);
Append(call, schedule);
}, ReadCreated);
return Run(bus.get(), notes, scheduleCall, ScheduleArguments(account, to, name, amount, description, schedule));
}
Client::Pending Client::Schedule(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description, const BunqSchedule& schedule, Then<Created> then) {
return Pending(Start(bus.get(), scheduleCall, ScheduleArguments(account, to, name, amount, description, schedule), std::move(then)));
}
Created Client::Draft(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description) {
return Call(bus.get(), notes, "Draft", true, PaymentArguments(account, to, name, amount, description), ReadCreated);
return Run(bus.get(), notes, draftCall, PaymentArguments(account, to, name, amount, description));
}
Client::Pending Client::Draft(std::string_view account, std::string_view to, std::string_view name, std::int64_t amount, std::string_view description, Then<Created> then) {
return Pending(Start(bus.get(), draftCall, PaymentArguments(account, to, name, amount, description), std::move(then)));
}
BunqPaymentRequest Client::Request(std::string_view account, std::string_view from, std::string_view name, std::int64_t amount, std::string_view description) {
return Call(bus.get(), notes, "Request", true, PaymentArguments(account, from, name, amount, description), ReadAs<BunqPaymentRequest>);
return Run(bus.get(), notes, requestCall, PaymentArguments(account, from, name, amount, description));
}
Client::Pending Client::Request(std::string_view account, std::string_view from, std::string_view name, std::int64_t amount, std::string_view description, Then<BunqPaymentRequest> then) {
return Pending(Start(bus.get(), requestCall, PaymentArguments(account, from, name, amount, description), std::move(then)));
}
std::vector<BunqPaymentRequest> Client::Requests(std::string_view account) {
return Call(bus.get(), notes, "Requests", false, AccountArgument(account), ReadAs<std::vector<BunqPaymentRequest>>);
return Run(bus.get(), notes, requestsCall, AccountArgument(account));
}
Client::Pending Client::Requests(std::string_view account, Then<std::vector<BunqPaymentRequest>> then) {
return Pending(Start(bus.get(), requestsCall, AccountArgument(account), std::move(then)));
}
void Client::RevokeRequest(std::string_view account, std::uint64_t id) {
Call(bus.get(), notes, "RevokeRequest", true, AccountAndId(account, id), NoAnswer);
Run(bus.get(), notes, revokeRequestCall, AccountAndId(account, id));
}
Client::Pending Client::RevokeRequest(std::string_view account, std::uint64_t id, Then<std::monostate> then) {
return Pending(Start(bus.get(), revokeRequestCall, AccountAndId(account, id), std::move(then)));
}
std::vector<BunqIncomingRequest> Client::IncomingRequests(std::string_view account) {
return Call(bus.get(), notes, "IncomingRequests", false, AccountArgument(account), ReadAs<std::vector<BunqIncomingRequest>>);
return Run(bus.get(), notes, incomingRequestsCall, AccountArgument(account));
}
Client::Pending Client::IncomingRequests(std::string_view account, Then<std::vector<BunqIncomingRequest>> then) {
return Pending(Start(bus.get(), incomingRequestsCall, AccountArgument(account), std::move(then)));
}
void Client::RespondToRequest(std::string_view account, std::uint64_t id, bool accept) {
Call(bus.get(), notes, "RespondToRequest", true, [account, id, accept](sd_bus_message* call) {
Append(call, std::string(account));
Append(call, id);
Append(call, accept);
}, NoAnswer);
Run(bus.get(), notes, respondToRequestCall, ResponseArguments(account, id, accept));
}
Client::Pending Client::RespondToRequest(std::string_view account, std::uint64_t id, bool accept, Then<std::monostate> then) {
return Pending(Start(bus.get(), respondToRequestCall, ResponseArguments(account, id, accept), std::move(then)));
}
std::vector<BunqScheduledPayment> Client::ScheduledPayments(std::string_view account) {
return Call(bus.get(), notes, "ScheduledPayments", false, AccountArgument(account), ReadAs<std::vector<BunqScheduledPayment>>);
return Run(bus.get(), notes, scheduledPaymentsCall, AccountArgument(account));
}
Client::Pending Client::ScheduledPayments(std::string_view account, Then<std::vector<BunqScheduledPayment>> then) {
return Pending(Start(bus.get(), scheduledPaymentsCall, AccountArgument(account), std::move(then)));
}
void Client::CancelScheduledPayment(std::string_view account, std::uint64_t id) {
Call(bus.get(), notes, "CancelScheduledPayment", true, AccountAndId(account, id), NoAnswer);
Run(bus.get(), notes, cancelScheduledPaymentCall, AccountAndId(account, id));
}
Client::Pending Client::CancelScheduledPayment(std::string_view account, std::uint64_t id, Then<std::monostate> then) {
return Pending(Start(bus.get(), cancelScheduledPaymentCall, AccountAndId(account, id), std::move(then)));
}
std::vector<BunqDraftPayment> Client::DraftPayments(std::string_view account) {
return Call(bus.get(), notes, "DraftPayments", false, AccountArgument(account), ReadAs<std::vector<BunqDraftPayment>>);
return Run(bus.get(), notes, draftPaymentsCall, AccountArgument(account));
}
Client::Pending Client::DraftPayments(std::string_view account, Then<std::vector<BunqDraftPayment>> then) {
return Pending(Start(bus.get(), draftPaymentsCall, AccountArgument(account), std::move(then)));
}
void Client::RespondToDraftPayment(std::string_view account, std::uint64_t id, bool accept) {
Call(bus.get(), notes, "RespondToDraftPayment", true, [account, id, accept](sd_bus_message* call) {
Append(call, std::string(account));
Append(call, id);
Append(call, accept);
}, NoAnswer);
Run(bus.get(), notes, respondToDraftPaymentCall, ResponseArguments(account, id, accept));
}
Client::Pending Client::RespondToDraftPayment(std::string_view account, std::uint64_t id, bool accept, Then<std::monostate> then) {
return Pending(Start(bus.get(), respondToDraftPaymentCall, ResponseArguments(account, id, accept), std::move(then)));
}
std::vector<ConnectorCards> Client::Cards() {
return Call(bus.get(), notes, "Cards", false, Nothing, ReadAs<std::vector<ConnectorCards>>);
return Run(bus.get(), notes, cardsCall, Nothing);
}
Client::Pending Client::Cards(Then<std::vector<ConnectorCards>> then) {
return Pending(Start(bus.get(), cardsCall, Nothing, std::move(then)));
}
BunqCard Client::SetCardStatus(std::uint64_t card, std::string_view status) {
return Call(bus.get(), notes, "SetCardStatus", true, [card, status](sd_bus_message* call) {
Append(call, card);
Append(call, std::string(status));
}, ReadAs<BunqCard>);
return Run(bus.get(), notes, setCardStatusCall, CardArguments(card, status));
}
Client::Pending Client::SetCardStatus(std::uint64_t card, std::string_view status, Then<BunqCard> then) {
return Pending(Start(bus.get(), setCardStatusCall, CardArguments(card, status), std::move(then)));
}
std::optional<Account> Client::DefaultCheckoutAccount() {
return Call(bus.get(), notes, "DefaultCheckoutAccount", false, Nothing, ReadAs<std::optional<Account>>);
return Run(bus.get(), notes, defaultCheckoutAccountCall, Nothing);
}
Client::Pending Client::DefaultCheckoutAccount(Then<std::optional<Account>> then) {
return Pending(Start(bus.get(), defaultCheckoutAccountCall, Nothing, std::move(then)));
}
Account Client::SetDefaultCheckoutAccount(std::string_view account) {
return Call(bus.get(), notes, "SetDefaultCheckoutAccount", true, AccountArgument(account), ReadAs<Account>);
return Run(bus.get(), notes, setDefaultCheckoutAccountCall, AccountArgument(account));
}
Client::Pending Client::SetDefaultCheckoutAccount(std::string_view account, Then<Account> then) {
return Pending(Start(bus.get(), setDefaultCheckoutAccountCall, AccountArgument(account), std::move(then)));
}
std::vector<std::string> Client::TakeNotes() {