@easyslip/sdk 0.0.0-stage → 1.0.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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +595 -2
- package/README.th.md +610 -0
- package/dist/cjs/client.d.ts +59 -0
- package/dist/cjs/client.js +150 -0
- package/dist/cjs/core/call.d.ts +18 -0
- package/dist/cjs/core/call.js +60 -0
- package/dist/cjs/core/error-codes.d.ts +8 -0
- package/dist/cjs/core/error-codes.js +87 -0
- package/dist/cjs/core/errors.d.ts +162 -0
- package/dist/cjs/core/errors.js +210 -0
- package/dist/cjs/core/files.d.ts +20 -0
- package/dist/cjs/core/files.js +131 -0
- package/dist/cjs/core/http.d.ts +65 -0
- package/dist/cjs/core/http.js +242 -0
- package/dist/cjs/core/meta.d.ts +33 -0
- package/dist/cjs/core/meta.js +52 -0
- package/dist/cjs/core/redact.d.ts +43 -0
- package/dist/cjs/core/redact.js +208 -0
- package/dist/cjs/core/runtime.d.ts +16 -0
- package/dist/cjs/core/runtime.js +86 -0
- package/dist/cjs/core/settings.d.ts +19 -0
- package/dist/cjs/core/settings.js +22 -0
- package/dist/cjs/core/sha256.d.ts +6 -0
- package/dist/cjs/core/sha256.js +101 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/models.d.ts +398 -0
- package/dist/cjs/models.js +234 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/bank-accounts.d.ts +63 -0
- package/dist/cjs/resources/bank-accounts.js +126 -0
- package/dist/cjs/resources/banks.d.ts +10 -0
- package/dist/cjs/resources/banks.js +22 -0
- package/dist/cjs/resources/jobs.d.ts +64 -0
- package/dist/cjs/resources/jobs.js +177 -0
- package/dist/cjs/resources/v1.d.ts +88 -0
- package/dist/cjs/resources/v1.js +137 -0
- package/dist/cjs/resources/verify.d.ts +39 -0
- package/dist/cjs/resources/verify.js +105 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/webhooks.d.ts +26 -0
- package/dist/cjs/webhooks.js +92 -0
- package/dist/esm/client.d.ts +59 -0
- package/dist/esm/client.js +146 -0
- package/dist/esm/core/call.d.ts +18 -0
- package/dist/esm/core/call.js +52 -0
- package/dist/esm/core/error-codes.d.ts +8 -0
- package/dist/esm/core/error-codes.js +84 -0
- package/dist/esm/core/errors.d.ts +162 -0
- package/dist/esm/core/errors.js +184 -0
- package/dist/esm/core/files.d.ts +20 -0
- package/dist/esm/core/files.js +126 -0
- package/dist/esm/core/http.d.ts +65 -0
- package/dist/esm/core/http.js +235 -0
- package/dist/esm/core/meta.d.ts +33 -0
- package/dist/esm/core/meta.js +45 -0
- package/dist/esm/core/redact.d.ts +43 -0
- package/dist/esm/core/redact.js +198 -0
- package/dist/esm/core/runtime.d.ts +16 -0
- package/dist/esm/core/runtime.js +47 -0
- package/dist/esm/core/settings.d.ts +19 -0
- package/dist/esm/core/settings.js +19 -0
- package/dist/esm/core/sha256.d.ts +6 -0
- package/dist/esm/core/sha256.js +96 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/models.d.ts +398 -0
- package/dist/esm/models.js +228 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/resources/bank-accounts.d.ts +63 -0
- package/dist/esm/resources/bank-accounts.js +122 -0
- package/dist/esm/resources/banks.d.ts +10 -0
- package/dist/esm/resources/banks.js +18 -0
- package/dist/esm/resources/jobs.d.ts +64 -0
- package/dist/esm/resources/jobs.js +173 -0
- package/dist/esm/resources/v1.d.ts +88 -0
- package/dist/esm/resources/v1.js +133 -0
- package/dist/esm/resources/verify.d.ts +39 -0
- package/dist/esm/resources/verify.js +100 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/webhooks.d.ts +26 -0
- package/dist/esm/webhooks.js +86 -0
- package/package.json +80 -5
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/** A string union that still accepts values added by the API later. */
|
|
2
|
+
export type Open<T extends string> = T | (string & {});
|
|
3
|
+
/** `GET /info`: the application, branch, account and plan behind the API key. */
|
|
4
|
+
export interface Info {
|
|
5
|
+
application: InfoApplication;
|
|
6
|
+
branch: InfoBranch;
|
|
7
|
+
account: InfoAccount;
|
|
8
|
+
product: InfoProduct;
|
|
9
|
+
}
|
|
10
|
+
export interface InfoApplication {
|
|
11
|
+
/** Application name. */
|
|
12
|
+
name: string;
|
|
13
|
+
autoRenew: AutoRenew;
|
|
14
|
+
quota: ApplicationQuota;
|
|
15
|
+
}
|
|
16
|
+
export interface AutoRenew {
|
|
17
|
+
/** Auto renew of the expiry date is on. */
|
|
18
|
+
expired: boolean;
|
|
19
|
+
/** Auto renew of the quota is on. */
|
|
20
|
+
quota: boolean;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
expiresAt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ApplicationQuota {
|
|
25
|
+
/** Used in the current period. */
|
|
26
|
+
used: number;
|
|
27
|
+
/** Period limit, null when unlimited. */
|
|
28
|
+
max: number | null;
|
|
29
|
+
/** Left in the current period, null when unlimited. */
|
|
30
|
+
remaining: number | null;
|
|
31
|
+
/** Used since the application was created. */
|
|
32
|
+
totalUsed: number;
|
|
33
|
+
}
|
|
34
|
+
export interface InfoBranch {
|
|
35
|
+
name: string;
|
|
36
|
+
isActive: boolean;
|
|
37
|
+
quota: BranchQuota;
|
|
38
|
+
}
|
|
39
|
+
export interface BranchQuota {
|
|
40
|
+
used: number;
|
|
41
|
+
totalUsed: number;
|
|
42
|
+
}
|
|
43
|
+
export interface InfoAccount {
|
|
44
|
+
email: string;
|
|
45
|
+
/** Account credit balance. */
|
|
46
|
+
credit: number;
|
|
47
|
+
}
|
|
48
|
+
export interface InfoProduct {
|
|
49
|
+
/** Plan name. */
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
/** A bank transfer slip as the bank reported it. v2 `rawSlip`, v1 verify `data`. */
|
|
53
|
+
export interface BankSlip {
|
|
54
|
+
payload: string;
|
|
55
|
+
transRef: string;
|
|
56
|
+
/** Transfer time, ISO 8601 with offset. */
|
|
57
|
+
date: string;
|
|
58
|
+
/** Country code, may be empty. */
|
|
59
|
+
countryCode: string;
|
|
60
|
+
amount: SlipAmount;
|
|
61
|
+
fee?: number;
|
|
62
|
+
ref1?: string;
|
|
63
|
+
ref2?: string;
|
|
64
|
+
ref3?: string;
|
|
65
|
+
sender: SlipParty;
|
|
66
|
+
receiver: SlipReceiver;
|
|
67
|
+
}
|
|
68
|
+
export interface SlipAmount {
|
|
69
|
+
amount: number;
|
|
70
|
+
local: LocalAmount;
|
|
71
|
+
}
|
|
72
|
+
/** Foreign leg of the transfer; `0` and `''` when there is none. */
|
|
73
|
+
export interface LocalAmount {
|
|
74
|
+
amount?: number;
|
|
75
|
+
currency?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface SlipParty {
|
|
78
|
+
bank?: SlipBank;
|
|
79
|
+
account: SlipAccount;
|
|
80
|
+
}
|
|
81
|
+
export interface SlipReceiver extends SlipParty {
|
|
82
|
+
/** Merchant id; v2 sends it (often empty), v1 leaves it out. */
|
|
83
|
+
merchantId?: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface SlipBank {
|
|
86
|
+
/**
|
|
87
|
+
* Bank code, for example `004`. Absent when the bank is unknown: v1 then sends the receiver
|
|
88
|
+
* bank as an empty object.
|
|
89
|
+
*/
|
|
90
|
+
id?: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
short?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface SlipAccount {
|
|
95
|
+
name: AccountName;
|
|
96
|
+
bank?: AccountNumber;
|
|
97
|
+
proxy?: AccountNumber;
|
|
98
|
+
}
|
|
99
|
+
/** Account holder name. v2 may send empty strings, v1 leaves empty names out. */
|
|
100
|
+
export interface AccountName {
|
|
101
|
+
th?: string;
|
|
102
|
+
en?: string;
|
|
103
|
+
}
|
|
104
|
+
/** A masked account number or proxy id. */
|
|
105
|
+
export interface AccountNumber {
|
|
106
|
+
/** `BANKAC`, `TOKEN`, `DUMMY` for accounts; `NATID`, `MSISDN`, `EWALLETID`, `EMAIL`, `BILLERID` for proxies. */
|
|
107
|
+
type: Open<'BANKAC' | 'TOKEN' | 'DUMMY' | 'NATID' | 'MSISDN' | 'EWALLETID' | 'EMAIL' | 'BILLERID'>;
|
|
108
|
+
account: string;
|
|
109
|
+
}
|
|
110
|
+
/** Known values of {@link MatchedAccount.type}. */
|
|
111
|
+
export declare const MatchedAccountType: {
|
|
112
|
+
readonly Personal: 'PERSONAL';
|
|
113
|
+
readonly Natural: 'NATURAL';
|
|
114
|
+
readonly Juristic: 'JURISTIC';
|
|
115
|
+
};
|
|
116
|
+
/** The registered bank account the slip's receiver matched (`matchAccount: true`). */
|
|
117
|
+
export interface MatchedAccount {
|
|
118
|
+
bank: MatchedBank;
|
|
119
|
+
nameTh: string;
|
|
120
|
+
nameEn: string;
|
|
121
|
+
/** `PERSONAL`, `NATURAL` or `JURISTIC`. */
|
|
122
|
+
type: Open<(typeof MatchedAccountType)[keyof typeof MatchedAccountType]>;
|
|
123
|
+
bankNumber: string;
|
|
124
|
+
}
|
|
125
|
+
export interface MatchedBank {
|
|
126
|
+
nameTh?: string;
|
|
127
|
+
nameEn?: string;
|
|
128
|
+
code?: string;
|
|
129
|
+
shortCode?: string;
|
|
130
|
+
}
|
|
131
|
+
/** v2 bank slip verification result. Also the `data` of finished jobs and webhooks. */
|
|
132
|
+
export interface BankSlipResult {
|
|
133
|
+
/** Echo of the `remark` option. Absent when not sent. */
|
|
134
|
+
remark?: string;
|
|
135
|
+
/** Present only with `checkDuplicate: true`. */
|
|
136
|
+
isDuplicate?: boolean;
|
|
137
|
+
/** Absent without `matchAccount`; null when no registered account matched. */
|
|
138
|
+
matchedAccount?: MatchedAccount | null;
|
|
139
|
+
/** Present only with `matchAmount`. */
|
|
140
|
+
amountInOrder?: number;
|
|
141
|
+
amountInSlip: number;
|
|
142
|
+
/** Present only with `matchAmount`. */
|
|
143
|
+
isAmountMatched?: boolean;
|
|
144
|
+
rawSlip: BankSlip;
|
|
145
|
+
}
|
|
146
|
+
/** A TrueMoney Wallet slip. v2 `rawSlip`, v1 TrueMoney `data`. */
|
|
147
|
+
export interface TrueWalletSlip {
|
|
148
|
+
transactionId: string;
|
|
149
|
+
date: string;
|
|
150
|
+
amount: number;
|
|
151
|
+
sender: TrueWalletSender;
|
|
152
|
+
receiver: TrueWalletReceiver;
|
|
153
|
+
}
|
|
154
|
+
export interface TrueWalletSender {
|
|
155
|
+
name: string;
|
|
156
|
+
}
|
|
157
|
+
export interface TrueWalletReceiver {
|
|
158
|
+
name: string;
|
|
159
|
+
/** Masked phone number. */
|
|
160
|
+
phone: string;
|
|
161
|
+
}
|
|
162
|
+
/** v2 TrueMoney Wallet verification result. Same options as {@link BankSlipResult}. */
|
|
163
|
+
export interface TrueWalletResult {
|
|
164
|
+
remark?: string;
|
|
165
|
+
isDuplicate?: boolean;
|
|
166
|
+
matchedAccount?: MatchedAccount | null;
|
|
167
|
+
amountInOrder?: number;
|
|
168
|
+
amountInSlip: number;
|
|
169
|
+
isAmountMatched?: boolean;
|
|
170
|
+
rawSlip: TrueWalletSlip;
|
|
171
|
+
}
|
|
172
|
+
/** A bank or receiving kind from `GET /banks`. */
|
|
173
|
+
export interface Bank {
|
|
174
|
+
code: string;
|
|
175
|
+
nameTh: string;
|
|
176
|
+
nameEn: string;
|
|
177
|
+
shortCode: string;
|
|
178
|
+
swiftCode: string;
|
|
179
|
+
/** Allowed `extraVerify` values for accounts at this bank, or null. */
|
|
180
|
+
extraVerify: ExtraVerifyOption[] | null;
|
|
181
|
+
}
|
|
182
|
+
export interface ExtraVerifyOption {
|
|
183
|
+
value: string;
|
|
184
|
+
label: string;
|
|
185
|
+
}
|
|
186
|
+
/** `GET /banks`. Iterable; serializes to the plain array the API sends. */
|
|
187
|
+
export declare class BankList implements Iterable<Bank> {
|
|
188
|
+
/** The banks, ordered by code. */
|
|
189
|
+
readonly items: Bank[];
|
|
190
|
+
constructor(items: Bank[]);
|
|
191
|
+
/** Number of entries. */
|
|
192
|
+
get length(): number;
|
|
193
|
+
/** Finds an entry by code, for example `004`. */
|
|
194
|
+
find(code: string): Bank | undefined;
|
|
195
|
+
[Symbol.iterator](): Iterator<Bank>;
|
|
196
|
+
toJSON(): Bank[];
|
|
197
|
+
}
|
|
198
|
+
/** Known values of {@link BankAccount.type}. */
|
|
199
|
+
export declare const BankAccountType: {
|
|
200
|
+
readonly Natural: 'NATURAL';
|
|
201
|
+
readonly Juristic: 'JURISTIC';
|
|
202
|
+
};
|
|
203
|
+
/** Known values of {@link BankAccount.matchMode}. */
|
|
204
|
+
export declare const MatchMode: {
|
|
205
|
+
readonly Name: 'NAME';
|
|
206
|
+
readonly Number: 'NUMBER';
|
|
207
|
+
readonly NameNumber: 'NAME_NUMBER';
|
|
208
|
+
};
|
|
209
|
+
/** A receiving bank account registered on the service. */
|
|
210
|
+
export interface BankAccount {
|
|
211
|
+
id: number;
|
|
212
|
+
bankCode: string;
|
|
213
|
+
bankNumber: string;
|
|
214
|
+
nameTh: string;
|
|
215
|
+
nameEn: string;
|
|
216
|
+
/** `NATURAL` or `JURISTIC`. */
|
|
217
|
+
type: Open<(typeof BankAccountType)[keyof typeof BankAccountType]>;
|
|
218
|
+
extraVerify: string | null;
|
|
219
|
+
/** PromptPay matching rule, null for other banks. */
|
|
220
|
+
matchMode: Open<(typeof MatchMode)[keyof typeof MatchMode]> | null;
|
|
221
|
+
createdAt: string;
|
|
222
|
+
updatedAt: string;
|
|
223
|
+
deletedAt: string | null;
|
|
224
|
+
}
|
|
225
|
+
/** One page of bank accounts. */
|
|
226
|
+
export interface BankAccountPage {
|
|
227
|
+
items: BankAccount[];
|
|
228
|
+
total: number;
|
|
229
|
+
page: number;
|
|
230
|
+
limit: number;
|
|
231
|
+
}
|
|
232
|
+
export interface LinkResult {
|
|
233
|
+
linked: boolean;
|
|
234
|
+
}
|
|
235
|
+
export interface UnlinkResult {
|
|
236
|
+
unlinked: boolean;
|
|
237
|
+
}
|
|
238
|
+
export interface JobSubmission {
|
|
239
|
+
jobId: string;
|
|
240
|
+
}
|
|
241
|
+
export interface BatchSubmission {
|
|
242
|
+
batchId: string;
|
|
243
|
+
jobs: BatchJob[];
|
|
244
|
+
}
|
|
245
|
+
export interface BatchJob {
|
|
246
|
+
jobId: string;
|
|
247
|
+
/** 0-based position in the submitted list. */
|
|
248
|
+
index: number;
|
|
249
|
+
}
|
|
250
|
+
/** Known values of {@link Job.status}. */
|
|
251
|
+
export declare const JobStatus: {
|
|
252
|
+
readonly Queued: 'queued';
|
|
253
|
+
readonly Processing: 'processing';
|
|
254
|
+
readonly Retrying: 'retrying';
|
|
255
|
+
readonly Done: 'done';
|
|
256
|
+
readonly Failed: 'failed';
|
|
257
|
+
};
|
|
258
|
+
/** An async verification job. Finished when `status` is `done` or `failed`. */
|
|
259
|
+
export interface Job {
|
|
260
|
+
jobId: string;
|
|
261
|
+
/** Absent for single jobs. */
|
|
262
|
+
batchId?: string;
|
|
263
|
+
status: Open<(typeof JobStatus)[keyof typeof JobStatus]>;
|
|
264
|
+
result?: JobResult;
|
|
265
|
+
error?: JobError;
|
|
266
|
+
attempts: number;
|
|
267
|
+
createdAt: string;
|
|
268
|
+
updatedAt: string;
|
|
269
|
+
branchId?: number;
|
|
270
|
+
serviceId?: number;
|
|
271
|
+
callbackEventId?: string;
|
|
272
|
+
callbackProtocol?: number;
|
|
273
|
+
callbackDelivery?: CallbackDelivery;
|
|
274
|
+
}
|
|
275
|
+
export interface JobResult {
|
|
276
|
+
/** `success` or `not_found`. */
|
|
277
|
+
status: Open<'success' | 'not_found'>;
|
|
278
|
+
/** Null for `not_found`. */
|
|
279
|
+
data: BankSlipResult | null;
|
|
280
|
+
}
|
|
281
|
+
export interface JobError {
|
|
282
|
+
code?: string;
|
|
283
|
+
message?: string;
|
|
284
|
+
webhook?: string;
|
|
285
|
+
url?: string;
|
|
286
|
+
status?: number;
|
|
287
|
+
at?: string;
|
|
288
|
+
}
|
|
289
|
+
export interface CallbackDelivery {
|
|
290
|
+
state: string | null;
|
|
291
|
+
httpStatus: number | null;
|
|
292
|
+
}
|
|
293
|
+
/** Body of the webhook the API posts when an async job finishes. */
|
|
294
|
+
export interface WebhookEvent {
|
|
295
|
+
jobId: string;
|
|
296
|
+
/** Null for single jobs. */
|
|
297
|
+
batchId: string | null;
|
|
298
|
+
/** `success`, `not_found` or `failed`. */
|
|
299
|
+
status: Open<'success' | 'not_found' | 'failed'>;
|
|
300
|
+
/** Null for `not_found` and `failed`. */
|
|
301
|
+
data: BankSlipResult | null;
|
|
302
|
+
/** Only on `failed`. */
|
|
303
|
+
error?: WebhookError;
|
|
304
|
+
timestamp: string;
|
|
305
|
+
}
|
|
306
|
+
export interface WebhookError {
|
|
307
|
+
code: string;
|
|
308
|
+
message: string;
|
|
309
|
+
}
|
|
310
|
+
/** v1 `GET /me`. */
|
|
311
|
+
export interface V1Me {
|
|
312
|
+
application: string;
|
|
313
|
+
usedQuota: number;
|
|
314
|
+
maxQuota: number | null;
|
|
315
|
+
remainingQuota: number | null;
|
|
316
|
+
expiredAt: string | null;
|
|
317
|
+
currentCredit: number;
|
|
318
|
+
}
|
|
319
|
+
/** v1 `POST /qr/generate` result. */
|
|
320
|
+
export interface QrCode {
|
|
321
|
+
/** Base64 PNG, no data URI prefix. */
|
|
322
|
+
image: string;
|
|
323
|
+
mime: string;
|
|
324
|
+
/** The EMVCo payload encoded in the QR. */
|
|
325
|
+
payload: string;
|
|
326
|
+
}
|
|
327
|
+
type Spec = 0 | Shape | readonly [Spec];
|
|
328
|
+
interface Shape {
|
|
329
|
+
readonly [key: string]: Spec;
|
|
330
|
+
}
|
|
331
|
+
type ShapeOf<T> = {
|
|
332
|
+
readonly [K in keyof Required<T>]: Spec;
|
|
333
|
+
};
|
|
334
|
+
export declare function pick(spec: Spec, raw: unknown): unknown;
|
|
335
|
+
/** Model name to shape, for every model a response can decode into. */
|
|
336
|
+
export declare const shapes: {
|
|
337
|
+
readonly Info: ShapeOf<Info>;
|
|
338
|
+
readonly BankSlip: ShapeOf<BankSlip>;
|
|
339
|
+
readonly BankSlipResult: ShapeOf<BankSlipResult>;
|
|
340
|
+
readonly TrueWalletSlip: ShapeOf<TrueWalletSlip>;
|
|
341
|
+
readonly TrueWalletResult: ShapeOf<TrueWalletResult>;
|
|
342
|
+
readonly BankAccount: ShapeOf<BankAccount>;
|
|
343
|
+
readonly BankAccountPage: ShapeOf<BankAccountPage>;
|
|
344
|
+
readonly LinkResult: {
|
|
345
|
+
linked: 0;
|
|
346
|
+
};
|
|
347
|
+
readonly UnlinkResult: {
|
|
348
|
+
unlinked: 0;
|
|
349
|
+
};
|
|
350
|
+
readonly JobSubmission: {
|
|
351
|
+
jobId: 0;
|
|
352
|
+
};
|
|
353
|
+
readonly BatchSubmission: {
|
|
354
|
+
batchId: 0;
|
|
355
|
+
jobs: [{
|
|
356
|
+
jobId: 0;
|
|
357
|
+
index: 0;
|
|
358
|
+
}];
|
|
359
|
+
};
|
|
360
|
+
readonly Job: ShapeOf<Job>;
|
|
361
|
+
readonly WebhookEvent: ShapeOf<WebhookEvent>;
|
|
362
|
+
readonly V1Me: {
|
|
363
|
+
application: 0;
|
|
364
|
+
usedQuota: 0;
|
|
365
|
+
maxQuota: 0;
|
|
366
|
+
remainingQuota: 0;
|
|
367
|
+
expiredAt: 0;
|
|
368
|
+
currentCredit: 0;
|
|
369
|
+
};
|
|
370
|
+
readonly QrCode: {
|
|
371
|
+
image: 0;
|
|
372
|
+
mime: 0;
|
|
373
|
+
payload: 0;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
/** Names of the models {@link parseModel} can build. */
|
|
377
|
+
export type ModelName = keyof typeof shapes | 'BankList';
|
|
378
|
+
interface ModelTypes {
|
|
379
|
+
Info: Info;
|
|
380
|
+
BankSlip: BankSlip;
|
|
381
|
+
BankSlipResult: BankSlipResult;
|
|
382
|
+
TrueWalletSlip: TrueWalletSlip;
|
|
383
|
+
TrueWalletResult: TrueWalletResult;
|
|
384
|
+
BankAccount: BankAccount;
|
|
385
|
+
BankAccountPage: BankAccountPage;
|
|
386
|
+
LinkResult: LinkResult;
|
|
387
|
+
UnlinkResult: UnlinkResult;
|
|
388
|
+
JobSubmission: JobSubmission;
|
|
389
|
+
BatchSubmission: BatchSubmission;
|
|
390
|
+
Job: Job;
|
|
391
|
+
WebhookEvent: WebhookEvent;
|
|
392
|
+
V1Me: V1Me;
|
|
393
|
+
QrCode: QrCode;
|
|
394
|
+
BankList: BankList;
|
|
395
|
+
}
|
|
396
|
+
/** Builds a model from decoded JSON, keeping only the fields the model knows. */
|
|
397
|
+
export declare function parseModel<N extends ModelName>(name: N, raw: unknown): ModelTypes[N];
|
|
398
|
+
export {};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Response models. Field presence follows the API: an optional field (`?`) can
|
|
3
|
+
// be absent, `| null` can be null, and the two are kept apart when a model is serialized again.
|
|
4
|
+
// Enum-like fields are open strings: the known values are listed, unknown values still parse.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.shapes = exports.JobStatus = exports.MatchMode = exports.BankAccountType = exports.BankList = exports.MatchedAccountType = void 0;
|
|
7
|
+
exports.pick = pick;
|
|
8
|
+
exports.parseModel = parseModel;
|
|
9
|
+
/** Known values of {@link MatchedAccount.type}. */
|
|
10
|
+
exports.MatchedAccountType = {
|
|
11
|
+
Personal: 'PERSONAL',
|
|
12
|
+
Natural: 'NATURAL',
|
|
13
|
+
Juristic: 'JURISTIC',
|
|
14
|
+
};
|
|
15
|
+
/** `GET /banks`. Iterable; serializes to the plain array the API sends. */
|
|
16
|
+
class BankList {
|
|
17
|
+
/** The banks, ordered by code. */
|
|
18
|
+
items;
|
|
19
|
+
constructor(items) {
|
|
20
|
+
this.items = items;
|
|
21
|
+
}
|
|
22
|
+
/** Number of entries. */
|
|
23
|
+
get length() {
|
|
24
|
+
return this.items.length;
|
|
25
|
+
}
|
|
26
|
+
/** Finds an entry by code, for example `004`. */
|
|
27
|
+
find(code) {
|
|
28
|
+
return this.items.find((bank) => bank.code === code);
|
|
29
|
+
}
|
|
30
|
+
[Symbol.iterator]() {
|
|
31
|
+
return this.items[Symbol.iterator]();
|
|
32
|
+
}
|
|
33
|
+
toJSON() {
|
|
34
|
+
return this.items;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BankList = BankList;
|
|
38
|
+
/** Known values of {@link BankAccount.type}. */
|
|
39
|
+
exports.BankAccountType = {
|
|
40
|
+
Natural: 'NATURAL',
|
|
41
|
+
Juristic: 'JURISTIC',
|
|
42
|
+
};
|
|
43
|
+
/** Known values of {@link BankAccount.matchMode}. */
|
|
44
|
+
exports.MatchMode = {
|
|
45
|
+
Name: 'NAME',
|
|
46
|
+
Number: 'NUMBER',
|
|
47
|
+
NameNumber: 'NAME_NUMBER',
|
|
48
|
+
};
|
|
49
|
+
/** Known values of {@link Job.status}. */
|
|
50
|
+
exports.JobStatus = {
|
|
51
|
+
Queued: 'queued',
|
|
52
|
+
Processing: 'processing',
|
|
53
|
+
Retrying: 'retrying',
|
|
54
|
+
Done: 'done',
|
|
55
|
+
Failed: 'failed',
|
|
56
|
+
};
|
|
57
|
+
function pick(spec, raw) {
|
|
58
|
+
if (spec === 0 || raw === null || typeof raw !== 'object')
|
|
59
|
+
return raw;
|
|
60
|
+
if (Array.isArray(spec)) {
|
|
61
|
+
const item = spec[0];
|
|
62
|
+
return Array.isArray(raw) ? raw.map((value) => pick(item, value)) : raw;
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(raw))
|
|
65
|
+
return raw;
|
|
66
|
+
const shape = spec;
|
|
67
|
+
const out = {};
|
|
68
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
69
|
+
const child = shape[key];
|
|
70
|
+
if (child !== undefined && Object.hasOwn(shape, key))
|
|
71
|
+
out[key] = pick(child, value);
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
const autoRenew = { expired: 0, quota: 0, createdAt: 0, expiresAt: 0 };
|
|
76
|
+
const applicationQuota = { used: 0, max: 0, remaining: 0, totalUsed: 0 };
|
|
77
|
+
const infoShape = {
|
|
78
|
+
application: { name: 0, autoRenew, quota: applicationQuota },
|
|
79
|
+
branch: {
|
|
80
|
+
name: 0,
|
|
81
|
+
isActive: 0,
|
|
82
|
+
quota: { used: 0, totalUsed: 0 },
|
|
83
|
+
},
|
|
84
|
+
account: { email: 0, credit: 0 },
|
|
85
|
+
product: { name: 0 },
|
|
86
|
+
};
|
|
87
|
+
const accountNumber = { type: 0, account: 0 };
|
|
88
|
+
const slipAccount = {
|
|
89
|
+
name: { th: 0, en: 0 },
|
|
90
|
+
bank: accountNumber,
|
|
91
|
+
proxy: accountNumber,
|
|
92
|
+
};
|
|
93
|
+
const slipBank = { id: 0, name: 0, short: 0 };
|
|
94
|
+
const slipParty = { bank: slipBank, account: slipAccount };
|
|
95
|
+
const bankSlipShape = {
|
|
96
|
+
payload: 0,
|
|
97
|
+
transRef: 0,
|
|
98
|
+
date: 0,
|
|
99
|
+
countryCode: 0,
|
|
100
|
+
amount: {
|
|
101
|
+
amount: 0,
|
|
102
|
+
local: { amount: 0, currency: 0 },
|
|
103
|
+
},
|
|
104
|
+
fee: 0,
|
|
105
|
+
ref1: 0,
|
|
106
|
+
ref2: 0,
|
|
107
|
+
ref3: 0,
|
|
108
|
+
sender: slipParty,
|
|
109
|
+
receiver: { ...slipParty, merchantId: 0 },
|
|
110
|
+
};
|
|
111
|
+
const matchedAccount = {
|
|
112
|
+
bank: { nameTh: 0, nameEn: 0, code: 0, shortCode: 0 },
|
|
113
|
+
nameTh: 0,
|
|
114
|
+
nameEn: 0,
|
|
115
|
+
type: 0,
|
|
116
|
+
bankNumber: 0,
|
|
117
|
+
};
|
|
118
|
+
const bankSlipResultShape = {
|
|
119
|
+
remark: 0,
|
|
120
|
+
isDuplicate: 0,
|
|
121
|
+
matchedAccount,
|
|
122
|
+
amountInOrder: 0,
|
|
123
|
+
amountInSlip: 0,
|
|
124
|
+
isAmountMatched: 0,
|
|
125
|
+
rawSlip: bankSlipShape,
|
|
126
|
+
};
|
|
127
|
+
const trueWalletSlipShape = {
|
|
128
|
+
transactionId: 0,
|
|
129
|
+
date: 0,
|
|
130
|
+
amount: 0,
|
|
131
|
+
sender: { name: 0 },
|
|
132
|
+
receiver: { name: 0, phone: 0 },
|
|
133
|
+
};
|
|
134
|
+
const trueWalletResultShape = {
|
|
135
|
+
...bankSlipResultShape,
|
|
136
|
+
rawSlip: trueWalletSlipShape,
|
|
137
|
+
};
|
|
138
|
+
const bankShape = {
|
|
139
|
+
code: 0,
|
|
140
|
+
nameTh: 0,
|
|
141
|
+
nameEn: 0,
|
|
142
|
+
shortCode: 0,
|
|
143
|
+
swiftCode: 0,
|
|
144
|
+
extraVerify: [{ value: 0, label: 0 }],
|
|
145
|
+
};
|
|
146
|
+
const bankAccountShape = {
|
|
147
|
+
id: 0,
|
|
148
|
+
bankCode: 0,
|
|
149
|
+
bankNumber: 0,
|
|
150
|
+
nameTh: 0,
|
|
151
|
+
nameEn: 0,
|
|
152
|
+
type: 0,
|
|
153
|
+
extraVerify: 0,
|
|
154
|
+
matchMode: 0,
|
|
155
|
+
createdAt: 0,
|
|
156
|
+
updatedAt: 0,
|
|
157
|
+
deletedAt: 0,
|
|
158
|
+
};
|
|
159
|
+
const bankAccountPageShape = {
|
|
160
|
+
items: [bankAccountShape],
|
|
161
|
+
total: 0,
|
|
162
|
+
page: 0,
|
|
163
|
+
limit: 0,
|
|
164
|
+
};
|
|
165
|
+
const jobShape = {
|
|
166
|
+
jobId: 0,
|
|
167
|
+
batchId: 0,
|
|
168
|
+
status: 0,
|
|
169
|
+
result: { status: 0, data: bankSlipResultShape },
|
|
170
|
+
error: {
|
|
171
|
+
code: 0,
|
|
172
|
+
message: 0,
|
|
173
|
+
webhook: 0,
|
|
174
|
+
url: 0,
|
|
175
|
+
status: 0,
|
|
176
|
+
at: 0,
|
|
177
|
+
},
|
|
178
|
+
attempts: 0,
|
|
179
|
+
createdAt: 0,
|
|
180
|
+
updatedAt: 0,
|
|
181
|
+
branchId: 0,
|
|
182
|
+
serviceId: 0,
|
|
183
|
+
callbackEventId: 0,
|
|
184
|
+
callbackProtocol: 0,
|
|
185
|
+
callbackDelivery: { state: 0, httpStatus: 0 },
|
|
186
|
+
};
|
|
187
|
+
const webhookEventShape = {
|
|
188
|
+
jobId: 0,
|
|
189
|
+
batchId: 0,
|
|
190
|
+
status: 0,
|
|
191
|
+
data: bankSlipResultShape,
|
|
192
|
+
error: { code: 0, message: 0 },
|
|
193
|
+
timestamp: 0,
|
|
194
|
+
};
|
|
195
|
+
/** Model name to shape, for every model a response can decode into. */
|
|
196
|
+
exports.shapes = {
|
|
197
|
+
Info: infoShape,
|
|
198
|
+
BankSlip: bankSlipShape,
|
|
199
|
+
BankSlipResult: bankSlipResultShape,
|
|
200
|
+
TrueWalletSlip: trueWalletSlipShape,
|
|
201
|
+
TrueWalletResult: trueWalletResultShape,
|
|
202
|
+
BankAccount: bankAccountShape,
|
|
203
|
+
BankAccountPage: bankAccountPageShape,
|
|
204
|
+
LinkResult: { linked: 0 },
|
|
205
|
+
UnlinkResult: { unlinked: 0 },
|
|
206
|
+
JobSubmission: { jobId: 0 },
|
|
207
|
+
BatchSubmission: {
|
|
208
|
+
batchId: 0,
|
|
209
|
+
jobs: [{ jobId: 0, index: 0 }],
|
|
210
|
+
},
|
|
211
|
+
Job: jobShape,
|
|
212
|
+
WebhookEvent: webhookEventShape,
|
|
213
|
+
V1Me: {
|
|
214
|
+
application: 0,
|
|
215
|
+
usedQuota: 0,
|
|
216
|
+
maxQuota: 0,
|
|
217
|
+
remainingQuota: 0,
|
|
218
|
+
expiredAt: 0,
|
|
219
|
+
currentCredit: 0,
|
|
220
|
+
},
|
|
221
|
+
QrCode: { image: 0, mime: 0, payload: 0 },
|
|
222
|
+
};
|
|
223
|
+
/** Builds a model from decoded JSON, keeping only the fields the model knows. */
|
|
224
|
+
function parseModel(name, raw) {
|
|
225
|
+
if (name === 'BankList') {
|
|
226
|
+
const items = Array.isArray(raw) ? pick([bankShape], raw) : [];
|
|
227
|
+
return new BankList(items);
|
|
228
|
+
}
|
|
229
|
+
const value = pick(exports.shapes[name], raw);
|
|
230
|
+
if (value === null || typeof value !== 'object') {
|
|
231
|
+
return {};
|
|
232
|
+
}
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { RequestOptions, Transport } from '../core/http.js';
|
|
2
|
+
import type { WithMeta } from '../core/meta.js';
|
|
3
|
+
import type { BankAccount, BankAccountPage, BankAccountType, LinkResult, MatchMode, Open, UnlinkResult } from '../models.js';
|
|
4
|
+
/** The receiving account types a request may send: `NATURAL` or `JURISTIC`. */
|
|
5
|
+
export type AccountType = (typeof BankAccountType)[keyof typeof BankAccountType];
|
|
6
|
+
type AccountMatchMode = Open<(typeof MatchMode)[keyof typeof MatchMode]>;
|
|
7
|
+
/** Filters and paging for the list calls. */
|
|
8
|
+
export interface ListBankAccountsParams {
|
|
9
|
+
/** `NATURAL` or `JURISTIC`. */
|
|
10
|
+
type?: AccountType;
|
|
11
|
+
/** Only accounts at this bank code. */
|
|
12
|
+
bankCode?: string;
|
|
13
|
+
/** Page number, from 1. */
|
|
14
|
+
page?: number;
|
|
15
|
+
/** Page size, 1 to 100. The API default is 20. */
|
|
16
|
+
limit?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateBankAccountParams {
|
|
19
|
+
/** A code from `client.banks.list()`. */
|
|
20
|
+
bankCode: string;
|
|
21
|
+
bankNumber: string;
|
|
22
|
+
nameTh: string;
|
|
23
|
+
nameEn: string;
|
|
24
|
+
type: AccountType;
|
|
25
|
+
/** One of the bank's `extraVerify[].value` options. */
|
|
26
|
+
extraVerify?: string;
|
|
27
|
+
/** PromptPay accounts only: `NAME`, `NUMBER` or `NAME_NUMBER`. */
|
|
28
|
+
matchMode?: AccountMatchMode;
|
|
29
|
+
}
|
|
30
|
+
export interface UpdateBankAccountParams {
|
|
31
|
+
bankCode?: string;
|
|
32
|
+
bankNumber?: string;
|
|
33
|
+
nameTh?: string;
|
|
34
|
+
nameEn?: string;
|
|
35
|
+
type?: AccountType;
|
|
36
|
+
/** Leave out to keep, a string to set, `null` to clear. */
|
|
37
|
+
extraVerify?: string | null;
|
|
38
|
+
matchMode?: AccountMatchMode;
|
|
39
|
+
}
|
|
40
|
+
/** Receiving bank accounts used by `matchAccount` (`client.bankAccounts`). */
|
|
41
|
+
export declare class BankAccounts {
|
|
42
|
+
#private;
|
|
43
|
+
constructor(transport: Transport);
|
|
44
|
+
/** One page of the accounts linked to this branch. */
|
|
45
|
+
list(params?: ListBankAccountsParams, options?: RequestOptions): Promise<WithMeta<BankAccountPage>>;
|
|
46
|
+
/** One page of every active account of the service, linked to this branch or not. */
|
|
47
|
+
listAll(params?: ListBankAccountsParams, options?: RequestOptions): Promise<WithMeta<BankAccountPage>>;
|
|
48
|
+
/** Gets one account linked to this branch. */
|
|
49
|
+
get(id: number, options?: RequestOptions): Promise<WithMeta<BankAccount>>;
|
|
50
|
+
/** Registers an account on the service and links it to this branch. */
|
|
51
|
+
create(params: CreateBankAccountParams, options?: RequestOptions): Promise<WithMeta<BankAccount>>;
|
|
52
|
+
/** Changes the fields you pass. Pass `extraVerify: null` to clear it. */
|
|
53
|
+
update(id: number, params: UpdateBankAccountParams, options?: RequestOptions): Promise<WithMeta<BankAccount>>;
|
|
54
|
+
/** Links an existing service account to this branch. Linking twice is fine. */
|
|
55
|
+
link(id: number, options?: RequestOptions): Promise<WithMeta<LinkResult>>;
|
|
56
|
+
/** Unlinks an account from this branch. The account stays on the service. */
|
|
57
|
+
unlink(id: number, options?: RequestOptions): Promise<WithMeta<UnlinkResult>>;
|
|
58
|
+
/** Walks every page of {@link list}, one request per page (100 accounts by default). */
|
|
59
|
+
iterate(params?: ListBankAccountsParams, options?: RequestOptions): AsyncGenerator<BankAccount>;
|
|
60
|
+
/** Walks every page of {@link listAll}. */
|
|
61
|
+
iterateAll(params?: ListBankAccountsParams, options?: RequestOptions): AsyncGenerator<BankAccount>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|