@@ -24,10 +24,12 @@ import CasParser from 'cas-parser-node';
2424
2525const client = new CasParser ({
2626 apiKey: process .env [' CAS_PARSER_API_KEY' ], // This is the default and can be omitted
27- environment: ' local' , // defaults to 'production'
2827});
2928
30- const unifiedResponse = await client .casParser .camsKfintech ();
29+ const unifiedResponse = await client .casParser .smartParse ({
30+ password: ' ABCDF' ,
31+ pdf_url: ' https://your-cas-pdf-url-here.com' ,
32+ });
3133
3234console .log (unifiedResponse .demat_accounts );
3335```
@@ -42,10 +44,13 @@ import CasParser from 'cas-parser-node';
4244
4345const client = new CasParser ({
4446 apiKey: process .env [' CAS_PARSER_API_KEY' ], // This is the default and can be omitted
45- environment: ' local' , // defaults to 'production'
4647});
4748
48- const unifiedResponse: CasParser .UnifiedResponse = await client .casParser .camsKfintech ();
49+ const params: CasParser .CasParserSmartParseParams = {
50+ password: ' ABCDF' ,
51+ pdf_url: ' https://you-cas-pdf-url-here.com' ,
52+ };
53+ const unifiedResponse: CasParser .UnifiedResponse = await client .casParser .smartParse (params );
4954```
5055
5156Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -58,15 +63,17 @@ a subclass of `APIError` will be thrown:
5863
5964<!-- prettier-ignore -->
6065``` ts
61- const unifiedResponse = await client .casParser .camsKfintech ().catch (async (err ) => {
62- if (err instanceof CasParser .APIError ) {
63- console .log (err .status ); // 400
64- console .log (err .name ); // BadRequestError
65- console .log (err .headers ); // {server: 'nginx', ...}
66- } else {
67- throw err ;
68- }
69- });
66+ const unifiedResponse = await client .casParser
67+ .smartParse ({ password: ' ABCDF' , pdf_url: ' https://you-cas-pdf-url-here.com' })
68+ .catch (async (err ) => {
69+ if (err instanceof CasParser .APIError ) {
70+ console .log (err .status ); // 400
71+ console .log (err .name ); // BadRequestError
72+ console .log (err .headers ); // {server: 'nginx', ...}
73+ } else {
74+ throw err ;
75+ }
76+ });
7077```
7178
7279Error codes are as follows:
@@ -98,7 +105,7 @@ const client = new CasParser({
98105});
99106
100107// Or, configure per-request:
101- await client .casParser .camsKfintech ( {
108+ await client .casParser .smartParse ({ password : ' ABCDF ' , pdf_url : ' https://you-cas-pdf-url-here.com ' }, {
102109 maxRetries: 5 ,
103110});
104111```
@@ -115,7 +122,7 @@ const client = new CasParser({
115122});
116123
117124// Override per-request:
118- await client .casParser .camsKfintech ( {
125+ await client .casParser .smartParse ({ password: ' ABCDF ' , pdf_url: ' https://you-cas-pdf-url-here.com ' }, {
119126 timeout: 5 * 1000 ,
120127});
121128```
@@ -138,11 +145,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
138145``` ts
139146const client = new CasParser ();
140147
141- const response = await client .casParser .camsKfintech ().asResponse ();
148+ const response = await client .casParser
149+ .smartParse ({ password: ' ABCDF' , pdf_url: ' https://you-cas-pdf-url-here.com' })
150+ .asResponse ();
142151console .log (response .headers .get (' X-My-Header' ));
143152console .log (response .statusText ); // access the underlying Response object
144153
145- const { data : unifiedResponse, response : raw } = await client .casParser .camsKfintech ().withResponse ();
154+ const { data : unifiedResponse, response : raw } = await client .casParser
155+ .smartParse ({ password: ' ABCDF' , pdf_url: ' https://you-cas-pdf-url-here.com' })
156+ .withResponse ();
146157console .log (raw .headers .get (' X-My-Header' ));
147158console .log (unifiedResponse .demat_accounts );
148159```
@@ -224,7 +235,7 @@ parameter. This library doesn't validate at runtime that the request matches the
224235send will be sent as-is.
225236
226237``` ts
227- client .casParser .camsKfintech ({
238+ client .casParser .smartParse ({
228239 // ...
229240 // @ts-expect-error baz is not yet public
230241 baz: ' undocumented option' ,
0 commit comments