Skip to content

Commit e2b558e

Browse files
Merge pull request #2 from CASParser/release-please--branches--main--changes--next
release: 0.1.0
2 parents 837da8b + dd7855a commit e2b558e

File tree

99 files changed

+1666
-1377
lines changed

Some content is hidden

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

99 files changed

+1666
-1377
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release Doctor
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
release_doctor:
10+
name: release doctor
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'CASParser/cas-parser-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Check release environment
18+
run: |
19+
bash ./bin/check-release-environment

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
*.swo
2-
*.swp
1+
composer.lock
2+
docs/
33
.idea/
44
.php-cs-fixer.cache
55
.php-cs-fixer.php
6-
.phpdoc/
76
.phpunit.cache
8-
composer.lock
97
phpunit.xml
108
playground/
9+
*.swo
10+
*.swp
1111
vendor/

.php-cs-fixer.dist.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
return (new Config())
88
->setParallelConfig(ParallelConfigFactory::detect())
99
->setFinder(Finder::create()->in([__DIR__.'/src', __DIR__.'/tests']))
10-
->setRules(['@PhpCsFixer' => true, 'phpdoc_align' => false, 'new_with_parentheses' => ['named_class' => false]])
10+
->setRules([
11+
'@PhpCsFixer' => true,
12+
'phpdoc_align' => false,
13+
'new_with_parentheses' => ['named_class' => false],
14+
'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
15+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
16+
])
1117
;

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.0.2"
2+
".": "0.1.0"
33
}

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
# Changelog
22

