Skip to content

Commit 90a131a

Browse files
feat(api): api update
1 parent 6b7a996 commit 90a131a

File tree

106 files changed

+5764
-1831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+5764
-1831
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-9eaed98ce5934f11e901cef376a28257d2c196bd3dba7c690babc6741a730ded.yml
3-
openapi_spec_hash: b76e4e830c4d03ba4cf9429bb9fb9c8a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-38618cc5c938e87eeacf4893d6a6ba4e6ef7da390e6283dc7b50b484a7b97165.yml
3+
openapi_spec_hash: b9e439ecee904ded01aa34efdee88856
44
config_hash: cb5d75abef6264b5d86448caf7295afa

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2025 Cas Parser
189+
Copyright 2026 Cas Parser
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ Parameters with a default value must be set by name.
4747

4848
use CasParser\Client;
4949

50-
$client = new Client(apiKey: getenv("CAS_PARSER_API_KEY") ?: "My API Key");
50+
$client = new Client(apiKey: getenv('CAS_PARSER_API_KEY') ?: 'My API Key');
5151

52-
$unifiedResponse = $client->casParser->smartParse([]);
52+
$unifiedResponse = $client->casParser->smartParse(
53+
password: 'ABCDF', pdfURL: 'https://your-cas-pdf-url-here.com'
54+
);
5355

5456
var_dump($unifiedResponse->demat_accounts);
5557
```
@@ -71,11 +73,11 @@ When the library is unable to connect to the API, or if the API returns a non-su
7173
use CasParser\Core\Exceptions\APIConnectionException;
7274

7375
try {
74-
$unifiedResponse = $client->casParser->smartParse([]);
76+
$unifiedResponse = $client->casParser->smartParse();
7577
} catch (APIConnectionException $e) {
7678
echo "The server could not be reached", PHP_EOL;
7779
var_dump($e->getPrevious());
78-
} catch (RateLimitError $_) {
80+
} catch (RateLimitError $e) {
7981
echo "A 429 status code was received; we should back off a bit.", PHP_EOL;
8082
} catch (APIStatusError $e) {
8183
echo "Another non-200-range status code was received", PHP_EOL;
@@ -118,7 +120,9 @@ $client = new Client(maxRetries: 0);
118120

119121
// Or, configure per-request:
120122
$result = $client->casParser->smartParse(
121-
[], RequestOptions::with(maxRetries: 5)
123+
password: 'ABCDF',
124+
pdfURL: 'https://you-cas-pdf-url-here.com',
125+
requestOptions: RequestOptions::with(maxRetries: 5),
122126
);
123127
```
124128

@@ -138,11 +142,12 @@ Note: the `extra*` parameters of the same name overrides the documented paramete
138142
use CasParser\RequestOptions;
139143

