@pax2pay/model-banking 0.1.150 → 0.1.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,14 @@ import { Notes } from "./Notes"
|
|
|
9
9
|
export class Transactions extends rest.Collection<gracely.Error> {
|
|
10
10
|
readonly Notes = new Notes(this.client)
|
|
11
11
|
constructor(client: http.Client) {
|
|
12
|
-
|
|
12
|
+
const httpClient = new http.Client<gracely.Error>(client.url, client.key, {
|
|
13
|
+
appendHeader: client.appendHeader,
|
|
14
|
+
postprocess: async response =>
|
|
15
|
+
Array.isArray(await response.body)
|
|
16
|
+
? http.Response.create({ cursor: response.header.cursor, list: await response.body })
|
|
17
|
+
: response,
|
|
18
|
+
})
|
|
19
|
+
super(httpClient)
|
|
13
20
|
}
|
|
14
21
|
async create(account: string, transaction: Transaction.Creatable): Promise<Transaction | gracely.Error> {
|
|
15
22
|
return this.client.post<Transaction>(`/account/${account}/transaction`, transaction)
|
|
@@ -22,16 +29,24 @@ export class Transactions extends rest.Collection<gracely.Error> {
|
|
|
22
29
|
dateRange?: isoly.DateRange
|
|
23
30
|
}): Promise<(Transaction[] & { cursor?: string | undefined }) | gracely.Error> {
|
|
24
31
|
const query = Object.entries({
|
|
32
|
+
...(options?.cursor ? { cursor: options.cursor } : {}),
|
|
25
33
|
...(options?.index ? { index: options.index.join(",") } : {}),
|
|
26
34
|
...(options?.dateRange ?? {}),
|
|
27
35
|
})
|
|
28
36
|
.map(([k, v]) => `${k}=${v}`)
|
|
29
37
|
.join("&")
|
|
30
38
|
const path = options?.account ? `/account/${options.account}/transaction` : `/transaction`
|
|
31
|
-
|
|
39
|
+
const listed = await this.client.get<{ list: Transaction[]; cursor?: string | undefined }>(
|
|
32
40
|
path + (query && "?" + query),
|
|
33
41
|
options?.limit ? { limit: options?.limit.toString() } : {}
|
|
34
42
|
)
|
|
43
|
+
let result: (Transaction[] & { cursor?: string | undefined }) | gracely.Error
|
|
44
|
+
if (!gracely.Error.is(listed)) {
|
|
45
|
+
result = listed.list
|
|
46
|
+
result.cursor = listed.cursor
|
|
47
|
+
} else
|
|
48
|
+
result = listed
|
|
49
|
+
return result
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { gracely } from "gracely";
|
|
2
|
+
import { http } from "cloudly-http";
|
|
1
3
|
import * as rest from "cloudly-rest";
|
|
2
4
|
import { Indices as TransactionIndex } from "./Indices";
|
|
3
5
|
import { Notes } from "./Notes";
|
|
4
6
|
export class Transactions extends rest.Collection {
|
|
5
7
|
constructor(client) {
|
|
6
|
-
|
|
8
|
+
const httpClient = new http.Client(client.url, client.key, {
|
|
9
|
+
appendHeader: client.appendHeader,
|
|
10
|
+
postprocess: async (response) => Array.isArray(await response.body)
|
|
11
|
+
? http.Response.create({ cursor: response.header.cursor, list: await response.body })
|
|
12
|
+
: response,
|
|
13
|
+
});
|
|
14
|
+
super(httpClient);
|
|
7
15
|
this.Notes = new Notes(this.client);
|
|
8
16
|
}
|
|
9
17
|
async create(account, transaction) {
|
|
@@ -11,13 +19,22 @@ export class Transactions extends rest.Collection {
|
|
|
11
19
|
}
|
|
12
20
|
async list(options) {
|
|
13
21
|
const query = Object.entries({
|
|
22
|
+
...(options?.cursor ? { cursor: options.cursor } : {}),
|
|
14
23
|
...(options?.index ? { index: options.index.join(",") } : {}),
|
|
15
24
|
...(options?.dateRange ?? {}),
|
|
16
25
|
})
|
|
17
26
|
.map(([k, v]) => `${k}=${v}`)
|
|
18
27
|
.join("&");
|
|
19
28
|
const path = options?.account ? `/account/${options.account}/transaction` : `/transaction`;
|
|
20
|
-
|
|
29
|
+
const listed = await this.client.get(path + (query && "?" + query), options?.limit ? { limit: options?.limit.toString() } : {});
|
|
30
|
+
let result;
|
|
31
|
+
if (!gracely.Error.is(listed)) {
|
|
32
|
+
result = listed.list;
|
|
33
|
+
result.cursor = listed.cursor;
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
result = listed;
|
|
37
|
+
return result;
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
40
|
(function (Transactions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Transactions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAEpC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,UAAyB;IAE/D,YAAY,MAAmB;QAC9B,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,MAAM,CAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;YACzE,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,KAAK,EAAC,QAAQ,EAAC,EAAE,CAC7B,KAAK,CAAC,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC;gBACjC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACrF,CAAC,CAAC,QAAQ;SACZ,CAAC,CAAA;QACF,KAAK,CAAC,UAAU,CAAC,CAAA;QATT,UAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAUvC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,WAAkC;QAC/D,OAAO,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