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
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 0.3.0 (2025-10-22)

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

### ⚠ BREAKING CHANGES

* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()`

### Features

* **api:** api update ([da8b838](https://github.com/CASParser/cas-parser-php/commit/da8b83821dab28680f72e98a943af25df296e314))
* 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))
* inverted retry condition ([0112a9a](https://github.com/CASParser/cas-parser-php/commit/0112a9a50be77cb4681413034b3d88d791774f6c))


### Chores

* add license ([7742369](https://github.com/CASParser/cas-parser-php/commit/7742369f0a91046a7aa843391627e8931c6280f8))
* **docs:** update readme formatting ([f992e92](https://github.com/CASParser/cas-parser-php/commit/f992e921cd7043ea562ad58fb01905bd2039fa50))
* refactor methods ([e25fa02](https://github.com/CASParser/cas-parser-php/commit/e25fa02ca0d7d49d88f1859c99e2db925a74e722))

## 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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ use CasParser\RequestOptions;
$client = new Client(maxRetries: 0);

// Or, configure per-request:

$result = $client->casParser->smartParse(
requestOptions: RequestOptions::with(maxRetries: 5)
);
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
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
15 changes: 2 additions & 13 deletions src/CasGenerator/CasGeneratorGenerateCasParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@
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.
*
* `$client->casGenerator->generateCas(...$params->toArray());`
*
* @see CasParser\CasGenerator->generateCas
*
* @phpstan-type cas_generator_generate_cas_params = array{
Expand Down Expand Up @@ -127,7 +116,7 @@ public static function with(
$obj->password = $password;
$obj->toDate = $toDate;

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

return $obj;
Expand Down Expand Up @@ -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['casAuthority'] = $casAuthority;

return $obj;
}
Expand Down
10 changes: 5 additions & 5 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
* }
* 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;

use SdkResponse;

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

Expand Down
11 changes: 0 additions & 11 deletions src/CasParser/CasParserCamsKfintechParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
use CasParser\Core\Contracts\BaseModel;

/**
* An object containing the method's parameters.
* Example usage:
* ```
* $params = (new CasParserCamsKfintechParams); // set properties as needed
* $client->casParser->camsKfintech(...$params->toArray());
* ```
* This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF files and returns data in a unified format.
* Use this endpoint when you know the PDF is from CAMS or KFintech.
*
* @method toArray()
* Returns the parameters as an associative array suitable for passing to the client method.
*
* `$client->casParser->camsKfintech(...$params->toArray());`
*
* @see CasParser\CasParser->camsKfintech
*
* @phpstan-type cas_parser_cams_kfintech_params = array{
Expand Down
11 changes: 0 additions & 11 deletions src/CasParser/CasParserCdslParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
use CasParser\Core\Contracts\BaseModel;

/**
* An object containing the method's parameters.
* Example usage:
* ```
* $params = (new CasParserCdslParams); // set properties as needed
* $client->casParser->cdsl(...$params->toArray());
* ```
* This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and returns data in a unified format.
* Use this endpoint when you know the PDF is from CDSL.
*
* @method toArray()
* Returns the parameters as an associative array suitable for passing to the client method.
*
* `$client->casParser->cdsl(...$params->toArray());`
*
* @see CasParser\CasParser->cdsl
*
* @phpstan-type cas_parser_cdsl_params = array{
Expand Down
11 changes: 0 additions & 11 deletions src/CasParser/CasParserNsdlParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
use CasParser\Core\Contracts\BaseModel;

/**
* An object containing the method's parameters.
* Example usage:
* ```
* $params = (new CasParserNsdlParams); // set properties as needed
* $client->casParser->nsdl(...$params->toArray());
* ```
* This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and returns data in a unified format.
* Use this endpoint when you know the PDF is from NSDL.
*
* @method toArray()
* Returns the parameters as an associative array suitable for passing to the client method.
*
* `$client->casParser->nsdl(...$params->toArray());`
*
* @see CasParser\CasParser->nsdl
*
* @phpstan-type cas_parser_nsdl_params = array{
Expand Down
11 changes: 0 additions & 11 deletions src/CasParser/CasParserSmartParseParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
use CasParser\Core\Contracts\BaseModel;

/**
* An object containing the method's parameters.
* Example usage:
* ```
* $params = (new CasParserSmartParseParams); // set properties as needed
* $client->casParser->smartParse(...$params->toArray());
* ```
* This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or CAMS/KFintech and returns data in a unified format.
* It auto-detects the CAS type and transforms the data into a consistent structure regardless of the source.
*
* @method toArray()
* Returns the parameters as an associative array suitable for passing to the client method.
*
* `$client->casParser->smartParse(...$params->toArray());`
*
* @see CasParser\CasParser->smartParse
*
* @phpstan-type cas_parser_smart_parse_params = array{
Expand Down
36 changes: 31 additions & 5 deletions src/CasParser/UnifiedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
use CasParser\CasParser\UnifiedResponse\Investor;
use CasParser\CasParser\UnifiedResponse\Meta;
use CasParser\CasParser\UnifiedResponse\MutualFund;
use CasParser\CasParser\UnifiedResponse\Np;
use CasParser\CasParser\UnifiedResponse\Summary;
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 unified_response = array{
Expand All @@ -21,18 +24,17 @@
* investor?: Investor,
* meta?: Meta,
* mutualFunds?: list<MutualFund>,
* nps?: list<Np>,
* summary?: Summary,
* }
* When used in a response, this type parameter can define a $rawResponse property.
* @template TRawResponse of object = object{}
*
* @mixin TRawResponse
*/
final class UnifiedResponse implements BaseModel
final class UnifiedResponse implements BaseModel, ResponseConverter
{
/** @use SdkModel<unified_response> */
use SdkModel;

use SdkResponse;

/** @var list<DematAccount>|null $dematAccounts */
#[Api('demat_accounts', list: DematAccount::class, optional: true)]
public ?array $dematAccounts;
Expand All @@ -50,6 +52,14 @@ final class UnifiedResponse implements BaseModel
#[Api('mutual_funds', list: MutualFund::class, optional: true)]
public ?array $mutualFunds;

/**
* List of NPS accounts.
*
* @var list<Np>|null $nps
*/
#[Api(list: Np::class, optional: true)]
public ?array $nps;

#[Api(optional: true)]
public ?Summary $summary;

Expand All @@ -65,13 +75,15 @@ public function __construct()
*
* @param list<DematAccount> $dematAccounts
* @param list<MutualFund> $mutualFunds
* @param list<Np> $nps
*/
public static function with(
?array $dematAccounts = null,
?Insurance $insurance = null,
?Investor $investor = null,
?Meta $meta = null,
?array $mutualFunds = null,
?array $nps = null,
?Summary $summary = null,
): self {
$obj = new self;
Expand All @@ -81,6 +93,7 @@ public static function with(
null !== $investor && $obj->investor = $investor;
null !== $meta && $obj->meta = $meta;
null !== $mutualFunds && $obj->mutualFunds = $mutualFunds;
null !== $nps && $obj->nps = $nps;
null !== $summary && $obj->summary = $summary;

return $obj;
Expand Down Expand Up @@ -132,6 +145,19 @@ public function withMutualFunds(array $mutualFunds): self
return $obj;
}

/**
* List of NPS accounts.
*
* @param list<Np> $nps
*/
public function withNps(array $nps): self
{
$obj = clone $this;
$obj->nps = $nps;

return $obj;
}

public function withSummary(Summary $summary): self
{
$obj = clone $this;
Expand Down
Loading