Anastasis API helper function.

This commit is contained in:
MS 2021-08-16 23:21:35 -11:00
parent 1f255b7f4e
commit 93b455a28a
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 31 additions and 0 deletions

View File

@ -1157,6 +1157,24 @@ export namespace LibeufinNexusApi {
let response = await axios.get(url.href);
}
// Uses the Anastasis API to get a list of transactions.
export async function getAnastasisTransactions(
libeufinNexusService: LibeufinNexusService,
anastasisBaseUrl: string,
params: {}, // of the request: {delta: 5, ..}
username: string = "admin",
password: string = "test",
): Promise<any> {
let url = new URL("/history/incoming", anastasisBaseUrl);
let response = await axios.get(url.href, { params: params,
auth: {
username: username,
password: password,
},
});
return response;
}
// FIXME: this function should return some structured
// object that represents a history.
export async function getAccountTransactions(

View File

@ -23,6 +23,7 @@ import {
NexusUserBundle,
launchLibeufinServices,
LibeufinNexusApi,
LibeufinSandboxApi,
} from "./libeufin";
/**
@ -58,6 +59,18 @@ export async function runLibeufinApiFacadeTest(t: GlobalTestState) {
t.assertTrue(anastasisBaseUrl.startsWith("http://"));
t.assertTrue(anastasisBaseUrl.endsWith("/"));
LibeufinSandboxApi.simulateIncomingTransaction(
libeufinServices.libeufinSandbox,
user01nexus.localAccountName,
{
debtorIban: "ES3314655813489414469157",
debtorBic: "BCMAESM1XXX",
debtorName: "Mock Donor",
subject: "Anastasis donation",
amount: "EUR:3",
},
)
//***************************************//
// Here payments need to be generated //
// and checked via the Anastasis facade. //