forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment-client.ts
More file actions
48 lines (44 loc) · 1.25 KB
/
Copy pathpayment-client.ts
File metadata and controls
48 lines (44 loc) · 1.25 KB
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
import { encodePathSegment } from '../http/path';
import type {
ExecutePaymentRequest,
Payment,
PaymentQuote,
PaymentQuoteRequest,
} from '../models';
import type { PaymentClientContract } from '../types/contracts';
import {
validateExecutePaymentRequest,
validatePaymentQuoteRequest,
} from '../validation';
import { BaseClient } from './base-client';
export class PaymentClient extends BaseClient implements PaymentClientContract {
public async quote(input: PaymentQuoteRequest): Promise<PaymentQuote> {
validatePaymentQuoteRequest(input);
return this.request({
method: 'POST',
path: '/v1/payments/quote',
body: input,
});
}
public async execute(input: ExecutePaymentRequest): Promise<Payment> {
validateExecutePaymentRequest(input);
return this.request({
method: 'POST',
path: '/v1/payments',
body: input,
});
}
public get(paymentId: string): Promise<Payment> {
return this.request({
method: 'GET',
path: `/v1/payments/${encodePathSegment(paymentId)}`,
});
}
public async list(query?: { limit?: number; cursor?: string }): Promise<readonly Payment[]> {
return this.request({
method: 'GET',
path: '/v1/payments',
query: query ?? {},
});
}
}