3+
## 0.1.0 (2025-09-03)
4+
5+
Full Changelog: [v0.0.2...v0.1.0](https://github.com/CASParser/cas-parser-php/compare/v0.0.2...v0.1.0)
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* use builders for RequestOptions
10+
* rename errors to exceptions
11+
* pagination field rename, and basic streaming docs
12+
* **refactor:** namespacing cleanup
13+
* **refactor:** clean up pagination, errors, as well as request methods
14+
15+
### Features
16+
17+
* **client:** add streaming ([8a3649a](https://github.com/CASParser/cas-parser-php/commit/8a3649ac38d283238cb78f183d88388d2220350f))
18+
* **client:** improve error handling ([b8969bb](https://github.com/CASParser/cas-parser-php/commit/b8969bb06c1b5c4575ad2f0a25af16f2bb0f5c5f))
19+
* **client:** use named parameters in methods ([f977b9a](https://github.com/CASParser/cas-parser-php/commit/f977b9a00b4f72c4d0add8e637baf699339b3707))
20+
* ensure `->toArray()` benefits from structural typing ([16e7c95](https://github.com/CASParser/cas-parser-php/commit/16e7c9593a3216a1af73bd62b8c3d9561d2a05ad))
21+
* pagination field rename, and basic streaming docs ([961e540](https://github.com/CASParser/cas-parser-php/commit/961e54000c4f7e50b2c2bdbed82ac08b4862450f))
22+
* **php:** differentiate null and omit ([d5736cf](https://github.com/CASParser/cas-parser-php/commit/d5736cf656dd266165e262c6fe85a6bc0a12e5d9))
23+
* **php:** rename internal types ([d8b47a2](https://github.com/CASParser/cas-parser-php/commit/d8b47a27256c7429058623b48624698804778320))
24+
* **refactor:** clean up pagination, errors, as well as request methods ([26437b5](https://github.com/CASParser/cas-parser-php/commit/26437b521827b8cf5393feee1e8af173e18d7a22))
25+
* **refactor:** namespacing cleanup ([666f374](https://github.com/CASParser/cas-parser-php/commit/666f37473888855fcc884cb9d851d43ce62aa75f))
26+
* rename errors to exceptions ([92d9817](https://github.com/CASParser/cas-parser-php/commit/92d9817bf28718bfe5ecc6e61f6ed42abe4b0d4b))
27+
* use builders for RequestOptions ([7f3730e](https://github.com/CASParser/cas-parser-php/commit/7f3730ee1d2081c219209b4cf06a9568af6b2559))
28+
29+
30+
### Bug Fixes
31+
32+
* add create release workflow ([11358ea](https://github.com/CASParser/cas-parser-php/commit/11358ea756b190e7c2f459311f409f7ec6ddd255))
33+
* basic pagination should work ([041e76c](https://github.com/CASParser/cas-parser-php/commit/041e76c9f5db339bd9834e609058b3b4edc865d3))
34+
* **client:** elide null named parameters ([47e2824](https://github.com/CASParser/cas-parser-php/commit/47e28244783dd47d03f095cf0015aa947c0db5b8))
35+
* minor bugs ([2e13643](https://github.com/CASParser/cas-parser-php/commit/2e13643e201a80bfb8d1ffbeea643133cb79701e))
36+
* remove inaccurate `license` field in composer.json ([86ba48b](https://github.com/CASParser/cas-parser-php/commit/86ba48b8fc66042665d86362545915504f04011e))
37+
* streaming internals ([39bcd29](https://github.com/CASParser/cas-parser-php/commit/39bcd29aa689ba5505428c732b63d07fc049c010))
38+
39+
40+
### Chores
41+
42+
* add additional php doc tags ([4403319](https://github.com/CASParser/cas-parser-php/commit/44033196dc6699b911b64f473f95badc0f548c71))
43+
* improve model annotations ([b45934c](https://github.com/CASParser/cas-parser-php/commit/b45934c91c079bc8eff6a3cfb53e8adab8927034))
44+
* **internal:** refactor base client internals ([36dc0b6](https://github.com/CASParser/cas-parser-php/commit/36dc0b68f8706fe3bd5fcbb7f57c5487cbea2496))
45+
* **internal:** refactored internal codepaths ([b306fa4](https://github.com/CASParser/cas-parser-php/commit/b306fa456c045ddd061225257fd4490e04099f12))
46+
* intuitively order union types ([150660a](https://github.com/CASParser/cas-parser-php/commit/150660ae58f257d5faaa6f8cf7c4f9093e0bae2c))
47+
* readme improvements ([ac66540](https://github.com/CASParser/cas-parser-php/commit/ac665402fa3edc84c13de25248d0b901e54aaab5))
48+
* refactor request options ([f1b303a](https://github.com/CASParser/cas-parser-php/commit/f1b303add63f19005284bec65d3b5907d8f34372))
49+
* **refactor:** simplify base page interface ([95b27e8](https://github.com/CASParser/cas-parser-php/commit/95b27e82468e3026ab7c6adad0af449ef2dd9355))
50+
* remove `php-http/multipart-stream-builder` as a required dependency ([607f49a](https://github.com/CASParser/cas-parser-php/commit/607f49a7bfb66fc667c15ced3baaa556e1b689ab))
51+
* remove type aliases ([ff49892](https://github.com/CASParser/cas-parser-php/commit/ff4989246f4c361a99aa1240db0b7c956fa5161d))
52+
* simplify model initialization ([f38ec08](https://github.com/CASParser/cas-parser-php/commit/f38ec08395db6f5fcf1c8a8e2ccae49cd0e4537a))
53+
354
## 0.0.2 (2025-08-18)
455

556
Full Changelog: [v0.0.1...v0.0.2](https://github.com/CASParser/cas-parser-php/compare/v0.0.1...v0.0.2)

README.md

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,88 +39,88 @@ To use this package, install via Composer by adding the following to your applic
3939

4040
## Usage
4141

42+
This library uses named parameters to specify optional arguments.
43+
Parameters with a default value must be set by name.
44+
4245
```php
4346
<?php
4447

4548
use CasParser\Client;
46-
use CasParser\CasParser\CasParserSmartParseParams;
4749

4850
$client = new Client(apiKey: getenv("CAS_PARSER_API_KEY") ?: "My API Key");
4951

50-
$params = CasParserSmartParseParams::with(
51-
password: "ABCDF", pdfURL: "https://your-cas-pdf-url-here.com"
52-
);
53-
$unifiedResponse = $client->casParser->smartParse($params);
52+
$unifiedResponse = $client->casParser->smartParse();
5453

5554
var_dump($unifiedResponse->demat_accounts);
5655
```
5756

57+
### Value Objects
58+
59+
It is recommended to use the static `with` constructor `Dog::with(name: "Joey")`
60+
and named parameters to initialize value objects.
61+
62+
However, builders are also provided `(new Dog)->withName("Joey")`.
63+
5864
### Handling errors
5965

60-
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `CasParser\Errors\APIError` will be thrown:
66+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `CasParser\Core\Exceptions\APIException` will be thrown:
6167

6268
```php
6369
<?php
6470

65-
use CasParser\CasParser\CasParserSmartParseParams;
66-
use CasParser\Errors\APIConnectionError;
71+
use CasParser\Core\Exceptions\APIConnectionException;
6772

68-
$params = CasParserSmartParseParams::with(
69-
password: "ABCDF", pdfURL: "https://you-cas-pdf-url-here.com"
70-
);
7173
try {
72-
$CasParser = $client->casParser->smartParse($params);
73-
} catch (APIConnectionError $e) {
74-
echo "The server could not be reached", PHP_EOL;
75-
var_dump($e->getPrevious());
74+
$unifiedResponse = $client->casParser->smartParse();
75+
} catch (APIConnectionException $e) {
76+
echo "The server could not be reached", PHP_EOL;
77+
var_dump($e->getPrevious());
7678
} catch (RateLimitError $_) {
77-
echo "A 429 status code was received; we should back off a bit.", PHP_EOL;
79+
echo "A 429 status code was received; we should back off a bit.", PHP_EOL;
7880
} catch (APIStatusError $e) {
79-
echo "Another non-200-range status code was received", PHP_EOL;
80-
var_dump($e->status);
81+
echo "Another non-200-range status code was received", PHP_EOL;
82+
echo $e->getMessage();
8183
}
8284
```
8385

8486
Error codes are as follows:
8587

86-
| Cause | Error Type |
87-
| ---------------- | -------------------------- |
88-
| HTTP 400 | `BadRequestError` |
89-
| HTTP 401 | `AuthenticationError` |
90-
| HTTP 403 | `PermissionDeniedError` |
91-
| HTTP 404 | `NotFoundError` |
92-
| HTTP 409 | `ConflictError` |
93-
| HTTP 422 | `UnprocessableEntityError` |
94-
| HTTP 429 | `RateLimitError` |
95-
| HTTP >= 500 | `InternalServerError` |
96-
| Other HTTP error | `APIStatusError` |
97-
| Timeout | `APITimeoutError` |
98-
| Network error | `APIConnectionError` |
88+
| Cause | Error Type |
89+
| ---------------- | ------------------------------ |
90+
| HTTP 400 | `BadRequestException` |
91+
| HTTP 401 | `AuthenticationException` |
92+
| HTTP 403 | `PermissionDeniedException` |
93+
| HTTP 404 | `NotFoundException` |
94+
| HTTP 409 | `ConflictException` |
95+
| HTTP 422 | `UnprocessableEntityException` |
96+
| HTTP 429 | `RateLimitException` |
97+
| HTTP >= 500 | `InternalServerException` |
98+
| Other HTTP error | `APIStatusException` |
99+
| Timeout | `APITimeoutException` |
100+
| Network error | `APIConnectionException` |
99101

100102
### Retries
101103

102104
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
103105

104106
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
105107

106-
You can use the `max_retries` option to configure or disable this:
108+
You can use the `maxRetries` option to configure or disable this:
107109

108110
```php
109111
<?php
110112

111113
use CasParser\Client;
112114
use CasParser\RequestOptions;
113-
use CasParser\CasParser\CasParserSmartParseParams;
114115

115116
// Configure the default for all requests:
116117
$client = new Client(maxRetries: 0);
117-
$params = CasParserSmartParseParams::with(
118-
password: "ABCDF", pdfURL: "https://you-cas-pdf-url-here.com"
119-
);
120118

121-
// Or, configure per-request:$result = $client
122-
->casParser
123-
->smartParse($params, new RequestOptions(maxRetries: 5));
119+
// Or, configure per-request:
120+
121+
$result = $client->casParser->smartParse(
122+
requestOptions: RequestOptions::with(maxRetries: 5)
123+
);
124124
```
125125

126126
## Advanced concepts
@@ -131,22 +131,15 @@ $params = CasParserSmartParseParams::with(
131131

132132
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
133133

134-
Note: the `extra_` parameters of the same name overrides the documented parameters.
134+
Note: the `extra*` parameters of the same name overrides the documented parameters.
135135

136136
```php
137137
<?php
138138

139139
use CasParser\RequestOptions;
140-
use CasParser\CasParser\CasParserSmartParseParams;
141140

142-
$params = CasParserSmartParseParams::with(
143-
password: "ABCDF", pdfURL: "https://you-cas-pdf-url-here.com"
144-
);
145-
$unifiedResponse = $client
146-
->casParser
147-
->smartParse(
148-
$params,
149-
new RequestOptions(
141+
$unifiedResponse = $client->casParser->smartParse(
142+
requestOptions: RequestOptions::with(
150143
extraQueryParams: ["my_query_parameter" => "value"],
151144
extraBodyParams: ["my_body_parameter" => "value"],
152145
extraHeaders: ["my-header" => "value"],

bin/check-release-environment

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
errors=()
4+
5+
if [ -z "${PACKAGIST_USERNAME}" ]; then
6+
errors+=("The PACKAGIST_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
7+
fi
8+
9+
if [ -z "${PACKAGIST_SAFE_KEY}" ]; then
10+
errors+=("The PACKAGIST_SAFE_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
11+
fi
12+
13+
lenErrors=${#errors[@]}
14+
15+
if [[ lenErrors -gt 0 ]]; then
16+
echo -e "Found the following errors in the release environment:\n"
17+
18+
for error in "${errors[@]}"; do
19+
echo -e "- $error\n"
20+
done
21+
22+
exit 1
23+
fi
24+
25+
echo "The environment is ready to push releases!"

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"$schema": "https://getcomposer.org/schema.json",
33
"autoload": {
4-
"files": [
5-
"src/Client.php"
6-
],
4+
"files": ["src/Core.php", "src/Client.php"],
75
"psr-4": {
86
"CasParser\\": "src/"
97
}
@@ -25,13 +23,11 @@
2523
"preferred-install": "dist",
2624
"sort-packages": true
2725
},
28-
"license": "APACHE-2.0",
2926
"description": "Cas Parser PHP SDK",
3027
"name": "org-placeholder/cas-parser",
3128
"require": {
3229
"php": "^8.1",
3330
"php-http/discovery": "^1",
34-
"php-http/multipart-stream-builder": "^1",
3531
"psr/http-client": "^1",
3632
"psr/http-client-implementation": "^1",
3733
"psr/http-factory-implementation": "^1",
@@ -48,6 +44,7 @@
4844
"symfony/http-client": "^7"
4945
},
5046
"scripts": {
47+
"build:docs": "curl --etag-save ./vendor/ag.etags --etag-compare ./vendor/ag.etags --create-dirs --remote-name --output-dir ./vendor/bin --no-progress-meter -- https://github.com/ApiGen/ApiGen/releases/latest/download/apigen.phar && php ./vendor/bin/apigen.phar --output docs -- src",
5148
"lint": "./scripts/lint",
5249
"test": "./scripts/test"
5350
}

src/CasGenerator/CasGeneratorGenerateCasParams.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66

77
use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority;
88
use CasParser\Core\Attributes\Api;
9-
use CasParser\Core\Concerns\Model;
10-
use CasParser\Core\Concerns\Params;
9+
use CasParser\Core\Concerns\SdkModel;
10+
use CasParser\Core\Concerns\SdkParams;
1111
use CasParser\Core\Contracts\BaseModel;
1212

1313
/**
1414
* This endpoint generates CAS (Consolidated Account Statement) documents by submitting a mailback request to the specified CAS authority.
1515
* Currently only supports KFintech, with plans to support CAMS, CDSL, and NSDL in the future.
1616
*
17-
* @phpstan-type generate_cas_params = array{
17+
* @see CasParser\CasGenerator->generateCas
18+
*
19+
* @phpstan-type cas_generator_generate_cas_params = array{
1820
* email: string,
1921
* fromDate: string,
2022
* password: string,
@@ -25,8 +27,9 @@
2527
*/
2628
final class CasGeneratorGenerateCasParams implements BaseModel
2729
{
28-
use Model;
29-
use Params;
30+
/** @use SdkModel<cas_generator_generate_cas_params> */
31+
use SdkModel;
32+
use SdkParams;
3033

3134
/**
3235
* Email address to receive the CAS document.
@@ -55,7 +58,7 @@ final class CasGeneratorGenerateCasParams implements BaseModel
5558
/**
5659
* CAS authority to generate the document from (currently only kfintech is supported).
5760
*
58-
* @var null|CasAuthority::* $casAuthority
61+
* @var CasAuthority::*|null $casAuthority
5962
*/
6063
#[Api('cas_authority', enum: CasAuthority::class, optional: true)]
6164
public ?string $casAuthority;
@@ -88,16 +91,15 @@ final class CasGeneratorGenerateCasParams implements BaseModel
8891
*/
8992
public function __construct()
9093
{
91-
self::introspect();
92-
$this->unsetOptionalProperties();
94+
$this->initialize();
9395
}
9496

9597
/**
9698
* Construct an instance from the required parameters.
9799
*
98100
* You must use named parameters to construct any parameters with a default value.
99101
*
100-
* @param null|CasAuthority::* $casAuthority
102+
* @param CasAuthority::* $casAuthority
101103
*/
102104
public static function with(
103105
string $email,

0 commit comments

Comments
 (0)