@pax2pay/client 0.1.11 → 0.1.13

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.
@@ -0,0 +1,18 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.auth.login", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ it("simple", async () => {
9
+ expect(
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ ).toMatchObject({
15
+ effectiveOrganisation: { code: expect.any(String), name: expect.any(String) },
16
+ })
17
+ })
18
+ })
@@ -0,0 +1,38 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as pax2pay from "../../../index"
4
+ import { ErrorResponse } from "../../../model"
5
+ import { actionTest } from "./actionTest"
6
+ import { factory } from "./factory"
7
+
8
+ dotenv.config()
9
+ jest.setTimeout(200000)
10
+
11
+ describe("pax2pay.cards.actions fake", () => {
12
+ const client = pax2pay.Client.create(process.env.url)
13
+ beforeAll(
14
+ async () =>
15
+ await client?.auth.login({
16
+ username: process.env.username ?? "user",
17
+ password: process.env.password ?? "password",
18
+ })
19
+ )
20
+
21
+ it("card EUR VISA_CREDIT", async () => {
22
+ const request = factory({
23
+ cardType: {
24
+ cardTypeId: "VISA_CREDIT",
25
+ },
26
+ currency: "EUR",
27
+ providerAccountId: process.env["accountFakeEur"],
28
+ providerCode: "fake",
29
+ })
30
+
31
+ const cardLegacy = await client?.cards.createLegacy(request)
32
+
33
+ assert(!ErrorResponse.is(cardLegacy))
34
+ assert(cardLegacy != undefined)
35
+ assert(client != undefined)
36
+ await actionTest(cardLegacy, client)
37
+ })
38
+ })
@@ -0,0 +1,40 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as pax2pay from "../../../index"
4
+ import { ErrorResponse } from "../../../model"
5
+ import { actionTest } from "./actionTest"
6
+ import { factory } from "./factory"
7
+
8
+ dotenv.config()
9
+ jest.setTimeout(200000)
10
+
11
+ describe("pax2pay.cards.actions ixaris", () => {
12
+ const client = pax2pay.Client.create(process.env.url)
13
+ beforeAll(
14
+ async () =>
15
+ await client?.auth.login({
16
+ username: process.env.username ?? "user",
17
+ password: process.env.password ?? "password",
18
+ })
19
+ )
20
+
21
+ it("card GBP MASTERCARD", async () => {
22
+ const request = factory({
23
+ cardType: {
24
+ cardTypeId: "MASTERCARD",
25
+ },
26
+ currency: "GBP",
27
+ providerAccountId: process.env["accountIxarisGbp"],
28
+ providerCode: "ixaris",
29
+ balance: 0,
30
+ friendlyName: new Date().toISOString().slice(0, 20) + "ixaris" + "MASTERCARDGBP",
31
+ })
32
+
33
+ const cardLegacy = await client?.cards.createLegacy(request)
34
+
35
+ assert(!ErrorResponse.is(cardLegacy))
36
+ assert(cardLegacy != undefined)
37
+ assert(client != undefined)
38
+ await actionTest(cardLegacy, client)
39
+ })
40
+ })
@@ -0,0 +1,40 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import { mathExact } from "math-exact"
4
+ import * as pax2pay from "../../../index"
5
+ import { ErrorResponse } from "../../../model"
6
+ import { actionTest } from "./actionTest"
7
+ import { factory } from "./factory"
8
+
9
+ dotenv.config()
10
+ jest.setTimeout(200000)
11
+
12
+ describe("pax2pay.cards.actions modulr", () => {
13
+ const client = pax2pay.Client.create(process.env.url)
14
+ beforeAll(
15
+ async () =>
16
+ await client?.auth.login({
17
+ username: process.env.username ?? "user",
18
+ password: process.env.password ?? "password",
19
+ })
20
+ )
21
+ it("card USD VISA", async () => {
22
+ const request = factory({
23
+ cardType: {
24
+ cardTypeId: "VISA",
25
+ },
26
+ currency: "USD",
27
+ providerAccountId: process.env["accountModulrUsd"],
28
+ providerCode: "modulr",
29
+ balance: mathExact("Divide", Math.round((Math.random() * 4 + 1) * 100), 100),
30
+ })
31
+
32
+ const cardLegacy = await client?.cards.createLegacy(request)
33
+
34
+ assert(!ErrorResponse.is(cardLegacy))
35
+ assert(cardLegacy != undefined)
36
+ assert(client != undefined)
37
+
38
+ await actionTest(cardLegacy, client)
39
+ })
40
+ })
@@ -0,0 +1,40 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as pax2pay from "../../../index"
4
+ import { ErrorResponse } from "../../../model"
5
+ import { actionTest } from "./actionTest"
6
+ import { factory } from "./factory"
7
+
8
+ dotenv.config()
9
+ jest.setTimeout(200000)
10
+
11
+ describe("pax2pay.cards.actions pax2pay", () => {
12
+ const client = pax2pay.Client.create(process.env.url)
13
+ beforeAll(
14
+ async () =>
15
+ await client?.auth.login({
16
+ username: process.env.username ?? "user",
17
+ password: process.env.password ?? "password",
18
+ })
19
+ )
20
+ for (const currency of ["GBP"])
21
+ for (const cardType of ["jittest"])
22
+ it(`card ${currency} ${cardType}`, async () => {
23
+ const request = factory({
24
+ cardType: {
25
+ cardTypeId: cardType,
26
+ },
27
+ currency: currency,
28
+ providerAccountId: process.env[`accountPax2pay${currency.charAt(0)}${currency.toLowerCase().slice(1)}`],
29
+ providerCode: "pax2pay",
30
+ })
31
+
32
+ const cardLegacy = await client?.cards.createLegacy(request)
33
+
34
+ assert(!ErrorResponse.is(cardLegacy))
35
+ assert(cardLegacy != undefined)
36
+ assert(client != undefined)
37
+
38
+ await actionTest(cardLegacy, client)
39
+ })
40
+ })
@@ -0,0 +1,44 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../../index"
3
+ import { ErrorResponse } from "../../../model"
4
+ import { factory } from "./factory"
5
+
6
+ dotenv.config()
7
+ jest.setTimeout(200000)
8
+
9
+ describe("pax2pay.cards.create fake", () => {
10
+ const client = pax2pay.Client.create(process.env.url)
11
+ beforeAll(
12
+ async () =>
13
+ await client?.auth.login({
14
+ username: process.env.username ?? "user",
15
+ password: process.env.password ?? "password",
16
+ })
17
+ )
18
+ for (const currency of ["EUR", "GBP", "SEK", "JPY", "BRL"])
19
+ for (const cardType of ["VISA_CREDIT", "MASTERCARD"])
20
+ it(`card ${currency} ${cardType}`, async () => {
21
+ const [request, expectedV2, expectedLegacy] = factory({
22
+ cardType: {
23
+ cardTypeId: cardType,
24
+ },
25
+ currency: currency,
26
+ providerAccountId: process.env[`accountFake${currency.charAt(0)}${currency.toLowerCase().slice(1)}`],
27
+ providerCode: "fake",
28
+ })
29
+ const cardV2 = await client?.cards.create(request)
30
+ const cardLegacy = await client?.cards.createLegacy(request)
31
+
32
+ if (ErrorResponse.is(cardV2))
33
+ throw Error(cardV2.errors?.[0].message)
34
+ else if (ErrorResponse.is(cardLegacy))
35
+ throw Error(cardLegacy.errors?.[0].message)
36
+ else {
37
+ expect(cardV2).toBeTruthy()
38
+ expect(cardLegacy).toBeTruthy()
39
+
40
+ expect(cardV2).toMatchObject(expectedV2)
41
+ expect(cardLegacy).toMatchObject(expectedLegacy)
42
+ }
43
+ })
44
+ })
@@ -0,0 +1,42 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../../index"
3
+ import { factory } from "./factory"
4
+
5
+ dotenv.config()
6
+ jest.setTimeout(200000)
7
+
8
+ describe("pax2pay.cards.create ixaris", () => {
9
+ const client = pax2pay.Client.create(process.env.url)
10
+ beforeAll(
11
+ async () =>
12
+ await client?.auth.login({
13
+ username: process.env.username ?? "user",
14
+ password: process.env.password ?? "password",
15
+ })
16
+ )
17
+
18
+ for (const currency of ["EUR", "GBP", "USD"])
19
+ for (const cardType of ["VISA_DEBIT", "VISA_CREDIT", "MASTERCARD"])
20
+ it(`card ${currency} ${cardType}`, async () => {
21
+ const [request, expectedV2, expectedLegacy] = factory({
22
+ cardType: {
23
+ cardTypeId: cardType,
24
+ },
25
+ currency: currency,
26
+ providerAccountId: process.env[`accountIxaris${currency.charAt(0)}${currency.toLowerCase().slice(1)}`],
27
+ providerCode: "ixaris",
28
+ friendlyName: new Date().toISOString().slice(0, 20) + "ixaris" + cardType + currency,
29
+ })
30
+
31
+ const cardV2 = await client?.cards.create({
32
+ ...request,
33
+ friendlyName: request.friendlyName + "V2",
34
+ })
35
+ const cardLegacy = await client?.cards.createLegacy({
36
+ ...request,
37
+ friendlyName: request.friendlyName + "Legacy",
38
+ })
39
+ expect(cardV2).toMatchObject(expectedV2)
40
+ expect(cardLegacy).toMatchObject(expectedLegacy)
41
+ })
42
+ })
@@ -0,0 +1,42 @@
1
+ import * as dotenv from "dotenv"
2
+ import { mathExact } from "math-exact"
3
+ import * as pax2pay from "../../../index"
4
+ import { factory } from "./factory"
5
+
6
+ dotenv.config()
7
+ jest.setTimeout(200000)
8
+
9
+ describe("pax2pay.cards.create modulr", () => {
10
+ const client = pax2pay.Client.create(process.env.url)
11
+ beforeAll(
12
+ async () =>
13
+ await client?.auth.login({
14
+ username: process.env.username ?? "user",
15
+ password: process.env.password ?? "password",
16
+ })
17
+ )
18
+ for (const currency of ["EUR", "GBP", "PLN", "USD"])
19
+ for (const cardType of ["VISA_DEBIT_CORPORATE", "VISA", "VISA_CREDIT_CORPORATE", "VISA_DEBIT"])
20
+ it(`card ${currency} ${cardType}`, async () => {
21
+ const [request, expectedV2, expectedLegacy] = factory({
22
+ cardType: {
23
+ cardTypeId: cardType,
24
+ },
25
+ currency: currency,
26
+ providerAccountId: process.env[`accountModulr${currency.charAt(0)}${currency.toLowerCase().slice(1)}`],
27
+ providerCode: "modulr",
28
+ balance: mathExact("Divide", Math.round((Math.random() * 4 + 1) * 100), 100),
29
+ })
30
+ const cardV2 = await client?.cards.create({
31
+ ...request,
32
+ balance: mathExact("Add", request.balance, 1),
33
+ })
34
+ const cardLegacy = await client?.cards.createLegacy({
35
+ ...request,
36
+ balance: mathExact("Add", request.balance, 2),
37
+ })
38
+
39
+ expect(cardV2).toMatchObject(expectedV2)
40
+ expect(cardLegacy).toMatchObject(expectedLegacy)
41
+ })
42
+ })
@@ -0,0 +1,43 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../../index"
3
+ import { ErrorResponse } from "../../../model"
4
+ import { factory } from "./factory"
5
+
6
+ dotenv.config()
7
+ jest.setTimeout(200000)
8
+
9
+ describe("pax2pay.cards.create pax2pay", () => {
10
+ const client = pax2pay.Client.create(process.env.url)
11
+ beforeAll(async () => {
12
+ await client?.auth.login({
13
+ username: process.env.username ?? "user",
14
+ password: process.env.password ?? "password",
15
+ })
16
+ })
17
+ for (const currency of ["GBP"])
18
+ for (const cardType of ["jittest"])
19
+ it(`card ${currency} ${cardType}`, async () => {
20
+ const [request, expectedV2, expectedLegacy] = factory({
21
+ cardType: {
22
+ cardTypeId: cardType,
23
+ },
24
+ currency: currency,
25
+ providerAccountId: process.env[`accountPax2pay${currency.charAt(0)}${currency.toLowerCase().slice(1)}`],
26
+ providerCode: "pax2pay",
27
+ })
28
+ const cardV2 = await client?.cards.create(request)
29
+ const cardLegacy = await client?.cards.createLegacy(request)
30
+
31
+ if (ErrorResponse.is(cardV2))
32
+ throw Error(cardV2.errors?.[0].message)
33
+ else if (ErrorResponse.is(cardLegacy))
34
+ throw Error(cardLegacy.errors?.[0].message)
35
+ else {
36
+ expect(cardV2).toBeTruthy()
37
+ expect(cardLegacy).toBeTruthy()
38
+
39
+ expect(cardV2).toMatchObject(expectedV2)
40
+ expect(cardLegacy).toMatchObject(expectedLegacy)
41
+ }
42
+ })
43
+ })
@@ -0,0 +1,65 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(200000)
5
+
6
+ describe("pax2pay.cards.list", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("first page", async () => {
16
+ const expected = {
17
+ balance: expect.any(Number),
18
+ cardAccount: {
19
+ accountType: "CARD",
20
+ balance: expect.any(Number),
21
+ createdOn: expect.any(String),
22
+ currency: expect.any(String),
23
+ friendlyName: expect.any(String),
24
+ id: expect.any(Number),
25
+ organisation: {
26
+ code: expect.any(String),
27
+ name: expect.any(String),
28
+ status: expect.stringMatching(/(ACTIVE)|(INACTIVE)/),
29
+ },
30
+ provider: {
31
+ code: expect.any(String),
32
+ id: expect.any(Number),
33
+ name: expect.any(String),
34
+ status: "ACTIVE",
35
+ },
36
+ providerAccountId: expect.any(String),
37
+ state: expect.stringMatching(/(DELETED)|(ACTIVE)|(EXPIRED)/),
38
+ updatedOn: expect.any(String),
39
+ },
40
+ cardForm: expect.any(String),
41
+ cardNumber: expect.any(String),
42
+ cardType: expect.any(String),
43
+ createdBy: expect.any(String),
44
+ creatingSystem: expect.any(String),
45
+ cvv: expect.any(String),
46
+ expiryDate: expect.any(String),
47
+ folder: expect.any(String),
48
+ issueDate: expect.any(String),
49
+ nameOnCard: expect.any(String),
50
+ providerCardId: expect.any(String),
51
+ providerCode: expect.any(String),
52
+ state: expect.any(String),
53
+ usage: expect.any(String),
54
+ useAs: expect.any(String),
55
+ }
56
+
57
+ const list = await client?.cards.list()
58
+ if (Array.isArray(list))
59
+ for (const card of list)
60
+ expect(card).toMatchObject(expected)
61
+ //if list only returns one card.
62
+ else
63
+ expect(list).toMatchObject(expected)
64
+ })
65
+ })
@@ -0,0 +1,24 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.organisations.fetch", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("mcom", async () => {
16
+ const name = "mcom"
17
+ expect(await client?.organisations.fetch(name)).toEqual({
18
+ code: name,
19
+ folder: "organisations/" + name,
20
+ name: expect.any(String),
21
+ status: "ACTIVE",
22
+ })
23
+ })
24
+ })
@@ -0,0 +1,28 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.organisations.list", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("all orgs", async () => {
16
+ const organizations = await client?.organisations.list()
17
+ expect(Array.isArray(organizations)).toEqual(true)
18
+ if (Array.isArray(organizations))
19
+ for (const organization of organizations) {
20
+ expect(organization).toMatchObject({
21
+ code: expect.stringContaining(""),
22
+ folder: expect.stringContaining("organisations/"),
23
+ name: expect.stringContaining(""),
24
+ status: expect.stringMatching(/(ACTIVE)|(INACTIVE)/),
25
+ })
26
+ }
27
+ })
28
+ })
@@ -0,0 +1,42 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.reports", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("reconciliation report", async () => {
16
+ const report = await client?.reports.reconciliation("2021-01-01T00:00:00.000Z", "2021-01-10T23:59:59.999Z")
17
+ expect(report).toMatchObject({
18
+ report: {
19
+ rows: expect.any(Array),
20
+ },
21
+ })
22
+ })
23
+ it("account statement", async () => {
24
+ const report = await client?.reports.statement("2021-01-01T00:00:00.000Z", "2021-06-14T23:59:59.999Z", "A120ABTA")
25
+ expect(report).toMatchObject({
26
+ report: {
27
+ accountIdentifier: expect.any(String),
28
+ closingBalance: expect.any(Number),
29
+ from: expect.any(String),
30
+ openingBalance: expect.any(Number),
31
+ statements: expect.any(Array),
32
+ },
33
+ })
34
+ })
35
+
36
+ it("attachPageable", async () => {
37
+ const result = await client?.reports.attachPageable("statement", 2, 10)
38
+ expect(result).toEqual("statement?page=2&size=10")
39
+ const result2 = await client?.reports.attachPageable("statement", 5, 30)
40
+ expect(result2).toEqual("statement?page=5&size=30")
41
+ })
42
+ })
@@ -0,0 +1,105 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as pax2pay from "../../index"
4
+ import { ErrorResponse } from "../../model"
5
+ import * as model from "../../model"
6
+ import * as factory from "./factory"
7
+ dotenv.config()
8
+ jest.setTimeout(200000)
9
+
10
+ describe("pax2pay.transfers.create", () => {
11
+ const client = pax2pay.Client.create(process.env.url)
12
+ beforeAll(
13
+ async () =>
14
+ await client?.auth.login({
15
+ username: process.env.username ?? "user",
16
+ password: process.env.password ?? "password",
17
+ })
18
+ )
19
+
20
+ it("with beneficiary", async () => {
21
+ const request: model.TransferRequest = factory.getRequestForBeneficiary()
22
+ const expected = factory.getExpectedForBeneficiary(request)
23
+
24
+ const transfer = await client?.transfers.create(request)
25
+
26
+ assert(!ErrorResponse.is(transfer))
27
+ assert(transfer != undefined)
28
+
29
+ expect(transfer).toMatchObject(expected)
30
+ })
31
+
32
+ it("with destination", async () => {
33
+ const request: model.TransferRequest = factory.getRequestForDestination()
34
+ const expected = factory.getExpectedForDestination(request)
35
+
36
+ const transfer = await client?.transfers.create(request)
37
+
38
+ assert(!ErrorResponse.is(transfer))
39
+ assert(transfer != undefined)
40
+
41
+ expect(transfer).toMatchObject(expected)
42
+
43
+ const saveBeneficiaryRequest = factory.getRequestForDestinationPlusBeneficiary()
44
+ const expectedWithBeneficiary = factory.getExpectedForDestinationPlusBeneficiary(saveBeneficiaryRequest)
45
+
46
+ const transferPlusNewBeneficiary = await client?.transfers.create(saveBeneficiaryRequest)
47
+
48
+ assert(!ErrorResponse.is(transferPlusNewBeneficiary))
49
+ assert(transferPlusNewBeneficiary != undefined)
50
+
51
+ expect(transferPlusNewBeneficiary).toMatchObject(expectedWithBeneficiary)
52
+
53
+ assert(transferPlusNewBeneficiary.beneficiary != undefined)
54
+ assert(transferPlusNewBeneficiary.beneficiary.beneficiaryId != undefined)
55
+ const beneficiary = await client?.beneficiaries.getBeneficiary(transferPlusNewBeneficiary.beneficiary.beneficiaryId)
56
+
57
+ assert(!ErrorResponse.is(beneficiary))
58
+ assert(beneficiary != undefined)
59
+
60
+ expect(beneficiary).toMatchObject({
61
+ transferDestination: transferPlusNewBeneficiary.beneficiary.transferDestination,
62
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)|(OUTDATED)/),
63
+ fullName: expect.any(String),
64
+ beneficiaryId: transferPlusNewBeneficiary.beneficiary.beneficiaryId,
65
+ createdOn: expect.any(String),
66
+ })
67
+ })
68
+
69
+ it("with funding account", async () => {
70
+ const request: model.TransferRequest = factory.getRequestForFundingAccount()
71
+ const expected = factory.getExpectedForFundingAccount(request)
72
+
73
+ const transfer = await client?.transfers.create(request)
74
+
75
+ assert(!ErrorResponse.is(transfer))
76
+ assert(transfer != undefined)
77
+
78
+ expect(transfer).toMatchObject(expected)
79
+ })
80
+
81
+ it("invalid input, multiple options", async () => {
82
+ const beneficiaryRequest = factory.getRequestForBeneficiary()
83
+ const destinationRequest = factory.getRequestForDestination()
84
+ const fundingAccountRequest = factory.getRequestForFundingAccount()
85
+
86
+ const testRequestAll = {
87
+ ...beneficiaryRequest,
88
+ ...destinationRequest,
89
+ ...fundingAccountRequest,
90
+ }
91
+
92
+ const allOptionsResponse = await client?.transfers.create(testRequestAll)
93
+
94
+ expect(ErrorResponse.is(allOptionsResponse)).toBeTruthy()
95
+
96
+ const testRequestTwo = {
97
+ ...beneficiaryRequest,
98
+ ...destinationRequest,
99
+ }
100
+
101
+ const twoOptionsResponse = await client?.transfers.create(testRequestTwo)
102
+
103
+ expect(ErrorResponse.is(twoOptionsResponse)).toBeTruthy()
104
+ })
105
+ })
@@ -0,0 +1,42 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as pax2pay from "../../index"
4
+ import { ErrorResponse } from "../../model"
5
+ import * as factory from "./factory"
6
+ dotenv.config()
7
+ jest.setTimeout(200000)
8
+
9
+ describe("pax2pay.transfers.list", () => {
10
+ const client = pax2pay.Client.create(process.env.url)
11
+ beforeAll(
12
+ async () =>
13
+ await client?.auth.login({
14
+ username: process.env.username ?? "user",
15
+ password: process.env.password ?? "password",
16
+ })
17
+ )
18
+
19
+ it("first page", async () => {
20
+ const expected = factory.getExpectedForGeneric()
21
+
22
+ const transfers = await client?.transfers.list()
23
+
24
+ assert(!ErrorResponse.is(transfers))
25
+ assert(transfers != undefined)
26
+ assert(Array.isArray(transfers))
27
+
28
+ expect(transfers).toHaveLength(20)
29
+ for (const transfer of transfers)
30
+ expect(transfer).toMatchObject(expected)
31
+
32
+ const transfers100 = await client?.transfers.list(1, 100)
33
+
34
+ assert(!ErrorResponse.is(transfers100))
35
+ assert(transfers100 != undefined)
36
+ assert(Array.isArray(transfers100))
37
+
38
+ expect(transfers100).toHaveLength(100)
39
+ for (const transfer of transfers100)
40
+ expect(transfer).toMatchObject(expected)
41
+ })
42
+ })
@@ -0,0 +1,32 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.users.fetch", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("current user", async () => {
16
+ const user = await client?.users.fetch(process.env.username)
17
+ expect(user).toMatchObject({
18
+ "2fa": {
19
+ enabled: expect.any(Boolean),
20
+ },
21
+ email: expect.any(String),
22
+ firstName: expect.any(String),
23
+ folder: expect.stringMatching(/users\/.*/),
24
+ lastName: expect.any(String),
25
+ organisation: {
26
+ code: expect.any(String),
27
+ name: expect.any(String),
28
+ status: expect.stringMatching(/(ACTIVE)|(INACTIVE)/),
29
+ },
30
+ })
31
+ })
32
+ })
@@ -58,4 +58,9 @@ export class Users extends Collection<model.UserResponse, model.UserSearchReques
58
58
  async checkUsernameAvailability(username: string): Promise<model.UsernameAvailabilityResponse | model.ErrorResponse> {
59
59
  return await this.connection.get<model.UsernameAvailabilityResponse>(`${this.folder}/username/${username}`)
60
60
  }
