@pax2pay/model-banking 0.1.412 → 0.1.414

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.
@@ -2,13 +2,9 @@ import { gracely } from "gracely"
2
2
  import { isoly } from "isoly"
3
3
  import { http } from "cloudly-http"
4
4
  import { Treasury as TreasuryModel } from "../Treasury"
5
- import { Result } from "../Treasury/Balance"
6
5
 
7
6
  export class Treasury {
8
7
  constructor(private readonly client: http.Client) {}
9
- async change(currency: isoly.Currency, changes: Result[]): Promise<gracely.Result> {
10
- return this.client.patch(`/treasury/${currency}`, changes)
11
- }
12
8
  async fetch(hour?: isoly.DateTime): Promise<TreasuryModel.Snapshot | gracely.Error> {
13
9
  const path = hour ? `/${isoly.DateTime.truncate(hour, "hours")}` : ""
14
10
  return this.client.get<TreasuryModel.Snapshot>(`/treasury/snapshot${path}`)
@@ -3,28 +3,29 @@ import { isly } from "isly"
3
3
  import { Transaction } from "."
4
4
 
5
5
  export type Statistics = Record<
6
- "capture" | "refund",
7
- {
8
- domestic: {
6
+ Statistics.TransactionType,
7
+ Record<
8
+ Statistics.Region,
9
+ {
9
10
  count: number
10
11
  amount: number
11
12
  }
12
- intraRegion: {
13
- count: number
14
- amount: number
15
- }
16
- extraRegion: {
17
- count: number
18
- amount: number
19
- }
20
- }
13
+ >
21
14
  >
22
15
 
23
16
  export namespace Statistics {
17
+ export type TransactionType = typeof TransactionType.values[number]
18
+ export namespace TransactionType {
19
+ export const values = ["capture", "refund"] as const
20
+ }
21
+ export type Region = typeof Region.values[number]
22
+ export namespace Region {
23
+ export const values = ["domestic", "intraRegion", "extraRegion"] as const
24
+ }
24
25
  export const type = isly.record<Statistics>(
25
- isly.string(["capture", "refund"]),
26
+ isly.string<TransactionType>(TransactionType.values),
26
27
  isly.record(
27
- isly.string(["domestic", "intraRegion", "extraRegion"]),
28
+ isly.string<Region>(Region.values),
28
29
  isly.object({
29
30
  count: isly.number(),
30
31
  amount: isly.number(),
@@ -50,4 +51,21 @@ export namespace Statistics {
50
51
  }
51
52
  return statistics
52
53
  }
54
+ export function combine(accumulation: Statistics, incoming: Statistics): Statistics {
55
+ Object.entries(incoming).forEach(([kind, statistic]: [TransactionType, Statistics[TransactionType]]) =>
56
+ Object.entries(statistic).forEach(
57
+ ([region, { count, amount }]: [
58
+ Region,
59
+ {
60
+ count: number
61
+ amount: number
62
+ }
63
+ ]) => {
64
+ accumulation[kind][region].count += count
65
+ accumulation[kind][region].amount += amount
66
+ }
67
+ )
68
+ )
69
+ return accumulation
70
+ }
53
71
  }
@@ -2,11 +2,9 @@ import { gracely } from "gracely";
2
2
  import { isoly } from "isoly";
3
3
  import { http } from "cloudly-http";
4
4
  import { Treasury as TreasuryModel } from "../Treasury";
5
- import { Result } from "../Treasury/Balance";
6
5
  export declare class Treasury {
7
6
  private readonly client;
8
7
  constructor(client: http.Client);
9
- change(currency: isoly.Currency, changes: Result[]): Promise<gracely.Result>;
10
8
  fetch(hour?: isoly.DateTime): Promise<TreasuryModel.Snapshot | gracely.Error>;
11
9
  listTransactions(accountId: string): Promise<TreasuryModel.Transaction[] | gracely.Error>;
12
10
  listAccounts(): Promise<TreasuryModel.Account.Listable[] | gracely.Error>;
@@ -3,9 +3,6 @@ export class Treasury {
3
3
  constructor(client) {
4
4
  this.client = client;
5
5
  }
6
- async change(currency, changes) {
7
- return this.client.patch(`/treasury/${currency}`, changes);
8
- }
9
6
  async fetch(hour) {
10
7
  const path = hour ? `/${isoly.DateTime.truncate(hour, "hours")}` : "";
11
8
  return this.client.get(`/treasury/snapshot${path}`);
@@ -1 +1 @@
1
- {"version":3,"file":"Treasury.js","sourceRoot":"../","sources":["Client/Treasury.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAK7B,MAAM,OAAO,QAAQ;IACpB,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IACpD,KAAK,CAAC,MAAM,CAAC,QA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qBAAqB,SAAS,cAAc,CAAC,CAAA;IAClG,CAAC;IACD,KAAK,CAAC,YAAY;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAmC,mBAAmB,CAAC,CAAA;IAC9E,CAAC;CACD"}
@@ -1,21 +1,20 @@
1
1
  import { isoly } from "isoly";
2
2
  import { isly } from "isly";
3
3
  import { Transaction } from ".";
4
- export type Statistics = Record<"capture" | "refund", {
5
- domestic: {
6
- count: number;
7
- amount: number;
8
- };
9
- intraRegion: {
10
- count: number;
11
- amount: number;
12
- };
13
- extraRegion: {
14
- count: number;
15
- amount: number;
16
- };
17
- }>;
4
+ export type Statistics = Record<Statistics.TransactionType, Record<Statistics.Region, {
5
+ count: number;
6
+ amount: number;
7
+ }>>;
18
8
  export declare namespace Statistics {
9
+ type TransactionType = typeof TransactionType.values[number];
10
+ namespace TransactionType {
11
+ const values: readonly ["capture", "refund"];
12
+ }
13
+ type Region = typeof Region.values[number];
14
+ namespace Region {
15
+ const values: readonly ["domestic", "intraRegion", "extraRegion"];
16
+ }
19
17
  const type: isly.Type<Transaction.Statistics>;
20
18
  function append(statistics: Statistics, transaction: Transaction, domestic: isoly.CountryCode.Alpha2[], intraRegion: isoly.CountryCode.Alpha2[]): Statistics;
19
+ function combine(accumulation: Statistics, incoming: Statistics): Statistics;
21
20
  }
@@ -1,7 +1,15 @@
1
1
  import { isly } from "isly";
2
2
  export var Statistics;
3
3
  (function (Statistics) {
4
- Statistics.type = isly.record(isly.string(["capture", "refund"]), isly.record(isly.string(["domestic", "intraRegion", "extraRegion"]), isly.object({
4
+ let TransactionType;
5
+ (function (TransactionType) {
6
+ TransactionType.values = ["capture", "refund"];
7
+ })(TransactionType = Statistics.TransactionType || (Statistics.TransactionType = {}));
8
+ let Region;
9
+ (function (Region) {
10
+ Region.values = ["domestic", "intraRegion", "extraRegion"];
11
+ })(Region = Statistics.Region || (Statistics.Region = {}));
12
+ Statistics.type = isly.record(isly.string(TransactionType.values), isly.record(isly.string(Region.values), isly.object({
5
13
  count: isly.number(),
6
14
  amount: isly.number(),
7
15
  })));
@@ -20,5 +28,13 @@ export var Statistics;
20
28
  return statistics;
21
29
  }
22
30
  Statistics.append = append;
31
+ function combine(accumulation, incoming) {
32
+ Object.entries(incoming).forEach(([kind, statistic]) => Object.entries(statistic).forEach(([region, { count, amount }]) => {
33
+ accumulation[kind][region].count += count;
34
+ accumulation[kind][region].amount += amount;
35
+ }));
36
+ return accumulation;
37
+ }
38
+ Statistics.combine = combine;
23
39
  })(Statistics || (Statistics = {}));
24
40
  //# sourceMappingURL=Statistics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Statistics.js","sourceRoot":"../","sources":["Transaction/Statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAqB3B,MAAM,KAAW,UAAU,CA8B1B;AA9BD,WAAiB,UAAU;IACb,eAAI,GAAG,IAAI,CAAC,MAAM,CAC9B,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,EAClC,IAAI,CAAC,MAAM,CACV,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,EACvD,IAAI,CAAC,MAAM,CAAC;QACX,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;QACpB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;KACrB,CAAC,CACF,CACD,CAAA;IACD,SAAgB,MAAM,CACrB,UAAsB,EACtB,WAAwB,EACxB,QAAoC,EACpC,WAAuC;QAEvC,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAA;QAC/B,MAAM,aAAa,GAAG,KAAK,EAAE,aAAa,CAAA;QAC1C,IAAI,KAAK,IAAI,aAAa,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,CAAC,EAAE,CAAC;YAC3G,M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C,IAAI,EAAE,SAAS,CAAiD,EAAE,EAAE,CACtG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAChC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAM1B,EAAE,EAAE;YACJ,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,KAAK,CAAA;YACzC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,IAAI,MAAM,CAAA;QAC5C,CAAC,CACD,CACD,CAAA;QACD,OAAO,YAAY,CAAA;IACpB,CAAC;IAhBe,kBAAO,UAgBtB,CAAA;AACF,CAAC,EAvDgB,UAAU,KAAV,UAAU,QAuD1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.412",
3
+ "version": "0.1.414",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",