paisr-js 0.1.0
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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/index.cjs +864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8140 -0
- package/dist/index.d.ts +8140 -0
- package/dist/index.js +831 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,831 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import createClient from "openapi-fetch";
|
|
3
|
+
var BASE_URLS = {
|
|
4
|
+
live: "https://api.live.paisr.tech/v2",
|
|
5
|
+
staging: "https://api.staging.paisr.tech/v2"
|
|
6
|
+
};
|
|
7
|
+
function createPaisrClient(options) {
|
|
8
|
+
if (!options.apiKey) {
|
|
9
|
+
throw new Error("Paisr: `apiKey` is required.");
|
|
10
|
+
}
|
|
11
|
+
const baseUrl = options.baseUrl ?? BASE_URLS[options.environment ?? "live"];
|
|
12
|
+
return createClient({
|
|
13
|
+
baseUrl,
|
|
14
|
+
fetch: options.fetch,
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var PaisrError = class extends Error {
|
|
21
|
+
/** HTTP status code of the failed response. */
|
|
22
|
+
status;
|
|
23
|
+
/** Parsed error response body, if any. */
|
|
24
|
+
body;
|
|
25
|
+
constructor(message, status, body) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "PaisrError";
|
|
28
|
+
this.status = status;
|
|
29
|
+
this.body = body;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
async function unwrap(resultPromise) {
|
|
33
|
+
const { data, error, response } = await resultPromise;
|
|
34
|
+
if (error !== void 0) {
|
|
35
|
+
const body = error;
|
|
36
|
+
throw new PaisrError(
|
|
37
|
+
body?.message ?? `Paisr API request failed with status ${response.status}`,
|
|
38
|
+
response.status,
|
|
39
|
+
error
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const envelope = data;
|
|
43
|
+
if (envelope && typeof envelope === "object" && "data" in envelope) {
|
|
44
|
+
return envelope.data;
|
|
45
|
+
}
|
|
46
|
+
return envelope;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/resources/access-tokens.ts
|
|
50
|
+
var AccessTokensResource = class {
|
|
51
|
+
constructor(client) {
|
|
52
|
+
this.client = client;
|
|
53
|
+
}
|
|
54
|
+
client;
|
|
55
|
+
/** Fetch a list of access tokens. */
|
|
56
|
+
list() {
|
|
57
|
+
return unwrap(this.client.GET("/access-tokens", {}));
|
|
58
|
+
}
|
|
59
|
+
/** Create a new access token. */
|
|
60
|
+
create(body) {
|
|
61
|
+
return unwrap(this.client.POST("/access-tokens", { body }));
|
|
62
|
+
}
|
|
63
|
+
/** Fetch a single access token. */
|
|
64
|
+
get(tokenId) {
|
|
65
|
+
return unwrap(this.client.GET("/access-tokens/{token_id}", { params: { path: { token_id: tokenId } } }));
|
|
66
|
+
}
|
|
67
|
+
/** Update an access token. */
|
|
68
|
+
update(tokenId, body) {
|
|
69
|
+
return unwrap(this.client.PUT("/access-tokens/{token_id}", { params: { path: { token_id: tokenId } }, body }));
|
|
70
|
+
}
|
|
71
|
+
/** Revoke an access token. */
|
|
72
|
+
revoke(tokenId) {
|
|
73
|
+
return unwrap(this.client.DELETE("/access-tokens/{token_id}", { params: { path: { token_id: tokenId } } }));
|
|
74
|
+
}
|
|
75
|
+
/** Add a permission scope to an access token. */
|
|
76
|
+
addPermission(tokenId, body) {
|
|
77
|
+
return unwrap(
|
|
78
|
+
this.client.POST("/access-tokens/{token_id}/permissions", { params: { path: { token_id: tokenId } }, body })
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
/** Remove a permission scope from an access token. */
|
|
82
|
+
removePermission(tokenId, permissionId) {
|
|
83
|
+
return unwrap(
|
|
84
|
+
this.client.DELETE("/access-tokens/{token_id}/permissions/{permission_id}", {
|
|
85
|
+
params: { path: { token_id: tokenId, permission_id: permissionId } }
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// src/resources/webhooks.ts
|
|
92
|
+
var WebhooksResource = class {
|
|
93
|
+
constructor(client) {
|
|
94
|
+
this.client = client;
|
|
95
|
+
}
|
|
96
|
+
client;
|
|
97
|
+
/** Fetch a list of webhooks. */
|
|
98
|
+
list() {
|
|
99
|
+
return unwrap(this.client.GET("/webhooks", {}));
|
|
100
|
+
}
|
|
101
|
+
/** Create a new webhook. */
|
|
102
|
+
create(body) {
|
|
103
|
+
return unwrap(this.client.POST("/webhooks", { body }));
|
|
104
|
+
}
|
|
105
|
+
/** Fetch a single webhook. */
|
|
106
|
+
get(webhookId) {
|
|
107
|
+
return unwrap(this.client.GET("/webhooks/{webhook_id}", { params: { path: { webhook_id: webhookId } } }));
|
|
108
|
+
}
|
|
109
|
+
/** Replace a webhook's configuration. */
|
|
110
|
+
update(webhookId, body) {
|
|
111
|
+
return unwrap(
|
|
112
|
+
this.client.PUT("/webhooks/{webhook_id}", { params: { path: { webhook_id: webhookId } }, body })
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
/** Partially modify a webhook (e.g. enable/disable). */
|
|
116
|
+
modify(webhookId) {
|
|
117
|
+
return unwrap(this.client.PATCH("/webhooks/{webhook_id}", { params: { path: { webhook_id: webhookId } } }));
|
|
118
|
+
}
|
|
119
|
+
/** Remove a webhook. */
|
|
120
|
+
remove(webhookId) {
|
|
121
|
+
return unwrap(this.client.DELETE("/webhooks/{webhook_id}", { params: { path: { webhook_id: webhookId } } }));
|
|
122
|
+
}
|
|
123
|
+
/** Send a test event to a webhook. */
|
|
124
|
+
test(webhookId) {
|
|
125
|
+
return unwrap(this.client.POST("/webhooks/{webhook_id}/test", { params: { path: { webhook_id: webhookId } } }));
|
|
126
|
+
}
|
|
127
|
+
/** Fetch delivery stats for a webhook. */
|
|
128
|
+
getStats(webhookId) {
|
|
129
|
+
return unwrap(this.client.GET("/webhooks/{webhook_id}/stats", { params: { path: { webhook_id: webhookId } } }));
|
|
130
|
+
}
|
|
131
|
+
/** Fetch a webhook's signing secret. */
|
|
132
|
+
getSecret(webhookId) {
|
|
133
|
+
return unwrap(this.client.GET("/webhooks/{webhook_id}/secret", { params: { path: { webhook_id: webhookId } } }));
|
|
134
|
+
}
|
|
135
|
+
/** Rotate a webhook's signing secret. */
|
|
136
|
+
rotateSecret(webhookId) {
|
|
137
|
+
return unwrap(
|
|
138
|
+
this.client.PATCH("/webhooks/{webhook_id}/secret", { params: { path: { webhook_id: webhookId } } })
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
/** Subscribe a webhook to an additional event trigger. */
|
|
142
|
+
addTrigger(webhookId, body) {
|
|
143
|
+
return unwrap(
|
|
144
|
+
this.client.POST("/webhooks/{webhook_id}/triggers", { params: { path: { webhook_id: webhookId } }, body })
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
/** Unsubscribe a webhook from an event trigger. */
|
|
148
|
+
removeTrigger(webhookId, triggerId) {
|
|
149
|
+
return unwrap(
|
|
150
|
+
this.client.DELETE("/webhooks/{webhook_id}/triggers/{trigger_id}", {
|
|
151
|
+
params: { path: { webhook_id: webhookId, trigger_id: triggerId } }
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
/** Fetch delivery events for a webhook. */
|
|
156
|
+
getEvents(webhookId) {
|
|
157
|
+
return unwrap(this.client.GET("/webhooks/{webhook_id}/events", { params: { path: { webhook_id: webhookId } } }));
|
|
158
|
+
}
|
|
159
|
+
/** Retry delivery of a specific webhook event. */
|
|
160
|
+
retryEvent(webhookId, eventId) {
|
|
161
|
+
return unwrap(
|
|
162
|
+
this.client.POST("/webhooks/{webhook_id}/events/{event_id}", {
|
|
163
|
+
params: { path: { webhook_id: webhookId, event_id: eventId } }
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// src/resources/wallets.ts
|
|
170
|
+
var WalletPinResource = class {
|
|
171
|
+
constructor(client) {
|
|
172
|
+
this.client = client;
|
|
173
|
+
}
|
|
174
|
+
client;
|
|
175
|
+
/** Fetch a wallet's PIN state (never the raw PIN itself). */
|
|
176
|
+
get(walletId) {
|
|
177
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}/pin", { params: { path: { wallet_id: walletId } } }));
|
|
178
|
+
}
|
|
179
|
+
/** Rotate a wallet's PIN. */
|
|
180
|
+
rotate(walletId) {
|
|
181
|
+
return unwrap(this.client.PATCH("/wallets/{wallet_id}/pin", { params: { path: { wallet_id: walletId } } }));
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var WalletStatementsResource = class {
|
|
185
|
+
constructor(client) {
|
|
186
|
+
this.client = client;
|
|
187
|
+
}
|
|
188
|
+
client;
|
|
189
|
+
/** Fetch a wallet's statements. */
|
|
190
|
+
list(walletId) {
|
|
191
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}/statements", { params: { path: { wallet_id: walletId } } }));
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var WalletTransactionsResource = class {
|
|
195
|
+
constructor(client) {
|
|
196
|
+
this.client = client;
|
|
197
|
+
}
|
|
198
|
+
client;
|
|
199
|
+
/** Fetch a wallet's transactions, optionally filtered by balance, status, type, or method. */
|
|
200
|
+
list(walletId, query) {
|
|
201
|
+
return unwrap(
|
|
202
|
+
this.client.GET("/wallets/{wallet_id}/transactions", { params: { path: { wallet_id: walletId }, query } })
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
/** Fetch a single transaction on a wallet. */
|
|
206
|
+
get(walletId, transactionId) {
|
|
207
|
+
return unwrap(
|
|
208
|
+
this.client.GET("/wallets/{wallet_id}/transactions/{transaction_id}", {
|
|
209
|
+
params: { path: { wallet_id: walletId, transaction_id: transactionId } }
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var WalletBalancesResource = class {
|
|
215
|
+
constructor(client) {
|
|
216
|
+
this.client = client;
|
|
217
|
+
}
|
|
218
|
+
client;
|
|
219
|
+
/** Fetch a wallet's balances, optionally filtered by type or currency. */
|
|
220
|
+
list(walletId, query) {
|
|
221
|
+
return unwrap(
|
|
222
|
+
this.client.GET("/wallets/{wallet_id}/balances", { params: { path: { wallet_id: walletId }, query } })
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
/** Open a new balance on a wallet. */
|
|
226
|
+
open(walletId, body) {
|
|
227
|
+
return unwrap(
|
|
228
|
+
this.client.POST("/wallets/{wallet_id}/balances", { params: { path: { wallet_id: walletId } }, body })
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
/** Fetch a single balance on a wallet. */
|
|
232
|
+
get(walletId, balanceId) {
|
|
233
|
+
return unwrap(
|
|
234
|
+
this.client.GET("/wallets/{wallet_id}/balances/{balance_id}", {
|
|
235
|
+
params: { path: { wallet_id: walletId, balance_id: balanceId } }
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
/** Update a balance on a wallet. */
|
|
240
|
+
update(walletId, balanceId, body) {
|
|
241
|
+
return unwrap(
|
|
242
|
+
this.client.PUT("/wallets/{wallet_id}/balances/{balance_id}", {
|
|
243
|
+
params: { path: { wallet_id: walletId, balance_id: balanceId } },
|
|
244
|
+
body
|
|
245
|
+
})
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
/** Close a balance on a wallet. */
|
|
249
|
+
close(walletId, balanceId) {
|
|
250
|
+
return unwrap(
|
|
251
|
+
this.client.DELETE("/wallets/{wallet_id}/balances/{balance_id}", {
|
|
252
|
+
params: { path: { wallet_id: walletId, balance_id: balanceId } }
|
|
253
|
+
})
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var WalletAccountsResource = class {
|
|
258
|
+
constructor(client) {
|
|
259
|
+
this.client = client;
|
|
260
|
+
}
|
|
261
|
+
client;
|
|
262
|
+
/** Fetch a wallet's linked external accounts. */
|
|
263
|
+
list(walletId) {
|
|
264
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}/accounts", { params: { path: { wallet_id: walletId } } }));
|
|
265
|
+
}
|
|
266
|
+
/** Connect a new external account to a wallet. */
|
|
267
|
+
connect(walletId, body) {
|
|
268
|
+
return unwrap(
|
|
269
|
+
this.client.POST("/wallets/{wallet_id}/accounts", { params: { path: { wallet_id: walletId } }, body })
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
/** Fetch a single linked account. */
|
|
273
|
+
get(walletId, accountId) {
|
|
274
|
+
return unwrap(
|
|
275
|
+
this.client.GET("/wallets/{wallet_id}/accounts/{account_id}", {
|
|
276
|
+
params: { path: { wallet_id: walletId, account_id: accountId } }
|
|
277
|
+
})
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
/** Verify a linked account (e.g. micro-deposit confirmation). */
|
|
281
|
+
verify(walletId, accountId, body) {
|
|
282
|
+
return unwrap(
|
|
283
|
+
this.client.PATCH("/wallets/{wallet_id}/accounts/{account_id}", {
|
|
284
|
+
params: { path: { wallet_id: walletId, account_id: accountId } },
|
|
285
|
+
body
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
/** Remove a linked account from a wallet. */
|
|
290
|
+
remove(walletId, accountId) {
|
|
291
|
+
return unwrap(
|
|
292
|
+
this.client.DELETE("/wallets/{wallet_id}/accounts/{account_id}", {
|
|
293
|
+
params: { path: { wallet_id: walletId, account_id: accountId } }
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
var WalletContactsResource = class {
|
|
299
|
+
constructor(client) {
|
|
300
|
+
this.client = client;
|
|
301
|
+
}
|
|
302
|
+
client;
|
|
303
|
+
/** Fetch a wallet's saved payment contacts. */
|
|
304
|
+
list(walletId) {
|
|
305
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}/contacts", { params: { path: { wallet_id: walletId } } }));
|
|
306
|
+
}
|
|
307
|
+
/** Add a payment contact to a wallet. */
|
|
308
|
+
add(walletId, body) {
|
|
309
|
+
return unwrap(
|
|
310
|
+
this.client.POST("/wallets/{wallet_id}/contacts", { params: { path: { wallet_id: walletId } }, body })
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
/** Fetch a single payment contact. */
|
|
314
|
+
get(walletId, contactId) {
|
|
315
|
+
return unwrap(
|
|
316
|
+
this.client.GET("/wallets/{wallet_id}/contacts/{contact_id}", {
|
|
317
|
+
params: { path: { wallet_id: walletId, contact_id: contactId } }
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
/** Remove a payment contact from a wallet. */
|
|
322
|
+
remove(walletId, contactId) {
|
|
323
|
+
return unwrap(
|
|
324
|
+
this.client.DELETE("/wallets/{wallet_id}/contacts/{contact_id}", {
|
|
325
|
+
params: { path: { wallet_id: walletId, contact_id: contactId } }
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
var WalletLinksResource = class {
|
|
331
|
+
constructor(client) {
|
|
332
|
+
this.client = client;
|
|
333
|
+
}
|
|
334
|
+
client;
|
|
335
|
+
/** Fetch a wallet's hosted links (e.g. onboarding or top-up links). */
|
|
336
|
+
list(walletId) {
|
|
337
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}/links", { params: { path: { wallet_id: walletId } } }));
|
|
338
|
+
}
|
|
339
|
+
/** Create a new hosted link for a wallet. */
|
|
340
|
+
create(walletId, body) {
|
|
341
|
+
return unwrap(this.client.POST("/wallets/{wallet_id}/links", { params: { path: { wallet_id: walletId } }, body }));
|
|
342
|
+
}
|
|
343
|
+
/** Fetch a single hosted link. */
|
|
344
|
+
get(walletId, linkId) {
|
|
345
|
+
return unwrap(
|
|
346
|
+
this.client.GET("/wallets/{wallet_id}/links/{link_id}", {
|
|
347
|
+
params: { path: { wallet_id: walletId, link_id: linkId } }
|
|
348
|
+
})
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
/** Update a hosted link. */
|
|
352
|
+
update(walletId, linkId, body) {
|
|
353
|
+
return unwrap(
|
|
354
|
+
this.client.PUT("/wallets/{wallet_id}/links/{link_id}", {
|
|
355
|
+
params: { path: { wallet_id: walletId, link_id: linkId } },
|
|
356
|
+
body
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
/** Remove a hosted link. */
|
|
361
|
+
remove(walletId, linkId) {
|
|
362
|
+
return unwrap(
|
|
363
|
+
this.client.DELETE("/wallets/{wallet_id}/links/{link_id}", {
|
|
364
|
+
params: { path: { wallet_id: walletId, link_id: linkId } }
|
|
365
|
+
})
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var WalletsResource = class {
|
|
370
|
+
constructor(client) {
|
|
371
|
+
this.client = client;
|
|
372
|
+
this.pin = new WalletPinResource(client);
|
|
373
|
+
this.statements = new WalletStatementsResource(client);
|
|
374
|
+
this.transactions = new WalletTransactionsResource(client);
|
|
375
|
+
this.balances = new WalletBalancesResource(client);
|
|
376
|
+
this.accounts = new WalletAccountsResource(client);
|
|
377
|
+
this.contacts = new WalletContactsResource(client);
|
|
378
|
+
this.links = new WalletLinksResource(client);
|
|
379
|
+
}
|
|
380
|
+
client;
|
|
381
|
+
pin;
|
|
382
|
+
statements;
|
|
383
|
+
transactions;
|
|
384
|
+
balances;
|
|
385
|
+
accounts;
|
|
386
|
+
contacts;
|
|
387
|
+
links;
|
|
388
|
+
/** Fetch a list of wallets. */
|
|
389
|
+
list() {
|
|
390
|
+
return unwrap(this.client.GET("/wallets", {}));
|
|
391
|
+
}
|
|
392
|
+
/** Create a new wallet. */
|
|
393
|
+
create(body) {
|
|
394
|
+
return unwrap(this.client.POST("/wallets", { body }));
|
|
395
|
+
}
|
|
396
|
+
/** Fetch a single wallet. */
|
|
397
|
+
get(walletId) {
|
|
398
|
+
return unwrap(this.client.GET("/wallets/{wallet_id}", { params: { path: { wallet_id: walletId } } }));
|
|
399
|
+
}
|
|
400
|
+
/** Update a wallet's profile details. */
|
|
401
|
+
updateProfile(walletId, body) {
|
|
402
|
+
return unwrap(this.client.PUT("/wallets/{wallet_id}", { params: { path: { wallet_id: walletId } }, body }));
|
|
403
|
+
}
|
|
404
|
+
/** Partially update a wallet. */
|
|
405
|
+
update(walletId, body) {
|
|
406
|
+
return unwrap(this.client.PATCH("/wallets/{wallet_id}", { params: { path: { wallet_id: walletId } }, body }));
|
|
407
|
+
}
|
|
408
|
+
/** Delete a wallet. */
|
|
409
|
+
delete(walletId) {
|
|
410
|
+
return unwrap(this.client.DELETE("/wallets/{wallet_id}", { params: { path: { wallet_id: walletId } } }));
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// src/resources/transfers.ts
|
|
415
|
+
var TransfersResource = class {
|
|
416
|
+
constructor(client) {
|
|
417
|
+
this.client = client;
|
|
418
|
+
}
|
|
419
|
+
client;
|
|
420
|
+
/** Initiate a transfer using the given method ("peer", "move", or "bank"). */
|
|
421
|
+
initiate(method, body) {
|
|
422
|
+
return unwrap(this.client.POST("/transfers/initiate/{method}", { params: { path: { method } }, body }));
|
|
423
|
+
}
|
|
424
|
+
/** Initiate a batch of transfers in a single request. */
|
|
425
|
+
initiateBatch(body) {
|
|
426
|
+
return unwrap(this.client.POST("/transfers/initiate/batch", { body }));
|
|
427
|
+
}
|
|
428
|
+
/** Approve a pending transfer. */
|
|
429
|
+
approve(transactionId, body) {
|
|
430
|
+
return unwrap(
|
|
431
|
+
this.client.POST("/transfers/{transaction_id}/approve", {
|
|
432
|
+
params: { path: { transaction_id: transactionId } },
|
|
433
|
+
body
|
|
434
|
+
})
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
/** Cancel a pending transfer. */
|
|
438
|
+
cancel(transactionId, body) {
|
|
439
|
+
return unwrap(
|
|
440
|
+
this.client.POST("/transfers/{transaction_id}/cancel", {
|
|
441
|
+
params: { path: { transaction_id: transactionId } },
|
|
442
|
+
body
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/resources/customers.ts
|
|
449
|
+
var CustomersResource = class {
|
|
450
|
+
constructor(client) {
|
|
451
|
+
this.client = client;
|
|
452
|
+
}
|
|
453
|
+
client;
|
|
454
|
+
/** Fetch a list of customers. */
|
|
455
|
+
list() {
|
|
456
|
+
return unwrap(this.client.GET("/customers", {}));
|
|
457
|
+
}
|
|
458
|
+
/** Add a new customer. */
|
|
459
|
+
add(body) {
|
|
460
|
+
return unwrap(this.client.POST("/customers", { body }));
|
|
461
|
+
}
|
|
462
|
+
/** Fetch a single customer. */
|
|
463
|
+
get(customerId) {
|
|
464
|
+
return unwrap(this.client.GET("/customers/{customer_id}", { params: { path: { customer_id: customerId } } }));
|
|
465
|
+
}
|
|
466
|
+
/** Update a customer. */
|
|
467
|
+
update(customerId, body) {
|
|
468
|
+
return unwrap(
|
|
469
|
+
this.client.PUT("/customers/{customer_id}", { params: { path: { customer_id: customerId } }, body })
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
/** Restore a previously removed customer. */
|
|
473
|
+
restore(customerId) {
|
|
474
|
+
return unwrap(this.client.PATCH("/customers/{customer_id}", { params: { path: { customer_id: customerId } } }));
|
|
475
|
+
}
|
|
476
|
+
/** Remove a customer. */
|
|
477
|
+
remove(customerId) {
|
|
478
|
+
return unwrap(this.client.DELETE("/customers/{customer_id}", { params: { path: { customer_id: customerId } } }));
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// src/resources/vouchers.ts
|
|
483
|
+
var VouchersResource = class {
|
|
484
|
+
constructor(client) {
|
|
485
|
+
this.client = client;
|
|
486
|
+
}
|
|
487
|
+
client;
|
|
488
|
+
/** Fetch a list of vouchers. */
|
|
489
|
+
list() {
|
|
490
|
+
return unwrap(this.client.GET("/vouchers", {}));
|
|
491
|
+
}
|
|
492
|
+
/** Create a new voucher. */
|
|
493
|
+
create(body) {
|
|
494
|
+
return unwrap(this.client.POST("/vouchers", { body }));
|
|
495
|
+
}
|
|
496
|
+
/** Apply a voucher code to a resource (e.g. an invoice or subscription). */
|
|
497
|
+
apply(body) {
|
|
498
|
+
return unwrap(this.client.POST("/vouchers/apply", { body }));
|
|
499
|
+
}
|
|
500
|
+
/** Fetch a single voucher. */
|
|
501
|
+
get(voucherId) {
|
|
502
|
+
return unwrap(this.client.GET("/vouchers/{voucher_id}", { params: { path: { voucher_id: voucherId } } }));
|
|
503
|
+
}
|
|
504
|
+
/** Update a voucher. */
|
|
505
|
+
update(voucherId, body) {
|
|
506
|
+
return unwrap(
|
|
507
|
+
this.client.PUT("/vouchers/{voucher_id}", { params: { path: { voucher_id: voucherId } }, body })
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
/** Remove a voucher. */
|
|
511
|
+
remove(voucherId) {
|
|
512
|
+
return unwrap(this.client.DELETE("/vouchers/{voucher_id}", { params: { path: { voucher_id: voucherId } } }));
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// src/resources/plans.ts
|
|
517
|
+
var PlanOptionsResource = class {
|
|
518
|
+
constructor(client) {
|
|
519
|
+
this.client = client;
|
|
520
|
+
}
|
|
521
|
+
client;
|
|
522
|
+
/** Add a price option to a plan. */
|
|
523
|
+
add(planId, body) {
|
|
524
|
+
return unwrap(this.client.POST("/plans/{plan_id}/options", { params: { path: { plan_id: planId } }, body }));
|
|
525
|
+
}
|
|
526
|
+
/** Replace a price option on a plan. */
|
|
527
|
+
update(planId, optionId, body) {
|
|
528
|
+
return unwrap(
|
|
529
|
+
this.client.PUT("/plans/{plan_id}/options/{option_id}", {
|
|
530
|
+
params: { path: { plan_id: planId, option_id: optionId } },
|
|
531
|
+
body
|
|
532
|
+
})
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
/** Partially modify a price option on a plan. */
|
|
536
|
+
modify(planId, optionId) {
|
|
537
|
+
return unwrap(
|
|
538
|
+
this.client.PATCH("/plans/{plan_id}/options/{option_id}", {
|
|
539
|
+
params: { path: { plan_id: planId, option_id: optionId } }
|
|
540
|
+
})
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
/** Remove a price option from a plan. */
|
|
544
|
+
remove(planId, optionId) {
|
|
545
|
+
return unwrap(
|
|
546
|
+
this.client.DELETE("/plans/{plan_id}/options/{option_id}", {
|
|
547
|
+
params: { path: { plan_id: planId, option_id: optionId } }
|
|
548
|
+
})
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
var PlansResource = class {
|
|
553
|
+
constructor(client) {
|
|
554
|
+
this.client = client;
|
|
555
|
+
this.options = new PlanOptionsResource(client);
|
|
556
|
+
}
|
|
557
|
+
client;
|
|
558
|
+
options;
|
|
559
|
+
/** Fetch a list of plans, optionally filtered by type, currency, or active state. */
|
|
560
|
+
list(query) {
|
|
561
|
+
return unwrap(this.client.GET("/plans", { params: { query } }));
|
|
562
|
+
}
|
|
563
|
+
/** Create a new plan. */
|
|
564
|
+
create(body) {
|
|
565
|
+
return unwrap(this.client.POST("/plans", { body }));
|
|
566
|
+
}
|
|
567
|
+
/** Fetch a single plan. */
|
|
568
|
+
get(planId, query) {
|
|
569
|
+
return unwrap(this.client.GET("/plans/{plan_id}", { params: { path: { plan_id: planId }, query } }));
|
|
570
|
+
}
|
|
571
|
+
/** Update a plan. */
|
|
572
|
+
update(planId, body) {
|
|
573
|
+
return unwrap(this.client.PUT("/plans/{plan_id}", { params: { path: { plan_id: planId } }, body }));
|
|
574
|
+
}
|
|
575
|
+
/** Remove a plan. */
|
|
576
|
+
remove(planId) {
|
|
577
|
+
return unwrap(this.client.DELETE("/plans/{plan_id}", { params: { path: { plan_id: planId } } }));
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
// src/resources/invoices.ts
|
|
582
|
+
var InvoiceItemsResource = class {
|
|
583
|
+
constructor(client) {
|
|
584
|
+
this.client = client;
|
|
585
|
+
}
|
|
586
|
+
client;
|
|
587
|
+
/** Add line items to an invoice. */
|
|
588
|
+
add(invoiceId, body) {
|
|
589
|
+
return unwrap(this.client.POST("/invoices/{invoice_id}/items", { params: { path: { invoice_id: invoiceId } }, body }));
|
|
590
|
+
}
|
|
591
|
+
/** Update a single line item on an invoice. */
|
|
592
|
+
update(invoiceId, itemId, body) {
|
|
593
|
+
return unwrap(
|
|
594
|
+
this.client.PUT("/invoices/{invoice_id}/items/{item_id}", {
|
|
595
|
+
params: { path: { invoice_id: invoiceId, item_id: itemId } },
|
|
596
|
+
body
|
|
597
|
+
})
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
/** Remove a line item from an invoice. */
|
|
601
|
+
remove(invoiceId, itemId) {
|
|
602
|
+
return unwrap(
|
|
603
|
+
this.client.DELETE("/invoices/{invoice_id}/items/{item_id}", {
|
|
604
|
+
params: { path: { invoice_id: invoiceId, item_id: itemId } }
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
var InvoicesResource = class {
|
|
610
|
+
constructor(client) {
|
|
611
|
+
this.client = client;
|
|
612
|
+
this.items = new InvoiceItemsResource(client);
|
|
613
|
+
}
|
|
614
|
+
client;
|
|
615
|
+
items;
|
|
616
|
+
/** Fetch a list of invoices, optionally filtered by resource, currency, or status. */
|
|
617
|
+
list(query) {
|
|
618
|
+
return unwrap(this.client.GET("/invoices", { params: { query } }));
|
|
619
|
+
}
|
|
620
|
+
/** Create a new invoice. */
|
|
621
|
+
create(body) {
|
|
622
|
+
return unwrap(this.client.POST("/invoices", { body }));
|
|
623
|
+
}
|
|
624
|
+
/** Fetch a single invoice. */
|
|
625
|
+
get(invoiceId) {
|
|
626
|
+
return unwrap(this.client.GET("/invoices/{invoice_id}", { params: { path: { invoice_id: invoiceId } } }));
|
|
627
|
+
}
|
|
628
|
+
/** Update an invoice. */
|
|
629
|
+
update(invoiceId, body) {
|
|
630
|
+
return unwrap(
|
|
631
|
+
this.client.PUT("/invoices/{invoice_id}", { params: { path: { invoice_id: invoiceId } }, body })
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
/** Remove an invoice. */
|
|
635
|
+
remove(invoiceId) {
|
|
636
|
+
return unwrap(this.client.DELETE("/invoices/{invoice_id}", { params: { path: { invoice_id: invoiceId } } }));
|
|
637
|
+
}
|
|
638
|
+
/** Send an invoice to the customer. */
|
|
639
|
+
send(invoiceId) {
|
|
640
|
+
return unwrap(this.client.POST("/invoices/{invoice_id}/send", { params: { path: { invoice_id: invoiceId } } }));
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// src/resources/subscriptions.ts
|
|
645
|
+
var SubscriptionsResource = class {
|
|
646
|
+
constructor(client) {
|
|
647
|
+
this.client = client;
|
|
648
|
+
}
|
|
649
|
+
client;
|
|
650
|
+
/** Fetch a list of subscriptions, optionally filtered by resource, currency, or status. */
|
|
651
|
+
list(query) {
|
|
652
|
+
return unwrap(this.client.GET("/subscriptions", { params: { query } }));
|
|
653
|
+
}
|
|
654
|
+
/** Create a new subscription. */
|
|
655
|
+
create(body) {
|
|
656
|
+
return unwrap(this.client.POST("/subscriptions", { body }));
|
|
657
|
+
}
|
|
658
|
+
/** Fetch a single subscription. */
|
|
659
|
+
get(subscriptionId) {
|
|
660
|
+
return unwrap(
|
|
661
|
+
this.client.GET("/subscriptions/{subscription_id}", { params: { path: { subscription_id: subscriptionId } } })
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
/** Update a subscription (e.g. change plan or price option). */
|
|
665
|
+
update(subscriptionId) {
|
|
666
|
+
return unwrap(
|
|
667
|
+
this.client.PATCH("/subscriptions/{subscription_id}", {
|
|
668
|
+
params: { path: { subscription_id: subscriptionId } }
|
|
669
|
+
})
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
/** Remove a subscription. */
|
|
673
|
+
remove(subscriptionId) {
|
|
674
|
+
return unwrap(
|
|
675
|
+
this.client.DELETE("/subscriptions/{subscription_id}", {
|
|
676
|
+
params: { path: { subscription_id: subscriptionId } }
|
|
677
|
+
})
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
/** Restore a previously canceled subscription. */
|
|
681
|
+
restore(subscriptionId) {
|
|
682
|
+
return unwrap(
|
|
683
|
+
this.client.POST("/subscriptions/{subscription_id}/restore", {
|
|
684
|
+
params: { path: { subscription_id: subscriptionId } }
|
|
685
|
+
})
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
/** Cancel a subscription. */
|
|
689
|
+
cancel(subscriptionId) {
|
|
690
|
+
return unwrap(
|
|
691
|
+
this.client.POST("/subscriptions/{subscription_id}/cancel", {
|
|
692
|
+
params: { path: { subscription_id: subscriptionId } }
|
|
693
|
+
})
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/resources/payments.ts
|
|
699
|
+
var PaymentsResource = class {
|
|
700
|
+
constructor(client) {
|
|
701
|
+
this.client = client;
|
|
702
|
+
}
|
|
703
|
+
client;
|
|
704
|
+
/** Fetch a list of payments, optionally filtered by resource, currency, status, or method. */
|
|
705
|
+
list(query) {
|
|
706
|
+
return unwrap(this.client.GET("/payments", { params: { query } }));
|
|
707
|
+
}
|
|
708
|
+
/** Initiate a payment using the given method ("bank", "wallet", "qr", or "card"). */
|
|
709
|
+
initiate(method, body) {
|
|
710
|
+
return unwrap(this.client.POST("/payments/initiate/{method}", { params: { path: { method } }, body }));
|
|
711
|
+
}
|
|
712
|
+
/** Fetch a single payment. */
|
|
713
|
+
get(paymentId) {
|
|
714
|
+
return unwrap(this.client.GET("/payments/{payment_id}", { params: { path: { payment_id: paymentId } } }));
|
|
715
|
+
}
|
|
716
|
+
/** Refund a payment, in full or in part. */
|
|
717
|
+
refund(paymentId, body) {
|
|
718
|
+
return unwrap(
|
|
719
|
+
this.client.POST("/payments/{payment_id}/refund", { params: { path: { payment_id: paymentId } }, body })
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// src/resources/providers.ts
|
|
725
|
+
var ProvidersResource = class {
|
|
726
|
+
constructor(client) {
|
|
727
|
+
this.client = client;
|
|
728
|
+
}
|
|
729
|
+
client;
|
|
730
|
+
/** Fetch a list of provider connections. */
|
|
731
|
+
list() {
|
|
732
|
+
return unwrap(this.client.GET("/providers", {}));
|
|
733
|
+
}
|
|
734
|
+
/** Connect a new provider. */
|
|
735
|
+
connect(body) {
|
|
736
|
+
return unwrap(this.client.POST("/providers", { body }));
|
|
737
|
+
}
|
|
738
|
+
/** Replace a provider connection's configuration. */
|
|
739
|
+
update(connectionId, body) {
|
|
740
|
+
return unwrap(
|
|
741
|
+
this.client.PUT("/providers/{connection_id}", { params: { path: { connection_id: connectionId } }, body })
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
/** Partially modify a provider connection. */
|
|
745
|
+
modify(connectionId) {
|
|
746
|
+
return unwrap(this.client.PATCH("/providers/{connection_id}", { params: { path: { connection_id: connectionId } } }));
|
|
747
|
+
}
|
|
748
|
+
/** Remove a provider connection. */
|
|
749
|
+
remove(connectionId) {
|
|
750
|
+
return unwrap(
|
|
751
|
+
this.client.DELETE("/providers/{connection_id}", { params: { path: { connection_id: connectionId } } })
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// src/resources/metrics.ts
|
|
757
|
+
var MetricsResource = class {
|
|
758
|
+
constructor(client) {
|
|
759
|
+
this.client = client;
|
|
760
|
+
}
|
|
761
|
+
client;
|
|
762
|
+
/** Fetch invoice metrics. */
|
|
763
|
+
invoices() {
|
|
764
|
+
return unwrap(this.client.GET("/metrics/invoices", {}));
|
|
765
|
+
}
|
|
766
|
+
/** Fetch subscription metrics. */
|
|
767
|
+
subscriptions() {
|
|
768
|
+
return unwrap(this.client.GET("/metrics/subscriptions", {}));
|
|
769
|
+
}
|
|
770
|
+
/** Fetch payment metrics. */
|
|
771
|
+
payments() {
|
|
772
|
+
return unwrap(this.client.GET("/metrics/payments", {}));
|
|
773
|
+
}
|
|
774
|
+
/** Fetch customer metrics. */
|
|
775
|
+
customers() {
|
|
776
|
+
return unwrap(this.client.GET("/metrics/customers", {}));
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// src/resources/logs.ts
|
|
781
|
+
var LogsResource = class {
|
|
782
|
+
constructor(client) {
|
|
783
|
+
this.client = client;
|
|
784
|
+
}
|
|
785
|
+
client;
|
|
786
|
+
/** Fetch API request logs, optionally filtered by resource, method, or auth flow. */
|
|
787
|
+
list(query) {
|
|
788
|
+
return unwrap(this.client.GET("/logs", { params: { query } }));
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
// src/index.ts
|
|
793
|
+
var Paisr = class {
|
|
794
|
+
client;
|
|
795
|
+
accessTokens;
|
|
796
|
+
webhooks;
|
|
797
|
+
wallets;
|
|
798
|
+
transfers;
|
|
799
|
+
customers;
|
|
800
|
+
vouchers;
|
|
801
|
+
plans;
|
|
802
|
+
invoices;
|
|
803
|
+
subscriptions;
|
|
804
|
+
payments;
|
|
805
|
+
providers;
|
|
806
|
+
metrics;
|
|
807
|
+
logs;
|
|
808
|
+
constructor(options) {
|
|
809
|
+
this.client = createPaisrClient(options);
|
|
810
|
+
this.accessTokens = new AccessTokensResource(this.client);
|
|
811
|
+
this.webhooks = new WebhooksResource(this.client);
|
|
812
|
+
this.wallets = new WalletsResource(this.client);
|
|
813
|
+
this.transfers = new TransfersResource(this.client);
|
|
814
|
+
this.customers = new CustomersResource(this.client);
|
|
815
|
+
this.vouchers = new VouchersResource(this.client);
|
|
816
|
+
this.plans = new PlansResource(this.client);
|
|
817
|
+
this.invoices = new InvoicesResource(this.client);
|
|
818
|
+
this.subscriptions = new SubscriptionsResource(this.client);
|
|
819
|
+
this.payments = new PaymentsResource(this.client);
|
|
820
|
+
this.providers = new ProvidersResource(this.client);
|
|
821
|
+
this.metrics = new MetricsResource(this.client);
|
|
822
|
+
this.logs = new LogsResource(this.client);
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
var index_default = Paisr;
|
|
826
|
+
export {
|
|
827
|
+
Paisr,
|
|
828
|
+
PaisrError,
|
|
829
|
+
index_default as default
|
|
830
|
+
};
|
|
831
|
+
//# sourceMappingURL=index.js.map
|