61
+ async checkPassword(
62
+ request: model.PasswordValidateRequest
63
+ ): Promise<model.PasswordValidateResponse | model.ErrorResponse> {
64
+ return await this.connection.post<model.PasswordValidateResponse>(`users/password/check`, request)
65
+ }
61
66
  }
@@ -0,0 +1,41 @@
1
+ import * as dotenv from "dotenv"
2
+ import * as pax2pay from "../../index"
3
+ dotenv.config()
4
+ jest.setTimeout(100000)
5
+
6
+ describe("pax2pay.users.list", () => {
7
+ const client = pax2pay.Client.create(process.env.url)
8
+ beforeAll(
9
+ async () =>
10
+ await client?.auth.login({
11
+ username: process.env.username ?? "user",
12
+ password: process.env.password ?? "password",
13
+ })
14
+ )
15
+ it("first page", async () => {
16
+ const users = await client?.users.list()
17
+ expect(Array.isArray(users)).toEqual(true)
18
+ if (Array.isArray(users))
19
+ for (const user of users)
20
+ expect(user).toMatchObject({
21
+ "2fa": {
22
+ enabled: expect.any(Boolean),
23
+ },
24
+ email: expect.any(String),
25
+ firstName: expect.any(String),
26
+ folder: expect.stringMatching(/users\/.*/),
27
+ lastName: expect.any(String),
28
+ organisation: {
29
+ code: expect.any(String),
30
+ name: expect.any(String),
31
+ status: expect.stringMatching(/(ACTIVE)|(INACTIVE)/),
32
+ },
33
+ })
34
+ })
35
+ it.skip("username asc, email desc", async () => {
36
+ const users = await client?.users.list(0, 20, ["username", { property: "email", direction: "descending" }])
37
+ expect(Array.isArray(users)).toEqual(true)
38
+ if (Array.isArray(users))
39
+ expect(users).toHaveLength(20)
40
+ })
41
+ })
@@ -19,4 +19,5 @@ export declare class Users extends Collection<model.UserResponse, model.UserSear
19
19
  updateRolesetOnUser(username: string, roleset: string): Promise<model.UserRoleResponse | model.ErrorResponse>;
