@pax2pay/model-banking 0.1.38 → 0.1.40

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.
package/Rail/Scan.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Iban } from "./Iban"
2
+
1
3
  //SCAN: Sort Code Account Number
2
4
  export interface Scan {
3
5
  type: "scan"
@@ -13,8 +15,13 @@ export namespace Scan {
13
15
  typeof value == "object" &&
14
16
  value.type == "scan" &&
15
17
  typeof value.sort == "string" &&
18
+ value.sort.length == 6 &&
16
19
  typeof value.account == "string" &&
20
+ value.account.length == 8 &&
17
21
  typeof value.holder == "string"
18
22
  )
19
23
  }
24
+ export function fromIban(iban: Iban): Scan {
25
+ return { type: "scan", sort: iban.iban.substring(8, 14), account: iban.iban.substring(14), holder: iban.holder }
26
+ }
20
27
  }
package/Rail/Type.ts CHANGED
@@ -1 +1 @@
1
- export type Type = "paxgiro" | "internal" | "iban" //| "scan" | "swedish" |
1
+ export type Type = "paxgiro" | "internal" | "iban" | "scan" //| "swedish" |
package/Rail/index.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { Iban as RailIban } from "./Iban"
2
2
  import { Internal as RailInternal } from "./internal"
3
3
  import { PaxGiro as RailPaxGiro } from "./PaxGiro"
4
+ import { Scan as RailScan } from "./Scan"
4
5
  import { Type as RailType } from "./Type"
5
6
 
6
- export type Rail = (RailPaxGiro | RailInternal | RailIban) & { reference?: { supplier: string; value: string } }
7
+ export type Rail = (RailPaxGiro | RailInternal | RailIban | RailScan) & {
8
+ reference?: { supplier: string; value: string }
9
+ }
7
10
 
