diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 8dec9f0..f7222cd 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -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 }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..6b7b74c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 92721c7..06e7614 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 57b6fa7..66a4913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 75f8882..d3c1a94 100644 --- a/README.md +++ b/README.md @@ -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); ``` @@ -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()); @@ -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) ); ``` @@ -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 diff --git a/composer.json b/composer.json index 7163498..1a19d72 100644 --- a/composer.json +++ b/composer.json @@ -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/" } diff --git a/release-please-config.json b/release-please-config.json index 1891660..5c15181 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -61,6 +61,7 @@ ], "release-type": "php", "extra-files": [ - "README.md" + "README.md", + "src/Client.php" ] } \ No newline at end of file diff --git a/scripts/lint b/scripts/lint index 6d629c2..13f2f01 100755 --- a/scripts/lint +++ b/scripts/lint @@ -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 diff --git a/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index 3f3de18..133346f 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -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, - * panNo?: string, + * to_date: string, + * cas_authority?: CasAuthority|value-of, + * pan_no?: string, * } */ final class CasGeneratorGenerateCasParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -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. @@ -63,22 +52,22 @@ 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|null $casAuthority + * @var value-of|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. @@ -86,7 +75,7 @@ final class CasGeneratorGenerateCasParams implements BaseModel * To enforce required parameters use * ``` * CasGeneratorGenerateCasParams::with( - * email: ..., fromDate: ..., password: ..., toDate: ... + * email: ..., from_date: ..., password: ..., to_date: ... * ) * ``` * @@ -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 + * @param CasAuthority|value-of $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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } diff --git a/src/CasGenerator/CasGeneratorGenerateCasResponse.php b/src/CasGenerator/CasGeneratorGenerateCasResponse.php index 86298f8..fc9e495 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasResponse.php +++ b/src/CasGenerator/CasGeneratorGenerateCasResponse.php @@ -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 */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?string $msg; diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index 8e09e3b..e615964 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -10,29 +10,18 @@ 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. + * @see CasParser\Services\CasParserService::camsKfintech() * - * `$client->casParser->camsKfintech(...$params->toArray());` - * - * @see CasParser\CasParser->camsKfintech - * - * @phpstan-type cas_parser_cams_kfintech_params = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * @phpstan-type CasParserCamsKfintechParamsShape = array{ + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserCamsKfintechParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -45,14 +34,14 @@ final class CasParserCamsKfintechParams implements BaseModel /** * Base64 encoded CAS PDF file. */ - #[Api('pdf_file', optional: true)] - public ?string $pdfFile; + #[Api(optional: true)] + public ?string $pdf_file; /** * URL to the CAS PDF file. */ - #[Api('pdf_url', optional: true)] - public ?string $pdfURL; + #[Api(optional: true)] + public ?string $pdf_url; public function __construct() { @@ -66,14 +55,14 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdfFile = null, - ?string $pdfURL = null + ?string $pdf_file = null, + ?string $pdf_url = null ): self { $obj = new self; null !== $password && $obj->password = $password; - null !== $pdfFile && $obj->pdfFile = $pdfFile; - null !== $pdfURL && $obj->pdfURL = $pdfURL; + null !== $pdf_file && $obj->pdf_file = $pdf_file; + null !== $pdf_url && $obj->pdf_url = $pdf_url; return $obj; } @@ -95,7 +84,7 @@ public function withPassword(string $password): self public function withPdfFile(string $pdfFile): self { $obj = clone $this; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdfFile; return $obj; } @@ -106,7 +95,7 @@ public function withPdfFile(string $pdfFile): self public function withPdfURL(string $pdfURL): self { $obj = clone $this; - $obj->pdfURL = $pdfURL; + $obj->pdf_url = $pdfURL; return $obj; } diff --git a/src/CasParser/CasParserCdslParams.php b/src/CasParser/CasParserCdslParams.php index d48b9b2..33f8d03 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -10,29 +10,18 @@ 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. + * @see CasParser\Services\CasParserService::cdsl() * - * `$client->casParser->cdsl(...$params->toArray());` - * - * @see CasParser\CasParser->cdsl - * - * @phpstan-type cas_parser_cdsl_params = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * @phpstan-type CasParserCdslParamsShape = array{ + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserCdslParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -45,14 +34,14 @@ final class CasParserCdslParams implements BaseModel /** * Base64 encoded CAS PDF file. */ - #[Api('pdf_file', optional: true)] - public ?string $pdfFile; + #[Api(optional: true)] + public ?string $pdf_file; /** * URL to the CAS PDF file. */ - #[Api('pdf_url', optional: true)] - public ?string $pdfURL; + #[Api(optional: true)] + public ?string $pdf_url; public function __construct() { @@ -66,14 +55,14 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdfFile = null, - ?string $pdfURL = null + ?string $pdf_file = null, + ?string $pdf_url = null ): self { $obj = new self; null !== $password && $obj->password = $password; - null !== $pdfFile && $obj->pdfFile = $pdfFile; - null !== $pdfURL && $obj->pdfURL = $pdfURL; + null !== $pdf_file && $obj->pdf_file = $pdf_file; + null !== $pdf_url && $obj->pdf_url = $pdf_url; return $obj; } @@ -95,7 +84,7 @@ public function withPassword(string $password): self public function withPdfFile(string $pdfFile): self { $obj = clone $this; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdfFile; return $obj; } @@ -106,7 +95,7 @@ public function withPdfFile(string $pdfFile): self public function withPdfURL(string $pdfURL): self { $obj = clone $this; - $obj->pdfURL = $pdfURL; + $obj->pdf_url = $pdfURL; return $obj; } diff --git a/src/CasParser/CasParserNsdlParams.php b/src/CasParser/CasParserNsdlParams.php index 98320b2..4b8b2dc 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -10,29 +10,18 @@ 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. + * @see CasParser\Services\CasParserService::nsdl() * - * `$client->casParser->nsdl(...$params->toArray());` - * - * @see CasParser\CasParser->nsdl - * - * @phpstan-type cas_parser_nsdl_params = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * @phpstan-type CasParserNsdlParamsShape = array{ + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserNsdlParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -45,14 +34,14 @@ final class CasParserNsdlParams implements BaseModel /** * Base64 encoded CAS PDF file. */ - #[Api('pdf_file', optional: true)] - public ?string $pdfFile; + #[Api(optional: true)] + public ?string $pdf_file; /** * URL to the CAS PDF file. */ - #[Api('pdf_url', optional: true)] - public ?string $pdfURL; + #[Api(optional: true)] + public ?string $pdf_url; public function __construct() { @@ -66,14 +55,14 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdfFile = null, - ?string $pdfURL = null + ?string $pdf_file = null, + ?string $pdf_url = null ): self { $obj = new self; null !== $password && $obj->password = $password; - null !== $pdfFile && $obj->pdfFile = $pdfFile; - null !== $pdfURL && $obj->pdfURL = $pdfURL; + null !== $pdf_file && $obj->pdf_file = $pdf_file; + null !== $pdf_url && $obj->pdf_url = $pdf_url; return $obj; } @@ -95,7 +84,7 @@ public function withPassword(string $password): self public function withPdfFile(string $pdfFile): self { $obj = clone $this; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdfFile; return $obj; } @@ -106,7 +95,7 @@ public function withPdfFile(string $pdfFile): self public function withPdfURL(string $pdfURL): self { $obj = clone $this; - $obj->pdfURL = $pdfURL; + $obj->pdf_url = $pdfURL; return $obj; } diff --git a/src/CasParser/CasParserSmartParseParams.php b/src/CasParser/CasParserSmartParseParams.php index 525ebf1..c67e47d 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -10,29 +10,18 @@ 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. + * @see CasParser\Services\CasParserService::smartParse() * - * `$client->casParser->smartParse(...$params->toArray());` - * - * @see CasParser\CasParser->smartParse - * - * @phpstan-type cas_parser_smart_parse_params = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * @phpstan-type CasParserSmartParseParamsShape = array{ + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserSmartParseParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -45,14 +34,14 @@ final class CasParserSmartParseParams implements BaseModel /** * Base64 encoded CAS PDF file. */ - #[Api('pdf_file', optional: true)] - public ?string $pdfFile; + #[Api(optional: true)] + public ?string $pdf_file; /** * URL to the CAS PDF file. */ - #[Api('pdf_url', optional: true)] - public ?string $pdfURL; + #[Api(optional: true)] + public ?string $pdf_url; public function __construct() { @@ -66,14 +55,14 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdfFile = null, - ?string $pdfURL = null + ?string $pdf_file = null, + ?string $pdf_url = null ): self { $obj = new self; null !== $password && $obj->password = $password; - null !== $pdfFile && $obj->pdfFile = $pdfFile; - null !== $pdfURL && $obj->pdfURL = $pdfURL; + null !== $pdf_file && $obj->pdf_file = $pdf_file; + null !== $pdf_url && $obj->pdf_url = $pdf_url; return $obj; } @@ -95,7 +84,7 @@ public function withPassword(string $password): self public function withPdfFile(string $pdfFile): self { $obj = clone $this; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdfFile; return $obj; } @@ -106,7 +95,7 @@ public function withPdfFile(string $pdfFile): self public function withPdfURL(string $pdfURL): self { $obj = clone $this; - $obj->pdfURL = $pdfURL; + $obj->pdf_url = $pdfURL; return $obj; } diff --git a/src/CasParser/UnifiedResponse.php b/src/CasParser/UnifiedResponse.php index 0eda57c..5de1d90 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -9,33 +9,35 @@ 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{ - * dematAccounts?: list, - * insurance?: Insurance, - * investor?: Investor, - * meta?: Meta, - * mutualFunds?: list, - * summary?: Summary, + * @phpstan-type UnifiedResponseShape = array{ + * demat_accounts?: list|null, + * insurance?: Insurance|null, + * investor?: Investor|null, + * meta?: Meta|null, + * mutual_funds?: list|null, + * nps?: list|null, + * summary?: Summary|null, * } - * 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 */ + /** @use SdkModel */ use SdkModel; - /** @var list|null $dematAccounts */ - #[Api('demat_accounts', list: DematAccount::class, optional: true)] - public ?array $dematAccounts; + use SdkResponse; + + /** @var list|null $demat_accounts */ + #[Api(list: DematAccount::class, optional: true)] + public ?array $demat_accounts; #[Api(optional: true)] public ?Insurance $insurance; @@ -46,9 +48,17 @@ final class UnifiedResponse implements BaseModel #[Api(optional: true)] public ?Meta $meta; - /** @var list|null $mutualFunds */ - #[Api('mutual_funds', list: MutualFund::class, optional: true)] - public ?array $mutualFunds; + /** @var list|null $mutual_funds */ + #[Api(list: MutualFund::class, optional: true)] + public ?array $mutual_funds; + + /** + * List of NPS accounts. + * + * @var list|null $nps + */ + #[Api(list: Np::class, optional: true)] + public ?array $nps; #[Api(optional: true)] public ?Summary $summary; @@ -63,24 +73,27 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $dematAccounts - * @param list $mutualFunds + * @param list $demat_accounts + * @param list $mutual_funds + * @param list $nps */ public static function with( - ?array $dematAccounts = null, + ?array $demat_accounts = null, ?Insurance $insurance = null, ?Investor $investor = null, ?Meta $meta = null, - ?array $mutualFunds = null, + ?array $mutual_funds = null, + ?array $nps = null, ?Summary $summary = null, ): self { $obj = new self; - null !== $dematAccounts && $obj->dematAccounts = $dematAccounts; + null !== $demat_accounts && $obj->demat_accounts = $demat_accounts; null !== $insurance && $obj->insurance = $insurance; null !== $investor && $obj->investor = $investor; null !== $meta && $obj->meta = $meta; - null !== $mutualFunds && $obj->mutualFunds = $mutualFunds; + null !== $mutual_funds && $obj->mutual_funds = $mutual_funds; + null !== $nps && $obj->nps = $nps; null !== $summary && $obj->summary = $summary; return $obj; @@ -92,7 +105,7 @@ public static function with( public function withDematAccounts(array $dematAccounts): self { $obj = clone $this; - $obj->dematAccounts = $dematAccounts; + $obj->demat_accounts = $dematAccounts; return $obj; } @@ -127,7 +140,20 @@ public function withMeta(Meta $meta): self public function withMutualFunds(array $mutualFunds): self { $obj = clone $this; - $obj->mutualFunds = $mutualFunds; + $obj->mutual_funds = $mutualFunds; + + return $obj; + } + + /** + * List of NPS accounts. + * + * @param list $nps + */ + public function withNps(array $nps): self + { + $obj = clone $this; + $obj->nps = $nps; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index 0c57e41..5901828 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -7,68 +7,78 @@ use CasParser\CasParser\UnifiedResponse\DematAccount\AdditionalInfo; use CasParser\CasParser\UnifiedResponse\DematAccount\DematType; use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings; +use CasParser\CasParser\UnifiedResponse\DematAccount\LinkedHolder; use CasParser\Core\Attributes\Api; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type demat_account = array{ - * additionalInfo?: AdditionalInfo, - * boID?: string, - * clientID?: string, - * dematType?: value-of, - * dpID?: string, - * dpName?: string, - * holdings?: Holdings, - * value?: float, + * @phpstan-type DematAccountShape = array{ + * additional_info?: AdditionalInfo|null, + * bo_id?: string|null, + * client_id?: string|null, + * demat_type?: value-of|null, + * dp_id?: string|null, + * dp_name?: string|null, + * holdings?: Holdings|null, + * linked_holders?: list|null, + * value?: float|null, * } */ final class DematAccount implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the demat account type. */ - #[Api('additional_info', optional: true)] - public ?AdditionalInfo $additionalInfo; + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; /** * Beneficiary Owner ID (primarily for CDSL). */ - #[Api('bo_id', optional: true)] - public ?string $boID; + #[Api(optional: true)] + public ?string $bo_id; /** * Client ID. */ - #[Api('client_id', optional: true)] - public ?string $clientID; + #[Api(optional: true)] + public ?string $client_id; /** * Type of demat account. * - * @var value-of|null $dematType + * @var value-of|null $demat_type */ - #[Api('demat_type', enum: DematType::class, optional: true)] - public ?string $dematType; + #[Api(enum: DematType::class, optional: true)] + public ?string $demat_type; /** * Depository Participant ID. */ - #[Api('dp_id', optional: true)] - public ?string $dpID; + #[Api(optional: true)] + public ?string $dp_id; /** * Depository Participant name. */ - #[Api('dp_name', optional: true)] - public ?string $dpName; + #[Api(optional: true)] + public ?string $dp_name; #[Api(optional: true)] public ?Holdings $holdings; + /** + * List of account holders linked to this demat account. + * + * @var list|null $linked_holders + */ + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; + /** * Total value of the demat account. */ @@ -85,27 +95,30 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param DematType|value-of $dematType + * @param DematType|value-of $demat_type + * @param list $linked_holders */ public static function with( - ?AdditionalInfo $additionalInfo = null, - ?string $boID = null, - ?string $clientID = null, - DematType|string|null $dematType = null, - ?string $dpID = null, - ?string $dpName = null, + ?AdditionalInfo $additional_info = null, + ?string $bo_id = null, + ?string $client_id = null, + DematType|string|null $demat_type = null, + ?string $dp_id = null, + ?string $dp_name = null, ?Holdings $holdings = null, + ?array $linked_holders = null, ?float $value = null, ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; - null !== $boID && $obj->boID = $boID; - null !== $clientID && $obj->clientID = $clientID; - null !== $dematType && $obj->dematType = $dematType instanceof DematType ? $dematType->value : $dematType; - null !== $dpID && $obj->dpID = $dpID; - null !== $dpName && $obj->dpName = $dpName; + null !== $additional_info && $obj->additional_info = $additional_info; + null !== $bo_id && $obj->bo_id = $bo_id; + null !== $client_id && $obj->client_id = $client_id; + null !== $demat_type && $obj['demat_type'] = $demat_type; + null !== $dp_id && $obj->dp_id = $dp_id; + null !== $dp_name && $obj->dp_name = $dp_name; null !== $holdings && $obj->holdings = $holdings; + null !== $linked_holders && $obj->linked_holders = $linked_holders; null !== $value && $obj->value = $value; return $obj; @@ -117,7 +130,7 @@ public static function with( public function withAdditionalInfo(AdditionalInfo $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } @@ -128,7 +141,7 @@ public function withAdditionalInfo(AdditionalInfo $additionalInfo): self public function withBoID(string $boID): self { $obj = clone $this; - $obj->boID = $boID; + $obj->bo_id = $boID; return $obj; } @@ -139,7 +152,7 @@ public function withBoID(string $boID): self public function withClientID(string $clientID): self { $obj = clone $this; - $obj->clientID = $clientID; + $obj->client_id = $clientID; return $obj; } @@ -152,7 +165,7 @@ public function withClientID(string $clientID): self public function withDematType(DematType|string $dematType): self { $obj = clone $this; - $obj->dematType = $dematType instanceof DematType ? $dematType->value : $dematType; + $obj['demat_type'] = $dematType; return $obj; } @@ -163,7 +176,7 @@ public function withDematType(DematType|string $dematType): self public function withDpID(string $dpID): self { $obj = clone $this; - $obj->dpID = $dpID; + $obj->dp_id = $dpID; return $obj; } @@ -174,7 +187,7 @@ public function withDpID(string $dpID): self public function withDpName(string $dpName): self { $obj = clone $this; - $obj->dpName = $dpName; + $obj->dp_name = $dpName; return $obj; } @@ -187,6 +200,19 @@ public function withHoldings(Holdings $holdings): self return $obj; } + /** + * List of account holders linked to this demat account. + * + * @param list $linkedHolders + */ + public function withLinkedHolders(array $linkedHolders): self + { + $obj = clone $this; + $obj->linked_holders = $linkedHolders; + + return $obj; + } + /** * Total value of the demat account. */ diff --git a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php index c7a8be5..38fbb27 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php @@ -11,39 +11,39 @@ /** * Additional information specific to the demat account type. * - * @phpstan-type additional_info = array{ - * boStatus?: string, - * boSubStatus?: string, - * boType?: string, - * bsda?: string, - * email?: string, - * linkedPans?: list, - * nominee?: string, - * status?: string, + * @phpstan-type AdditionalInfoShape = array{ + * bo_status?: string|null, + * bo_sub_status?: string|null, + * bo_type?: string|null, + * bsda?: string|null, + * email?: string|null, + * linked_pans?: list|null, + * nominee?: string|null, + * status?: string|null, * } */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Beneficiary Owner status (CDSL). */ - #[Api('bo_status', optional: true)] - public ?string $boStatus; + #[Api(optional: true)] + public ?string $bo_status; /** * Beneficiary Owner sub-status (CDSL). */ - #[Api('bo_sub_status', optional: true)] - public ?string $boSubStatus; + #[Api(optional: true)] + public ?string $bo_sub_status; /** * Beneficiary Owner type (CDSL). */ - #[Api('bo_type', optional: true)] - public ?string $boType; + #[Api(optional: true)] + public ?string $bo_type; /** * Basic Services Demat Account status (CDSL). @@ -60,10 +60,10 @@ final class AdditionalInfo implements BaseModel /** * List of linked PAN numbers (NSDL). * - * @var list|null $linkedPans + * @var list|null $linked_pans */ - #[Api('linked_pans', list: 'string', optional: true)] - public ?array $linkedPans; + #[Api(list: 'string', optional: true)] + public ?array $linked_pans; /** * Nominee details (CDSL). @@ -87,26 +87,26 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $linkedPans + * @param list $linked_pans */ public static function with( - ?string $boStatus = null, - ?string $boSubStatus = null, - ?string $boType = null, + ?string $bo_status = null, + ?string $bo_sub_status = null, + ?string $bo_type = null, ?string $bsda = null, ?string $email = null, - ?array $linkedPans = null, + ?array $linked_pans = null, ?string $nominee = null, ?string $status = null, ): self { $obj = new self; - null !== $boStatus && $obj->boStatus = $boStatus; - null !== $boSubStatus && $obj->boSubStatus = $boSubStatus; - null !== $boType && $obj->boType = $boType; + null !== $bo_status && $obj->bo_status = $bo_status; + null !== $bo_sub_status && $obj->bo_sub_status = $bo_sub_status; + null !== $bo_type && $obj->bo_type = $bo_type; null !== $bsda && $obj->bsda = $bsda; null !== $email && $obj->email = $email; - null !== $linkedPans && $obj->linkedPans = $linkedPans; + null !== $linked_pans && $obj->linked_pans = $linked_pans; null !== $nominee && $obj->nominee = $nominee; null !== $status && $obj->status = $status; @@ -119,7 +119,7 @@ public static function with( public function withBoStatus(string $boStatus): self { $obj = clone $this; - $obj->boStatus = $boStatus; + $obj->bo_status = $boStatus; return $obj; } @@ -130,7 +130,7 @@ public function withBoStatus(string $boStatus): self public function withBoSubStatus(string $boSubStatus): self { $obj = clone $this; - $obj->boSubStatus = $boSubStatus; + $obj->bo_sub_status = $boSubStatus; return $obj; } @@ -141,7 +141,7 @@ public function withBoSubStatus(string $boSubStatus): self public function withBoType(string $boType): self { $obj = clone $this; - $obj->boType = $boType; + $obj->bo_type = $boType; return $obj; } @@ -176,7 +176,7 @@ public function withEmail(string $email): self public function withLinkedPans(array $linkedPans): self { $obj = clone $this; - $obj->linkedPans = $linkedPans; + $obj->linked_pans = $linkedPans; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php index eb3b0d1..e800558 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php @@ -14,42 +14,38 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type holdings_alias = array{ - * aifs?: list, - * corporateBonds?: list, - * dematMutualFunds?: list, - * equities?: list, - * governmentSecurities?: list, + * @phpstan-type HoldingsShape = array{ + * aifs?: list|null, + * corporate_bonds?: list|null, + * demat_mutual_funds?: list|null, + * equities?: list|null, + * government_securities?: list|null, * } */ final class Holdings implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @var list|null $aifs */ #[Api(list: Aif::class, optional: true)] public ?array $aifs; - /** @var list|null $corporateBonds */ - #[Api('corporate_bonds', list: CorporateBond::class, optional: true)] - public ?array $corporateBonds; + /** @var list|null $corporate_bonds */ + #[Api(list: CorporateBond::class, optional: true)] + public ?array $corporate_bonds; - /** @var list|null $dematMutualFunds */ - #[Api('demat_mutual_funds', list: DematMutualFund::class, optional: true)] - public ?array $dematMutualFunds; + /** @var list|null $demat_mutual_funds */ + #[Api(list: DematMutualFund::class, optional: true)] + public ?array $demat_mutual_funds; /** @var list|null $equities */ #[Api(list: Equity::class, optional: true)] public ?array $equities; - /** @var list|null $governmentSecurities */ - #[Api( - 'government_securities', - list: GovernmentSecurity::class, - optional: true - )] - public ?array $governmentSecurities; + /** @var list|null $government_securities */ + #[Api(list: GovernmentSecurity::class, optional: true)] + public ?array $government_securities; public function __construct() { @@ -62,25 +58,25 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param list $aifs - * @param list $corporateBonds - * @param list $dematMutualFunds + * @param list $corporate_bonds + * @param list $demat_mutual_funds * @param list $equities - * @param list $governmentSecurities + * @param list $government_securities */ public static function with( ?array $aifs = null, - ?array $corporateBonds = null, - ?array $dematMutualFunds = null, + ?array $corporate_bonds = null, + ?array $demat_mutual_funds = null, ?array $equities = null, - ?array $governmentSecurities = null, + ?array $government_securities = null, ): self { $obj = new self; null !== $aifs && $obj->aifs = $aifs; - null !== $corporateBonds && $obj->corporateBonds = $corporateBonds; - null !== $dematMutualFunds && $obj->dematMutualFunds = $dematMutualFunds; + null !== $corporate_bonds && $obj->corporate_bonds = $corporate_bonds; + null !== $demat_mutual_funds && $obj->demat_mutual_funds = $demat_mutual_funds; null !== $equities && $obj->equities = $equities; - null !== $governmentSecurities && $obj->governmentSecurities = $governmentSecurities; + null !== $government_securities && $obj->government_securities = $government_securities; return $obj; } @@ -102,7 +98,7 @@ public function withAifs(array $aifs): self public function withCorporateBonds(array $corporateBonds): self { $obj = clone $this; - $obj->corporateBonds = $corporateBonds; + $obj->corporate_bonds = $corporateBonds; return $obj; } @@ -113,7 +109,7 @@ public function withCorporateBonds(array $corporateBonds): self public function withDematMutualFunds(array $dematMutualFunds): self { $obj = clone $this; - $obj->dematMutualFunds = $dematMutualFunds; + $obj->demat_mutual_funds = $dematMutualFunds; return $obj; } @@ -135,7 +131,7 @@ public function withEquities(array $equities): self public function withGovernmentSecurities(array $governmentSecurities): self { $obj = clone $this; - $obj->governmentSecurities = $governmentSecurities; + $obj->government_securities = $governmentSecurities; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php index 1df6013..f5b39f5 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php @@ -9,24 +9,24 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type aif_alias = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * @phpstan-type AifShape = array{ + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class Aif implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the AIF. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * ISIN code of the AIF. @@ -63,7 +63,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $isin = null, ?string $name = null, ?float $units = null, @@ -71,7 +71,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $isin && $obj->isin = $isin; null !== $name && $obj->name = $name; null !== $units && $obj->units = $units; @@ -86,7 +86,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php index bfb4d84..0de214f 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php @@ -9,24 +9,24 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type corporate_bond = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * @phpstan-type CorporateBondShape = array{ + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class CorporateBond implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the corporate bond. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * ISIN code of the corporate bond. @@ -63,7 +63,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $isin = null, ?string $name = null, ?float $units = null, @@ -71,7 +71,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $isin && $obj->isin = $isin; null !== $name && $obj->name = $name; null !== $units && $obj->units = $units; @@ -86,7 +86,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php index 36015d7..dbc6a82 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php @@ -9,24 +9,24 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type demat_mutual_fund = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * @phpstan-type DematMutualFundShape = array{ + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class DematMutualFund implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the mutual fund. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * ISIN code of the mutual fund. @@ -63,7 +63,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $isin = null, ?string $name = null, ?float $units = null, @@ -71,7 +71,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $isin && $obj->isin = $isin; null !== $name && $obj->name = $name; null !== $units && $obj->units = $units; @@ -86,7 +86,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php index 0c1b5c2..b6eee88 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php @@ -9,24 +9,24 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type equity_alias = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * @phpstan-type EquityShape = array{ + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class Equity implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the equity. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * ISIN code of the equity. @@ -63,7 +63,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $isin = null, ?string $name = null, ?float $units = null, @@ -71,7 +71,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $isin && $obj->isin = $isin; null !== $name && $obj->name = $name; null !== $units && $obj->units = $units; @@ -86,7 +86,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php index cd4249f..0d295bd 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php @@ -9,24 +9,24 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type government_security = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * @phpstan-type GovernmentSecurityShape = array{ + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class GovernmentSecurity implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the government security. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * ISIN code of the government security. @@ -63,7 +63,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $isin = null, ?string $name = null, ?float $units = null, @@ -71,7 +71,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $isin && $obj->isin = $isin; null !== $name && $obj->name = $name; null !== $units && $obj->units = $units; @@ -86,7 +86,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php new file mode 100644 index 0000000..5b9ac2e --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php @@ -0,0 +1,72 @@ + */ + use SdkModel; + + /** + * Name of the account holder. + */ + #[Api(optional: true)] + public ?string $name; + + /** + * PAN of the account holder. + */ + #[Api(optional: true)] + public ?string $pan; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(?string $name = null, ?string $pan = null): self + { + $obj = new self; + + null !== $name && $obj->name = $name; + null !== $pan && $obj->pan = $pan; + + return $obj; + } + + /** + * Name of the account holder. + */ + public function withName(string $name): self + { + $obj = clone $this; + $obj->name = $name; + + return $obj; + } + + /** + * PAN of the account holder. + */ + public function withPan(string $pan): self + { + $obj = clone $this; + $obj->pan = $pan; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/Insurance.php b/src/CasParser/UnifiedResponse/Insurance.php index 2a42859..336278f 100644 --- a/src/CasParser/UnifiedResponse/Insurance.php +++ b/src/CasParser/UnifiedResponse/Insurance.php @@ -10,22 +10,18 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type insurance_alias = array{ - * lifeInsurancePolicies?: list + * @phpstan-type InsuranceShape = array{ + * life_insurance_policies?: list|null * } */ final class Insurance implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; - /** @var list|null $lifeInsurancePolicies */ - #[Api( - 'life_insurance_policies', - list: LifeInsurancePolicy::class, - optional: true - )] - public ?array $lifeInsurancePolicies; + /** @var list|null $life_insurance_policies */ + #[Api(list: LifeInsurancePolicy::class, optional: true)] + public ?array $life_insurance_policies; public function __construct() { @@ -37,13 +33,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $lifeInsurancePolicies + * @param list $life_insurance_policies */ - public static function with(?array $lifeInsurancePolicies = null): self + public static function with(?array $life_insurance_policies = null): self { $obj = new self; - null !== $lifeInsurancePolicies && $obj->lifeInsurancePolicies = $lifeInsurancePolicies; + null !== $life_insurance_policies && $obj->life_insurance_policies = $life_insurance_policies; return $obj; } @@ -55,7 +51,7 @@ public function withLifeInsurancePolicies( array $lifeInsurancePolicies ): self { $obj = clone $this; - $obj->lifeInsurancePolicies = $lifeInsurancePolicies; + $obj->life_insurance_policies = $lifeInsurancePolicies; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php index c106c9c..0734bdf 100644 --- a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php +++ b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php @@ -9,58 +9,58 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type life_insurance_policy = array{ - * additionalInfo?: mixed, - * lifeAssured?: string, - * policyName?: string, - * policyNumber?: string, - * premiumAmount?: float, - * premiumFrequency?: string, - * provider?: string, - * status?: string, - * sumAssured?: float, + * @phpstan-type LifeInsurancePolicyShape = array{ + * additional_info?: mixed, + * life_assured?: string|null, + * policy_name?: string|null, + * policy_number?: string|null, + * premium_amount?: float|null, + * premium_frequency?: string|null, + * provider?: string|null, + * status?: string|null, + * sum_assured?: float|null, * } */ final class LifeInsurancePolicy implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the policy. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * Name of the life assured. */ - #[Api('life_assured', optional: true)] - public ?string $lifeAssured; + #[Api(optional: true)] + public ?string $life_assured; /** * Name of the insurance policy. */ - #[Api('policy_name', optional: true)] - public ?string $policyName; + #[Api(optional: true)] + public ?string $policy_name; /** * Insurance policy number. */ - #[Api('policy_number', optional: true)] - public ?string $policyNumber; + #[Api(optional: true)] + public ?string $policy_number; /** * Premium amount. */ - #[Api('premium_amount', optional: true)] - public ?float $premiumAmount; + #[Api(optional: true)] + public ?float $premium_amount; /** * Frequency of premium payment (e.g., Annual, Monthly). */ - #[Api('premium_frequency', optional: true)] - public ?string $premiumFrequency; + #[Api(optional: true)] + public ?string $premium_frequency; /** * Insurance company name. @@ -77,8 +77,8 @@ final class LifeInsurancePolicy implements BaseModel /** * Sum assured amount. */ - #[Api('sum_assured', optional: true)] - public ?float $sumAssured; + #[Api(optional: true)] + public ?float $sum_assured; public function __construct() { @@ -91,27 +91,27 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additionalInfo = null, - ?string $lifeAssured = null, - ?string $policyName = null, - ?string $policyNumber = null, - ?float $premiumAmount = null, - ?string $premiumFrequency = null, + mixed $additional_info = null, + ?string $life_assured = null, + ?string $policy_name = null, + ?string $policy_number = null, + ?float $premium_amount = null, + ?string $premium_frequency = null, ?string $provider = null, ?string $status = null, - ?float $sumAssured = null, + ?float $sum_assured = null, ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; - null !== $lifeAssured && $obj->lifeAssured = $lifeAssured; - null !== $policyName && $obj->policyName = $policyName; - null !== $policyNumber && $obj->policyNumber = $policyNumber; - null !== $premiumAmount && $obj->premiumAmount = $premiumAmount; - null !== $premiumFrequency && $obj->premiumFrequency = $premiumFrequency; + null !== $additional_info && $obj->additional_info = $additional_info; + null !== $life_assured && $obj->life_assured = $life_assured; + null !== $policy_name && $obj->policy_name = $policy_name; + null !== $policy_number && $obj->policy_number = $policy_number; + null !== $premium_amount && $obj->premium_amount = $premium_amount; + null !== $premium_frequency && $obj->premium_frequency = $premium_frequency; null !== $provider && $obj->provider = $provider; null !== $status && $obj->status = $status; - null !== $sumAssured && $obj->sumAssured = $sumAssured; + null !== $sum_assured && $obj->sum_assured = $sum_assured; return $obj; } @@ -122,7 +122,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } @@ -133,7 +133,7 @@ public function withAdditionalInfo(mixed $additionalInfo): self public function withLifeAssured(string $lifeAssured): self { $obj = clone $this; - $obj->lifeAssured = $lifeAssured; + $obj->life_assured = $lifeAssured; return $obj; } @@ -144,7 +144,7 @@ public function withLifeAssured(string $lifeAssured): self public function withPolicyName(string $policyName): self { $obj = clone $this; - $obj->policyName = $policyName; + $obj->policy_name = $policyName; return $obj; } @@ -155,7 +155,7 @@ public function withPolicyName(string $policyName): self public function withPolicyNumber(string $policyNumber): self { $obj = clone $this; - $obj->policyNumber = $policyNumber; + $obj->policy_number = $policyNumber; return $obj; } @@ -166,7 +166,7 @@ public function withPolicyNumber(string $policyNumber): self public function withPremiumAmount(float $premiumAmount): self { $obj = clone $this; - $obj->premiumAmount = $premiumAmount; + $obj->premium_amount = $premiumAmount; return $obj; } @@ -177,7 +177,7 @@ public function withPremiumAmount(float $premiumAmount): self public function withPremiumFrequency(string $premiumFrequency): self { $obj = clone $this; - $obj->premiumFrequency = $premiumFrequency; + $obj->premium_frequency = $premiumFrequency; return $obj; } @@ -210,7 +210,7 @@ public function withStatus(string $status): self public function withSumAssured(float $sumAssured): self { $obj = clone $this; - $obj->sumAssured = $sumAssured; + $obj->sum_assured = $sumAssured; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Investor.php b/src/CasParser/UnifiedResponse/Investor.php index dd04ddc..272a2cd 100644 --- a/src/CasParser/UnifiedResponse/Investor.php +++ b/src/CasParser/UnifiedResponse/Investor.php @@ -9,19 +9,19 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type investor_alias = array{ - * address?: string, - * casID?: string, - * email?: string, - * mobile?: string, - * name?: string, - * pan?: string, - * pincode?: string, + * @phpstan-type InvestorShape = array{ + * address?: string|null, + * cas_id?: string|null, + * email?: string|null, + * mobile?: string|null, + * name?: string|null, + * pan?: string|null, + * pincode?: string|null, * } */ final class Investor implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -33,8 +33,8 @@ final class Investor implements BaseModel /** * CAS ID of the investor (only for NSDL and CDSL). */ - #[Api('cas_id', optional: true)] - public ?string $casID; + #[Api(optional: true)] + public ?string $cas_id; /** * Email address of the investor. @@ -78,7 +78,7 @@ public function __construct() */ public static function with( ?string $address = null, - ?string $casID = null, + ?string $cas_id = null, ?string $email = null, ?string $mobile = null, ?string $name = null, @@ -88,7 +88,7 @@ public static function with( $obj = new self; null !== $address && $obj->address = $address; - null !== $casID && $obj->casID = $casID; + null !== $cas_id && $obj->cas_id = $cas_id; null !== $email && $obj->email = $email; null !== $mobile && $obj->mobile = $mobile; null !== $name && $obj->name = $name; @@ -115,7 +115,7 @@ public function withAddress(string $address): self public function withCasID(string $casID): self { $obj = clone $this; - $obj->casID = $casID; + $obj->cas_id = $casID; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Meta.php b/src/CasParser/UnifiedResponse/Meta.php index 7f55cb7..ab759db 100644 --- a/src/CasParser/UnifiedResponse/Meta.php +++ b/src/CasParser/UnifiedResponse/Meta.php @@ -11,33 +11,33 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type meta_alias = array{ - * casType?: value-of, - * generatedAt?: \DateTimeInterface, - * statementPeriod?: StatementPeriod, + * @phpstan-type MetaShape = array{ + * cas_type?: value-of|null, + * generated_at?: \DateTimeInterface|null, + * statement_period?: StatementPeriod|null, * } */ final class Meta implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Type of CAS detected and processed. * - * @var value-of|null $casType + * @var value-of|null $cas_type */ - #[Api('cas_type', enum: CasType::class, optional: true)] - public ?string $casType; + #[Api(enum: CasType::class, optional: true)] + public ?string $cas_type; /** * Timestamp when the response was generated. */ - #[Api('generated_at', optional: true)] - public ?\DateTimeInterface $generatedAt; + #[Api(optional: true)] + public ?\DateTimeInterface $generated_at; - #[Api('statement_period', optional: true)] - public ?StatementPeriod $statementPeriod; + #[Api(optional: true)] + public ?StatementPeriod $statement_period; public function __construct() { @@ -49,18 +49,18 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param CasType|value-of $casType + * @param CasType|value-of $cas_type */ public static function with( - CasType|string|null $casType = null, - ?\DateTimeInterface $generatedAt = null, - ?StatementPeriod $statementPeriod = null, + CasType|string|null $cas_type = null, + ?\DateTimeInterface $generated_at = null, + ?StatementPeriod $statement_period = null, ): self { $obj = new self; - null !== $casType && $obj->casType = $casType instanceof CasType ? $casType->value : $casType; - null !== $generatedAt && $obj->generatedAt = $generatedAt; - null !== $statementPeriod && $obj->statementPeriod = $statementPeriod; + null !== $cas_type && $obj['cas_type'] = $cas_type; + null !== $generated_at && $obj->generated_at = $generated_at; + null !== $statement_period && $obj->statement_period = $statement_period; return $obj; } @@ -73,7 +73,7 @@ public static function with( public function withCasType(CasType|string $casType): self { $obj = clone $this; - $obj->casType = $casType instanceof CasType ? $casType->value : $casType; + $obj['cas_type'] = $casType; return $obj; } @@ -84,7 +84,7 @@ public function withCasType(CasType|string $casType): self public function withGeneratedAt(\DateTimeInterface $generatedAt): self { $obj = clone $this; - $obj->generatedAt = $generatedAt; + $obj->generated_at = $generatedAt; return $obj; } @@ -92,7 +92,7 @@ public function withGeneratedAt(\DateTimeInterface $generatedAt): self public function withStatementPeriod(StatementPeriod $statementPeriod): self { $obj = clone $this; - $obj->statementPeriod = $statementPeriod; + $obj->statement_period = $statementPeriod; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php index ebeb0f2..d7b088b 100644 --- a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php +++ b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php @@ -9,13 +9,13 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type statement_period = array{ - * from?: \DateTimeInterface, to?: \DateTimeInterface + * @phpstan-type StatementPeriodShape = array{ + * from?: \DateTimeInterface|null, to?: \DateTimeInterface|null * } */ final class StatementPeriod implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund.php b/src/CasParser/UnifiedResponse/MutualFund.php index 2f1da0c..d1448f7 100644 --- a/src/CasParser/UnifiedResponse/MutualFund.php +++ b/src/CasParser/UnifiedResponse/MutualFund.php @@ -5,31 +5,33 @@ namespace CasParser\CasParser\UnifiedResponse; use CasParser\CasParser\UnifiedResponse\MutualFund\AdditionalInfo; +use CasParser\CasParser\UnifiedResponse\MutualFund\LinkedHolder; use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme; use CasParser\Core\Attributes\Api; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type mutual_fund = array{ - * additionalInfo?: AdditionalInfo, - * amc?: string, - * folioNumber?: string, - * registrar?: string, - * schemes?: list, - * value?: float, + * @phpstan-type MutualFundShape = array{ + * additional_info?: AdditionalInfo|null, + * amc?: string|null, + * folio_number?: string|null, + * linked_holders?: list|null, + * registrar?: string|null, + * schemes?: list|null, + * value?: float|null, * } */ final class MutualFund implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional folio information. */ - #[Api('additional_info', optional: true)] - public ?AdditionalInfo $additionalInfo; + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; /** * Asset Management Company name. @@ -40,8 +42,16 @@ final class MutualFund implements BaseModel /** * Folio number. */ - #[Api('folio_number', optional: true)] - public ?string $folioNumber; + #[Api(optional: true)] + public ?string $folio_number; + + /** + * List of account holders linked to this mutual fund folio. + * + * @var list|null $linked_holders + */ + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; /** * Registrar and Transfer Agent name. @@ -69,21 +79,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param list $linked_holders * @param list $schemes */ public static function with( - ?AdditionalInfo $additionalInfo = null, + ?AdditionalInfo $additional_info = null, ?string $amc = null, - ?string $folioNumber = null, + ?string $folio_number = null, + ?array $linked_holders = null, ?string $registrar = null, ?array $schemes = null, ?float $value = null, ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $amc && $obj->amc = $amc; - null !== $folioNumber && $obj->folioNumber = $folioNumber; + null !== $folio_number && $obj->folio_number = $folio_number; + null !== $linked_holders && $obj->linked_holders = $linked_holders; null !== $registrar && $obj->registrar = $registrar; null !== $schemes && $obj->schemes = $schemes; null !== $value && $obj->value = $value; @@ -97,7 +110,7 @@ public static function with( public function withAdditionalInfo(AdditionalInfo $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } @@ -119,7 +132,20 @@ public function withAmc(string $amc): self public function withFolioNumber(string $folioNumber): self { $obj = clone $this; - $obj->folioNumber = $folioNumber; + $obj->folio_number = $folioNumber; + + return $obj; + } + + /** + * List of account holders linked to this mutual fund folio. + * + * @param list $linkedHolders + */ + public function withLinkedHolders(array $linkedHolders): self + { + $obj = clone $this; + $obj->linked_holders = $linkedHolders; return $obj; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php index b79ad23..1ff28f5 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php @@ -11,13 +11,13 @@ /** * Additional folio information. * - * @phpstan-type additional_info = array{ - * kyc?: string, pan?: string, pankyc?: string + * @phpstan-type AdditionalInfoShape = array{ + * kyc?: string|null, pan?: string|null, pankyc?: string|null * } */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php new file mode 100644 index 0000000..cf09088 --- /dev/null +++ b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php @@ -0,0 +1,72 @@ + */ + use SdkModel; + + /** + * Name of the account holder. + */ + #[Api(optional: true)] + public ?string $name; + + /** + * PAN of the account holder. + */ + #[Api(optional: true)] + public ?string $pan; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(?string $name = null, ?string $pan = null): self + { + $obj = new self; + + null !== $name && $obj->name = $name; + null !== $pan && $obj->pan = $pan; + + return $obj; + } + + /** + * Name of the account holder. + */ + public function withName(string $name): self + { + $obj = clone $this; + $obj->name = $name; + + return $obj; + } + + /** + * PAN of the account holder. + */ + public function withPan(string $pan): self + { + $obj = clone $this; + $obj->pan = $pan; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php index 8775dbb..666a2b6 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php @@ -13,30 +13,30 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type scheme_alias = array{ - * additionalInfo?: AdditionalInfo, - * cost?: float, - * gain?: Gain, - * isin?: string, - * name?: string, - * nav?: float, - * nominees?: list, - * transactions?: list, - * type?: value-of, - * units?: float, - * value?: float, + * @phpstan-type SchemeShape = array{ + * additional_info?: AdditionalInfo|null, + * cost?: float|null, + * gain?: Gain|null, + * isin?: string|null, + * name?: string|null, + * nav?: float|null, + * nominees?: list|null, + * transactions?: list|null, + * type?: value-of|null, + * units?: float|null, + * value?: float|null, * } */ final class Scheme implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** * Additional information specific to the scheme. */ - #[Api('additional_info', optional: true)] - public ?AdditionalInfo $additionalInfo; + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; /** * Cost of investment. @@ -112,7 +112,7 @@ public function __construct() * @param Type|value-of $type */ public static function with( - ?AdditionalInfo $additionalInfo = null, + ?AdditionalInfo $additional_info = null, ?float $cost = null, ?Gain $gain = null, ?string $isin = null, @@ -126,7 +126,7 @@ public static function with( ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $cost && $obj->cost = $cost; null !== $gain && $obj->gain = $gain; null !== $isin && $obj->isin = $isin; @@ -134,7 +134,7 @@ public static function with( null !== $nav && $obj->nav = $nav; null !== $nominees && $obj->nominees = $nominees; null !== $transactions && $obj->transactions = $transactions; - null !== $type && $obj->type = $type instanceof Type ? $type->value : $type; + null !== $type && $obj['type'] = $type; null !== $units && $obj->units = $units; null !== $value && $obj->value = $value; @@ -147,7 +147,7 @@ public static function with( public function withAdditionalInfo(AdditionalInfo $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } @@ -236,7 +236,7 @@ public function withTransactions(array $transactions): self public function withType(Type|string $type): self { $obj = clone $this; - $obj->type = $type instanceof Type ? $type->value : $type; + $obj['type'] = $type; return $obj; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php index e5f16cd..7ba0897 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php @@ -11,17 +11,17 @@ /** * Additional information specific to the scheme. * - * @phpstan-type additional_info = array{ - * advisor?: string, - * amfi?: string, - * closeUnits?: float, - * openUnits?: float, - * rtaCode?: string, + * @phpstan-type AdditionalInfoShape = array{ + * advisor?: string|null, + * amfi?: string|null, + * close_units?: float|null, + * open_units?: float|null, + * rta_code?: string|null, * } */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -39,20 +39,20 @@ final class AdditionalInfo implements BaseModel /** * Closing balance units (CAMS/KFintech). */ - #[Api('close_units', optional: true)] - public ?float $closeUnits; + #[Api(optional: true)] + public ?float $close_units; /** * Opening balance units (CAMS/KFintech). */ - #[Api('open_units', optional: true)] - public ?float $openUnits; + #[Api(optional: true)] + public ?float $open_units; /** * RTA code for the scheme (CAMS/KFintech). */ - #[Api('rta_code', optional: true)] - public ?string $rtaCode; + #[Api(optional: true)] + public ?string $rta_code; public function __construct() { @@ -67,17 +67,17 @@ public function __construct() public static function with( ?string $advisor = null, ?string $amfi = null, - ?float $closeUnits = null, - ?float $openUnits = null, - ?string $rtaCode = null, + ?float $close_units = null, + ?float $open_units = null, + ?string $rta_code = null, ): self { $obj = new self; null !== $advisor && $obj->advisor = $advisor; null !== $amfi && $obj->amfi = $amfi; - null !== $closeUnits && $obj->closeUnits = $closeUnits; - null !== $openUnits && $obj->openUnits = $openUnits; - null !== $rtaCode && $obj->rtaCode = $rtaCode; + null !== $close_units && $obj->close_units = $close_units; + null !== $open_units && $obj->open_units = $open_units; + null !== $rta_code && $obj->rta_code = $rta_code; return $obj; } @@ -110,7 +110,7 @@ public function withAmfi(string $amfi): self public function withCloseUnits(float $closeUnits): self { $obj = clone $this; - $obj->closeUnits = $closeUnits; + $obj->close_units = $closeUnits; return $obj; } @@ -121,7 +121,7 @@ public function withCloseUnits(float $closeUnits): self public function withOpenUnits(float $openUnits): self { $obj = clone $this; - $obj->openUnits = $openUnits; + $obj->open_units = $openUnits; return $obj; } @@ -132,7 +132,7 @@ public function withOpenUnits(float $openUnits): self public function withRtaCode(string $rtaCode): self { $obj = clone $this; - $obj->rtaCode = $rtaCode; + $obj->rta_code = $rtaCode; return $obj; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php index 8006cfa..9de949d 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type gain_alias = array{absolute?: float, percentage?: float} + * @phpstan-type GainShape = array{absolute?: float|null, percentage?: float|null} */ final class Gain implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php index 0ea64d4..2da3426 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php @@ -9,20 +9,20 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type transaction_alias = array{ - * amount?: float, - * balance?: float, - * date?: \DateTimeInterface, - * description?: string, - * dividendRate?: float, - * nav?: float, - * type?: string, - * units?: float, + * @phpstan-type TransactionShape = array{ + * amount?: float|null, + * balance?: float|null, + * date?: \DateTimeInterface|null, + * description?: string|null, + * dividend_rate?: float|null, + * nav?: float|null, + * type?: string|null, + * units?: float|null, * } */ final class Transaction implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -52,8 +52,8 @@ final class Transaction implements BaseModel /** * Dividend rate (for dividend transactions). */ - #[Api('dividend_rate', optional: true)] - public ?float $dividendRate; + #[Api(optional: true)] + public ?float $dividend_rate; /** * NAV on transaction date. @@ -88,7 +88,7 @@ public static function with( ?float $balance = null, ?\DateTimeInterface $date = null, ?string $description = null, - ?float $dividendRate = null, + ?float $dividend_rate = null, ?float $nav = null, ?string $type = null, ?float $units = null, @@ -99,7 +99,7 @@ public static function with( null !== $balance && $obj->balance = $balance; null !== $date && $obj->date = $date; null !== $description && $obj->description = $description; - null !== $dividendRate && $obj->dividendRate = $dividendRate; + null !== $dividend_rate && $obj->dividend_rate = $dividend_rate; null !== $nav && $obj->nav = $nav; null !== $type && $obj->type = $type; null !== $units && $obj->units = $units; @@ -157,7 +157,7 @@ public function withDescription(string $description): self public function withDividendRate(float $dividendRate): self { $obj = clone $this; - $obj->dividendRate = $dividendRate; + $obj->dividend_rate = $dividendRate; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Np.php b/src/CasParser/UnifiedResponse/Np.php new file mode 100644 index 0000000..5bdb79f --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np.php @@ -0,0 +1,164 @@ +|null, + * linked_holders?: list|null, + * pran?: string|null, + * value?: float|null, + * } + */ +final class Np implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional information specific to the NPS account. + */ + #[Api(optional: true)] + public mixed $additional_info; + + /** + * Central Record Keeping Agency name. + */ + #[Api(optional: true)] + public ?string $cra; + + /** @var list|null $funds */ + #[Api(list: Fund::class, optional: true)] + public ?array $funds; + + /** + * List of account holders linked to this NPS account. + * + * @var list|null $linked_holders + */ + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; + + /** + * Permanent Retirement Account Number (PRAN). + */ + #[Api(optional: true)] + public ?string $pran; + + /** + * Total value of the NPS account. + */ + #[Api(optional: true)] + public ?float $value; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list $funds + * @param list $linked_holders + */ + public static function with( + mixed $additional_info = null, + ?string $cra = null, + ?array $funds = null, + ?array $linked_holders = null, + ?string $pran = null, + ?float $value = null, + ): self { + $obj = new self; + + null !== $additional_info && $obj->additional_info = $additional_info; + null !== $cra && $obj->cra = $cra; + null !== $funds && $obj->funds = $funds; + null !== $linked_holders && $obj->linked_holders = $linked_holders; + null !== $pran && $obj->pran = $pran; + null !== $value && $obj->value = $value; + + return $obj; + } + + /** + * Additional information specific to the NPS account. + */ + public function withAdditionalInfo(mixed $additionalInfo): self + { + $obj = clone $this; + $obj->additional_info = $additionalInfo; + + return $obj; + } + + /** + * Central Record Keeping Agency name. + */ + public function withCra(string $cra): self + { + $obj = clone $this; + $obj->cra = $cra; + + return $obj; + } + + /** + * @param list $funds + */ + public function withFunds(array $funds): self + { + $obj = clone $this; + $obj->funds = $funds; + + return $obj; + } + + /** + * List of account holders linked to this NPS account. + * + * @param list $linkedHolders + */ + public function withLinkedHolders(array $linkedHolders): self + { + $obj = clone $this; + $obj->linked_holders = $linkedHolders; + + return $obj; + } + + /** + * Permanent Retirement Account Number (PRAN). + */ + public function withPran(string $pran): self + { + $obj = clone $this; + $obj->pran = $pran; + + return $obj; + } + + /** + * Total value of the NPS account. + */ + public function withValue(float $value): self + { + $obj = clone $this; + $obj->value = $value; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/Np/Fund.php b/src/CasParser/UnifiedResponse/Np/Fund.php new file mode 100644 index 0000000..24351fc --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np/Fund.php @@ -0,0 +1,158 @@ + */ + use SdkModel; + + /** + * Additional information specific to the NPS fund. + */ + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; + + /** + * Cost of investment. + */ + #[Api(optional: true)] + public ?float $cost; + + /** + * Name of the NPS fund. + */ + #[Api(optional: true)] + public ?string $name; + + /** + * Net Asset Value per unit. + */ + #[Api(optional: true)] + public ?float $nav; + + /** + * Number of units held. + */ + #[Api(optional: true)] + public ?float $units; + + /** + * Current market value of the holding. + */ + #[Api(optional: true)] + public ?float $value; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?AdditionalInfo $additional_info = null, + ?float $cost = null, + ?string $name = null, + ?float $nav = null, + ?float $units = null, + ?float $value = null, + ): self { + $obj = new self; + + null !== $additional_info && $obj->additional_info = $additional_info; + null !== $cost && $obj->cost = $cost; + null !== $name && $obj->name = $name; + null !== $nav && $obj->nav = $nav; + null !== $units && $obj->units = $units; + null !== $value && $obj->value = $value; + + return $obj; + } + + /** + * Additional information specific to the NPS fund. + */ + public function withAdditionalInfo(AdditionalInfo $additionalInfo): self + { + $obj = clone $this; + $obj->additional_info = $additionalInfo; + + return $obj; + } + + /** + * Cost of investment. + */ + public function withCost(float $cost): self + { + $obj = clone $this; + $obj->cost = $cost; + + return $obj; + } + + /** + * Name of the NPS fund. + */ + public function withName(string $name): self + { + $obj = clone $this; + $obj->name = $name; + + return $obj; + } + + /** + * Net Asset Value per unit. + */ + public function withNav(float $nav): self + { + $obj = clone $this; + $obj->nav = $nav; + + return $obj; + } + + /** + * Number of units held. + */ + public function withUnits(float $units): self + { + $obj = clone $this; + $obj->units = $units; + + return $obj; + } + + /** + * Current market value of the holding. + */ + public function withValue(float $value): self + { + $obj = clone $this; + $obj->value = $value; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php new file mode 100644 index 0000000..e14ee64 --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Fund manager name. + */ + #[Api(optional: true)] + public ?string $manager; + + /** + * NPS tier (Tier I or Tier II). + */ + #[Api(nullable: true, optional: true)] + public ?float $tier; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?string $manager = null, + ?float $tier = null + ): self { + $obj = new self; + + null !== $manager && $obj->manager = $manager; + null !== $tier && $obj->tier = $tier; + + return $obj; + } + + /** + * Fund manager name. + */ + public function withManager(string $manager): self + { + $obj = clone $this; + $obj->manager = $manager; + + return $obj; + } + + /** + * NPS tier (Tier I or Tier II). + */ + public function withTier(?float $tier): self + { + $obj = clone $this; + $obj->tier = $tier; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php new file mode 100644 index 0000000..ade9223 --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php @@ -0,0 +1,72 @@ + */ + use SdkModel; + + /** + * Name of the account holder. + */ + #[Api(optional: true)] + public ?string $name; + + /** + * PAN of the account holder. + */ + #[Api(optional: true)] + public ?string $pan; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(?string $name = null, ?string $pan = null): self + { + $obj = new self; + + null !== $name && $obj->name = $name; + null !== $pan && $obj->pan = $pan; + + return $obj; + } + + /** + * Name of the account holder. + */ + public function withName(string $name): self + { + $obj = clone $this; + $obj->name = $name; + + return $obj; + } + + /** + * PAN of the account holder. + */ + public function withPan(string $pan): self + { + $obj = clone $this; + $obj->pan = $pan; + + return $obj; + } +} diff --git a/src/CasParser/UnifiedResponse/Summary.php b/src/CasParser/UnifiedResponse/Summary.php index 6b32295..68f5e5f 100644 --- a/src/CasParser/UnifiedResponse/Summary.php +++ b/src/CasParser/UnifiedResponse/Summary.php @@ -10,11 +10,13 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type summary_alias = array{accounts?: Accounts, totalValue?: float} + * @phpstan-type SummaryShape = array{ + * accounts?: Accounts|null, total_value?: float|null + * } */ final class Summary implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] @@ -23,8 +25,8 @@ final class Summary implements BaseModel /** * Total portfolio value across all accounts. */ - #[Api('total_value', optional: true)] - public ?float $totalValue; + #[Api(optional: true)] + public ?float $total_value; public function __construct() { @@ -38,12 +40,12 @@ public function __construct() */ public static function with( ?Accounts $accounts = null, - ?float $totalValue = null + ?float $total_value = null ): self { $obj = new self; null !== $accounts && $obj->accounts = $accounts; - null !== $totalValue && $obj->totalValue = $totalValue; + null !== $total_value && $obj->total_value = $total_value; return $obj; } @@ -62,7 +64,7 @@ public function withAccounts(Accounts $accounts): self public function withTotalValue(float $totalValue): self { $obj = clone $this; - $obj->totalValue = $totalValue; + $obj->total_value = $totalValue; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts.php b/src/CasParser/UnifiedResponse/Summary/Accounts.php index 82b1f21..1663b4e 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts.php @@ -7,18 +7,22 @@ use CasParser\CasParser\UnifiedResponse\Summary\Accounts\Demat; use CasParser\CasParser\UnifiedResponse\Summary\Accounts\Insurance; use CasParser\CasParser\UnifiedResponse\Summary\Accounts\MutualFunds; +use CasParser\CasParser\UnifiedResponse\Summary\Accounts\Nps; use CasParser\Core\Attributes\Api; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type accounts_alias = array{ - * demat?: Demat, insurance?: Insurance, mutualFunds?: MutualFunds + * @phpstan-type AccountsShape = array{ + * demat?: Demat|null, + * insurance?: Insurance|null, + * mutual_funds?: MutualFunds|null, + * nps?: Nps|null, * } */ final class Accounts implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] @@ -27,8 +31,11 @@ final class Accounts implements BaseModel #[Api(optional: true)] public ?Insurance $insurance; - #[Api('mutual_funds', optional: true)] - public ?MutualFunds $mutualFunds; + #[Api(optional: true)] + public ?MutualFunds $mutual_funds; + + #[Api(optional: true)] + public ?Nps $nps; public function __construct() { @@ -43,13 +50,15 @@ public function __construct() public static function with( ?Demat $demat = null, ?Insurance $insurance = null, - ?MutualFunds $mutualFunds = null, + ?MutualFunds $mutual_funds = null, + ?Nps $nps = null, ): self { $obj = new self; null !== $demat && $obj->demat = $demat; null !== $insurance && $obj->insurance = $insurance; - null !== $mutualFunds && $obj->mutualFunds = $mutualFunds; + null !== $mutual_funds && $obj->mutual_funds = $mutual_funds; + null !== $nps && $obj->nps = $nps; return $obj; } @@ -73,7 +82,15 @@ public function withInsurance(Insurance $insurance): self public function withMutualFunds(MutualFunds $mutualFunds): self { $obj = clone $this; - $obj->mutualFunds = $mutualFunds; + $obj->mutual_funds = $mutualFunds; + + return $obj; + } + + public function withNps(Nps $nps): self + { + $obj = clone $this; + $obj->nps = $nps; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php index 50165c2..6aac885 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type demat_alias = array{count?: int, totalValue?: float} + * @phpstan-type DematShape = array{count?: int|null, total_value?: float|null} */ final class Demat implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -25,8 +25,8 @@ final class Demat implements BaseModel /** * Total value of demat accounts. */ - #[Api('total_value', optional: true)] - public ?float $totalValue; + #[Api(optional: true)] + public ?float $total_value; public function __construct() { @@ -40,12 +40,12 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $totalValue = null + ?float $total_value = null ): self { $obj = new self; null !== $count && $obj->count = $count; - null !== $totalValue && $obj->totalValue = $totalValue; + null !== $total_value && $obj->total_value = $total_value; return $obj; } @@ -67,7 +67,7 @@ public function withCount(int $count): self public function withTotalValue(float $totalValue): self { $obj = clone $this; - $obj->totalValue = $totalValue; + $obj->total_value = $totalValue; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php index a14d733..55a4cec 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type insurance_alias = array{count?: int, totalValue?: float} + * @phpstan-type InsuranceShape = array{count?: int|null, total_value?: float|null} */ final class Insurance implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -25,8 +25,8 @@ final class Insurance implements BaseModel /** * Total value of insurance policies. */ - #[Api('total_value', optional: true)] - public ?float $totalValue; + #[Api(optional: true)] + public ?float $total_value; public function __construct() { @@ -40,12 +40,12 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $totalValue = null + ?float $total_value = null ): self { $obj = new self; null !== $count && $obj->count = $count; - null !== $totalValue && $obj->totalValue = $totalValue; + null !== $total_value && $obj->total_value = $total_value; return $obj; } @@ -67,7 +67,7 @@ public function withCount(int $count): self public function withTotalValue(float $totalValue): self { $obj = clone $this; - $obj->totalValue = $totalValue; + $obj->total_value = $totalValue; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php index dc2f0c0..2bd2d57 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php @@ -9,11 +9,13 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type mutual_funds = array{count?: int, totalValue?: float} + * @phpstan-type MutualFundsShape = array{ + * count?: int|null, total_value?: float|null + * } */ final class MutualFunds implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -25,8 +27,8 @@ final class MutualFunds implements BaseModel /** * Total value of mutual funds. */ - #[Api('total_value', optional: true)] - public ?float $totalValue; + #[Api(optional: true)] + public ?float $total_value; public function __construct() { @@ -40,12 +42,12 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $totalValue = null + ?float $total_value = null ): self { $obj = new self; null !== $count && $obj->count = $count; - null !== $totalValue && $obj->totalValue = $totalValue; + null !== $total_value && $obj->total_value = $total_value; return $obj; } @@ -67,7 +69,7 @@ public function withCount(int $count): self public function withTotalValue(float $totalValue): self { $obj = clone $this; - $obj->totalValue = $totalValue; + $obj->total_value = $totalValue; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php new file mode 100644 index 0000000..d1e08d8 --- /dev/null +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php @@ -0,0 +1,74 @@ + */ + use SdkModel; + + /** + * Number of NPS accounts. + */ + #[Api(optional: true)] + public ?int $count; + + /** + * Total value of NPS accounts. + */ + #[Api(optional: true)] + public ?float $total_value; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?int $count = null, + ?float $total_value = null + ): self { + $obj = new self; + + null !== $count && $obj->count = $count; + null !== $total_value && $obj->total_value = $total_value; + + return $obj; + } + + /** + * Number of NPS accounts. + */ + public function withCount(int $count): self + { + $obj = clone $this; + $obj->count = $count; + + return $obj; + } + + /** + * Total value of NPS accounts. + */ + public function withTotalValue(float $totalValue): self + { + $obj = clone $this; + $obj->total_value = $totalValue; + + return $obj; + } +} diff --git a/src/Client.php b/src/Client.php index 947f3cc..d2d2cf6 100644 --- a/src/Client.php +++ b/src/Client.php @@ -28,7 +28,7 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) { $this->apiKey = (string) ($apiKey ?? getenv('CAS_PARSER_API_KEY')); - $base = $baseUrl ?? getenv( + $baseUrl ??= getenv( 'CAS_PARSER_BASE_URL' ) ?: 'https://portfolio-parser.api.casparser.in'; @@ -40,10 +40,20 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) ); parent::__construct( + // x-release-please-start-version headers: [ - 'Content-Type' => 'application/json', 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'User-Agent' => sprintf('CAS Parser/PHP %s', '0.3.0'), + 'X-Stainless-Lang' => 'php', + 'X-Stainless-Package-Version' => '0.3.0', + 'X-Stainless-OS' => $this->getNormalizedOS(), + 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), + 'X-Stainless-Runtime' => 'php', + 'X-Stainless-Runtime-Version' => phpversion(), ], - baseUrl: $base, + // x-release-please-end + baseUrl: $baseUrl, options: $options, ); @@ -51,9 +61,9 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) $this->casGenerator = new CasGeneratorService($this); } - /** @return array */ + /** @return array */ protected function authHeaders(): array { - return ['x-api-key' => $this->apiKey]; + return $this->apiKey ? ['x-api-key' => $this->apiKey] : []; } } diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index cae68a4..973279c 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -24,19 +24,19 @@ * @phpstan-type normalized_request = array{ * method: string, * path: string, - * query: array, - * headers: array>, + * query: array, + * headers: array>, * body: mixed, * } */ -class BaseClient +abstract class BaseClient { protected UriInterface $baseUrl; /** * @internal * - * @param array|null> $headers + * @param array|null> $headers */ public function __construct( protected array $headers, @@ -49,11 +49,11 @@ public function __construct( /** * @param string|list $path - * @param array $query - * @param array $headers + * @param array $query + * @param array $headers * @param class-string> $page * @param class-string> $stream - * @param RequestOptions|array|null $options + * @param RequestOptions|array|null $options */ public function request( string $method, @@ -77,14 +77,11 @@ public function request( // @phpstan-ignore-next-line $rsp = $this->sendRequest($opts, req: $request, data: $body, redirectCount: 0, retryCount: 0); - $decoded = Util::decodeContent($rsp); - if (!is_null($stream)) { return new $stream( convert: $convert, request: $request, - response: $rsp, - stream: $decoded + response: $rsp ); } @@ -93,37 +90,84 @@ public function request( convert: $convert, client: $this, request: $req, + response: $rsp, options: $opts, - data: $decoded, ); } if (!is_null($convert)) { - return Conversion::coerce($convert, value: $decoded); + return Conversion::coerceResponse($convert, response: $rsp); } - return $decoded; + return Util::decodeContent($rsp); } - /** @return array */ - protected function authHeaders(): array + /** @return array */ + abstract protected function authHeaders(): array; + + protected function getNormalizedOS(): string { - return []; + $os = strtolower(PHP_OS_FAMILY); + + switch ($os) { + case 'windows': + return 'Windows'; + + case 'darwin': + return 'MacOS'; + + case 'linux': + return 'Linux'; + + case 'bsd': + case 'freebsd': + case 'openbsd': + return 'BSD'; + + case 'solaris': + return 'Solaris'; + + case 'unix': + case 'unknown': + return 'Unknown'; + + default: + return 'Other:'.$os; + } + } + + protected function getNormalizedArchitecture(): string + { + $arch = php_uname('m'); + if (false !== strpos($arch, 'x86_64') || false !== strpos($arch, 'amd64')) { + return 'x64'; + } + if (false !== strpos($arch, 'i386') || false !== strpos($arch, 'i686')) { + return 'x32'; + } + if (false !== strpos($arch, 'aarch64') || false !== strpos($arch, 'arm64')) { + return 'arm64'; + } + if (false !== strpos($arch, 'arm')) { + return 'arm'; + } + + return 'unknown'; } /** * @internal * * @param string|list $path - * @param array $query - * @param array|null> $headers + * @param array $query + * @param array|null> $headers * @param array{ * timeout?: float|null, * maxRetries?: int|null, * initialRetryDelay?: float|null, * maxRetryDelay?: float|null, - * extraHeaders?: array|null>|null, - * extraQueryParams?: array|null, + * extraHeaders?: array|null>|null, + * extraQueryParams?: array|null, * extraBodyParams?: mixed, * transporter?: ClientInterface|null, * uriFactory?: UriFactoryInterface|null, @@ -145,14 +189,14 @@ protected function buildRequest( $parsedPath = Util::parsePath($path); - /** @var array $mergedQuery */ + /** @var array $mergedQuery */ $mergedQuery = array_merge_recursive( $query, $options->extraQueryParams ?? [], ); $uri = Util::joinUri($this->baseUrl, path: $parsedPath, query: $mergedQuery)->__toString(); - /** @var array|null> $mergedHeaders */ + /** @var array|null> $mergedHeaders */ $mergedHeaders = [...$this->headers, ...$this->authHeaders(), ...$headers, @@ -232,8 +276,7 @@ protected function retryDelay( /** * @internal * - * @param bool|int|float|string|resource|\Traversable|array|null $data + * @param bool|int|float|string|resource|\Traversable|array|null $data */ protected function sendRequest( RequestOptions $opts, @@ -244,6 +287,8 @@ protected function sendRequest( ): ResponseInterface { assert(null !== $opts->streamFactory && null !== $opts->transporter); + $req = $req->withHeader('X-Stainless-Retry-Count', strval($retryCount)); + $req = Util::withSetBody($opts->streamFactory, req: $req, body: $data); $rsp = null; @@ -270,7 +315,7 @@ protected function sendRequest( } if ($code >= 400 || is_null($rsp)) { - if ($this->shouldRetry($opts, retryCount: $retryCount, rsp: $rsp)) { + if (!$this->shouldRetry($opts, retryCount: $retryCount, rsp: $rsp)) { $exn = is_null($rsp) ? new APIConnectionException($req, previous: $err) : APIStatusException::from(request: $req, response: $rsp); throw $exn; diff --git a/src/Core/Concerns/SdkModel.php b/src/Core/Concerns/SdkModel.php index 27f095b..3f0e929 100644 --- a/src/Core/Concerns/SdkModel.php +++ b/src/Core/Concerns/SdkModel.php @@ -32,9 +32,9 @@ trait SdkModel */ public function __serialize(): array { - $rows = [...Util::get_object_vars($this), ...$this->_data]; // @phpstan-ignore-line + $properties = $this->toProperties(); // @phpstan-ignore-line - return array_map(static fn ($v) => self::serialize($v), array: $rows); + return array_map(static fn ($v) => self::serialize($v), array: $properties); } /** @@ -98,11 +98,13 @@ public function __get(string $key): mixed } /** + * @internal + * * @return Shape */ - public function toArray(): array + public function toProperties(): array { - return $this->__serialize(); // @phpstan-ignore-line + return [...Util::get_object_vars($this), ...$this->_data]; // @phpstan-ignore-line } /** @@ -257,7 +259,7 @@ private function initialize(): void private static function serialize(mixed $value): mixed { if ($value instanceof BaseModel) { - return $value->toArray(); + return $value->toProperties(); } if (is_array($value)) { diff --git a/src/Core/Concerns/SdkResponse.php b/src/Core/Concerns/SdkResponse.php new file mode 100644 index 0000000..95bf61f --- /dev/null +++ b/src/Core/Concerns/SdkResponse.php @@ -0,0 +1,29 @@ +_rawResponse = $response; + $instance->__unserialize(Util::decodeContent($response)); // @phpstan-ignore-line + + return $instance; + } + + public function getRawResponse(): ?ResponseInterface + { + return $this->_rawResponse; + } +} diff --git a/src/Core/Contracts/BaseModel.php b/src/Core/Contracts/BaseModel.php index a6b38d2..1938411 100644 --- a/src/Core/Contracts/BaseModel.php +++ b/src/Core/Contracts/BaseModel.php @@ -14,5 +14,5 @@ interface BaseModel extends \ArrayAccess, \JsonSerializable, \Stringable, ConverterSource { /** @return array */ - public function toArray(): array; + public function toProperties(): array; } diff --git a/src/Core/Contracts/BasePage.php b/src/Core/Contracts/BasePage.php index 40eecd6..c997b93 100644 --- a/src/Core/Contracts/BasePage.php +++ b/src/Core/Contracts/BasePage.php @@ -8,6 +8,7 @@ use CasParser\Core\Conversion\Contracts\Converter; use CasParser\Core\Conversion\Contracts\ConverterSource; use CasParser\RequestOptions; +use Psr\Http\Message\ResponseInterface; /** * @internal @@ -30,7 +31,7 @@ public function __construct( Client $client, array $request, RequestOptions $options, - mixed $data, + ResponseInterface $response, ); public function hasNextPage(): bool; diff --git a/src/Core/Contracts/BaseStream.php b/src/Core/Contracts/BaseStream.php index 26a9dd7..dd75235 100644 --- a/src/Core/Contracts/BaseStream.php +++ b/src/Core/Contracts/BaseStream.php @@ -18,14 +18,10 @@ */ interface BaseStream extends \IteratorAggregate { - /** - * @param \Generator $stream - */ public function __construct( Converter|ConverterSource|string $convert, RequestInterface $request, ResponseInterface $response, - \Generator $stream, ); /** diff --git a/src/Core/Conversion.php b/src/Core/Conversion.php index e8c605e..697b753 100644 --- a/src/Core/Conversion.php +++ b/src/Core/Conversion.php @@ -7,8 +7,13 @@ use CasParser\Core\Conversion\CoerceState; use CasParser\Core\Conversion\Contracts\Converter; use CasParser\Core\Conversion\Contracts\ConverterSource; +use CasParser\Core\Conversion\Contracts\ResponseConverter; use CasParser\Core\Conversion\DumpState; +use Psr\Http\Message\ResponseInterface; +/** + * @internal + */ final class Conversion { public static function dump_unknown(mixed $value, DumpState $state): mixed @@ -38,6 +43,15 @@ public static function dump_unknown(mixed $value, DumpState $state): mixed return $value; } + public static function coerceResponse(Converter|ConverterSource|string $target, ResponseInterface $response): mixed + { + if (is_a($target, ResponseConverter::class, allow_string: true)) { + return $target::fromResponse($response); + } + + return self::coerce($target, Util::decodeContent($response)); + } + public static function coerce(Converter|ConverterSource|string $target, mixed $value, CoerceState $state = new CoerceState): mixed { if ($value instanceof $target) { diff --git a/src/Core/Conversion/Contracts/ResponseConverter.php b/src/Core/Conversion/Contracts/ResponseConverter.php new file mode 100644 index 0000000..69ad591 --- /dev/null +++ b/src/Core/Conversion/Contracts/ResponseConverter.php @@ -0,0 +1,18 @@ +toArray(); + $value = $value->toProperties(); } if (is_array($value)) { diff --git a/src/Core/Implementation/HasRawResponse.php b/src/Core/Implementation/HasRawResponse.php deleted file mode 100644 index d3ffd67..0000000 --- a/src/Core/Implementation/HasRawResponse.php +++ /dev/null @@ -1,10 +0,0 @@ - + * @return array */ - public static function get_object_vars(object $object1): array + public static function get_object_vars(object $object): array { - return get_object_vars($object1); + return get_object_vars($object); } /** * @template T * - * @param array $array - * @param array $map + * @param array $array + * @param array $map * - * @return array + * @return array */ public static function array_transform_keys(array $array, array $map): array { @@ -52,9 +52,9 @@ public static function array_transform_keys(array $array, array $map): array } /** - * @param array $arr + * @param array $arr * - * @return array + * @return array */ public static function array_filter_omit(array $arr): array { @@ -106,7 +106,7 @@ public static function parsePath(string|array $path): string } /** - * @param array $query + * @param array $query */ public static function joinUri( UriInterface $base, @@ -141,7 +141,7 @@ public static function joinUri( } /** - * @param array|null> $headers + * @param array|null> $headers */ public static function withSetHeaders( RequestInterface $req, @@ -182,8 +182,7 @@ public static function streamIterator(StreamInterface $stream): \Iterator } /** - * @param bool|int|float|string|resource|\Traversable|array|null $body + * @param bool|int|float|string|resource|\Traversable|array|null $body */ public static function withSetBody( StreamFactoryInterface $factory, @@ -409,8 +408,7 @@ private static function writeMultipartChunk( } /** - * @param bool|int|float|string|resource|\Traversable|array|null $body + * @param bool|int|float|string|resource|\Traversable|array|null $body * * @return array{string, \Generator} */ diff --git a/src/RequestOptions.php b/src/RequestOptions.php index 03ece1a..e8066fc 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -21,8 +21,8 @@ * maxRetries?: int|null, * initialRetryDelay?: float|null, * maxRetryDelay?: float|null, - * extraHeaders?: array>|null, - * extraQueryParams?: array|null, + * extraHeaders?: array>|null, + * extraQueryParams?: array|null, * extraBodyParams?: mixed, * transporter?: ClientInterface|null, * uriFactory?: UriFactoryInterface|null, @@ -48,11 +48,11 @@ final class RequestOptions implements BaseModel #[Property] public float $maxRetryDelay = 8.0; - /** @var array|null>|null $extraHeaders */ + /** @var array|null>|null $extraHeaders */ #[Property(optional: true)] public ?array $extraHeaders; - /** @var array|null $extraQueryParams */ + /** @var array|null $extraQueryParams */ #[Property(optional: true)] public ?array $extraQueryParams; @@ -81,14 +81,14 @@ public function __construct() */ public static function parse(RequestOptions|array|null ...$options): self { - $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toArray() : $o ?? [], array: $options); + $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toProperties() : $o ?? [], array: $options); return self::with(...array_merge(...$parsed)); // @phpstan-ignore-line } /** - * @param array|null>|null $extraHeaders - * @param array|null $extraQueryParams + * @param array|null>|null $extraHeaders + * @param array|null $extraQueryParams * @param mixed|Omit $extraBodyParams */ public static function with( @@ -154,7 +154,7 @@ public function withMaxRetryDelay(float $maxRetryDelay): self } /** - * @param array|null> $extraHeaders + * @param array|null> $extraHeaders */ public function withExtraHeaders(array $extraHeaders): self { @@ -165,7 +165,7 @@ public function withExtraHeaders(array $extraHeaders): self } /** - * @param array $extraQueryParams + * @param array $extraQueryParams */ public function withExtraQueryParams(array $extraQueryParams): self { diff --git a/src/ServiceContracts/CasGeneratorContract.php b/src/ServiceContracts/CasGeneratorContract.php index 240aad8..f20cc7d 100644 --- a/src/ServiceContracts/CasGeneratorContract.php +++ b/src/ServiceContracts/CasGeneratorContract.php @@ -4,51 +4,22 @@ namespace CasParser\ServiceContracts; -use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority; +use CasParser\CasGenerator\CasGeneratorGenerateCasParams; use CasParser\CasGenerator\CasGeneratorGenerateCasResponse; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; -use const CasParser\Core\OMIT as omit; - interface CasGeneratorContract { /** * @api * - * @param string $email Email address to receive the CAS document - * @param string $fromDate Start date for the CAS period (format YYYY-MM-DD) - * @param string $password Password to protect the generated CAS PDF - * @param string $toDate End date for the CAS period (format YYYY-MM-DD) - * @param CasAuthority|value-of $casAuthority CAS authority to generate the document from (currently only kfintech is supported) - * @param string $panNo PAN number (optional for some CAS authorities) - * - * @return CasGeneratorGenerateCasResponse + * @param array|CasGeneratorGenerateCasParams $params * * @throws APIException */ public function generateCas( - $email, - $fromDate, - $password, - $toDate, - $casAuthority = omit, - $panNo = omit, + array|CasGeneratorGenerateCasParams $params, ?RequestOptions $requestOptions = null, ): CasGeneratorGenerateCasResponse; - - /** - * @api - * - * @param array $params - * - * @return CasGeneratorGenerateCasResponse - * - * @throws APIException - */ - public function generateCasRaw( - array $params, - ?RequestOptions $requestOptions = null - ): CasGeneratorGenerateCasResponse; } diff --git a/src/ServiceContracts/CasParserContract.php b/src/ServiceContracts/CasParserContract.php index c21836f..2c02ea7 100644 --- a/src/ServiceContracts/CasParserContract.php +++ b/src/ServiceContracts/CasParserContract.php @@ -4,140 +4,61 @@ namespace CasParser\ServiceContracts; +use CasParser\CasParser\CasParserCamsKfintechParams; +use CasParser\CasParser\CasParserCdslParams; +use CasParser\CasParser\CasParserNsdlParams; +use CasParser\CasParser\CasParserSmartParseParams; use CasParser\CasParser\UnifiedResponse; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; -use const CasParser\Core\OMIT as omit; - interface CasParserContract { /** * @api * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array|CasParserCamsKfintechParams $params * * @throws APIException */ public function camsKfintech( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserCamsKfintechParams $params, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function camsKfintechRaw( - array $params, - ?RequestOptions $requestOptions = null - ): UnifiedResponse; - - /** - * @api - * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array|CasParserCdslParams $params * * @throws APIException */ public function cdsl( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserCdslParams $params, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function cdslRaw( - array $params, - ?RequestOptions $requestOptions = null - ): UnifiedResponse; - - /** - * @api - * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array|CasParserNsdlParams $params * * @throws APIException */ public function nsdl( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserNsdlParams $params, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function nsdlRaw( - array $params, - ?RequestOptions $requestOptions = null - ): UnifiedResponse; - - /** - * @api - * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array|CasParserSmartParseParams $params * * @throws APIException */ public function smartParse( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserSmartParseParams $params, ?RequestOptions $requestOptions = null, ): UnifiedResponse; - - /** - * @api - * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function smartParseRaw( - array $params, - ?RequestOptions $requestOptions = null - ): UnifiedResponse; } diff --git a/src/Services/CasGeneratorService.php b/src/Services/CasGeneratorService.php index c7d2e8e..6392643 100644 --- a/src/Services/CasGeneratorService.php +++ b/src/Services/CasGeneratorService.php @@ -5,16 +5,12 @@ namespace CasParser\Services; use CasParser\CasGenerator\CasGeneratorGenerateCasParams; -use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority; use CasParser\CasGenerator\CasGeneratorGenerateCasResponse; use CasParser\Client; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasGeneratorContract; -use const CasParser\Core\OMIT as omit; - final class CasGeneratorService implements CasGeneratorContract { /** @@ -28,54 +24,24 @@ public function __construct(private Client $client) {} * 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. * - * @param string $email Email address to receive the CAS document - * @param string $fromDate Start date for the CAS period (format YYYY-MM-DD) - * @param string $password Password to protect the generated CAS PDF - * @param string $toDate End date for the CAS period (format YYYY-MM-DD) - * @param CasAuthority|value-of $casAuthority CAS authority to generate the document from (currently only kfintech is supported) - * @param string $panNo PAN number (optional for some CAS authorities) - * - * @return CasGeneratorGenerateCasResponse + * @param array{ + * email: string, + * from_date: string, + * password: string, + * to_date: string, + * cas_authority?: "kfintech"|"cams"|"cdsl"|"nsdl", + * pan_no?: string, + * }|CasGeneratorGenerateCasParams $params * * @throws APIException */ public function generateCas( - $email, - $fromDate, - $password, - $toDate, - $casAuthority = omit, - $panNo = omit, + array|CasGeneratorGenerateCasParams $params, ?RequestOptions $requestOptions = null, - ): CasGeneratorGenerateCasResponse { - $params = [ - 'email' => $email, - 'fromDate' => $fromDate, - 'password' => $password, - 'toDate' => $toDate, - 'casAuthority' => $casAuthority, - 'panNo' => $panNo, - ]; - - return $this->generateCasRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return CasGeneratorGenerateCasResponse - * - * @throws APIException - */ - public function generateCasRaw( - array $params, - ?RequestOptions $requestOptions = null ): CasGeneratorGenerateCasResponse { [$parsed, $options] = CasGeneratorGenerateCasParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; diff --git a/src/Services/CasParserService.php b/src/Services/CasParserService.php index 8c2adff..9915576 100644 --- a/src/Services/CasParserService.php +++ b/src/Services/CasParserService.php @@ -11,12 +11,9 @@ use CasParser\CasParser\UnifiedResponse; use CasParser\Client; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasParserContract; -use const CasParser\Core\OMIT as omit; - final class CasParserService implements CasParserContract { /** @@ -30,43 +27,19 @@ public function __construct(private Client $client) {} * 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. * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array{ + * password?: string, pdf_file?: string, pdf_url?: string + * }|CasParserCamsKfintechParams $params * * @throws APIException */ public function camsKfintech( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserCamsKfintechParams $params, ?RequestOptions $requestOptions = null, - ): UnifiedResponse { - $params = [ - 'password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL, - ]; - - return $this->camsKfintechRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function camsKfintechRaw( - array $params, - ?RequestOptions $requestOptions = null ): UnifiedResponse { [$parsed, $options] = CasParserCamsKfintechParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -85,43 +58,19 @@ public function camsKfintechRaw( * 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. * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array{ + * password?: string, pdf_file?: string, pdf_url?: string + * }|CasParserCdslParams $params * * @throws APIException */ public function cdsl( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, - ?RequestOptions $requestOptions = null, - ): UnifiedResponse { - $params = [ - 'password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL, - ]; - - return $this->cdslRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function cdslRaw( - array $params, + array|CasParserCdslParams $params, ?RequestOptions $requestOptions = null ): UnifiedResponse { [$parsed, $options] = CasParserCdslParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -140,43 +89,19 @@ public function cdslRaw( * 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. * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array{ + * password?: string, pdf_file?: string, pdf_url?: string + * }|CasParserNsdlParams $params * * @throws APIException */ public function nsdl( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, - ?RequestOptions $requestOptions = null, - ): UnifiedResponse { - $params = [ - 'password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL, - ]; - - return $this->nsdlRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function nsdlRaw( - array $params, + array|CasParserNsdlParams $params, ?RequestOptions $requestOptions = null ): UnifiedResponse { [$parsed, $options] = CasParserNsdlParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -195,43 +120,19 @@ public function nsdlRaw( * 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. * - * @param string $password Password for the PDF file (if required) - * @param string $pdfFile Base64 encoded CAS PDF file - * @param string $pdfURL URL to the CAS PDF file - * - * @return UnifiedResponse + * @param array{ + * password?: string, pdf_file?: string, pdf_url?: string + * }|CasParserSmartParseParams $params * * @throws APIException */ public function smartParse( - $password = omit, - $pdfFile = omit, - $pdfURL = omit, + array|CasParserSmartParseParams $params, ?RequestOptions $requestOptions = null, - ): UnifiedResponse { - $params = [ - 'password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL, - ]; - - return $this->smartParseRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return UnifiedResponse - * - * @throws APIException - */ - public function smartParseRaw( - array $params, - ?RequestOptions $requestOptions = null ): UnifiedResponse { [$parsed, $options] = CasParserSmartParseParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; diff --git a/tests/Services/CasGeneratorTest.php b/tests/Services/CasGeneratorTest.php index ac566d8..58aa931 100644 --- a/tests/Services/CasGeneratorTest.php +++ b/tests/Services/CasGeneratorTest.php @@ -33,12 +33,12 @@ public function testGenerateCas(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casGenerator->generateCas( - email: 'user@example.com', - fromDate: '2023-01-01', - password: 'Abcdefghi12$', - toDate: '2023-12-31', - ); + $result = $this->client->casGenerator->generateCas([ + 'email' => 'user@example.com', + 'from_date' => '2023-01-01', + 'password' => 'Abcdefghi12$', + 'to_date' => '2023-12-31', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -50,12 +50,12 @@ public function testGenerateCasWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casGenerator->generateCas( - email: 'user@example.com', - fromDate: '2023-01-01', - password: 'Abcdefghi12$', - toDate: '2023-12-31', - ); + $result = $this->client->casGenerator->generateCas([ + 'email' => 'user@example.com', + 'from_date' => '2023-01-01', + 'password' => 'Abcdefghi12$', + 'to_date' => '2023-12-31', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } diff --git a/tests/Services/CasParserTest.php b/tests/Services/CasParserTest.php index 17f3bb6..7b66bf4 100644 --- a/tests/Services/CasParserTest.php +++ b/tests/Services/CasParserTest.php @@ -33,7 +33,7 @@ public function testCamsKfintech(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casParser->camsKfintech(); + $result = $this->client->casParser->camsKfintech([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -45,7 +45,7 @@ public function testCdsl(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casParser->cdsl(); + $result = $this->client->casParser->cdsl([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -57,7 +57,7 @@ public function testNsdl(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casParser->nsdl(); + $result = $this->client->casParser->nsdl([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -69,7 +69,7 @@ public function testSmartParse(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casParser->smartParse(); + $result = $this->client->casParser->smartParse([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType }