-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.ts
More file actions
126 lines (109 loc) · 2.87 KB
/
fetch.ts
File metadata and controls
126 lines (109 loc) · 2.87 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
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
/**
* Endpoints for fetching CAS documents with instant download.
* Currently supports CDSL via OTP authentication.
*/
export class Fetch extends APIResource {
/**
* **Step 1 of 2**: Request OTP for CDSL CAS fetch.
*
* This endpoint:
*
* 1. Solves reCAPTCHA automatically (~15-20 seconds)
* 2. Submits login credentials to CDSL portal
* 3. Triggers OTP to user's registered mobile number
*
* After user receives OTP, call `/v4/cdsl/fetch/{session_id}/verify` to complete.
*
* @example
* ```ts
* const response = await client.cdsl.fetch.requestOtp({
* bo_id: '1234567890123456',
* dob: '1990-01-15',
* pan: 'ABCDE1234F',
* });
* ```
*/
requestOtp(body: FetchRequestOtpParams, options?: RequestOptions): APIPromise<FetchRequestOtpResponse> {
return this._client.post('/v4/cdsl/fetch', { body, ...options });
}
/**
* **Step 2 of 2**: Verify OTP and retrieve CDSL CAS files.
*
* After successful verification, CAS PDFs are fetched from CDSL portal, uploaded
* to cloud storage, and returned as direct download URLs.
*
* @example
* ```ts
* const response = await client.cdsl.fetch.verifyOtp(
* 'session_id',
* { otp: '123456' },
* );
* ```
*/
verifyOtp(
sessionID: string,
body: FetchVerifyOtpParams,
options?: RequestOptions,
): APIPromise<FetchVerifyOtpResponse> {
return this._client.post(path`/v4/cdsl/fetch/${sessionID}/verify`, { body, ...options });
}
}
export interface FetchRequestOtpResponse {
msg?: string;
/**
* Session ID for verify step
*/
session_id?: string;
status?: string;
}
export interface FetchVerifyOtpResponse {
files?: Array<FetchVerifyOtpResponse.File>;
msg?: string;
status?: string;
}
export namespace FetchVerifyOtpResponse {
export interface File {
filename?: string;
/**
* Direct download URL (cloud storage)
*/
url?: string;
}
}
export interface FetchRequestOtpParams {
/**
* CDSL BO ID (16 digits)
*/
bo_id: string;
/**
* Date of birth (YYYY-MM-DD)
*/
dob: string;
/**
* PAN number
*/
pan: string;
}
export interface FetchVerifyOtpParams {
/**
* OTP received on mobile
*/
otp: string;
/**
* Number of monthly statements to fetch (default 6)
*/
num_periods?: number;
}
export declare namespace Fetch {
export {
type FetchRequestOtpResponse as FetchRequestOtpResponse,
type FetchVerifyOtpResponse as FetchVerifyOtpResponse,
type FetchRequestOtpParams as FetchRequestOtpParams,
type FetchVerifyOtpParams as FetchVerifyOtpParams,
};
}