8
11
  export namespace Rail {
9
12
  export function parse(value: string): Rail | undefined {
@@ -37,6 +40,30 @@ export namespace Rail {
37
40
  case "internal":
38
41
  result = `internal-${rail.identifier}`
39
42
  break
43
+ case "scan":
44
+ result = `scan-${rail.sort}-${rail.account}`
45
+ break
46
+ //case "swedish":
47
+ // result = `swe-${rail.clearing}-${rail.account}`
48
+ // break
49
+ }
50
+ return result
51
+ }
52
+ export function beautify(rail: Rail): string {
53
+ let result: string
54
+ switch (rail.type) {
55
+ case "iban":
56
+ result = `${rail.iban}`
57
+ break
58
+ case "paxgiro":
59
+ result = `${rail.identifier}`
60
+ break
61
+ case "internal":
62
+ result = `${rail.identifier}`
63
+ break
64
+ case "scan":
65
+ result = `sort code: ${rail.sort} account number: ${rail.account}`
66
+ break
40
67
  //case "swedish":
41
68
  // result = `swe-${rail.clearing}-${rail.account}`
42
69
  // break
@@ -44,7 +71,7 @@ export namespace Rail {
44
71
  return result
45
72
  }
46
73
  export function is(value: Rail | any): value is Rail {
47
- return typeof value == "object" && (PaxGiro.is(value) || Iban.is(value) || Internal.is(value))
74
+ return typeof value == "object" && (PaxGiro.is(value) || Iban.is(value) || Internal.is(value) || Scan.is(value))
48
75
  }
49
76
 
50
77
  export type Type = RailType
@@ -52,6 +79,8 @@ export namespace Rail {
52
79
  export const PaxGiro = RailPaxGiro
53
80
  export type Iban = RailIban
54
81
  export const Iban = RailIban
82
+ export type Scan = RailScan
83
+ export const Scan = RailScan
55
84
  export type Internal = RailInternal
56
85
  export const Internal = RailInternal
57
86
  }
@@ -0,0 +1,12 @@
1
+ import { Iban } from "./Iban";
2
+ export interface Scan {
3
+ type: "scan";
4
+ sort: string;
5
+ account: string;
6
+ holder: string;
7
+ }
8
+ export declare namespace Scan {
9
+ const currencies: readonly ["GBP"];
10
+ function is(value: Scan | any): value is Scan;
11
+ function fromIban(iban: Iban): Scan;
12
+ }
@@ -0,0 +1,20 @@
1
+ export var Scan;
2
+ (function (Scan) {
3
+ Scan.currencies = ["GBP"];
4
+ function is(value) {
5
+ return (value &&
6
+ typeof value == "object" &&
7
+ value.type == "scan" &&
8
+ typeof value.sort == "string" &&
9
+ value.sort.length == 6 &&
10
+ typeof value.account == "string" &&
11
+ value.account.length == 8 &&
12
+ typeof value.holder == "string");
13
+ }
14
+ Scan.is = is;
15
+ function fromIban(iban) {
16
+ return { type: "scan", sort: iban.iban.substring(8, 14), account: iban.iban.substring(14), holder: iban.holder };
17
+ }
18
+ Scan.fromIban = fromIban;
19
+ })(Scan || (Scan = {}));
20
+ //# sourceMappingURL=Scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Scan.js","sourceRoot":"../","sources":["Rail/Scan.ts"],"names":[],"mappings":"AASA,MAAM,KAAW,IAAI,CAiBpB;AAjBD,WAAiB,IAAI;IACP,eAAU,GAAG,CAAC,KAAK,CAAU,CAAA;IAC1C,SAAgB,EAAE,CAAC,KAAiB;QACnC,OAAO,CACN,KAAK;YACL,OAAO,KAAK,IAAI,QAAQ;YACxB,KAAK,CAAC,IAAI,IAAI,MAAM;YACpB,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ;YAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC;YACtB,OAAO,KAAK,CAAC,OAAO,IAAI,QAAQ;YAChC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC;YACzB,OAAO,KAAK,CAAC,MAAM,IAAI,QAAQ,CAC/B,CAAA;IACF,CAAC;IAXe,OAAE,KAWjB,CAAA;IACD,SAAgB,QAAQ,CAAC,IAAU;QAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;IACjH,CAAC;IAFe,aAAQ,WAEvB,CAAA;AACF,CAAC,EAjBgB,IAAI,KAAJ,IAAI,QAiBpB"}
@@ -1 +1 @@
1
- export type Type = "paxgiro" | "internal" | "iban";
1
+ export type Type = "paxgiro" | "internal" | "iban" | "scan";
@@ -1,8 +1,9 @@
1
1
  import { Iban as RailIban } from "./Iban";
2
2
  import { Internal as RailInternal } from "./internal";
3
3
  import { PaxGiro as RailPaxGiro } from "./PaxGiro";
4
+ import { Scan as RailScan } from "./Scan";
4
5
  import { Type as RailType } from "./Type";
5
- export type Rail = (RailPaxGiro | RailInternal | RailIban) & {
6
+ export type Rail = (RailPaxGiro | RailInternal | RailIban | RailScan) & {
6
7
  reference?: {
7
8
  supplier: string;
8
9
  value: string;
@@ -11,12 +12,15 @@ export type Rail = (RailPaxGiro | RailInternal | RailIban) & {
11
12
  export declare namespace Rail {
12
13
  function parse(value: string): Rail | undefined;
13
14
  function stringify(rail: Rail): string;
15
+ function beautify(rail: Rail): string;
14
16
  function is(value: Rail | any): value is Rail;
15
17
  type Type = RailType;
16
18
  type PaxGiro = RailPaxGiro;
17
19
  const PaxGiro: typeof RailPaxGiro;
18
20
  type Iban = RailIban;
19
21
  const Iban: typeof RailIban;
22
+ type Scan = RailScan;
23
+ const Scan: typeof RailScan;
20
24
  type Internal = RailInternal;
21
25
  const Internal: typeof RailInternal;
22
26
  }
@@ -1,6 +1,7 @@
1
1
  import { Iban as RailIban } from "./Iban";
2
2
  import { Internal as RailInternal } from "./internal";
3
3
  import { PaxGiro as RailPaxGiro } from "./PaxGiro";
4
+ import { Scan as RailScan } from "./Scan";
4
5
  export var Rail;
5
6
  (function (Rail) {
6
7
  function parse(value) {
@@ -26,16 +27,39 @@ export var Rail;
26
27
  case "internal":
27
28
  result = `internal-${rail.identifier}`;
28
29
  break;
30
+ case "scan":
31
+ result = `scan-${rail.sort}-${rail.account}`;
32
+ break;
29
33
  }
30
34
  return result;
31
35
  }
32
36
  Rail.stringify = stringify;
37
+ function beautify(rail) {
38
+ let result;
39
+ switch (rail.type) {
40
+ case "iban":
41
+ result = `${rail.iban}`;
42
+ break;
43
+ case "paxgiro":
44
+ result = `${rail.identifier}`;
45
+ break;
46
+ case "internal":
47
+ result = `${rail.identifier}`;
48
+ break;
49
+ case "scan":
50
+ result = `sort code: ${rail.sort} account number: ${rail.account}`;
51
+ break;
52
+ }
53
+ return result;
54
+ }
55
+ Rail.beautify = beautify;
33
56
  function is(value) {
34
- return typeof value == "object" && (Rail.PaxGiro.is(value) || Rail.Iban.is(value) || Rail.Internal.is(value));
57
+ return typeof value == "object" && (Rail.PaxGiro.is(value) || Rail.Iban.is(value) || Rail.Internal.is(value) || Rail.Scan.is(value));
35
58
  }
36
59
  Rail.is = is;
37
60
  Rail.PaxGiro = RailPaxGiro;
38
61
  Rail.Iban = RailIban;
62
+ Rail.Scan = RailScan;
39
63
  Rail.Internal = RailInternal;
40
64
  })(Rail || (Rail = {}));
41
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Rail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAKlD,MAAM,KAAW,IAAI,CAiDpB;AAjDD,WAAiB,IAAI;IACpB,SAAgB,KAAK,CAAC,KAAa;QAClC,IAAI,MAAwB,CAAA;QAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,QAAQ,QAAQ,CAAC,CAAC,CAAC,EAAE;YAIpB,KAAK,KAAK;gBACT,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;gBACxF,MAAK;SAON;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAlBe,UAAK,QAkBpB,CAAA;IACD,SAAgB,SAAS,CAAC,IAAU;QACnC,IAAI,MAAc,CAAA;QAClB,QAAQ,IAAI,CAAC,IAAI,EAAE;YAClB,KAAK,MAAM;gBACV,MAAM,GAAG,QAAQ,IA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A;gBAClE,MAAK;SAIN;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IApBe,aAAQ,WAoBvB,CAAA;IACD,SAAgB,EAAE,CAAC,KAAiB;QACnC,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,KAAA,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAA,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACjH,CAAC;IAFe,OAAE,KAEjB,CAAA;IAIY,YAAO,GAAG,WAAW,CAAA;IAErB,SAAI,GAAG,QAAQ,CAAA;IAEf,SAAI,GAAG,QAAQ,CAAA;IAEf,aAAQ,GAAG,YAAY,CAAA;AACrC,CAAC,EA3EgB,IAAI,KAAJ,IAAI,QA2EpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",