@pax2pay/model-banking 0.0.35 → 0.0.37

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.
@@ -13,22 +13,31 @@ export class Transactions extends rest.Collection<gracely.Error> {
13
13
  return this.client.post<Transaction>(`/account/${account}/transaction`, transaction)
14
14
  }
15
15
  async list(
16
- account?: string,
17
- currency?: string,
18
- start?: string,
19
- end?: string
16
+ args?:
17
+ | {
18
+ account: string
19
+ search?: {
20
+ currency?: string
21
+ start?: string
22
+ end?: string
23
+ reserved?: boolean
24
+ }
25
+ }
26
+ | {
27
+ search?: {
28
+ currency?: string
29
+ status?: string
30
+ start?: string
31
+ end?: string
32
+ }
33
+ }
20
34
  ): Promise<Transaction[] | gracely.Error> {
21
- const search =
22
- currency && start && end
23
- ? `?currency=${currency}&start=${start}&end=${end}`
24
- : currency && start
25
- ? `?currency=${currency}&start=${start}`
26
- : currency && end
27
- ? `?currency=${currency}&end=${end}`
28
- : currency
29
- ? `?currency=${currency}`
30
- : ""
31
- const path = account ? `/account/${account}/transaction` : `/transaction${search}`
35
+ const query = args?.search
36
+ ? Object.entries(args.search)
37
+ .map(([k, v]) => `${k}=${v}`)
38
+ .reduce((prev, curr, i) => `${prev}${i == 0 ? "?" : "&"}${curr}`, "")
39
+ : ""
40
+ const path = args && "account" in args ? `/account/${args.account}/transaction${query}` : `/transaction${query}`
32
41
  return this.client.get<Transaction[]>(path)
33
42
  }
34
43
  }
@@ -7,5 +7,20 @@ export declare class Transactions extends rest.Collection<gracely.Error> {
7
7
  readonly Notes: Notes;
8
8
  constructor(client: http.Client);
9
9
  create(account: string, transaction: Transaction.Creatable): Promise<Transaction | gracely.Error>;
10
- list(account?: string, currency?: string, start?: string, end?: string): Promise<Transaction[] | gracely.Error>;
10
+ list(args?: {
11
+ account: string;
12
+ search?: {
13
+ currency?: string;
14
+ start?: string;
15
+ end?: string;
16
+ reserved?: boolean;
17
+ };
18
+ } | {
19
+ search?: {
20
+ currency?: string;
21
+ status?: string;
22
+ start?: string;
23
+ end?: string;
24
+ };
25
+ }): Promise<Transaction[] | gracely.Error>;
11
26
  }
@@ -8,17 +8,13 @@ export class Transactions extends rest.Collection {
8
8
  async create(account, transaction) {
9
9
  return this.client.post(`/account/${account}/transaction`, transaction);
10
10
  }
11
- async list(account, currency, start, end) {
12
- const search = currency && start && end
13
- ? `?currency=${currency}&start=${start}&end=${end}`
14
- : currency && start
15
- ? `?currency=${currency}&start=${start}`
16
- : currency && end
17
- ? `?currency=${currency}&end=${end}`
18
- : currency
19
- ? `?currency=${currency}`
20
- : "";
21
- const path = account ? `/account/${account}/transaction` : `/transaction${search}`;
11
+ async list(args) {
12
+ const query = args?.search
13
+ ? Object.entries(args.search)
14
+ .map(([k, v]) => `${k}=${v}`)
15
+ .reduce((prev, curr, i) => `${prev}${i == 0 ? "?" : "&"}${curr}`, "")
16
+ : "";
17
+ const path = args && "account" in args ? `/account/${args.account}/transaction${query}` : `/transaction${query}`;
22
18
  return this.client.get(path);
23
19
  }
24
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Transactions/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,UAAyB;IAE/D,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAA;QAFL,UAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAGvC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,WAAkC;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAc,YAAY,OAAO,cAAc,EAAE,WAAW,CAAC,CAAA;IACrF,CAAC;IACD,KAAK,CAAC,IAAI,CACT,OAAgB,EAChB,QAAiB,EACjB,KAAc,EACd,GA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C;iBAC1B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC5B,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC;YACvE,CAAC,CAAC,EAAE,CAAA;QACL,MAAM,IAAI,GAAG,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,OAAO,eAAe,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAA;QAChH,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgB,IAAI,CAAC,CAAA;IAC5C,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",