@pax2pay/client 0.0.51 → 0.0.54

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.
Files changed (65) hide show
  1. package/.eslintignore +3 -1
  2. package/Client/Auth/index.ts +6 -0
  3. package/Client/Beneficiaries/index.ts +33 -0
  4. package/Client/Beneficiary/index.ts +9 -0
  5. package/Client/Card/index.ts +38 -18
  6. package/Client/Cards/actions/actionTest.ts +4 -10
  7. package/Client/Cards/create/factory.ts +27 -20
  8. package/Client/Transfer/index.ts +9 -0
  9. package/Client/Transfers/factory.ts +172 -0
  10. package/Client/Transfers/index.ts +37 -0
  11. package/Client/generatePagination.ts +2 -2
  12. package/Client/index.ts +7 -1
  13. package/dist/Client/Auth/index.d.ts +2 -0
  14. package/dist/Client/Auth/index.js +6 -0
  15. package/dist/Client/Auth/index.js.map +1 -1
  16. package/dist/Client/Beneficiaries/index.d.ts +21 -0
  17. package/dist/Client/Beneficiaries/index.js +32 -0
  18. package/dist/Client/Beneficiaries/index.js.map +1 -0
  19. package/dist/Client/Beneficiary/index.d.ts +6 -0
  20. package/dist/Client/Beneficiary/index.js +7 -0
  21. package/dist/Client/Beneficiary/index.js.map +1 -0
  22. package/dist/Client/Card/index.js.map +1 -1
  23. package/dist/Client/Transfer/index.d.ts +6 -0
  24. package/dist/Client/Transfer/index.js +7 -0
  25. package/dist/Client/Transfer/index.js.map +1 -0
  26. package/dist/Client/Transfers/index.d.ts +21 -0
  27. package/dist/Client/Transfers/index.js +32 -0
  28. package/dist/Client/Transfers/index.js.map +1 -0
  29. package/dist/Client/generatePagination.js +2 -2
  30. package/dist/Client/generatePagination.js.map +1 -1
  31. package/dist/Client/index.d.ts +7 -1
  32. package/dist/Client/index.js +5 -1
  33. package/dist/Client/index.js.map +1 -1
  34. package/dist/model/BookingInfoRequest.d.ts +4 -3
  35. package/dist/model/CardDeliveryRequest.d.ts +6 -0
  36. package/dist/model/CardDeliveryRequest.js +2 -0
  37. package/dist/model/CardDeliveryRequest.js.map +1 -0
  38. package/dist/model/CreateCardRequest.d.ts +7 -3
  39. package/dist/model/ErrorMessageDto.js +2 -2
  40. package/dist/model/ErrorMessageDto.js.map +1 -1
  41. package/dist/model/FlightBookingInfoRequest.d.ts +33 -0
  42. package/dist/model/FlightBookingInfoRequest.js +4 -0
  43. package/dist/model/FlightBookingInfoRequest.js.map +1 -0
  44. package/dist/model/HotelBookingInfoRequest.d.ts +7 -0
  45. package/dist/model/HotelBookingInfoRequest.js +2 -0
  46. package/dist/model/HotelBookingInfoRequest.js.map +1 -0
  47. package/dist/model/LegacyBookingInfoRequest.d.ts +21 -0
  48. package/dist/model/LegacyBookingInfoRequest.js +2 -0
  49. package/dist/model/LegacyBookingInfoRequest.js.map +1 -0
  50. package/dist/model/ScheduledTaskRequest.d.ts +22 -0
  51. package/dist/model/ScheduledTaskRequest.js +7 -0
  52. package/dist/model/ScheduledTaskRequest.js.map +1 -0
  53. package/dist/model/index.d.ts +6 -1
  54. package/dist/model/index.js.map +1 -1
  55. package/model/BookingInfoRequest.ts +8 -3
  56. package/model/CardDeliveryRequest.ts +7 -0
  57. package/model/CreateCardRequest.ts +7 -3
  58. package/model/ErrorMessageDto.ts +2 -2
  59. package/model/FlightBookingInfoRequest.ts +33 -0
  60. package/model/HotelBookingInfoRequest.ts +8 -0
  61. package/model/LegacyBookingInfoRequest.ts +22 -0
  62. package/model/ScheduledTaskRequest.ts +32 -0
  63. package/model/Sorting.ts +1 -1
  64. package/model/index.ts +11 -0
  65. package/package.json +13 -12
package/.eslintignore CHANGED
@@ -1,3 +1,5 @@
1
1
  node_modules
