Skip to content

Commit cec98f9

Browse files
feat(client): add raw methods
1 parent db0fac3 commit cec98f9

File tree

6 files changed

+211
-19
lines changed

6 files changed

+211
-19
lines changed

src/CasGenerator/CasGeneratorGenerateCasResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @phpstan-type cas_generator_generate_cas_response = array{
1313
* msg?: string, status?: string
1414
* }
15-
* When used in a response, this type parameter can be used to define a $rawResponse property.
15+
* When used in a response, this type parameter can define a $rawResponse property.
1616
* @template TRawResponse of object = object{}
1717
*
1818
* @mixin TRawResponse

src/CasParser/UnifiedResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* mutualFunds?: list<MutualFund>,
2424
* summary?: Summary,
2525
* }
26-
* When used in a response, this type parameter can be used to define a $rawResponse property.
26+
* When used in a response, this type parameter can define a $rawResponse property.
2727
* @template TRawResponse of object = object{}
2828
*
2929
* @mixin TRawResponse

src/ServiceContracts/CasGeneratorContract.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority;
88
use CasParser\CasGenerator\CasGeneratorGenerateCasResponse;
9+
use CasParser\Core\Exceptions\APIException;
910
use CasParser\Core\Implementation\HasRawResponse;
1011
use CasParser\RequestOptions;
1112

@@ -24,6 +25,8 @@ interface CasGeneratorContract
2425
* @param string $panNo PAN number (optional for some CAS authorities)
2526
*
2627
* @return CasGeneratorGenerateCasResponse<HasRawResponse>
28+
*
29+
* @throws APIException
2730
*/
2831
public function generateCas(
2932
$email,
@@ -34,4 +37,18 @@ public function generateCas(
3437
$panNo = omit,
3538
?RequestOptions $requestOptions = null,
3639
): CasGeneratorGenerateCasResponse;
40+
41+
/**
42+
* @api
43+
*
44+
* @param array<string, mixed> $params
45+
*
46+
* @return CasGeneratorGenerateCasResponse<HasRawResponse>
47+
*
48+
* @throws APIException
49+
*/
50+
public function generateCasRaw(
51+
array $params,
52+
?RequestOptions $requestOptions = null
53+
): CasGeneratorGenerateCasResponse;
3754
}

src/ServiceContracts/CasParserContract.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace CasParser\ServiceContracts;
66

77
use CasParser\CasParser\UnifiedResponse;
8+
use CasParser\Core\Exceptions\APIException;
89
use CasParser\Core\Implementation\HasRawResponse;
910
use CasParser\RequestOptions;
1011

