initial commit
This commit is contained in:
commit
be13205ffd
19 changed files with 33596 additions and 0 deletions
67
interfaces/Nostro-Bunq.cppm
Normal file
67
interfaces/Nostro-Bunq.cppm
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
//SPDX-License-Identifier: LGPL-3.0-only
|
||||
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
module;
|
||||
|
||||
#ifdef NOSTRO_BUNQ_ENABLED
|
||||
#include "../lib/json.hpp"
|
||||
#include <openssl/types.h>
|
||||
#endif
|
||||
|
||||
export module Nostro:Bunq;
|
||||
#ifdef NOSTRO_BUNQ_ENABLED
|
||||
|
||||
import std;
|
||||
import Crafter.Network;
|
||||
import :Account;
|
||||
import :Currency;
|
||||
import :Transaction;
|
||||
|
||||
using namespace Crafter;
|
||||
|
||||
namespace Nostro {
|
||||
export struct BunqConnector;
|
||||
|
||||
export struct BunqAccount : public Account {
|
||||
std::uint32_t id;
|
||||
BunqConnector* connector;
|
||||
|
||||
BunqAccount(std::string&& name, std::string&& bic, std::string&& iban, Currency currency, std::int64_t balance, std::uint32_t id, BunqConnector* connector);
|
||||
void Send(std::string_view iban, std::string_view name, std::int64_t amount, Currency currency) const;
|
||||
void Send(std::string_view iban, std::string_view name, std::int64_t amount, Currency currency, std::string_view description) const;
|
||||
private:
|
||||
void SendPayment(std::string iban) const;
|
||||
};
|
||||
|
||||
export struct BunqConnector {
|
||||
std::string sessionToken;
|
||||
std::string installationToken;
|
||||
EVP_PKEY* privateKey;
|
||||
std::string apiKey;
|
||||
std::string name;
|
||||
std::vector<BunqAccount> accounts;
|
||||
std::uint32_t id;
|
||||
|
||||
void RefreshSession();
|
||||
void RefreshAccounts();
|
||||
bool TestConnector();
|
||||
|
||||
static constexpr std::string connectorId = "bunq";
|
||||
inline static ClientHTTP1 client = ClientHTTP1("public-api.sandbox.bunq.com", 443, Crafter::TLSClientCredentials{});
|
||||
static std::vector<BunqConnector> connectors;
|
||||
static BunqConnector& Create(std::string&& apiKey, std::string_view allowedIp);
|
||||
using Account = BunqAccount;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& j, const BunqConnector& connector);
|
||||
void from_json(const nlohmann::json& j, BunqConnector& connector);
|
||||
}
|
||||
|
||||
template<>
|
||||
struct std::formatter<Nostro::BunqConnector> : std::formatter<std::string> {
|
||||
auto format(const Nostro::BunqConnector& obj, std::format_context& ctx) const {
|
||||
return std::formatter<std::string>::format(obj.name, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue