Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ jobs:
- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PACKAGIST_USERNAME: ${{ secrets.CAS_PARSER_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }}
PACKAGIST_SAFE_KEY: ${{ secrets.CAS_PARSER_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0"
".": "0.3.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml
openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-9eaed98ce5934f11e901cef376a28257d2c196bd3dba7c690babc6741a730ded.yml
openapi_spec_hash: b76e4e830c4d03ba4cf9429bb9fb9c8a
config_hash: cb5d75abef6264b5d86448caf7295afa
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 0.3.0 (2025-11-13)

Full Changelog: [v0.2.0...v0.3.0](https://github.com/CASParser/cas-parser-php/compare/v0.2.0...v0.3.0)

### ⚠ BREAKING CHANGES

* **client:** redesign methods
* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()`

### Features

* **api:** api update ([da8b838](https://github.com/CASParser/cas-parser-php/commit/da8b83821dab28680f72e98a943af25df296e314))
* **client:** redesign methods ([5bc4f8f](https://github.com/CASParser/cas-parser-php/commit/5bc4f8fbca8bd998535963059460dcc2285c479e))
* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` ([84053c4](https://github.com/CASParser/cas-parser-php/commit/84053c4b32db33f341e5e9bf89f2aabe982a2695))


### Bug Fixes

* **ci:** release doctor workflow ([d7d0f00](https://github.com/CASParser/cas-parser-php/commit/d7d0f005e9022cce83d3316626e5746a3a02b694))
* ensure auth methods return non-nullable arrays ([fd0ab3b](https://github.com/CASParser/cas-parser-php/commit/fd0ab3bb4232369f31350fb47d0aca4d916f5739))
* inverted retry condition ([0112a9a](https://github.com/CASParser/cas-parser-php/commit/0112a9a50be77cb4681413034b3d88d791774f6c))
* rename invalid types ([6b7a996](https://github.com/CASParser/cas-parser-php/commit/6b7a99682bfce707850bfddeb41d2474f109ba83))


### Chores

* add license ([7742369](https://github.com/CASParser/cas-parser-php/commit/7742369f0a91046a7aa843391627e8931c6280f8))
* **client:** send metadata headers ([9a72241](https://github.com/CASParser/cas-parser-php/commit/9a72241ae57939ae08709709a26a87f1ad83d9e2))
* **docs:** update readme formatting ([f992e92](https://github.com/CASParser/cas-parser-php/commit/f992e921cd7043ea562ad58fb01905bd2039fa50))
* **internal:** codegen related update ([c124b7b](https://github.com/CASParser/cas-parser-php/commit/c124b7bdd9b7d6f7bbef3d386f9eb4038a6b20f3))
* refactor methods ([e25fa02](https://github.com/CASParser/cas-parser-php/commit/e25fa02ca0d7d49d88f1859c99e2db925a74e722))
* use pascal case for phpstan typedefs ([574d168](https://github.com/CASParser/cas-parser-php/commit/574d1680fbbaccfc4281a98e33d205f4d8a7e043))

## 0.2.0 (2025-09-13)

Full Changelog: [v0.1.0...v0.2.0](https://github.com/CASParser/cas-parser-php/compare/v0.1.0...v0.2.0)
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use CasParser\Client;

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

$unifiedResponse = $client->casParser->smartParse();
$unifiedResponse = $client->casParser->smartParse([]);

var_dump($unifiedResponse->demat_accounts);
```
Expand All @@ -71,7 +71,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
use CasParser\Core\Exceptions\APIConnectionException;

try {
$unifiedResponse = $client->casParser->smartParse();
$unifiedResponse = $client->casParser->smartParse([]);
} catch (APIConnectionException $e) {
echo "The server could not be reached", PHP_EOL;
var_dump($e->getPrevious());
Expand Down Expand Up @@ -117,9 +117,8 @@ use CasParser\RequestOptions;
$client = new Client(maxRetries: 0);

// Or, configure per-request:

$result = $client->casParser->smartParse(
requestOptions: RequestOptions::with(maxRetries: 5)
[], RequestOptions::with(maxRetries: 5)
);
```

Expand All @@ -139,14 +138,13 @@ Note: the `extra*` parameters of the same name overrides the documented paramete
use CasParser\RequestOptions;

$unifiedResponse = $client->casParser->smartParse(
requestOptions: RequestOptions::with(
[],
RequestOptions::with(
extraQueryParams: ["my_query_parameter" => "value"],
extraBodyParams: ["my_body_parameter" => "value"],
extraHeaders: ["my-header" => "value"],
),
);

var_dump($unifiedResponse["my_undocumented_property"]);
```

#### Undocumented request params
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"$schema": "https://getcomposer.org/schema.json",
"license": "Apache-2.0",
"autoload": {
"files": ["src/Core.php", "src/Client.php"],
"files": [
"src/Core.php",
"src/Client.php"
],
"psr-4": {
"CasParser\\": "src/"
}
Expand Down
3 changes: 2 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
],
"release-type": "php",
"extra-files": [
"README.md"
"README.md",
"src/Client.php"
]
}
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e
cd -- "$(dirname -- "$0")/.."

echo "==> Running PHPStan"
exec -- ./vendor/bin/phpstan analyse --memory-limit=1G
exec -- ./vendor/bin/phpstan analyse --memory-limit=2G
71 changes: 30 additions & 41 deletions src/CasGenerator/CasGeneratorGenerateCasParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,23 @@
use CasParser\Core\Contracts\BaseModel;

/**
* An object containing the method's parameters.
* Example usage:
* ```
* $params = (new CasGeneratorGenerateCasParams); // set properties as needed
* $client->casGenerator->generateCas(...$params->toArray());
* ```
* This endpoint generates CAS (Consolidated Account Statement) documents by submitting a mailback request to the specified CAS authority.
* Currently only supports KFintech, with plans to support CAMS, CDSL, and NSDL in the future.
*
* @method toArray()
* Returns the parameters as an associative array suitable for passing to the client method.
* @see CasParser\Services\CasGeneratorService::generateCas()
*
* `$client->casGenerator->generateCas(...$params->toArray());`
*
* @see CasParser\CasGenerator->generateCas
*
* @phpstan-type cas_generator_generate_cas_params = array{
* @phpstan-type CasGeneratorGenerateCasParamsShape = array{
* email: string,
* fromDate: string,
* from_date: string,
* password: string,
* toDate: string,
* casAuthority?: CasAuthority|value-of<CasAuthority>,
* panNo?: string,
* to_date: string,
* cas_authority?: CasAuthority|value-of<CasAuthority>,
* pan_no?: string,
* }
*/
final class CasGeneratorGenerateCasParams implements BaseModel
{
/** @use SdkModel<cas_generator_generate_cas_params> */
/** @use SdkModel<CasGeneratorGenerateCasParamsShape> */
use SdkModel;
use SdkParams;

Expand All @@ -51,8 +40,8 @@ final class CasGeneratorGenerateCasParams implements BaseModel
/**
* Start date for the CAS period (format YYYY-MM-DD).
*/
#[Api('from_date')]
public string $fromDate;
#[Api]
public string $from_date;

/**
* Password to protect the generated CAS PDF.
Expand All @@ -63,30 +52,30 @@ final class CasGeneratorGenerateCasParams implements BaseModel
/**
* End date for the CAS period (format YYYY-MM-DD).
*/
#[Api('to_date')]
public string $toDate;
#[Api]
public string $to_date;

/**
* CAS authority to generate the document from (currently only kfintech is supported).
*
* @var value-of<CasAuthority>|null $casAuthority
* @var value-of<CasAuthority>|null $cas_authority
*/
#[Api('cas_authority', enum: CasAuthority::class, optional: true)]
public ?string $casAuthority;
#[Api(enum: CasAuthority::class, optional: true)]
public ?string $cas_authority;

/**
* PAN number (optional for some CAS authorities).
*/
#[Api('pan_no', optional: true)]
public ?string $panNo;
#[Api(optional: true)]
public ?string $pan_no;

/**
* `new CasGeneratorGenerateCasParams()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* CasGeneratorGenerateCasParams::with(
* email: ..., fromDate: ..., password: ..., toDate: ...
* email: ..., from_date: ..., password: ..., to_date: ...
* )
* ```
*
Expand All @@ -110,25 +99,25 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param CasAuthority|value-of<CasAuthority> $casAuthority
* @param CasAuthority|value-of<CasAuthority> $cas_authority
*/
public static function with(
string $email,
string $fromDate,
string $from_date,
string $password,
string $toDate,
CasAuthority|string|null $casAuthority = null,
?string $panNo = null,
string $to_date,
CasAuthority|string|null $cas_authority = null,
?string $pan_no = null,
): self {
$obj = new self;

$obj->email = $email;
$obj->fromDate = $fromDate;
$obj->from_date = $from_date;
$obj->password = $password;
$obj->toDate = $toDate;
$obj->to_date = $to_date;

null !== $casAuthority && $obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority;
null !== $panNo && $obj->panNo = $panNo;
null !== $cas_authority && $obj['cas_authority'] = $cas_authority;
null !== $pan_no && $obj->pan_no = $pan_no;

return $obj;
}
Expand All @@ -150,7 +139,7 @@ public function withEmail(string $email): self
public function withFromDate(string $fromDate): self
{
$obj = clone $this;
$obj->fromDate = $fromDate;
$obj->from_date = $fromDate;

return $obj;
}
Expand All @@ -172,7 +161,7 @@ public function withPassword(string $password): self
public function withToDate(string $toDate): self
{
$obj = clone $this;
$obj->toDate = $toDate;
$obj->to_date = $toDate;

return $obj;
}
Expand All @@ -185,7 +174,7 @@ public function withToDate(string $toDate): self
public function withCasAuthority(CasAuthority|string $casAuthority): self
{
$obj = clone $this;
$obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority;
$obj['cas_authority'] = $casAuthority;

return $obj;
}
Expand All @@ -196,7 +185,7 @@ public function withCasAuthority(CasAuthority|string $casAuthority): self
public function withPanNo(string $panNo): self
{
$obj = clone $this;
$obj->panNo = $panNo;
$obj->pan_no = $panNo;

return $obj;
}
Expand Down
16 changes: 8 additions & 8 deletions src/CasGenerator/CasGeneratorGenerateCasResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

use CasParser\Core\Attributes\Api;
use CasParser\Core\Concerns\SdkModel;
use CasParser\Core\Concerns\SdkResponse;
use CasParser\Core\Contracts\BaseModel;
use CasParser\Core\Conversion\Contracts\ResponseConverter;

/**
* @phpstan-type cas_generator_generate_cas_response = array{
* msg?: string, status?: string
* @phpstan-type CasGeneratorGenerateCasResponseShape = array{
* msg?: string|null, status?: string|null
* }
* When used in a response, this type parameter can define a $rawResponse property.
* @template TRawResponse of object = object{}
*
* @mixin TRawResponse
*/
final class CasGeneratorGenerateCasResponse implements BaseModel
final class CasGeneratorGenerateCasResponse implements BaseModel, ResponseConverter
{
/** @use SdkModel<cas_generator_generate_cas_response> */
/** @use SdkModel<CasGeneratorGenerateCasResponseShape> */
use SdkModel;

use SdkResponse;

#[Api(optional: true)]
public ?string $msg;

Expand Down
Loading