20
20
  updateUser(username: string, request: model.UserChangeRequest): Promise<model.UserResponse | model.ErrorResponse>;
21
21
  checkUsernameAvailability(username: string): Promise<model.UsernameAvailabilityResponse | model.ErrorResponse>;
22
+ checkPassword(request: model.PasswordValidateRequest): Promise<model.PasswordValidateResponse | model.ErrorResponse>;
22
23
  }
@@ -51,5 +51,8 @@ export class Users extends Collection {
51
51
  async checkUsernameAvailability(username) {
52
52
  return await this.connection.get(`${this.folder}/username/${username}`);
53
53
  }
54
+ async checkPassword(request) {
55
+ return await this.connection.post(`users/password/check`, request);
56
+ }
54
57
  }
55
58
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Users/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,MAAM,OAAO,KAAM,SAAQ,UAA0E;IAEpG,YAAoB,UAAsB;QACzC,KAAK,CAAC,UAAU,CAAC,CAAA;QAFR,WAAM,GAAG,OAAO,CAAA;IAG1B,CAAC;IACS,cAAc,CAAC,QAA4B;QACpD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;IACvF,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,UAAsB;QACnC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,QAAgB;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAqB,SAAS,QAAQ,EAAE,CAAC,CAAA;QACpF,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,WAAW;QAChB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAuB,8BAA8B,CA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AC,CAAA;QAC1F,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,yBAAyB,CAAC,QAAgB;QAC/C,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAqC,GAAG,IAAI,CAAC,MAAM,aAAa,QAAQ,EAAE,CAAC,CAAA;IAC5G,CAAC;IACD,KAAK,CAAC,aAAa,CAClB,OAAsC;QAEtC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAiC,sBAAsB,EAAE,OAAO,CAAC,CAAA;IACnG,CAAC;CACD"}
@@ -27,7 +27,7 @@ export var CardResponseV2;
27
27
  return CardScheduleResponseItem.is(a);