@@ -20,6 +21,8 @@ interface CasParserContract
2021
* @param string $pdfURL URL to the CAS PDF file
2122
*
2223
* @return UnifiedResponse<HasRawResponse>
24+
*
25+
* @throws APIException
2326
*/
2427
public function camsKfintech(
2528
$password = omit,
@@ -28,6 +31,20 @@ public function camsKfintech(
2831
?RequestOptions $requestOptions = null,
2932
): UnifiedResponse;
3033

34+
/**
35+
* @api
36+
*
37+
* @param array<string, mixed> $params
38+
*
39+
* @return UnifiedResponse<HasRawResponse>
40+
*
41+
* @throws APIException
42+
*/
43+
public function camsKfintechRaw(
44+
array $params,
45+
?RequestOptions $requestOptions = null
46+
): UnifiedResponse;
47+
3148
/**
3249
* @api
3350
*
@@ -36,6 +53,8 @@ public function camsKfintech(
3653
* @param string $pdfURL URL to the CAS PDF file
3754
*
3855
* @return UnifiedResponse<HasRawResponse>
56+
*
57+
* @throws APIException
3958
*/
4059
public function cdsl(
4160
$password = omit,
@@ -44,6 +63,20 @@ public function cdsl(
4463
?RequestOptions $requestOptions = null,
4564
): UnifiedResponse;
4665

66+
/**
67+
* @api
68+
*
69+
* @param array<string, mixed> $params
70+
*
71+
* @return UnifiedResponse<HasRawResponse>
72+
*
73+
* @throws APIException
74+
*/
75+
public function cdslRaw(
76+
array $params,
77+
?RequestOptions $requestOptions = null
78+
): UnifiedResponse;
79+
4780
/**
4881
* @api
4982
*
@@ -52,6 +85,8 @@ public function cdsl(
5285
* @param string $pdfURL URL to the CAS PDF file
5386
*
5487
* @return UnifiedResponse<HasRawResponse>
88+
*
89+
* @throws APIException
5590
*/
5691
public function nsdl(
5792
$password = omit,
@@ -60,6 +95,20 @@ public function nsdl(
6095
?RequestOptions $requestOptions = null,
6196
): UnifiedResponse;
6297

98+
/**
99+
* @api
100+
*
101+
* @param array<string, mixed> $params
102+
*
103+
* @return UnifiedResponse<HasRawResponse>
104+
*
105+
* @throws APIException
106+
*/
107+
public function nsdlRaw(
108+
array $params,
109+
?RequestOptions $requestOptions = null
110+
): UnifiedResponse;
111+
63112
/**
64113
* @api
65114
*
@@ -68,11 +117,27 @@ public function nsdl(
68117
* @param string $pdfURL URL to the CAS PDF file
69118
*
70119
* @return UnifiedResponse<HasRawResponse>
120+
*
121+
* @throws APIException
71122
*/
72123
public function smartParse(
73124
$password = omit,
74125
$pdfFile = omit,
75126
$pdfURL = omit,
76127
?RequestOptions $requestOptions = null,
77128
): UnifiedResponse;
129+
130+
/**
131+
* @api
132+
*
133+
* @param array<string, mixed> $params
134+
*
135+
* @return UnifiedResponse<HasRawResponse>
136+
*
137+
* @throws APIException
138+
*/
139+
public function smartParseRaw(
140+
array $params,
141+
?RequestOptions $requestOptions = null
142+
): UnifiedResponse;
78143
}

src/Services/CasGeneratorService.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority;
99
use CasParser\CasGenerator\CasGeneratorGenerateCasResponse;
1010
use CasParser\Client;
11+
use CasParser\Core\Exceptions\APIException;
1112
use CasParser\Core\Implementation\HasRawResponse;
1213
use CasParser\RequestOptions;
1314
use CasParser\ServiceContracts\CasGeneratorContract;
@@ -35,6 +36,8 @@ public function __construct(private Client $client) {}
3536
* @param string $panNo PAN number (optional for some CAS authorities)
3637
*
3738
* @return CasGeneratorGenerateCasResponse<HasRawResponse>
39+
*
40+
* @throws APIException
3841
*/
3942
public function generateCas(
4043
$email,
@@ -44,17 +47,35 @@ public function generateCas(
4447
$casAuthority = omit,
4548
$panNo = omit,
4649
?RequestOptions $requestOptions = null,
50+
): CasGeneratorGenerateCasResponse {
51+
$params = [
52+
'email' => $email,
53+
'fromDate' => $fromDate,
54+
'password' => $password,
55+
'toDate' => $toDate,
56+
'casAuthority' => $casAuthority,
57+
'panNo' => $panNo,
58+
];
59+
60+
return $this->generateCasRaw($params, $requestOptions);
61+
}
62+
63+
/**
64+
* @api
65+
*
66+
* @param array<string, mixed> $params
67+
*
68+
* @return CasGeneratorGenerateCasResponse<HasRawResponse>
69+
*
70+
* @throws APIException
71+
*/
72+
public function generateCasRaw(
73+
array $params,
74+
?RequestOptions $requestOptions = null
4775
): CasGeneratorGenerateCasResponse {
4876
[$parsed, $options] = CasGeneratorGenerateCasParams::parseRequest(
49-
[
50-
'email' => $email,
51-
'fromDate' => $fromDate,
52-
'password' => $password,
53-
'toDate' => $toDate,
54-
'casAuthority' => $casAuthority,
55-
'panNo' => $panNo,
56-
],
57-
$requestOptions,
77+
$params,
78+
$requestOptions
5879
);
5980

6081
// @phpstan-ignore-next-line;

0 commit comments

Comments
 (0)