140144
$unifiedResponse = $client->casParser->smartParse(
141-
[],
142-
RequestOptions::with(
143-
extraQueryParams: ["my_query_parameter" => "value"],
144-
extraBodyParams: ["my_body_parameter" => "value"],
145-
extraHeaders: ["my-header" => "value"],
145+
password: 'ABCDF',
146+
pdfURL: 'https://you-cas-pdf-url-here.com',
147+
requestOptions: RequestOptions::with(
148+
extraQueryParams: ['my_query_parameter' => 'value'],
149+
extraBodyParams: ['my_body_parameter' => 'value'],
150+
extraHeaders: ['my-header' => 'value'],
146151
),
147152
);
148153
```

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"autoload": {
55
"files": [
66
"src/Core.php",
7+
"src/Version.php",
78
"src/Client.php"
89
],
910
"psr-4": {

release-please-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"release-type": "php",
6363
"extra-files": [
6464
"README.md",
65-
"src/Client.php"
65+
"src/Version.php"
6666
]
6767
}

scripts/lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -e
55
cd -- "$(dirname -- "$0")/.."
66

77
echo "==> Running PHPStan"
8-
exec -- ./vendor/bin/phpstan analyse --memory-limit=2G
8+
exec -- ./vendor/bin/phpstan analyse --memory-limit=12G

src/CasGenerator/CasGeneratorGenerateCasParams.php

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
namespace CasParser\CasGenerator;
66

77
use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority;
8-
use CasParser\Core\Attributes\Api;
8+
use CasParser\Core\Attributes\Optional;
9+
use CasParser\Core\Attributes\Required;
910
use CasParser\Core\Concerns\SdkModel;
1011
use CasParser\Core\Concerns\SdkParams;
1112
use CasParser\Core\Contracts\BaseModel;
@@ -18,11 +19,11 @@
1819
*
1920
* @phpstan-type CasGeneratorGenerateCasParamsShape = array{
2021
* email: string,
21-
* from_date: string,
22+
* fromDate: string,
2223
* password: string,
23-
* to_date: string,
24-
* cas_authority?: CasAuthority|value-of<CasAuthority>,
25-
* pan_no?: string,
24+
* toDate: string,
25+
* casAuthority?: null|CasAuthority|value-of<CasAuthority>,
26+
* panNo?: string|null,
2627
* }
2728
*/
2829
final class CasGeneratorGenerateCasParams implements BaseModel
@@ -34,48 +35,48 @@ final class CasGeneratorGenerateCasParams implements BaseModel
3435
/**
3536
* Email address to receive the CAS document.
3637
*/
37-
#[Api]
38+
#[Required]
3839
public string $email;
3940

4041
/**
4142
* Start date for the CAS period (format YYYY-MM-DD).
4243
*/
43-
#[Api]
44-
public string $from_date;
44+
#[Required('from_date')]
45+
public string $fromDate;
4546

4647
/**
4748
* Password to protect the generated CAS PDF.
4849
*/
49-
#[Api]
50+
#[Required]
5051
public string $password;
5152

5253
/**
5354
* End date for the CAS period (format YYYY-MM-DD).
5455
*/
55-
#[Api]
56-
public string $to_date;
56+
#[Required('to_date')]
57+
public string $toDate;
5758

5859
/**
5960
* CAS authority to generate the document from (currently only kfintech is supported).
6061
*
61-
* @var value-of<CasAuthority>|null $cas_authority
62+
* @var value-of<CasAuthority>|null $casAuthority
6263
*/
63-
#[Api(enum: CasAuthority::class, optional: true)]
64-
public ?string $cas_authority;
64+
#[Optional('cas_authority', enum: CasAuthority::class)]
65+
public ?string $casAuthority;
6566

6667
/**
6768
* PAN number (optional for some CAS authorities).
6869
*/
69-
#[Api(optional: true)]
70-
public ?string $pan_no;
70+
#[Optional('pan_no')]
71+
public ?string $panNo;
7172

7273
/**
7374
* `new CasGeneratorGenerateCasParams()` is missing required properties by the API.
7475
*
7576
* To enforce required parameters use
7677
* ```
7778
* CasGeneratorGenerateCasParams::with(
78-
* email: ..., from_date: ..., password: ..., to_date: ...
79+
* email: ..., fromDate: ..., password: ..., toDate: ...
7980
* )
8081
* ```
8182
*
@@ -99,71 +100,71 @@ public function __construct()
99100
*
100101
* You must use named parameters to construct any parameters with a default value.
101102
*
102-
* @param CasAuthority|value-of<CasAuthority> $cas_authority
103+
* @param CasAuthority|value-of<CasAuthority>|null $casAuthority
103104
*/
104105
public static function with(
105106
string $email,
106-
string $from_date,
107+
string $fromDate,
107108
string $password,
108-
string $to_date,
109-
CasAuthority|string|null $cas_authority = null,
110-
?string $pan_no = null,
109+
string $toDate,
110+
CasAuthority|string|null $casAuthority = null,
111+
?string $panNo = null,
111112
): self {
112-
$obj = new self;
113+
$self = new self;
113114

114-
$obj->email = $email;
115-
$obj->from_date = $from_date;
116-
$obj->password = $password;
117-
$obj->to_date = $to_date;
115+
$self['email'] = $email;
116+
$self['fromDate'] = $fromDate;
117+
$self['password'] = $password;
118+
$self['toDate'] = $toDate;
118119

119-
null !== $cas_authority && $obj['cas_authority'] = $cas_authority;
120-
null !== $pan_no && $obj->pan_no = $pan_no;
120+
null !== $casAuthority && $self['casAuthority'] = $casAuthority;
121+
null !== $panNo && $self['panNo'] = $panNo;
121122

122-
return $obj;
123+
return $self;
123124
}
124125

125126
/**
126127
* Email address to receive the CAS document.
127128
*/
128129
public function withEmail(string $email): self
129130
{
130-
$obj = clone $this;
131-
$obj->email = $email;
131+
$self = clone $this;
132+
$self['email'] = $email;
132133

133-
return $obj;
134+
return $self;
134135
}
135136

136137
/**
137138
* Start date for the CAS period (format YYYY-MM-DD).
138139
*/
139140
public function withFromDate(string $fromDate): self
140141
{
141-
$obj = clone $this;
142-
$obj->from_date = $fromDate;
142+
$self = clone $this;
143+
$self['fromDate'] = $fromDate;
143144

144-
return $obj;
145+
return $self;
145146
}
146147

147148
/**
148149
* Password to protect the generated CAS PDF.
149150
*/
150151
public function withPassword(string $password): self
151152
{
152-
$obj = clone $this;
153-
$obj->password = $password;
153+
$self = clone $this;
154+
$self['password'] = $password;
154155

155-
return $obj;
156+
return $self;
156157
}
157158

158159
/**
159160
* End date for the CAS period (format YYYY-MM-DD).
160161
*/
161162
public function withToDate(string $toDate): self
162163
{
163-
$obj = clone $this;
164-
$obj->to_date = $toDate;
164+
$self = clone $this;
165+
$self['toDate'] = $toDate;
165166

166-
return $obj;
167+
return $self;
167168
}
168169

169170
/**
@@ -173,20 +174,20 @@ public function withToDate(string $toDate): self
173174
*/
174175
public function withCasAuthority(CasAuthority|string $casAuthority): self
175176
{
176-
$obj = clone $this;
177-
$obj['cas_authority'] = $casAuthority;
177+
$self = clone $this;
178+
$self['casAuthority'] = $casAuthority;
178179

179-
return $obj;
180+
return $self;
180181
}
181182

182183
/**
183184
* PAN number (optional for some CAS authorities).
184185
*/
185186
public function withPanNo(string $panNo): self
186187
{
187-
$obj = clone $this;
188-
$obj->pan_no = $panNo;
188+
$self = clone $this;
189+
$self['panNo'] = $panNo;
189190

190-
return $obj;
191+
return $self;
191192
}
192193
}

src/CasGenerator/CasGeneratorGenerateCasResponse.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,24 @@
44

55
namespace CasParser\CasGenerator;
66

7-
use CasParser\Core\Attributes\Api;
7+
use CasParser\Core\Attributes\Optional;
88
use CasParser\Core\Concerns\SdkModel;
9-
use CasParser\Core\Concerns\SdkResponse;
109
use CasParser\Core\Contracts\BaseModel;
11-
use CasParser\Core\Conversion\Contracts\ResponseConverter;
1210

1311
/**
1412
* @phpstan-type CasGeneratorGenerateCasResponseShape = array{
1513
* msg?: string|null, status?: string|null
1614
* }
1715
*/
18-
final class CasGeneratorGenerateCasResponse implements BaseModel, ResponseConverter
16+
final class CasGeneratorGenerateCasResponse implements BaseModel
1917
{
2018
/** @use SdkModel<CasGeneratorGenerateCasResponseShape> */
2119
use SdkModel;
2220

23-
use SdkResponse;
24-
25-
#[Api(optional: true)]
21+
#[Optional]
2622
public ?string $msg;
2723

28-
#[Api(optional: true)]
24+
#[Optional]
2925
public ?string $status;
3026

3127
public function __construct()
@@ -40,27 +36,27 @@ public function __construct()
4036
*/
4137
public static function with(?string $msg = null, ?string $status = null): self
4238
{
43-
$obj = new self;
39+
$self = new self;
4440

45-
null !== $msg && $obj->msg = $msg;
46-
null !== $status && $obj->status = $status;
41+
null !== $msg && $self['msg'] = $msg;
42+
null !== $status && $self['status'] = $status;
4743

48-
return $obj;
44+
return $self;
4945
}
5046

5147
public function withMsg(string $msg): self
5248
{
53-
$obj = clone $this;
54-
$obj->msg = $msg;
49+
$self = clone $this;
50+
$self['msg'] = $msg;
5551

56-
return $obj;
52+
return $self;
5753
}
5854

5955
public function withStatus(string $status): self
6056
{
61-
$obj = clone $this;
62-
$obj->status = $status;
57+
$self = clone $this;
58+
$self['status'] = $status;
6359

64-
return $obj;
60+
return $self;
6561
}
6662
}

0 commit comments

Comments
 (0)