28
28
  }))) &&
29
29
  typeof value.createdBy == "string" &&
30
- CardDeliveryResponse.is(value.delivery) &&
30
+ (value.delivery == undefined || CardDeliveryResponse.is(value.delivery)) &&
31
31
  (value.batchId == undefined || typeof value.batchId == "string") &&
32
32
  (value.bookingInfo == undefined || BookingInfoResponse.is(value.bookingInfo)));
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CardResponseV2.js","sourceRoot":"../","sources":["model/CardResponseV2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAyBvC,MAAM,KAAW,cAAc,CA0B9B;AA1BD,WAAiB,cAAc;IAC9B,SAAgB,EAAE,CAAC,KAA2B;QAC7C,OAAO,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AAwB,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;YACjD,CAAC,KAAK,CAAC,QAAQ,IAAI,SAAS;gBAC3B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;oBAC7B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE;wBAC/B,OAAO,wBAAwB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;oBACtC,CAAC,CAAC,CAAC,CAAC;YACN,OAAO,KAAK,CAAC,SAAS,IAAI,QAAQ;YAClC,CAAC,KAAK,CAAC,QAAQ,IAAI,SAAS,IAAI,oBAAoB,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACxE,CAAC,KAAK,CAAC,OAAO,IAAI,SAAS,IAAI,OAAO,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC;YAChE,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,IAAI,mBAAmB,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAC7E,CAAA;IACF,CAAC;IAxBe,iBAAE,KAwBjB,CAAA;AACF,CAAC,EA1BgB,cAAc,KAAd,cAAc,QA0B9B"}
@@ -53,7 +53,7 @@ export namespace CardResponseV2 {
53
53
  return CardScheduleResponseItem.is(a)
54
54
  }))) &&
55
55
  typeof value.createdBy == "string" &&
56
- CardDeliveryResponse.is(value.delivery) &&
56
+ (value.delivery == undefined || CardDeliveryResponse.is(value.delivery)) &&
57
57
  (value.batchId == undefined || typeof value.batchId == "string") &&
58
58
  (value.bookingInfo == undefined || BookingInfoResponse.is(value.bookingInfo))
59
59
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/client",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Client library for the Pax2Pay API",
5
5
  "author": "Pax2Pay Ltd.",
6
6
  "license": "MIT",