2
2
  dist
3
- README.md
3
+ transpiled
4
+ *.js
5
+ **/*.d.ts
@@ -2,6 +2,12 @@ import * as model from "../../model"
2
2
  import { Connection } from "../Connection"
3
3
 
4
4
  export class Auth {
5
+ get token(): string | undefined {
6
+ return this.connection.token
7
+ }
8
+ set token(value: string | undefined) {
9
+ this.connection.token = value
10
+ }
5
11
  constructor(private connection: Connection) {}
6
12
  async login(request: model.LoginRequest) {
7
13
  const result = await this.connection.post<model.LoginResponse, 400 | 403 | 404 | 500>("auth/login", request)
@@ -0,0 +1,33 @@
1
+ import * as model from "../../model"
2
+ import { Beneficiary } from "../Beneficiary"
3
+ import { Connection } from "../Connection"
4
+ import { List } from "../List"
5
+
6
+ export class Beneficiaries extends List<model.BeneficiaryResponse, model.BeneficiaryRequest> {
7
+ protected folder = "beneficiaries"
8
+ constructor(connection: Connection) {
9
+ super(connection)
10
+ }
11
+ static create(connection: Connection): Beneficiaries {
12
+ return new Beneficiaries(connection)
13
+ }
14
+ protected getResourcePath(resource: model.BeneficiaryResponse): string {
15
+ return [this.folder, resource.beneficiaryId].join("/")
16
+ }
17
+ protected createResource(response: model.BeneficiaryResponse): Beneficiary {
18
+ return new Beneficiary(this.connection, [this.folder, response.beneficiaryId].join("/"), response)
19
+ }
20
+ async getAll() {
21
+ return await this.connection.get<model.BeneficiaryResponse[]>(`${this.folder}`)
22
+ }
23
+ async getBeneficiary(beneficiaryId: string) {
24
+ return await this.connection.get<model.BeneficiaryResponse>([this.folder, beneficiaryId].join("/"))
25
+ }
26
+ protected map(response: model.BeneficiaryResponse): Beneficiary & model.BeneficiaryResponse {
27
+ return Object.assign(new Beneficiary(this.connection, this.getResourcePath(response), response), response)
28
+ }
29
+ async create(request: model.BeneficiaryRequest) {
30
+ const result = await this.connection.post<model.BeneficiaryResponse>(`${this.folder}`, request)
31
+ return model.ErrorResponse.is(result) ? result : this.map(result)
32
+ }
33
+ }
@@ -0,0 +1,9 @@
1
+ import * as model from "../../model"
2
+ import { Connection } from "../Connection"
3
+ import { Resource } from "../Resource"
4
+
5
+ export class Beneficiary extends Resource<model.BeneficiaryResponse, model.BeneficiaryRequest> {
6
+ constructor(connection: Connection, folder: string, backend: model.BeneficiaryResponse) {
7
+ super(connection, folder, backend)
8
+ }
9
+ }
@@ -6,34 +6,54 @@ export class Card extends Resource<model.CardResponse, model.CreateCardRequest>
6
6
  constructor(connection: Connection, folder: string, backend: model.CardResponse) {
7
7
  super(connection, folder, backend)
8
8
  }
9
- amend(request: model.AmendCardRequest): Promise<model.CardResponse | (model.ErrorResponse & {
10
- status: 400 | 403 | 404 | 500 | 503;
11
- })> {
9
+ amend(
10
+ request: model.AmendCardRequest
11
+ ): Promise<
12
+ | model.CardResponse
13
+ | (model.ErrorResponse & {
14
+ status: 400 | 403 | 404 | 500 | 503
15
+ })
16
+ > {
12
17
  return this.connection.post<model.CardResponse>(`${this.folder}/amend`, request)
13
18
  }
14
- freeze(): Promise<model.CardResponse | (model.ErrorResponse & {
15
- status: 400 | 403 | 404 | 500 | 503;
16
- })> {
19
+ freeze(): Promise<
20
+ | model.CardResponse
21
+ | (model.ErrorResponse & {
22
+ status: 400 | 403 | 404 | 500 | 503
23
+ })
24
+ > {
17
25
  return this.connection.get<model.CardResponse>(`${this.folder}/freeze`)
18
26
  }
19
- thaw(): Promise<model.CardResponse | (model.ErrorResponse & {
20
- status: 400 | 403 | 404 | 500 | 503;
21
- })> {
27
+ thaw(): Promise<
28
+ | model.CardResponse
29
+ | (model.ErrorResponse & {
30
+ status: 400 | 403 | 404 | 500 | 503
31
+ })
32
+ > {
22
33
  return this.connection.get<model.CardResponse>(`${this.folder}/thaw`)
23
34
  }
24
- cancel(): Promise<model.CardResponse | (model.ErrorResponse & {
25
- status: 400 | 403 | 404 | 500 | 503;
26
- })> {
35
+ cancel(): Promise<
36
+ | model.CardResponse
37
+ | (model.ErrorResponse & {
38
+ status: 400 | 403 | 404 | 500 | 503
39
+ })
40
+ > {
27
41
  return this.connection.get<model.CardResponse>(`${this.folder}/cancel`)
28
42
  }
29
- process(): Promise<model.CardResponse | (model.ErrorResponse & {
30
- status: 400 | 403 | 404 | 500 | 503;
31
- })> {
43
+ process(): Promise<
44
+ | model.CardResponse
45
+ | (model.ErrorResponse & {
46
+ status: 400 | 403 | 404 | 500 | 503
47
+ })
48
+ > {
32
49
  return this.connection.get<model.CardResponse>(`${this.folder}/statements/processed`)
33
50
  }
34
- getTransactions(): Promise<model.CardResponse | (model.ErrorResponse & {
35
- status: 400 | 403 | 404 | 500 | 503;
36
- })> {
51
+ getTransactions(): Promise<
52
+ | model.CardResponse
53
+ | (model.ErrorResponse & {
54
+ status: 400 | 403 | 404 | 500 | 503
55
+ })
56
+ > {
37
57
  return this.connection.get<model.TransactionResponse>(`${this.folder}/transactions`)
38
58
  }
39
59
  }
@@ -5,7 +5,6 @@ import * as model from "../../../model"
5
5
  import { Card } from "../../Card"
6
6
 
7
7
  export async function actionTest(card: Card & model.CardResponse, client: pax2pay.Client) {
8
-
9
8
  assert(card.providerCardId && card.providerCode)
10
9
  assert(card.fundingAccount)
11
10
 
@@ -16,7 +15,7 @@ export async function actionTest(card: Card & model.CardResponse, client: pax2pa
16
15
  const amendedActualCard = await client?.cards.getCard(card.providerCardId, card.providerCode)
17
16
 
18
17
  assert(!(ErrorResponse.is(amendedActualCard) || ErrorResponse.is(amendedCard)))
19
-
18
+
20
19
  expect(amendedCard).toMatchObject({ balance: 2 })
21
20
  expect(amendedActualCard).toMatchObject({ balance: 2 })
22
21
 
@@ -24,7 +23,7 @@ export async function actionTest(card: Card & model.CardResponse, client: pax2pa
24
23
  const frozenActualCard = await client?.cards.getCard(card.providerCardId, card.providerCode)
25
24
 
26
25
  assert(!(ErrorResponse.is(frozenActualCard) || ErrorResponse.is(frozenCard)))
27
-
26
+
28
27
  expect(frozenCard).toMatchObject({ state: "INACTIVE" })
29
28
  expect(frozenActualCard).toMatchObject({ state: "INACTIVE" })
30
29
 
@@ -32,7 +31,7 @@ export async function actionTest(card: Card & model.CardResponse, client: pax2pa
32
31
  const thawedActualCard = await client?.cards.getCard(card.providerCardId, card.providerCode)
33
32
 
34
33
  assert(!(ErrorResponse.is(thawedActualCard) || ErrorResponse.is(thawedCard)))
35
-
34
+
36
35
  expect(thawedCard).toMatchObject({ state: "ACTIVE" })
37
36
  expect(thawedActualCard).toMatchObject({ state: "ACTIVE" })
38
37
 
@@ -40,12 +39,7 @@ export async function actionTest(card: Card & model.CardResponse, client: pax2pa
40
39
  const cancelledActualCard = await client?.cards.getCard(card.providerCardId, card.providerCode)
41
40
 
42
41
  assert(!(ErrorResponse.is(cancelledActualCard) || ErrorResponse.is(cancelledCard)))
43
-
42
+
44
43
  expect(cancelledCard).toMatchObject({ state: "DELETED" })
45
44
  expect(cancelledActualCard).toMatchObject({ state: "DELETED" })
46
-
47
-
48
-
49
-
50
-
51
45
  }
@@ -1,7 +1,9 @@
1
1
  import { mathExact } from "math-exact"
2
2
  import * as model from "../../../model"
3
3
 
4
- export function factory(card: Partial<model.CreateCardRequest>): [model.CreateCardRequest, model.CardResponseV2, model.CardResponse] {
4
+ export function factory(
5
+ card: Partial<model.CreateCardRequest>
6
+ ) /*TODO: issue with linter : [model.CreateCardRequest, model.CardResponseV2, model.CardResponse] */ {
5
7
  const request: model.CreateCardRequest = {
6
8
  cardType: {
7
9
  cardTypeId: "VISA_DEBIT_CORPORATE",
@@ -22,7 +24,7 @@ export function factory(card: Partial<model.CreateCardRequest>): [model.CreateCa
22
24
  expiryDate: expect.stringMatching(/\d{4}-\d{2}/),
23
25
  nameOnCard: expect.any(String),
24
26
  balance: request.providerCode == "modulr" ? mathExact("Add", request.balance, 1) : request.balance,
25
- issueDate: new Date().toISOString().slice(0,10),
27
+ issueDate: new Date().toISOString().slice(0, 10),
26
28
  providerCardId: expect.any(String),
27
29
  providerCode: request.providerCode,
28
30
  usage: request.providerCode == "modulr" ? "SINGLE_USE_ALLOW_TEST_AUTH" : "SINGLE_USE",
@@ -35,7 +37,7 @@ export function factory(card: Partial<model.CreateCardRequest>): [model.CreateCa
35
37
  expiryDate: expect.stringMatching(/\d{4}-\d{2}/),
36
38
  nameOnCard: expect.any(String),
37
39
  balance: request.providerCode == "modulr" ? mathExact("Add", request.balance, 2) : request.balance,
38
- issueDate: new Date().toISOString().slice(0,10),
40
+ issueDate: new Date().toISOString().slice(0, 10),
39
41
  providerCardId: expect.any(String),
40
42
  providerCode: request.providerCode,
41
43
  usage: request.providerCode == "modulr" ? "SINGLE_USE_ALLOW_TEST_AUTH" : "SINGLE_USE",
@@ -46,27 +48,32 @@ export function factory(card: Partial<model.CreateCardRequest>): [model.CreateCa
46
48
  cardAccount: {
47
49
  id: expect.any(Number),
48
50
  providerAccountId: expect.any(String),
49
- provider: expect.objectContaining({ id: expect.any(Number), code: request.providerCode, name: expect.any(String), status: 'ACTIVE' }),
50
- organisation: { code: expect.any(String), name: expect.any(String), status: 'ACTIVE' },
51
- currency: request.currency,
52
- state: 'ACTIVE',
53
- friendlyName: expect.any(String),
54
- balance: request.providerCode == "modulr" ? mathExact("Add", request.balance, 2) : request.balance,
55
- accountType: 'CARD',
56
- updatedOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
57
- createdOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
51
+ provider: expect.objectContaining({
52
+ id: expect.any(Number),
53
+ code: request.providerCode,
54
+ name: expect.any(String),
55
+ status: "ACTIVE",
56
+ }),
57
+ organisation: { code: expect.any(String), name: expect.any(String), status: "ACTIVE" },
58
+ currency: request.currency,
59
+ state: "ACTIVE",
60
+ friendlyName: expect.any(String),
61
+ balance: request.providerCode == "modulr" ? mathExact("Add", request.balance, 2) : request.balance,
62
+ accountType: "CARD",
63
+ updatedOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
64
+ createdOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
58
65
  },
59
66
  fundingAccount: {
60
67
  id: expect.any(Number),
61
68
  providerAccountId: expect.any(String),
62
- provider: { id: expect.any(Number), code: request.providerCode, name: expect.any(String), status: 'ACTIVE' },
63
- organisation: { code: expect.any(String), name: expect.any(String), status: 'ACTIVE' },
64
- currency: request.currency,
65
- state: 'ACTIVE',
66
- friendlyName: expect.any(String),
67
- balance: expect.any(Number),
68
- accountType: 'FUNDING',
69
- updatedOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
69
+ provider: { id: expect.any(Number), code: request.providerCode, name: expect.any(String), status: "ACTIVE" },
70
+ organisation: { code: expect.any(String), name: expect.any(String), status: "ACTIVE" },
71
+ currency: request.currency,
72
+ state: "ACTIVE",
73
+ friendlyName: expect.any(String),
74
+ balance: expect.any(Number),
75
+ accountType: "FUNDING",
76
+ updatedOn: expect.stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+/),
70
77
  },
71
78
  creatingSystem: expect.any(String),
72
79
  },
@@ -0,0 +1,9 @@
1
+ import * as model from "../../model"
2
+ import { Connection } from "../Connection"
3
+ import { Resource } from "../Resource"
4
+
5
+ export class Transfer extends Resource<model.TransferResponse, model.TransferRequest> {
6
+ constructor(connection: Connection, folder: string, backend: model.TransferResponse) {
7
+ super(connection, folder, backend)
8
+ }
9
+ }
@@ -0,0 +1,172 @@
1
+ import assert from "assert"
2
+ import * as dotenv from "dotenv"
3
+ import * as model from "../../model"
4
+
5
+ dotenv.config()
6
+
7
+ const sourceAccount = process.env["accountModulrEur"]
8
+ assert(sourceAccount)
9
+
10
+ const basicRequest: model.TransferRequest = {
11
+ providerCode: "modulr" as model.ProviderCode,
12
+ providerSourceAccountId: sourceAccount,
13
+ amount: 1,
14
+ currency: "EUR",
15
+ }
16
+
17
+ const basicExpected = {
18
+ sourceAccount: {
19
+ id: expect.any(Number),
20
+ providerAccountId: expect.any(String),
21
+ currency: expect.any(String),
22
+ state: expect.stringMatching(
23
+ /(ACTIVE)|(INACTIVE)|(CLOSED)|(DELETED)|(EXPIRED)|(PENDING)|(APPROVED)|(DECLINED)|(GENERATED)/
24
+ ),
25
+ friendlyName: expect.any(String),
26
+ balance: expect.any(Number),
27
+ accountType: expect.stringMatching(/(FUNDING)|(CARD)/),
28
+ updatedOn: expect.any(String),
29
+ createdOn: expect.any(String),
30
+ provider: {
31
+ id: expect.any(Number),
32
+ code: basicRequest.providerCode,
33
+ name: expect.any(String),
34
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)|(INACTIVE)/),
35
+ },
36
+ organisation: {
37
+ code: expect.any(String),
38
+ name: expect.any(String),
39
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)/),
40
+ },
41
+ },
42
+ amount: expect.any(Number),
43
+ status: expect.stringMatching(
44
+ /(PENDING)|(PENDING_FOR_DATE)|(PENDING_FOR_FUNDS)|(SETTLED)|(CANCELLED)|(ERROR_REJECTED)|(APPROVAL_PENDING)|(DECLINED)|(APPROVED)|(GENERATED)/
45
+ ),
46
+ createdDate: expect.any(String),
47
+ paymentDate: expect.any(String),
48
+ reference: expect.any(String),
49
+ providerCode: basicRequest.providerCode,
50
+ providerTransferId: expect.any(String),
51
+ scheduled: expect.any(Boolean),
52
+ }
53
+
54
+ export function getRequestForBeneficiary(): model.TransferRequest {
55
+ return {
56
+ ...basicRequest,
57
+ beneficiaryId: process.env.beneficiaryModulr,
58
+ }
59
+ }
60
+
61
+ export function getExpectedForBeneficiary(request: model.TransferRequest): model.TransferResponse {
62
+ assert(request.currency)
63
+
64
+ return {
65
+ ...basicExpected,
66
+ amount: request.amount,
67
+ beneficiary: {
68
+ transferDestination: {
69
+ currency: request.currency,
70
+ fullName: expect.any(String),
71
+ },
72
+ defaultReference: expect.any(String),
73
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)|(OUTDATED)/),
74
+ fullName: expect.any(String),
75
+ beneficiaryId: process.env.beneficiaryModulr,
76
+ createdOn: expect.any(String),
77
+ },
78
+ }
79
+ }
80
+
81
+ export function getRequestForDestination(): model.TransferRequest {
82
+ assert(process.env.testIban)
83
+
84
+ return {
85
+ ...basicRequest,
86
+ destination: {
87
+ iban: process.env.testIban,
88
+ fullName: "Test Transfer",
89
+ },
90
+ reference: "iban transfer test",
91
+ }
92
+ }
93
+ export function getExpectedForDestination(request: model.TransferRequest): model.TransferResponse {
94
+ assert(request.currency)
95
+ assert(request.destination)
96
+ return {
97
+ ...basicExpected,
98
+ destination: {
99
+ iban: request.destination.iban,
100
+ currency: request.currency,
101
+ fullName: request.destination.fullName,
102
+ },
103
+ }
104
+ }
105
+ export function getRequestForDestinationPlusBeneficiary(): model.TransferRequest {
106
+ const otherAccount = process.env["accountModulrEur2"]
107
+ assert(otherAccount)
108
+ assert(process.env.testIban)
109
+
110
+ return {
111
+ ...basicRequest,
112
+ providerSourceAccountId: otherAccount,
113
+ destination: {
114
+ iban: process.env.testIban,
115
+ fullName: "Test Beneficiary tx",
116
+ saveAsNewBeneficiary: true,
117
+ },
118
+ reference: "save beneficiary",
119
+ }
120
+ }
121
+
122
+ export function getExpectedForDestinationPlusBeneficiary(request: model.TransferRequest): model.TransferResponse {
123
+ assert(request.currency)
124
+ assert(request.destination)
125
+ return {
126
+ ...basicExpected,
127
+ beneficiary: {
128
+ transferDestination: {
129
+ iban: request.destination.iban,
130
+ currency: request.currency,
131
+ fullName: request.destination.fullName,
132
+ },
133
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)|(OUTDATED)/),
134
+ fullName: expect.any(String),
135
+ beneficiaryId: expect.any(String),
136
+ createdOn: expect.any(String),
137
+ },
138
+ }
139
+ }
140
+
141
+ export function getRequestForFundingAccount(): model.TransferRequest {
142
+ return {
143
+ ...basicRequest,
144
+ destinationProviderAccountId: process.env.accountModulrEur2,
145
+ reference: "acc transfer test",
146
+ }
147
+ }
148
+
149
+ export function getExpectedForFundingAccount(request: model.TransferRequest) {
150
+ return {
151
+ ...basicExpected,
152
+ destinationAccount: {
153
+ providerAccountId: request.destinationProviderAccountId,
154
+ },
155
+ }
156
+ }
157
+
158
+ export function getExpectedForGeneric(): model.TransferResponse {
159
+ return {
160
+ ...basicExpected,
161
+ sourceAccount: {
162
+ ...basicExpected.sourceAccount,
163
+ provider: {
164
+ id: expect.any(Number),
165
+ code: expect.stringMatching(/(conferma)|(ixaris)|(wex)|(fake)|(lodged)|(modulr)|(unknown)|(pax2pay)/),
166
+ name: expect.any(String),
167
+ status: expect.stringMatching(/(ACTIVE)|(DELETED)|(INACTIVE)/),
168
+ },
169
+ },
170
+ providerCode: expect.stringMatching(/(conferma)|(ixaris)|(wex)|(fake)|(lodged)|(modulr)|(unknown)|(pax2pay)/),
171
+ }
172
+ }
@@ -0,0 +1,37 @@
1
+ import * as model from "../../model"
2
+ import { Connection } from "../Connection"
3
+ import { List } from "../List"
4
+ import { Transfer } from "../Transfer"
5
+
6
+ export class Transfers extends List<model.TransferResponse, model.TransferSearch, model.TransferRequest> {
7
+ protected folder = "transfers"
8
+ constructor(connection: Connection) {
9
+ super(connection)
10
+ }
11
+ static create(connection: Connection): Transfers {
12
+ return new Transfers(connection)
13
+ }
14
+ protected getResourcePath(resource: model.TransferResponse): string {
15
+ return [this.folder, resource.providerCode, resource.providerTransferId].join("/")
16
+ }
17
+ protected createResource(response: model.TransferResponse): Transfer {
18
+ return new Transfer(
19
+ this.connection,
20
+ [this.folder, response.providerCode, response.providerTransferId].join("/"),
21
+ response
22
+ )
23
+ }
24
+ async getAll() {
25
+ return await this.connection.get<model.TransferResponse[]>(`${this.folder}`)
26
+ }
27
+ async getTransfer(provider: model.ProviderCode, transferId: string) {
28
+ return await this.connection.get<model.TransferResponse>([this.folder, provider, transferId].join("/"))
29
+ }
30
+ protected map(response: model.TransferResponse): Transfer & model.TransferResponse {
31
+ return Object.assign(new Transfer(this.connection, this.getResourcePath(response), response), response)
32
+ }
33
+ async create(request: model.TransferRequest) {
34
+ const result = await this.connection.post<model.TransferResponse>(`${this.folder}`, request)
35
+ return model.ErrorResponse.is(result) ? result : this.map(result)
36
+ }
37
+ }
@@ -6,8 +6,8 @@ export function generatePagination<T extends { [key: string]: any } = { [key: st
6
6
  sort: model.Sorting<T>[] = []
7
7
  ): string {
8
8
  const result = [
9
- ...(page == 0 ? [`page=${page}`] : []),
10
- ...(size == 20 ? [`size=${size}`] : []),
9
+ ...(page ? [`page=${page}`] : []),
10
+ ...(size ? [`size=${size}`] : []),
11
11
  ...sort.map(s => `sort=${typeof s == "object" ? s + (s.direction == "descending" ? "desc" : "") : s}`),
12
12
  ].join("&")
13
13
  return result ? "?" + result : ""
package/Client/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Account as ClientAccount } from "./Account"
2
2
  import { Accounts as ClientAccounts } from "./Accounts"
3
3
  import { Auth as ClientAuth } from "./Auth"
4
+ import { Beneficiaries as ClientBeneficiaries } from "./Beneficiaries"
4
5
  import { Card as ClientCard } from "./Card"
5
6
  import { Cards as ClientCards } from "./Cards"
6
7
  import { Collection as ClientCollection } from "./Collection"
@@ -10,6 +11,7 @@ import { Organisation as ClientOrganisation } from "./Organisation"
10
11
  import { Organisations as ClientOrganisations } from "./Organisations"
11
12
  import { Reports as ClientReports } from "./Reports"
12
13
  import { Resource as ClientResource } from "./Resource"
14
+ import { Transfers as ClientTransfers } from "./Transfers"
13
15
  import { User as ClientUser } from "./User"
14
16
  import { Users as ClientUsers } from "./Users"
15
17
 
@@ -20,11 +22,13 @@ export class Client {
20
22
  this.$authenticate = value
21
23
  }
22
24
  accounts = ClientAccounts.create(this.connection)
23
- cards = ClientCards.create(this.connection)
24
25
  auth = ClientAuth.create(this.connection)
26
+ beneficiaries = ClientBeneficiaries.create(this.connection)
27
+ cards = ClientCards.create(this.connection)
25
28
  users = ClientUsers.create(this.connection)
26
29
  organisations = ClientOrganisations.create(this.connection)
27
30
  reports = ClientReports.create(this.connection)
31
+ transfers = ClientTransfers.create(this.connection)
28
32
  constructor(private connection: Connection, private $authenticate?: Authenticate) {
29
33
  connection.unauthorized = async () => (await this.$authenticate?.(this)) ?? false
30
34
  }
@@ -38,11 +42,13 @@ export namespace Client {
38
42
  export type Account = ClientAccount
39
43
  export type Accounts = ClientAccounts
40
44
  export type Auth = ClientAuth
45
+ export type Beneficiaries = ClientBeneficiaries
41
46
  export type Card = ClientCard
42
47
  export type Cards = ClientCards
43
48
  export type Organisation = ClientOrganisation
44
49
  export type Organisations = ClientOrganisations
45
50
  export type Reports = ClientReports
51
+ export type Transfers = ClientTransfers
46
52
  export type User = ClientUser
47
53
  export type Users = ClientUsers
48
54
  export type Collection<
@@ -2,6 +2,8 @@ import * as model from "../../model";
2
2
  import { Connection } from "../Connection";
3
3
  export declare class Auth {
4
4
  private connection;
5
+ get token(): string | undefined;
6
+ set token(value: string | undefined);
5
7
  constructor(connection: Connection);
6
8
  login(request: model.LoginRequest): Promise<model.LoginResponse | (model.ErrorResponse & {
7
9
  status: 400 | 404 | 500 | 403 | 503;
@@ -2,6 +2,12 @@ export class Auth {
2
2
  constructor(connection) {
3
3
  this.connection = connection;
4
4
  }
5
+ get token() {
6
+ return this.connection.token;
7
+ }
8
+ set token(value) {
9
+ this.connection.token = value;
10
+ }
5
11
  async login(request) {
6
12
  const result = await this.connection.post("auth/login", request);
7
13
  if (!isError(result))
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Auth/index.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,IAAI;IAChB,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAC9C,KAAK,CAAC,KAAK,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA6C,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5G,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACrC,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,OAAgD;QAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA6C,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5G,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACrC,OAAO,MAAM,CAAA;IACd,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,UAAsB;QACnC,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC5B,CAAC;CACD;AAED,SAAS,OAAO,CAAC,KAAgC;IAChD,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAA;AACjE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Auth/index.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,IAAI;IAOhB,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAN9C,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAA;IAC7B,CAAC;IACD,IAAI,KAAK,CAAC,KAAyB;QAClC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA6C,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5G,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACrC,OAAO,MAAM,CAAA;IACd,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,OAAgD;QAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA6C,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5G,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACnB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACrC,OAAO,MAAM,CAAA;IACd,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,UAAsB;QACnC,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC5B,CAAC;CACD;AAED,SAAS,OAAO,CAAC,KAAgC;IAChD,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAA;AACjE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import * as model from "../../model";
2
+ import { Beneficiary } from "../Beneficiary";
3
+ import { Connection } from "../Connection";
4
+ import { List } from "../List";
5
+ export declare class Beneficiaries extends List<model.BeneficiaryResponse, model.BeneficiaryRequest> {
6
+ protected folder: string;
7
+ constructor(connection: Connection);
8
+ static create(connection: Connection): Beneficiaries;
9
+ protected getResourcePath(resource: model.BeneficiaryResponse): string;
10
+ protected createResource(response: model.BeneficiaryResponse): Beneficiary;
11
+ getAll(): Promise<model.BeneficiaryResponse[] | (model.ErrorResponse & {
12
+ status: 400 | 404 | 500 | 403 | 503;
13
+ })>;
14
+ getBeneficiary(beneficiaryId: string): Promise<model.BeneficiaryResponse | (model.ErrorResponse & {
15
+ status: 400 | 404 | 500 | 403 | 503;
16
+ })>;
17
+ protected map(response: model.BeneficiaryResponse): Beneficiary & model.BeneficiaryResponse;
18
+ create(request: model.BeneficiaryRequest): Promise<(model.ErrorResponse & {
19
+ status: 400 | 404 | 500 | 403 | 503;
20
+ }) | (Beneficiary & model.BeneficiaryResponse)>;
21
+ }
@@ -0,0 +1,32 @@
1
+ import * as model from "../../model";
2
+ import { Beneficiary } from "../Beneficiary";
3
+ import { List } from "../List";
4
+ export class Beneficiaries extends List {
5
+ constructor(connection) {
6
+ super(connection);
7
+ this.folder = "beneficiaries";
8
+ }
9
+ static create(connection) {
10
+ return new Beneficiaries(connection);
11
+ }
12
+ getResourcePath(resource) {
13
+ return [this.folder, resource.beneficiaryId].join("/");
14
+ }
15
+ createResource(response) {
16
+ return new Beneficiary(this.connection, [this.folder, response.beneficiaryId].join("/"), response);
17
+ }
18
+ async getAll() {
19
+ return await this.connection.get(`${this.folder}`);
20
+ }
21
+ async getBeneficiary(beneficiaryId) {
22
+ return await this.connection.get([this.folder, beneficiaryId].join("/"));
23
+ }
24
+ map(response) {
25
+ return Object.assign(new Beneficiary(this.connection, this.getResourcePath(response), response), response);
26
+ }
27
+ async create(request) {
28
+ const result = await this.connection.post(`${this.folder}`, request);
29
+ return model.ErrorResponse.is(result) ? result : this.map(result);
30
+ }
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Beneficiaries/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,MAAM,OAAO,aAAc,SAAQ,IAAyD;IAE3F,YAAY,UAAsB;QACjC,KAAK,CAAC,UAAU,CAAC,CAAA;QAFR,WAAM,GAAG,eAAe,CAAA;IAGlC,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,UAAsB;QACnC,OAAO,IAAI,aAAa,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;IACS,eAAe,CAAC,QAAmC;QAC5D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvD,CAAC;IACS,cAAc,CAAC,QAAmC;QAC3D,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;IACnG,CAAC;IACD,KAAK,CAAC,MAAM;QACX,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAA8B,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAChF,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,aAAqB;QACzC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAA4B,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACpG,CAAC;IACS,GAAG,CAAC,QAAmC;QAChD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC3G,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAiC;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA4B,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAA;QAC/F,OAAO,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAClE,CAAC;CACD"}
@@ -0,0 +1,6 @@
1
+ import * as model from "../../model";
2
+ import { Connection } from "../Connection";
3
+ import { Resource } from "../Resource";
4
+ export declare class Beneficiary extends Resource<model.BeneficiaryResponse, model.BeneficiaryRequest> {
5
+ constructor(connection: Connection, folder: string, backend: model.BeneficiaryResponse);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Resource } from "../Resource";
2
+ export class Beneficiary extends Resource {
3
+ constructor(connection, folder, backend) {
4
+ super(connection, folder, backend);
5
+ }
6
+ }
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/Beneficiary/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,OAAO,WAAY,SAAQ,QAA6D;IAC7F,YAAY,UAAsB,EAAE,MAAc,EAAE,OAAkC;QACrF,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;CACD"}