Skip to content
Merged
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
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.1.0"
".": "0.2.0"
}
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 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)

### ⚠ BREAKING CHANGES

* expose services and service contracts

### Features

* **client:** add raw methods ([cec98f9](https://github.com/CASParser/cas-parser-php/commit/cec98f994a8f4b1dc12905a2dcd269cebbcc000d))
* **client:** support raw responses ([db0fac3](https://github.com/CASParser/cas-parser-php/commit/db0fac37cc5a9f56fb8f095f4c895f91a206bfa5))
* **client:** use real enums ([9b7428f](https://github.com/CASParser/cas-parser-php/commit/9b7428ffe0e2a19b1b7ad6c87e90ee14eddce749))
* expose services and service contracts ([36e3c1d](https://github.com/CASParser/cas-parser-php/commit/36e3c1d53c72f8b86e8ccf565fd3399bb3847834))


### Chores

* cleanup streaming ([d8d2163](https://github.com/CASParser/cas-parser-php/commit/d8d2163afa66e726f571c31276eaca485c4dda84))
* document parameter object usage ([8e520a0](https://github.com/CASParser/cas-parser-php/commit/8e520a0452175fc10becdd28fc9bf5b37cecf434))
* fix lints in UnionOf ([4fcc712](https://github.com/CASParser/cas-parser-php/commit/4fcc712c36036429b1f410f3c3ae88f3a8ad3147))
* make more targeted phpstan ignores ([35208e4](https://github.com/CASParser/cas-parser-php/commit/35208e4d7fced2de5826111980cfd51bebd1ad74))

## 0.1.0 (2025-09-03)

Full Changelog: [v0.0.2...v0.1.0](https://github.com/CASParser/cas-parser-php/compare/v0.0.2...v0.1.0)
Expand Down
27 changes: 19 additions & 8 deletions src/CasGenerator/CasGeneratorGenerateCasParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
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{
* email: string,
* fromDate: string,
* password: string,
* toDate: string,
* casAuthority?: CasAuthority::*,
* casAuthority?: CasAuthority|value-of<CasAuthority>,
* panNo?: string,
* }
*/
Expand Down Expand Up @@ -58,7 +69,7 @@ final class CasGeneratorGenerateCasParams implements BaseModel
/**
* CAS authority to generate the document from (currently only kfintech is supported).
*
* @var CasAuthority::*|null $casAuthority
* @var value-of<CasAuthority>|null $casAuthority
*/
#[Api('cas_authority', enum: CasAuthority::class, optional: true)]
public ?string $casAuthority;
Expand Down Expand Up @@ -99,14 +110,14 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param CasAuthority::* $casAuthority
* @param CasAuthority|value-of<CasAuthority> $casAuthority
*/
public static function with(
string $email,
string $fromDate,
string $password,
string $toDate,
?string $casAuthority = null,
CasAuthority|string|null $casAuthority = null,
?string $panNo = null,
): self {
$obj = new self;
Expand All @@ -116,7 +127,7 @@ public static function with(
$obj->password = $password;
$obj->toDate = $toDate;

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

return $obj;
Expand Down Expand Up @@ -169,12 +180,12 @@ public function withToDate(string $toDate): self
/**
* CAS authority to generate the document from (currently only kfintech is supported).
*
* @param CasAuthority::* $casAuthority
* @param CasAuthority|value-of<CasAuthority> $casAuthority
*/
public function withCasAuthority(string $casAuthority): self
public function withCasAuthority(CasAuthority|string $casAuthority): self
{
$obj = clone $this;
$obj->casAuthority = $casAuthority;
$obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority;

return $obj;
}
Expand Down
15 changes: 5 additions & 10 deletions src/CasGenerator/CasGeneratorGenerateCasParams/CasAuthority.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@

namespace CasParser\CasGenerator\CasGeneratorGenerateCasParams;

use CasParser\Core\Concerns\SdkEnum;
use CasParser\Core\Conversion\Contracts\ConverterSource;

/**
* CAS authority to generate the document from (currently only kfintech is supported).
*/
final class CasAuthority implements ConverterSource
enum CasAuthority: string
{
use SdkEnum;

public const KFINTECH = 'kfintech';
case KFINTECH = 'kfintech';

public const CAMS = 'cams';
case CAMS = 'cams';

public const CDSL = 'cdsl';
case CDSL = 'cdsl';

public const NSDL = 'nsdl';
case NSDL = 'nsdl';
}
6 changes: 5 additions & 1 deletion src/CasGenerator/CasGeneratorGenerateCasResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

/**
* @phpstan-type cas_generator_generate_cas_response = array{
* msg?: string|null, status?: string|null
* 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
{
Expand Down
11 changes: 11 additions & 0 deletions src/CasParser/CasParserCamsKfintechParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
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: 11 additions & 0 deletions src/CasParser/CasParserCdslParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
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: 11 additions & 0 deletions src/CasParser/CasParserNsdlParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
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: 11 additions & 0 deletions src/CasParser/CasParserSmartParseParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@
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
16 changes: 10 additions & 6 deletions src/CasParser/UnifiedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

/**
* @phpstan-type unified_response = array{
* dematAccounts?: list<DematAccount>|null,
* insurance?: Insurance|null,
* investor?: Investor|null,
* meta?: Meta|null,
* mutualFunds?: list<MutualFund>|null,
* summary?: Summary|null,
* dematAccounts?: list<DematAccount>,
* insurance?: Insurance,
* investor?: Investor,
* meta?: Meta,
* mutualFunds?: list<MutualFund>,
* 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
{
Expand Down
30 changes: 15 additions & 15 deletions src/CasParser/UnifiedResponse/DematAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

/**
* @phpstan-type demat_account = array{
* additionalInfo?: AdditionalInfo|null,
* boID?: string|null,
* clientID?: string|null,
* dematType?: DematType::*|null,
* dpID?: string|null,
* dpName?: string|null,
* holdings?: Holdings|null,
* value?: float|null,
* additionalInfo?: AdditionalInfo,
* boID?: string,
* clientID?: string,
* dematType?: value-of<DematType>,
* dpID?: string,
* dpName?: string,
* holdings?: Holdings,
* value?: float,
* }
*/
final class DematAccount implements BaseModel
Expand Down Expand Up @@ -49,7 +49,7 @@ final class DematAccount implements BaseModel
/**
* Type of demat account.
*
* @var DematType::*|null $dematType
* @var value-of<DematType>|null $dematType
*/
#[Api('demat_type', enum: DematType::class, optional: true)]
public ?string $dematType;
Expand Down Expand Up @@ -85,13 +85,13 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param DematType::* $dematType
* @param DematType|value-of<DematType> $dematType
*/
public static function with(
?AdditionalInfo $additionalInfo = null,
?string $boID = null,
?string $clientID = null,
?string $dematType = null,
DematType|string|null $dematType = null,
?string $dpID = null,
?string $dpName = null,
?Holdings $holdings = null,
Expand All @@ -102,7 +102,7 @@ public static function with(
null !== $additionalInfo && $obj->additionalInfo = $additionalInfo;
null !== $boID && $obj->boID = $boID;
null !== $clientID && $obj->clientID = $clientID;
null !== $dematType && $obj->dematType = $dematType;
null !== $dematType && $obj->dematType = $dematType instanceof DematType ? $dematType->value : $dematType;
null !== $dpID && $obj->dpID = $dpID;
null !== $dpName && $obj->dpName = $dpName;
null !== $holdings && $obj->holdings = $holdings;
Expand Down Expand Up @@ -147,12 +147,12 @@ public function withClientID(string $clientID): self
/**
* Type of demat account.
*
* @param DematType::* $dematType
* @param DematType|value-of<DematType> $dematType
*/
public function withDematType(string $dematType): self
public function withDematType(DematType|string $dematType): self
{
$obj = clone $this;
$obj->dematType = $dematType;
$obj->dematType = $dematType instanceof DematType ? $dematType->value : $dematType;

return $obj;
}
Expand Down
16 changes: 8 additions & 8 deletions src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* Additional information specific to the demat account type.
*
* @phpstan-type additional_info = array{
* boStatus?: string|null,
* boSubStatus?: string|null,
* boType?: string|null,
* bsda?: string|null,
* email?: string|null,
* linkedPans?: list<string>|null,
* nominee?: string|null,
* status?: string|null,
* boStatus?: string,
* boSubStatus?: string,
* boType?: string,
* bsda?: string,
* email?: string,
* linkedPans?: list<string>,
* nominee?: string,
* status?: string,
* }
*/
final class AdditionalInfo implements BaseModel
Expand Down
11 changes: 3 additions & 8 deletions src/CasParser/UnifiedResponse/DematAccount/DematType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@

namespace CasParser\CasParser\UnifiedResponse\DematAccount;

use CasParser\Core\Concerns\SdkEnum;
use CasParser\Core\Conversion\Contracts\ConverterSource;

/**
* Type of demat account.
*/
final class DematType implements ConverterSource
enum DematType: string
{
use SdkEnum;

public const NSDL = 'NSDL';
case NSDL = 'NSDL';

public const CDSL = 'CDSL';
case CDSL = 'CDSL';
}
10 changes: 5 additions & 5 deletions src/CasParser/UnifiedResponse/DematAccount/Holdings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

/**
* @phpstan-type holdings_alias = array{
* aifs?: list<Aif>|null,
* corporateBonds?: list<CorporateBond>|null,
* dematMutualFunds?: list<DematMutualFund>|null,
* equities?: list<Equity>|null,
* governmentSecurities?: list<GovernmentSecurity>|null,
* aifs?: list<Aif>,
* corporateBonds?: list<CorporateBond>,
* dematMutualFunds?: list<DematMutualFund>,
* equities?: list<Equity>,
* governmentSecurities?: list<GovernmentSecurity>,
* }
*/
final class Holdings implements BaseModel
Expand Down
Loading
Loading