-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.d.ts
507 lines (441 loc) · 14 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// Type definitions for omise-node
// Project: https://github.com/omise/omise-node
// Definitions by: Bhoomtawath Plinsut <https://github.com/varshard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as Bluebird from 'bluebird';
declare function Omise(options: Omise.IOptions): Omise.IOmise;
export = Omise;
declare namespace Omise {
export interface IOptions {
publicKey: string;
secretKey: string;
}
export interface IOmise {
accounts: Account.IAccountAPI;
balances: Balance.IBalanceAPI;
charges: Charges.IChargesAPI;
customers: Customers.ICustomersAPI;
disputes: Disputes.IDisputesAPI;
events: Events.IEventsAPI;
links: Links.ILinksAPI;
recipients: Recipients.IRecipientsAPI;
schedules: Schedules.ISchedulesAPI;
sources: Sources.ISourcesAPI;
tokens: Tokens.ITokensAPI;
transactions: Transactions.ITransactionsAPI;
transfers: Transfers.ITransfersAPI;
}
export namespace Account {
interface IAccountAPI {
retrieve(callback?: ResponseCallback<IAccount>): Bluebird<IAccount>;
}
interface IAccount extends IBaseResponse {
email: string;
currency: string;
supported_currencies: string[];
created: string;
}
}
export namespace Balance {
interface IBalanceAPI {
retrieve(callback?: ResponseCallback<IBalance>): Bluebird<IBalance>;
}
interface IBalance extends IBaseResponse {
available: number;
total: number;
currency: string;
}
}
export namespace Cards {
interface ICard extends IBaseResponse {
country: string;
city: string;
postal_code: string;
financing: string;
bank: string;
last_digits: string;
brand: string;
expiration_month: number;
expiration_year: number;
fingerprint: string;
name: string;
security_code_check: boolean;
created: string;
}
interface ICardRequest {
name?: string;
expiration_month?: number;
expiration_year?: number;
postal_code?: string;
city?: string;
}
interface ICardList extends IOccurrences {
data: ICard[];
}
}
export namespace Charges {
interface IChargesAPI {
create(req: IRequest, callback?: ResponseCallback<ICharge>): Bluebird<ICharge>;
update(chargeID: string, req: IRequest, callback?: ResponseCallback<ICharge>): Bluebird<ICharge>;
retrieve(chargeID: string, callback?: ResponseCallback<ICharge>): Bluebird<ICharge>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<IChargeList>): Bluebird<IChargeList>;
capture(chargeID: string, callback?: ResponseCallback<ICharge>): Bluebird<ICharge>;
reverse(chargeID: string, callback?: ResponseCallback<ICharge>): Bluebird<ICharge>;
createRefund(chargeID: string, callback?: ResponseCallback<IRefundResponse>): Bluebird<IRefundResponse>;
listRefunds(chargeID: string, callback?: ResponseCallback<IListRefundResponse>): Bluebird<IListRefundResponse>;
retrieveRefund(chargeID: string, refundID: string, callback?: ResponseCallback<IRefundResponse>): Bluebird<IRefundResponse>;
}
interface IRequest {
description?: string;
amount: number;
currency: string;
capture?: boolean;
card?: string;
customer?: string;
return_uri?: string;
metadata?: any;
source?: string;
}
interface ICharge extends IBaseResponse {
amount: number;
currency: string;
description: string;
capture: boolean;
authorized: boolean;
reversed: boolean;
paid: boolean;
transaction: string;
refunded: number;
refunds: IListRefundResponse;
failure_code: string;
failure_message: string;
card: Cards.ICard;
customer: string;
ip: string;
dispute: string;
created: string;
metadata: {[key: string]: any};
source?: Sources.ISource;
}
interface IListRefundResponse extends IOccurrences {
data: IRefundResponse[];
}
interface IChargeList extends IOccurrences {
data: ICharge[];
}
interface IRefundResponse extends IBaseResponse {
amount: number;
currency: string;
charge: string;
transaction: string;
created: string;
voided: boolean;
}
}
export namespace Sources {
interface ISourcesAPI {
create(req: IRequest, callback?: ResponseCallback<ISource>): Bluebird<ISource>;
}
interface IRequest {
type: string;
amount: number;
currency: string;
}
interface ISource extends IBaseResponse {
type: string;
flow: string;
amount: number;
currency: string;
}
}
export namespace Customers {
interface ICustomersAPI {
create(req: IRequest, callback?: ResponseCallback<ICustomer>): Bluebird<ICustomer>;
retrieve(customerID: string, callback?: ResponseCallback<ICustomer>): Bluebird<ICustomer>;
update(customerID: string, req: IRequest, callback?: ResponseCallback<ICustomer>): Bluebird<ICustomer>;
destroy(customerID: string, callback?: ResponseCallback<IDestroyResponse>): Bluebird<IDestroyResponse>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<ICustomerList>): Bluebird<ICustomerList>;
listCards(customerID: string, parameters?: Pagination.IRequest, callback?: ResponseCallback<Cards.ICardList>)
: Bluebird<Cards.ICardList>;
retrieveCard(customerID: string, cardID: string, callback?: ResponseCallback<Cards.ICard>): Bluebird<Cards.ICard>;
updateCard(customerID: string, cardID: string, details: Cards.ICardRequest,
callback?: ResponseCallback<Cards.ICard>): Bluebird<Cards.ICard>;
destroyCard(customerID: string, cardID: string, callback?: ResponseCallback<Cards.ICard>): Bluebird<Cards.ICard>;
}
interface IRequest {
email?: string;
description?: string;
card?: string;
metadata?: any;
}
interface ICustomer extends IBaseResponse {
default_card: string;
email: string;
description: string;
created: string;
cards: Cards.ICardList;
metadata: {[key: string]: any};
}
interface ICustomerList extends IOccurrences {
data: ICustomer[];
}
}
export namespace Disputes {
interface IDisputesAPI {
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<IListResponse>): Bluebird<IListResponse>;
listClosed(callback?: ResponseCallback<IListResponse>): Bluebird<IListResponse>;
listOpen(callback?: ResponseCallback<IListResponse>): Bluebird<IListResponse>;
listPending(callback?: ResponseCallback<IListResponse>): Bluebird<IListResponse>;
retrieve(disputeID: string, callback?: ResponseCallback<IResponse>): Bluebird<IResponse>;
update(disputeID: string, req: IRequest, callback?: ResponseCallback<IResponse>): Bluebird<IResponse>;
}
interface IRequest {
message: string;
}
interface IResponse extends IBaseResponse {
amount: number;
charge: string;
created: string;
closed_at: string;
currency: string;
message: string;
documents: IDocumentsList;
reason_code: string;
reason_message: string;
status: string;
transaction: string;
}
interface IListResponse extends IOccurrences {
data: IResponse[];
}
interface IDocument extends IBaseResponse {
filename: string;
created: string;
}
interface IDocumentsList extends IOccurrences {
data: IDocument[];
}
}
export namespace Events {
interface IEventsAPI {
retrieve(eventID: string, callback?: ResponseCallback<IEvent>): Bluebird<IEvent>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<IEventList>): Bluebird<IEventList>;
}
interface IEvent extends IBaseResponse {
key: string;
created: string;
data: any;
}
interface IEventList extends IOccurrences {
data: IEvent[];
}
}
export namespace Links {
interface ILinksAPI {
retrieve(linkID: string, callback?: ResponseCallback<ILink>): Bluebird<ILink>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<ILinkListResponse>): Bluebird<ILinkListResponse>;
create(req: IRequest, callback?: ResponseCallback<ILink>): Bluebird<ILink>;
}
interface IRequest {
amount: number;
currency: string;
title: string;
description: string;
multiple?: boolean;
}
interface ILink extends IBaseResponse {
amount: number;
currency: string;
used: boolean;
multiple: boolean;
title: string;
description: string;
charges: Charges.IChargeList;
payment_uri: string;
created: string;
}
interface ILinkListResponse extends IOccurrences {
data: ILink[];
}
}
export namespace Recipients {
interface IRecipientsAPI {
create(req: IRequest, callback?: ResponseCallback<IRecipient>): Bluebird<IRecipient>;
update(recipientID: string, req: IRequest, callback?: ResponseCallback<IRecipient>): Bluebird<IRecipient>;
retrieve(recipientID: string, callback?: ResponseCallback<IRecipient>): Bluebird<IRecipient>;
destroy(recipientID: string, callback?: ResponseCallback<IDestroyResponse>): Bluebird<IDestroyResponse>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<IRecipientList>): Bluebird<IRecipientList>;
}
interface IRequest {
name: string;
email?: string;
description?: string;
type: string;
tax_id?: string;
back_account: IBankAccount;
}
interface IRecipient extends IBaseResponse {
verified: boolean;
active: boolean;
name: string;
email: string;
description: string;
type: string;
tax_id: string;
bank_account: IBankAccount;
failure_code: string;
created: string;
}
interface IRecipientList extends IOccurrences {
data: IRecipient[];
}
}
export namespace Transactions {
interface ITransactionsAPI {
retrieve(transactionID: string, callback?: ResponseCallback<ITransaction>): Bluebird<ITransaction>;
list(parameters?: Pagination.IRequest, callback?: ResponseCallback<ITransactionList>): Bluebird<ITransactionList>;
}
interface ITransaction extends IBaseResponse {
type: string;
amount: number;
currency: string;
transferable: string;
created: string;
}
interface ITransactionList extends IOccurrences {
data: ITransaction[];
}
}
export namespace Transfers {
interface ITransfersAPI {
create(req: IRequest, callback?: ResponseCallback<ITransfer>): Bluebird<ITransfer>;
update(transferID: string, req: IRequest, callback?: ResponseCallback<ITransfer>): Bluebird<ITransfer>;
retrieve(transferID: string, callback?: ResponseCallback<ITransfer>): Bluebird<ITransfer>;
destroy(transferID: string, callback?: ResponseCallback<IDestroyResponse>): Bluebird<IDestroyResponse>;
list(parameters: Pagination.IRequest, callback?: ResponseCallback<ITransferList>): Bluebird<ITransferList>;
}
interface IRequest {
amount: number;
recipient?: string;
fail_fast?: boolean;
}
interface ITransfer extends IBaseResponse {
recipient: string;
bank_account: IBankAccount;
sent: boolean;
paid: boolean;
amount: number;
currency: string;
fee: number;
fail_fast: boolean;
failure_code: boolean;
failure_message: string;
transaction: string;
created: string;
}
interface ITransferList extends IOccurrences {
data: ITransfer[];
}
}
export namespace Tokens {
interface ITokensAPI {
create(options: IRequest, callback?: ResponseCallback<IToken>): Bluebird<IToken>;
retrieve(tokenID: string, callback?: ResponseCallback<IToken>): Bluebird<IToken>;
}
interface IRequest {
card: ICard;
}
interface ICard {
name: string;
city: string;
postal_code: number|string;
number: string;
security_code: string;
expiration_month: number|string;
expiration_year: number|string;
}
interface IToken extends IBaseResponse {
used: boolean;
card: Cards.ICard;
created: string;
}
}
export namespace Schedules {
interface ISchedulesAPI {
create(options: ICreateSchedule, callback?: ResponseCallback<ISchedule>): Bluebird<ISchedule>;
retrieve(scheduleID: string, callback?: ResponseCallback<ISchedule>): Bluebird<ISchedule>;
}
interface IChargeSchedule extends ICreateSchedule {
charge: ICharge;
}
interface ICharge {
amount: number;
currency: string;
description: string;
customer: string;
card: string;
}
interface ICreateSchedule {
every: number;
period: string;
on?: Ion;
start_date: string;
end_date: string;
}
interface Ion {
weekdays?: string[];
days_of_month?: number[];
weekday_of_month?: string;
}
interface ISchedule extends IBaseResponse {
status: string;
every: number;
period: string;
on: Ion;
in_words: string;
start_date: string;
end_date: string;
occurrences: IOccurrences;
next_occurrence_dates: string[];
charge?: ICharge;
}
}
export namespace Pagination {
interface IRequest {
offset?: number;
limit?: number;
from?: string;
to?: string;
order?: string;
total?: number;
}
}
interface IOccurrences {
object: string;
offset: number;
limit: number;
from: string;
to: string;
order: string;
total: number;
data: any[];
location?: string;
}
interface IBankAccount {
object: string;
brand: string;
last_digits: string;
name: string;
created: string;
}
interface IBaseResponse {
object: string;
id: string;
livemode?: boolean;
location?: string;
}
interface IDestroyResponse extends IBaseResponse {
deleted: boolean;
}
type ResponseCallback<R> = (err: any, resp: R) => void;
}