From da8b83821dab28680f72e98a943af25df296e314 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 00:18:53 +0000 Subject: [PATCH 01/15] feat(api): api update --- .stats.yml | 4 +- src/CasParser/UnifiedResponse.php | 26 +++ .../UnifiedResponse/DematAccount.php | 26 +++ .../DematAccount/LinkedHolder.php | 72 ++++++++ src/CasParser/UnifiedResponse/MutualFund.php | 26 +++ .../MutualFund/LinkedHolder.php | 72 ++++++++ src/CasParser/UnifiedResponse/Np.php | 164 ++++++++++++++++++ src/CasParser/UnifiedResponse/Np/Fund.php | 158 +++++++++++++++++ .../Np/Fund/AdditionalInfo.php | 76 ++++++++ .../UnifiedResponse/Np/LinkedHolder.php | 72 ++++++++ .../UnifiedResponse/Summary/Accounts.php | 16 +- .../UnifiedResponse/Summary/Accounts/Nps.php | 74 ++++++++ 12 files changed, 783 insertions(+), 3 deletions(-) create mode 100644 src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php create mode 100644 src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php create mode 100644 src/CasParser/UnifiedResponse/Np.php create mode 100644 src/CasParser/UnifiedResponse/Np/Fund.php create mode 100644 src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/Np/LinkedHolder.php create mode 100644 src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php 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/src/CasParser/UnifiedResponse.php b/src/CasParser/UnifiedResponse.php index 0eda57c..b620ac4 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -9,6 +9,7 @@ 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; @@ -21,6 +22,7 @@ * investor?: Investor, * meta?: Meta, * mutualFunds?: list, + * nps?: list, * summary?: Summary, * } * When used in a response, this type parameter can define a $rawResponse property. @@ -50,6 +52,14 @@ final class UnifiedResponse implements BaseModel #[Api('mutual_funds', list: MutualFund::class, optional: true)] public ?array $mutualFunds; + /** + * List of NPS accounts. + * + * @var list|null $nps + */ + #[Api(list: Np::class, optional: true)] + public ?array $nps; + #[Api(optional: true)] public ?Summary $summary; @@ -65,6 +75,7 @@ public function __construct() * * @param list $dematAccounts * @param list $mutualFunds + * @param list $nps */ public static function with( ?array $dematAccounts = null, @@ -72,6 +83,7 @@ public static function with( ?Investor $investor = null, ?Meta $meta = null, ?array $mutualFunds = null, + ?array $nps = null, ?Summary $summary = null, ): self { $obj = new self; @@ -81,6 +93,7 @@ public static function with( null !== $investor && $obj->investor = $investor; null !== $meta && $obj->meta = $meta; null !== $mutualFunds && $obj->mutualFunds = $mutualFunds; + null !== $nps && $obj->nps = $nps; null !== $summary && $obj->summary = $summary; return $obj; @@ -132,6 +145,19 @@ public function withMutualFunds(array $mutualFunds): self return $obj; } + /** + * List of NPS accounts. + * + * @param list $nps + */ + public function withNps(array $nps): self + { + $obj = clone $this; + $obj->nps = $nps; + + return $obj; + } + public function withSummary(Summary $summary): self { $obj = clone $this; diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index 0c57e41..62eb715 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -7,6 +7,7 @@ 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; @@ -20,6 +21,7 @@ * dpID?: string, * dpName?: string, * holdings?: Holdings, + * linkedHolders?: list, * value?: float, * } */ @@ -69,6 +71,14 @@ final class DematAccount implements BaseModel #[Api(optional: true)] public ?Holdings $holdings; + /** + * List of account holders linked to this demat account. + * + * @var list|null $linkedHolders + */ + #[Api('linked_holders', list: LinkedHolder::class, optional: true)] + public ?array $linkedHolders; + /** * Total value of the demat account. */ @@ -86,6 +96,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param DematType|value-of $dematType + * @param list $linkedHolders */ public static function with( ?AdditionalInfo $additionalInfo = null, @@ -95,6 +106,7 @@ public static function with( ?string $dpID = null, ?string $dpName = null, ?Holdings $holdings = null, + ?array $linkedHolders = null, ?float $value = null, ): self { $obj = new self; @@ -106,6 +118,7 @@ public static function with( null !== $dpID && $obj->dpID = $dpID; null !== $dpName && $obj->dpName = $dpName; null !== $holdings && $obj->holdings = $holdings; + null !== $linkedHolders && $obj->linkedHolders = $linkedHolders; null !== $value && $obj->value = $value; 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->linkedHolders = $linkedHolders; + + return $obj; + } + /** * Total value of the demat account. */ diff --git a/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php new file mode 100644 index 0000000..7d1b2b6 --- /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/MutualFund.php b/src/CasParser/UnifiedResponse/MutualFund.php index 2f1da0c..9b1ea68 100644 --- a/src/CasParser/UnifiedResponse/MutualFund.php +++ b/src/CasParser/UnifiedResponse/MutualFund.php @@ -5,6 +5,7 @@ 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; @@ -15,6 +16,7 @@ * additionalInfo?: AdditionalInfo, * amc?: string, * folioNumber?: string, + * linkedHolders?: list, * registrar?: string, * schemes?: list, * value?: float, @@ -43,6 +45,14 @@ final class MutualFund implements BaseModel #[Api('folio_number', optional: true)] public ?string $folioNumber; + /** + * List of account holders linked to this mutual fund folio. + * + * @var list|null $linkedHolders + */ + #[Api('linked_holders', list: LinkedHolder::class, optional: true)] + public ?array $linkedHolders; + /** * Registrar and Transfer Agent name. */ @@ -69,12 +79,14 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param list $linkedHolders * @param list $schemes */ public static function with( ?AdditionalInfo $additionalInfo = null, ?string $amc = null, ?string $folioNumber = null, + ?array $linkedHolders = null, ?string $registrar = null, ?array $schemes = null, ?float $value = null, @@ -84,6 +96,7 @@ public static function with( null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; null !== $amc && $obj->amc = $amc; null !== $folioNumber && $obj->folioNumber = $folioNumber; + null !== $linkedHolders && $obj->linkedHolders = $linkedHolders; null !== $registrar && $obj->registrar = $registrar; null !== $schemes && $obj->schemes = $schemes; null !== $value && $obj->value = $value; @@ -124,6 +137,19 @@ public function withFolioNumber(string $folioNumber): self 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->linkedHolders = $linkedHolders; + + return $obj; + } + /** * Registrar and Transfer Agent name. */ diff --git a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php new file mode 100644 index 0000000..dbab7bb --- /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/Np.php b/src/CasParser/UnifiedResponse/Np.php new file mode 100644 index 0000000..32bb8f5 --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np.php @@ -0,0 +1,164 @@ +, + * linkedHolders?: list, + * pran?: string, + * value?: float, + * } + */ +final class Np implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional information specific to the NPS account. + */ + #[Api('additional_info', optional: true)] + public mixed $additionalInfo; + + /** + * 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 $linkedHolders + */ + #[Api('linked_holders', list: LinkedHolder::class, optional: true)] + public ?array $linkedHolders; + + /** + * 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 $linkedHolders + */ + public static function with( + mixed $additionalInfo = null, + ?string $cra = null, + ?array $funds = null, + ?array $linkedHolders = null, + ?string $pran = null, + ?float $value = null, + ): self { + $obj = new self; + + null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $cra && $obj->cra = $cra; + null !== $funds && $obj->funds = $funds; + null !== $linkedHolders && $obj->linkedHolders = $linkedHolders; + 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->additionalInfo = $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->linkedHolders = $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..9aad9fa --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np/Fund.php @@ -0,0 +1,158 @@ + */ + use SdkModel; + + /** + * Additional information specific to the NPS fund. + */ + #[Api('additional_info', optional: true)] + public ?AdditionalInfo $additionalInfo; + + /** + * 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 $additionalInfo = null, + ?float $cost = null, + ?string $name = null, + ?float $nav = null, + ?float $units = null, + ?float $value = null, + ): self { + $obj = new self; + + null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + 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->additionalInfo = $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..1c6a52b --- /dev/null +++ b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php @@ -0,0 +1,76 @@ + */ + 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..6f2b941 --- /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/Accounts.php b/src/CasParser/UnifiedResponse/Summary/Accounts.php index 82b1f21..02c1e54 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts.php @@ -7,13 +7,14 @@ 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 + * demat?: Demat, insurance?: Insurance, mutualFunds?: MutualFunds, nps?: Nps * } */ final class Accounts implements BaseModel @@ -30,6 +31,9 @@ final class Accounts implements BaseModel #[Api('mutual_funds', optional: true)] public ?MutualFunds $mutualFunds; + #[Api(optional: true)] + public ?Nps $nps; + public function __construct() { $this->initialize(); @@ -44,12 +48,14 @@ public static function with( ?Demat $demat = null, ?Insurance $insurance = null, ?MutualFunds $mutualFunds = null, + ?Nps $nps = null, ): self { $obj = new self; null !== $demat && $obj->demat = $demat; null !== $insurance && $obj->insurance = $insurance; null !== $mutualFunds && $obj->mutualFunds = $mutualFunds; + null !== $nps && $obj->nps = $nps; return $obj; } @@ -77,4 +83,12 @@ public function withMutualFunds(MutualFunds $mutualFunds): self return $obj; } + + public function withNps(Nps $nps): self + { + $obj = clone $this; + $obj->nps = $nps; + + 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..e2cb548 --- /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('total_value', optional: true)] + public ?float $totalValue; + + 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 $totalValue = null + ): self { + $obj = new self; + + null !== $count && $obj->count = $count; + null !== $totalValue && $obj->totalValue = $totalValue; + + 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->totalValue = $totalValue; + + return $obj; + } +} From f992e921cd7043ea562ad58fb01905bd2039fa50 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 02:24:47 +0000 Subject: [PATCH 02/15] chore(docs): update readme formatting --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 75f8882..c30e278 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,6 @@ use CasParser\RequestOptions; $client = new Client(maxRetries: 0); // Or, configure per-request: - $result = $client->casParser->smartParse( requestOptions: RequestOptions::with(maxRetries: 5) ); From e25fa02ca0d7d49d88f1859c99e2db925a74e722 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 4 Oct 2025 02:14:34 +0000 Subject: [PATCH 03/15] chore: refactor methods --- scripts/lint | 2 +- .../CasGeneratorGenerateCasParams.php | 4 +-- .../CasGeneratorGenerateCasResponse.php | 10 +++---- src/CasParser/UnifiedResponse.php | 10 +++---- .../UnifiedResponse/DematAccount.php | 4 +-- src/CasParser/UnifiedResponse/Meta.php | 4 +-- .../UnifiedResponse/MutualFund/Scheme.php | 4 +-- src/Client.php | 4 +-- src/Core/BaseClient.php | 18 ++++-------- src/Core/Concerns/SdkResponse.php | 29 +++++++++++++++++++ src/Core/Contracts/BasePage.php | 3 +- src/Core/Contracts/BaseStream.php | 4 --- src/Core/Conversion.php | 14 +++++++++ .../Contracts/ResponseConverter.php | 18 ++++++++++++ src/Core/Implementation/HasRawResponse.php | 10 ------- src/ServiceContracts/CasGeneratorContract.php | 5 ---- src/ServiceContracts/CasParserContract.php | 17 ----------- src/Services/CasGeneratorService.php | 5 ---- src/Services/CasParserService.php | 17 ----------- 19 files changed, 90 insertions(+), 92 deletions(-) create mode 100644 src/Core/Concerns/SdkResponse.php create mode 100644 src/Core/Conversion/Contracts/ResponseConverter.php delete mode 100644 src/Core/Implementation/HasRawResponse.php 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..bd9e669 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -127,7 +127,7 @@ public static function with( $obj->password = $password; $obj->toDate = $toDate; - null !== $casAuthority && $obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority; + null !== $casAuthority && $obj['casAuthority'] = $casAuthority; null !== $panNo && $obj->panNo = $panNo; return $obj; @@ -185,7 +185,7 @@ public function withToDate(string $toDate): self public function withCasAuthority(CasAuthority|string $casAuthority): self { $obj = clone $this; - $obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority; + $obj['casAuthority'] = $casAuthority; return $obj; } diff --git a/src/CasGenerator/CasGeneratorGenerateCasResponse.php b/src/CasGenerator/CasGeneratorGenerateCasResponse.php index 86298f8..fbfc3b8 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 * } - * 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 SdkResponse; + #[Api(optional: true)] public ?string $msg; diff --git a/src/CasParser/UnifiedResponse.php b/src/CasParser/UnifiedResponse.php index b620ac4..b90393e 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -13,7 +13,9 @@ 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{ @@ -25,16 +27,14 @@ * nps?: list, * summary?: Summary, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class UnifiedResponse implements BaseModel +final class UnifiedResponse implements BaseModel, ResponseConverter { /** @use SdkModel */ use SdkModel; + use SdkResponse; + /** @var list|null $dematAccounts */ #[Api('demat_accounts', list: DematAccount::class, optional: true)] public ?array $dematAccounts; diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index 62eb715..2c51ed7 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -114,7 +114,7 @@ public static function with( null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; null !== $boID && $obj->boID = $boID; null !== $clientID && $obj->clientID = $clientID; - null !== $dematType && $obj->dematType = $dematType instanceof DematType ? $dematType->value : $dematType; + null !== $dematType && $obj['dematType'] = $dematType; null !== $dpID && $obj->dpID = $dpID; null !== $dpName && $obj->dpName = $dpName; null !== $holdings && $obj->holdings = $holdings; @@ -165,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['dematType'] = $dematType; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Meta.php b/src/CasParser/UnifiedResponse/Meta.php index 7f55cb7..ceacd10 100644 --- a/src/CasParser/UnifiedResponse/Meta.php +++ b/src/CasParser/UnifiedResponse/Meta.php @@ -58,7 +58,7 @@ public static function with( ): self { $obj = new self; - null !== $casType && $obj->casType = $casType instanceof CasType ? $casType->value : $casType; + null !== $casType && $obj['casType'] = $casType; null !== $generatedAt && $obj->generatedAt = $generatedAt; null !== $statementPeriod && $obj->statementPeriod = $statementPeriod; @@ -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['casType'] = $casType; return $obj; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php index 8775dbb..2b48637 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php @@ -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; @@ -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/Client.php b/src/Client.php index 947f3cc..b576691 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'; @@ -43,7 +43,7 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) headers: [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], - baseUrl: $base, + baseUrl: $baseUrl, options: $options, ); diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index cae68a4..eab6b98 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -29,7 +29,7 @@ * body: mixed, * } */ -class BaseClient +abstract class BaseClient { protected UriInterface $baseUrl; @@ -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,23 +90,20 @@ 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 []; - } + abstract protected function authHeaders(): array; /** * @internal 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/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 @@ + $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 - * * @throws APIException */ public function generateCas( @@ -43,8 +40,6 @@ public function generateCas( * * @param array $params * - * @return CasGeneratorGenerateCasResponse - * * @throws APIException */ public function generateCasRaw( diff --git a/src/ServiceContracts/CasParserContract.php b/src/ServiceContracts/CasParserContract.php index c21836f..977b15d 100644 --- a/src/ServiceContracts/CasParserContract.php +++ b/src/ServiceContracts/CasParserContract.php @@ -6,7 +6,6 @@ use CasParser\CasParser\UnifiedResponse; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; use const CasParser\Core\OMIT as omit; @@ -20,8 +19,6 @@ interface CasParserContract * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function camsKfintech( @@ -36,8 +33,6 @@ public function camsKfintech( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function camsKfintechRaw( @@ -52,8 +47,6 @@ public function camsKfintechRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function cdsl( @@ -68,8 +61,6 @@ public function cdsl( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function cdslRaw( @@ -84,8 +75,6 @@ public function cdslRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function nsdl( @@ -100,8 +89,6 @@ public function nsdl( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function nsdlRaw( @@ -116,8 +103,6 @@ public function nsdlRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function smartParse( @@ -132,8 +117,6 @@ public function smartParse( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function smartParseRaw( diff --git a/src/Services/CasGeneratorService.php b/src/Services/CasGeneratorService.php index c7d2e8e..1a4227e 100644 --- a/src/Services/CasGeneratorService.php +++ b/src/Services/CasGeneratorService.php @@ -9,7 +9,6 @@ use CasParser\CasGenerator\CasGeneratorGenerateCasResponse; use CasParser\Client; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasGeneratorContract; @@ -35,8 +34,6 @@ public function __construct(private Client $client) {} * @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 - * * @throws APIException */ public function generateCas( @@ -65,8 +62,6 @@ public function generateCas( * * @param array $params * - * @return CasGeneratorGenerateCasResponse - * * @throws APIException */ public function generateCasRaw( diff --git a/src/Services/CasParserService.php b/src/Services/CasParserService.php index 8c2adff..b0a900d 100644 --- a/src/Services/CasParserService.php +++ b/src/Services/CasParserService.php @@ -11,7 +11,6 @@ use CasParser\CasParser\UnifiedResponse; use CasParser\Client; use CasParser\Core\Exceptions\APIException; -use CasParser\Core\Implementation\HasRawResponse; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasParserContract; @@ -34,8 +33,6 @@ public function __construct(private Client $client) {} * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function camsKfintech( @@ -56,8 +53,6 @@ public function camsKfintech( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function camsKfintechRaw( @@ -89,8 +84,6 @@ public function camsKfintechRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function cdsl( @@ -111,8 +104,6 @@ public function cdsl( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function cdslRaw( @@ -144,8 +135,6 @@ public function cdslRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function nsdl( @@ -166,8 +155,6 @@ public function nsdl( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function nsdlRaw( @@ -199,8 +186,6 @@ public function nsdlRaw( * @param string $pdfFile Base64 encoded CAS PDF file * @param string $pdfURL URL to the CAS PDF file * - * @return UnifiedResponse - * * @throws APIException */ public function smartParse( @@ -221,8 +206,6 @@ public function smartParse( * * @param array $params * - * @return UnifiedResponse - * * @throws APIException */ public function smartParseRaw( From d7d0f005e9022cce83d3316626e5746a3a02b694 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 02:38:38 +0000 Subject: [PATCH 04/15] fix(ci): release doctor workflow --- .github/workflows/release-doctor.yml | 3 +++ 1 file changed, 3 insertions(+) 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 }} From 7742369f0a91046a7aa843391627e8931c6280f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Oct 2025 02:14:04 +0000 Subject: [PATCH 05/15] chore: add license --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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/" } From 0112a9a50be77cb4681413034b3d88d791774f6c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 02:07:12 +0000 Subject: [PATCH 06/15] fix: inverted retry condition --- src/Core/BaseClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index eab6b98..126c638 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -264,7 +264,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; From 84053c4b32db33f341e5e9bf89f2aabe982a2695 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Oct 2025 02:25:57 +0000 Subject: [PATCH 07/15] feat!: remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` --- src/CasGenerator/CasGeneratorGenerateCasParams.php | 11 ----------- src/CasParser/CasParserCamsKfintechParams.php | 11 ----------- src/CasParser/CasParserCdslParams.php | 11 ----------- src/CasParser/CasParserNsdlParams.php | 11 ----------- src/CasParser/CasParserSmartParseParams.php | 11 ----------- src/Core/Concerns/SdkModel.php | 12 +++++++----- src/Core/Contracts/BaseModel.php | 2 +- src/Core/Conversion/ModelOf.php | 2 +- src/RequestOptions.php | 2 +- 9 files changed, 10 insertions(+), 63 deletions(-) diff --git a/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index bd9e669..5e2b655 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -11,20 +11,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new CasGeneratorGenerateCasParams); // set properties as needed - * $client->casGenerator->generateCas(...$params->toArray()); - * ``` * This endpoint generates CAS (Consolidated Account Statement) documents by submitting a mailback request to the specified CAS authority. * Currently only supports KFintech, with plans to support CAMS, CDSL, and NSDL in the future. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. - * - * `$client->casGenerator->generateCas(...$params->toArray());` - * * @see CasParser\CasGenerator->generateCas * * @phpstan-type cas_generator_generate_cas_params = array{ diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index 8e09e3b..0dda13d 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -10,20 +10,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new CasParserCamsKfintechParams); // set properties as needed - * $client->casParser->camsKfintech(...$params->toArray()); - * ``` * This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF files and returns data in a unified format. * Use this endpoint when you know the PDF is from CAMS or KFintech. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. - * - * `$client->casParser->camsKfintech(...$params->toArray());` - * * @see CasParser\CasParser->camsKfintech * * @phpstan-type cas_parser_cams_kfintech_params = array{ diff --git a/src/CasParser/CasParserCdslParams.php b/src/CasParser/CasParserCdslParams.php index d48b9b2..c8401d7 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -10,20 +10,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new CasParserCdslParams); // set properties as needed - * $client->casParser->cdsl(...$params->toArray()); - * ``` * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and returns data in a unified format. * Use this endpoint when you know the PDF is from CDSL. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. - * - * `$client->casParser->cdsl(...$params->toArray());` - * * @see CasParser\CasParser->cdsl * * @phpstan-type cas_parser_cdsl_params = array{ diff --git a/src/CasParser/CasParserNsdlParams.php b/src/CasParser/CasParserNsdlParams.php index 98320b2..df6c11a 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -10,20 +10,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new CasParserNsdlParams); // set properties as needed - * $client->casParser->nsdl(...$params->toArray()); - * ``` * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and returns data in a unified format. * Use this endpoint when you know the PDF is from NSDL. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. - * - * `$client->casParser->nsdl(...$params->toArray());` - * * @see CasParser\CasParser->nsdl * * @phpstan-type cas_parser_nsdl_params = array{ diff --git a/src/CasParser/CasParserSmartParseParams.php b/src/CasParser/CasParserSmartParseParams.php index 525ebf1..5596cf1 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -10,20 +10,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new CasParserSmartParseParams); // set properties as needed - * $client->casParser->smartParse(...$params->toArray()); - * ``` * This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or CAMS/KFintech and returns data in a unified format. * It auto-detects the CAS type and transforms the data into a consistent structure regardless of the source. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. - * - * `$client->casParser->smartParse(...$params->toArray());` - * * @see CasParser\CasParser->smartParse * * @phpstan-type cas_parser_smart_parse_params = array{ 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/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/Conversion/ModelOf.php b/src/Core/Conversion/ModelOf.php index 0dbf406..eaac34c 100644 --- a/src/Core/Conversion/ModelOf.php +++ b/src/Core/Conversion/ModelOf.php @@ -105,7 +105,7 @@ public function from(array $data): BaseModel public function dump(mixed $value, DumpState $state): mixed { if ($value instanceof BaseModel) { - $value = $value->toArray(); + $value = $value->toProperties(); } if (is_array($value)) { diff --git a/src/RequestOptions.php b/src/RequestOptions.php index 03ece1a..1fd8c90 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -81,7 +81,7 @@ 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 } From 574d1680fbbaccfc4281a98e33d205f4d8a7e043 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 02:13:07 +0000 Subject: [PATCH 08/15] chore: use pascal case for phpstan typedefs --- src/CasGenerator/CasGeneratorGenerateCasParams.php | 4 ++-- src/CasGenerator/CasGeneratorGenerateCasResponse.php | 4 ++-- src/CasParser/CasParserCamsKfintechParams.php | 4 ++-- src/CasParser/CasParserCdslParams.php | 4 ++-- src/CasParser/CasParserNsdlParams.php | 4 ++-- src/CasParser/CasParserSmartParseParams.php | 4 ++-- src/CasParser/UnifiedResponse.php | 4 ++-- src/CasParser/UnifiedResponse/DematAccount.php | 4 ++-- src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php | 4 ++-- src/CasParser/UnifiedResponse/DematAccount/Holdings.php | 4 ++-- src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php | 4 ++-- .../UnifiedResponse/DematAccount/Holdings/CorporateBond.php | 4 ++-- .../UnifiedResponse/DematAccount/Holdings/DematMutualFund.php | 4 ++-- .../UnifiedResponse/DematAccount/Holdings/Equity.php | 4 ++-- .../DematAccount/Holdings/GovernmentSecurity.php | 4 ++-- src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php | 4 ++-- src/CasParser/UnifiedResponse/Insurance.php | 4 ++-- .../UnifiedResponse/Insurance/LifeInsurancePolicy.php | 4 ++-- src/CasParser/UnifiedResponse/Investor.php | 4 ++-- src/CasParser/UnifiedResponse/Meta.php | 4 ++-- src/CasParser/UnifiedResponse/Meta/StatementPeriod.php | 4 ++-- src/CasParser/UnifiedResponse/MutualFund.php | 4 ++-- src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php | 4 ++-- src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php | 4 ++-- src/CasParser/UnifiedResponse/MutualFund/Scheme.php | 4 ++-- .../UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php | 4 ++-- src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php | 4 ++-- .../UnifiedResponse/MutualFund/Scheme/Transaction.php | 4 ++-- src/CasParser/UnifiedResponse/Np.php | 4 ++-- src/CasParser/UnifiedResponse/Np/Fund.php | 4 ++-- src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php | 4 ++-- src/CasParser/UnifiedResponse/Np/LinkedHolder.php | 4 ++-- src/CasParser/UnifiedResponse/Summary.php | 4 ++-- src/CasParser/UnifiedResponse/Summary/Accounts.php | 4 ++-- src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php | 4 ++-- src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php | 4 ++-- .../UnifiedResponse/Summary/Accounts/MutualFunds.php | 4 ++-- src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php | 4 ++-- 38 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index 5e2b655..02614fa 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -16,7 +16,7 @@ * * @see CasParser\CasGenerator->generateCas * - * @phpstan-type cas_generator_generate_cas_params = array{ + * @phpstan-type CasGeneratorGenerateCasParamsShape = array{ * email: string, * fromDate: string, * password: string, @@ -27,7 +27,7 @@ */ final class CasGeneratorGenerateCasParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/CasGenerator/CasGeneratorGenerateCasResponse.php b/src/CasGenerator/CasGeneratorGenerateCasResponse.php index fbfc3b8..736691f 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasResponse.php +++ b/src/CasGenerator/CasGeneratorGenerateCasResponse.php @@ -11,13 +11,13 @@ use CasParser\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type cas_generator_generate_cas_response = array{ + * @phpstan-type CasGeneratorGenerateCasResponseShape = array{ * msg?: string, status?: string * } */ final class CasGeneratorGenerateCasResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkResponse; diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index 0dda13d..197b273 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -15,13 +15,13 @@ * * @see CasParser\CasParser->camsKfintech * - * @phpstan-type cas_parser_cams_kfintech_params = array{ + * @phpstan-type CasParserCamsKfintechParamsShape = array{ * password?: string, pdfFile?: string, pdfURL?: string * } */ final class CasParserCamsKfintechParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/CasParser/CasParserCdslParams.php b/src/CasParser/CasParserCdslParams.php index c8401d7..e3e93f4 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -15,13 +15,13 @@ * * @see CasParser\CasParser->cdsl * - * @phpstan-type cas_parser_cdsl_params = array{ + * @phpstan-type CasParserCdslParamsShape = array{ * password?: string, pdfFile?: string, pdfURL?: string * } */ final class CasParserCdslParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/CasParser/CasParserNsdlParams.php b/src/CasParser/CasParserNsdlParams.php index df6c11a..20911bf 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -15,13 +15,13 @@ * * @see CasParser\CasParser->nsdl * - * @phpstan-type cas_parser_nsdl_params = array{ + * @phpstan-type CasParserNsdlParamsShape = array{ * password?: string, pdfFile?: string, pdfURL?: string * } */ final class CasParserNsdlParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/CasParser/CasParserSmartParseParams.php b/src/CasParser/CasParserSmartParseParams.php index 5596cf1..4de5e15 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -15,13 +15,13 @@ * * @see CasParser\CasParser->smartParse * - * @phpstan-type cas_parser_smart_parse_params = array{ + * @phpstan-type CasParserSmartParseParamsShape = array{ * password?: string, pdfFile?: string, pdfURL?: string * } */ final class CasParserSmartParseParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/CasParser/UnifiedResponse.php b/src/CasParser/UnifiedResponse.php index b90393e..a164884 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -18,7 +18,7 @@ use CasParser\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type unified_response = array{ + * @phpstan-type UnifiedResponseShape = array{ * dematAccounts?: list, * insurance?: Insurance, * investor?: Investor, @@ -30,7 +30,7 @@ */ final class UnifiedResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkResponse; diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index 2c51ed7..c3df839 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -13,7 +13,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type demat_account = array{ + * @phpstan-type DematAccountShape = array{ * additionalInfo?: AdditionalInfo, * boID?: string, * clientID?: string, @@ -27,7 +27,7 @@ */ final class DematAccount implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php index c7a8be5..4244d41 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php @@ -11,7 +11,7 @@ /** * Additional information specific to the demat account type. * - * @phpstan-type additional_info = array{ + * @phpstan-type AdditionalInfoShape = array{ * boStatus?: string, * boSubStatus?: string, * boType?: string, @@ -24,7 +24,7 @@ */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php index eb3b0d1..fa8713b 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php @@ -14,7 +14,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type holdings_alias = array{ + * @phpstan-type HoldingsShape = array{ * aifs?: list, * corporateBonds?: list, * dematMutualFunds?: list, @@ -24,7 +24,7 @@ */ final class Holdings implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @var list|null $aifs */ diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php index 1df6013..a5ff45a 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type aif_alias = array{ + * @phpstan-type AifShape = array{ * additionalInfo?: mixed, * isin?: string, * name?: string, @@ -19,7 +19,7 @@ */ final class Aif implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php index bfb4d84..4c815dc 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type corporate_bond = array{ + * @phpstan-type CorporateBondShape = array{ * additionalInfo?: mixed, * isin?: string, * name?: string, @@ -19,7 +19,7 @@ */ final class CorporateBond implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php index 36015d7..072a276 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type demat_mutual_fund = array{ + * @phpstan-type DematMutualFundShape = array{ * additionalInfo?: mixed, * isin?: string, * name?: string, @@ -19,7 +19,7 @@ */ final class DematMutualFund implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php index 0c1b5c2..4ce5c46 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type equity_alias = array{ + * @phpstan-type EquityShape = array{ * additionalInfo?: mixed, * isin?: string, * name?: string, @@ -19,7 +19,7 @@ */ final class Equity implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php index cd4249f..be303b1 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type government_security = array{ + * @phpstan-type GovernmentSecurityShape = array{ * additionalInfo?: mixed, * isin?: string, * name?: string, @@ -19,7 +19,7 @@ */ final class GovernmentSecurity implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php index 7d1b2b6..940d72f 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type linked_holder = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} */ final class LinkedHolder implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Insurance.php b/src/CasParser/UnifiedResponse/Insurance.php index 2a42859..a068cc5 100644 --- a/src/CasParser/UnifiedResponse/Insurance.php +++ b/src/CasParser/UnifiedResponse/Insurance.php @@ -10,13 +10,13 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type insurance_alias = array{ + * @phpstan-type InsuranceShape = array{ * lifeInsurancePolicies?: list * } */ final class Insurance implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @var list|null $lifeInsurancePolicies */ diff --git a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php index c106c9c..fd935e9 100644 --- a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php +++ b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type life_insurance_policy = array{ + * @phpstan-type LifeInsurancePolicyShape = array{ * additionalInfo?: mixed, * lifeAssured?: string, * policyName?: string, @@ -23,7 +23,7 @@ */ final class LifeInsurancePolicy implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Investor.php b/src/CasParser/UnifiedResponse/Investor.php index dd04ddc..679d124 100644 --- a/src/CasParser/UnifiedResponse/Investor.php +++ b/src/CasParser/UnifiedResponse/Investor.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type investor_alias = array{ + * @phpstan-type InvestorShape = array{ * address?: string, * casID?: string, * email?: string, @@ -21,7 +21,7 @@ */ final class Investor implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Meta.php b/src/CasParser/UnifiedResponse/Meta.php index ceacd10..71fca99 100644 --- a/src/CasParser/UnifiedResponse/Meta.php +++ b/src/CasParser/UnifiedResponse/Meta.php @@ -11,7 +11,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type meta_alias = array{ + * @phpstan-type MetaShape = array{ * casType?: value-of, * generatedAt?: \DateTimeInterface, * statementPeriod?: StatementPeriod, @@ -19,7 +19,7 @@ */ final class Meta implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php index ebeb0f2..5fc9522 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{ + * @phpstan-type StatementPeriodShape = array{ * from?: \DateTimeInterface, to?: \DateTimeInterface * } */ 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 9b1ea68..77d6544 100644 --- a/src/CasParser/UnifiedResponse/MutualFund.php +++ b/src/CasParser/UnifiedResponse/MutualFund.php @@ -12,7 +12,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type mutual_fund = array{ + * @phpstan-type MutualFundShape = array{ * additionalInfo?: AdditionalInfo, * amc?: string, * folioNumber?: string, @@ -24,7 +24,7 @@ */ final class MutualFund implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php index b79ad23..dfe2dac 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{ + * @phpstan-type AdditionalInfoShape = array{ * kyc?: string, pan?: string, pankyc?: string * } */ 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 index dbab7bb..ba4a9f6 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type linked_holder = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} */ final class LinkedHolder implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php index 2b48637..ec58b72 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php @@ -13,7 +13,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type scheme_alias = array{ + * @phpstan-type SchemeShape = array{ * additionalInfo?: AdditionalInfo, * cost?: float, * gain?: Gain, @@ -29,7 +29,7 @@ */ final class Scheme implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php index e5f16cd..383c960 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php @@ -11,7 +11,7 @@ /** * Additional information specific to the scheme. * - * @phpstan-type additional_info = array{ + * @phpstan-type AdditionalInfoShape = array{ * advisor?: string, * amfi?: string, * closeUnits?: float, @@ -21,7 +21,7 @@ */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php index 8006cfa..94cac52 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, percentage?: float} */ 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..331458b 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type transaction_alias = array{ + * @phpstan-type TransactionShape = array{ * amount?: float, * balance?: float, * date?: \DateTimeInterface, @@ -22,7 +22,7 @@ */ final class Transaction implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Np.php b/src/CasParser/UnifiedResponse/Np.php index 32bb8f5..666f586 100644 --- a/src/CasParser/UnifiedResponse/Np.php +++ b/src/CasParser/UnifiedResponse/Np.php @@ -11,7 +11,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type np_alias = array{ + * @phpstan-type NpShape = array{ * additionalInfo?: mixed, * cra?: string, * funds?: list, @@ -22,7 +22,7 @@ */ final class Np implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Np/Fund.php b/src/CasParser/UnifiedResponse/Np/Fund.php index 9aad9fa..727ad14 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund.php +++ b/src/CasParser/UnifiedResponse/Np/Fund.php @@ -10,7 +10,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type fund_alias = array{ + * @phpstan-type FundShape = array{ * additionalInfo?: AdditionalInfo, * cost?: float, * name?: string, @@ -21,7 +21,7 @@ */ final class Fund implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php index 1c6a52b..79a16db 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php @@ -11,11 +11,11 @@ /** * Additional information specific to the NPS fund. * - * @phpstan-type additional_info = array{manager?: string, tier?: float|null} + * @phpstan-type AdditionalInfoShape = array{manager?: string, tier?: float|null} */ final class AdditionalInfo implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php index 6f2b941..07b6856 100644 --- a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type linked_holder = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} */ final class LinkedHolder implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Summary.php b/src/CasParser/UnifiedResponse/Summary.php index 6b32295..99771b2 100644 --- a/src/CasParser/UnifiedResponse/Summary.php +++ b/src/CasParser/UnifiedResponse/Summary.php @@ -10,11 +10,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type summary_alias = array{accounts?: Accounts, totalValue?: float} + * @phpstan-type SummaryShape = array{accounts?: Accounts, totalValue?: float} */ final class Summary implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts.php b/src/CasParser/UnifiedResponse/Summary/Accounts.php index 02c1e54..ce5d3ee 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts.php @@ -13,13 +13,13 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type accounts_alias = array{ + * @phpstan-type AccountsShape = array{ * demat?: Demat, insurance?: Insurance, mutualFunds?: MutualFunds, nps?: Nps * } */ final class Accounts implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php index 50165c2..77e37ca 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, totalValue?: float} */ final class Demat implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php index a14d733..ec2d5b4 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, totalValue?: float} */ final class Insurance implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php index dc2f0c0..08bdf24 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type mutual_funds = array{count?: int, totalValue?: float} + * @phpstan-type MutualFundsShape = array{count?: int, totalValue?: float} */ final class MutualFunds implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php index e2cb548..ce9d152 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php @@ -9,11 +9,11 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type nps_alias = array{count?: int, totalValue?: float} + * @phpstan-type NpsShape = array{count?: int, totalValue?: float} */ final class Nps implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** From 9a72241ae57939ae08709709a26a87f1ad83d9e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 03:36:53 +0000 Subject: [PATCH 09/15] chore(client): send metadata headers --- release-please-config.json | 3 ++- src/Client.php | 12 ++++++++- src/Core/BaseClient.php | 52 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) 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/src/Client.php b/src/Client.php index b576691..7e48280 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,9 +40,19 @@ 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.0.1'), + 'X-Stainless-Lang' => 'php', + 'X-Stainless-Package-Version' => '0.0.1', + 'X-Stainless-OS' => $this->getNormalizedOS(), + 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), + 'X-Stainless-Runtime' => 'php', + 'X-Stainless-Runtime-Version' => phpversion(), ], + // x-release-please-end baseUrl: $baseUrl, options: $options, ); diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index 126c638..e907bda 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -105,6 +105,56 @@ public function request( /** @return array */ abstract protected function authHeaders(): array; + protected function getNormalizedOS(): string + { + $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 * @@ -238,6 +288,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; From fd0ab3bb4232369f31350fb47d0aca4d916f5739 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Nov 2025 03:31:10 +0000 Subject: [PATCH 10/15] fix: ensure auth methods return non-nullable arrays --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 7e48280..8469878 100644 --- a/src/Client.php +++ b/src/Client.php @@ -64,6 +64,6 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) /** @return array */ protected function authHeaders(): array { - return ['x-api-key' => $this->apiKey]; + return $this->apiKey ? ['x-api-key' => $this->apiKey] : []; } } From 5bc4f8fbca8bd998535963059460dcc2285c479e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:28:47 +0000 Subject: [PATCH 11/15] feat(client)!: redesign methods --- README.md | 11 +- .../CasGeneratorGenerateCasParams.php | 54 ++++---- .../CasGeneratorGenerateCasResponse.php | 2 +- src/CasParser/CasParserCamsKfintechParams.php | 22 ++-- src/CasParser/CasParserCdslParams.php | 22 ++-- src/CasParser/CasParserNsdlParams.php | 22 ++-- src/CasParser/CasParserSmartParseParams.php | 22 ++-- src/CasParser/UnifiedResponse.php | 42 +++--- .../UnifiedResponse/DematAccount.php | 96 +++++++------- .../DematAccount/AdditionalInfo.php | 60 ++++----- .../UnifiedResponse/DematAccount/Holdings.php | 56 ++++---- .../DematAccount/Holdings/Aif.php | 20 +-- .../DematAccount/Holdings/CorporateBond.php | 20 +-- .../DematAccount/Holdings/DematMutualFund.php | 20 +-- .../DematAccount/Holdings/Equity.php | 20 +-- .../Holdings/GovernmentSecurity.php | 20 +-- .../DematAccount/LinkedHolder.php | 2 +- src/CasParser/UnifiedResponse/Insurance.php | 20 ++- .../Insurance/LifeInsurancePolicy.php | 88 ++++++------- src/CasParser/UnifiedResponse/Investor.php | 24 ++-- src/CasParser/UnifiedResponse/Meta.php | 40 +++--- .../UnifiedResponse/Meta/StatementPeriod.php | 2 +- src/CasParser/UnifiedResponse/MutualFund.php | 48 +++---- .../MutualFund/AdditionalInfo.php | 2 +- .../MutualFund/LinkedHolder.php | 2 +- .../UnifiedResponse/MutualFund/Scheme.php | 32 ++--- .../MutualFund/Scheme/AdditionalInfo.php | 40 +++--- .../MutualFund/Scheme/Gain.php | 2 +- .../MutualFund/Scheme/Transaction.php | 26 ++-- src/CasParser/UnifiedResponse/Np.php | 36 +++--- src/CasParser/UnifiedResponse/Np/Fund.php | 22 ++-- .../Np/Fund/AdditionalInfo.php | 4 +- .../UnifiedResponse/Np/LinkedHolder.php | 2 +- src/CasParser/UnifiedResponse/Summary.php | 14 +- .../UnifiedResponse/Summary/Accounts.php | 15 ++- .../Summary/Accounts/Demat.php | 12 +- .../Summary/Accounts/Insurance.php | 12 +- .../Summary/Accounts/MutualFunds.php | 14 +- .../UnifiedResponse/Summary/Accounts/Nps.php | 12 +- src/Client.php | 2 +- src/Core/BaseClient.php | 29 ++--- src/Core/Util.php | 22 ++-- src/RequestOptions.php | 16 +-- src/ServiceContracts/CasGeneratorContract.php | 30 +---- src/ServiceContracts/CasParserContract.php | 86 ++---------- src/Services/CasGeneratorService.php | 49 ++----- src/Services/CasParserService.php | 122 +++--------------- tests/Services/CasGeneratorTest.php | 24 ++-- tests/Services/CasParserTest.php | 8 +- 49 files changed, 584 insertions(+), 784 deletions(-) diff --git a/README.md b/README.md index c30e278..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()); @@ -118,7 +118,7 @@ $client = new Client(maxRetries: 0); // Or, configure per-request: $result = $client->casParser->smartParse( - requestOptions: RequestOptions::with(maxRetries: 5) + [], RequestOptions::with(maxRetries: 5) ); ``` @@ -138,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/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index 02614fa..062a4be 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -18,11 +18,11 @@ * * @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 @@ -40,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. @@ -52,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. @@ -75,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: ... * ) * ``` * @@ -99,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; - null !== $panNo && $obj->panNo = $panNo; + null !== $cas_authority && $obj['cas_authority'] = $cas_authority; + null !== $pan_no && $obj->pan_no = $pan_no; return $obj; } @@ -139,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; } @@ -161,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; } @@ -174,7 +174,7 @@ public function withToDate(string $toDate): self public function withCasAuthority(CasAuthority|string $casAuthority): self { $obj = clone $this; - $obj['casAuthority'] = $casAuthority; + $obj['cas_authority'] = $casAuthority; return $obj; } @@ -185,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 736691f..fc9e495 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasResponse.php +++ b/src/CasGenerator/CasGeneratorGenerateCasResponse.php @@ -12,7 +12,7 @@ /** * @phpstan-type CasGeneratorGenerateCasResponseShape = array{ - * msg?: string, status?: string + * msg?: string|null, status?: string|null * } */ final class CasGeneratorGenerateCasResponse implements BaseModel, ResponseConverter diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index 197b273..575b586 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -16,7 +16,7 @@ * @see CasParser\CasParser->camsKfintech * * @phpstan-type CasParserCamsKfintechParamsShape = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserCamsKfintechParams implements BaseModel @@ -34,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() { @@ -55,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; } @@ -84,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; } @@ -95,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 e3e93f4..2d7bfae 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -16,7 +16,7 @@ * @see CasParser\CasParser->cdsl * * @phpstan-type CasParserCdslParamsShape = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserCdslParams implements BaseModel @@ -34,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() { @@ -55,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; } @@ -84,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; } @@ -95,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 20911bf..8e8d831 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -16,7 +16,7 @@ * @see CasParser\CasParser->nsdl * * @phpstan-type CasParserNsdlParamsShape = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserNsdlParams implements BaseModel @@ -34,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() { @@ -55,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; } @@ -84,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; } @@ -95,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 4de5e15..eb3911a 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -16,7 +16,7 @@ * @see CasParser\CasParser->smartParse * * @phpstan-type CasParserSmartParseParamsShape = array{ - * password?: string, pdfFile?: string, pdfURL?: string + * password?: string, pdf_file?: string, pdf_url?: string * } */ final class CasParserSmartParseParams implements BaseModel @@ -34,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() { @@ -55,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; } @@ -84,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; } @@ -95,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 a164884..5de1d90 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -19,13 +19,13 @@ /** * @phpstan-type UnifiedResponseShape = array{ - * dematAccounts?: list, - * insurance?: Insurance, - * investor?: Investor, - * meta?: Meta, - * mutualFunds?: list, - * nps?: list, - * summary?: Summary, + * demat_accounts?: list|null, + * insurance?: Insurance|null, + * investor?: Investor|null, + * meta?: Meta|null, + * mutual_funds?: list|null, + * nps?: list|null, + * summary?: Summary|null, * } */ final class UnifiedResponse implements BaseModel, ResponseConverter @@ -35,9 +35,9 @@ final class UnifiedResponse implements BaseModel, ResponseConverter use SdkResponse; - /** @var list|null $dematAccounts */ - #[Api('demat_accounts', list: DematAccount::class, optional: true)] - public ?array $dematAccounts; + /** @var list|null $demat_accounts */ + #[Api(list: DematAccount::class, optional: true)] + public ?array $demat_accounts; #[Api(optional: true)] public ?Insurance $insurance; @@ -48,9 +48,9 @@ final class UnifiedResponse implements BaseModel, ResponseConverter #[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. @@ -73,26 +73,26 @@ 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; @@ -105,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; } @@ -140,7 +140,7 @@ public function withMeta(Meta $meta): self public function withMutualFunds(array $mutualFunds): self { $obj = clone $this; - $obj->mutualFunds = $mutualFunds; + $obj->mutual_funds = $mutualFunds; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index c3df839..5901828 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -14,15 +14,15 @@ /** * @phpstan-type DematAccountShape = array{ - * additionalInfo?: AdditionalInfo, - * boID?: string, - * clientID?: string, - * dematType?: value-of, - * dpID?: string, - * dpName?: string, - * holdings?: Holdings, - * linkedHolders?: list, - * value?: float, + * 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 @@ -33,40 +33,40 @@ final class DematAccount implements BaseModel /** * 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; @@ -74,10 +74,10 @@ final class DematAccount implements BaseModel /** * List of account holders linked to this demat account. * - * @var list|null $linkedHolders + * @var list|null $linked_holders */ - #[Api('linked_holders', list: LinkedHolder::class, optional: true)] - public ?array $linkedHolders; + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; /** * Total value of the demat account. @@ -95,30 +95,30 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param DematType|value-of $dematType - * @param list $linkedHolders + * @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 $linkedHolders = 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; - 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 !== $linkedHolders && $obj->linkedHolders = $linkedHolders; + null !== $linked_holders && $obj->linked_holders = $linked_holders; null !== $value && $obj->value = $value; return $obj; @@ -130,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; } @@ -141,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; } @@ -152,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; } @@ -165,7 +165,7 @@ public function withClientID(string $clientID): self public function withDematType(DematType|string $dematType): self { $obj = clone $this; - $obj['dematType'] = $dematType; + $obj['demat_type'] = $dematType; return $obj; } @@ -176,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; } @@ -187,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; } @@ -208,7 +208,7 @@ public function withHoldings(Holdings $holdings): self public function withLinkedHolders(array $linkedHolders): self { $obj = clone $this; - $obj->linkedHolders = $linkedHolders; + $obj->linked_holders = $linkedHolders; return $obj; } diff --git a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php index 4244d41..38fbb27 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php @@ -12,14 +12,14 @@ * Additional information specific to the demat account type. * * @phpstan-type AdditionalInfoShape = array{ - * boStatus?: string, - * boSubStatus?: string, - * boType?: string, - * bsda?: string, - * email?: string, - * linkedPans?: list, - * nominee?: string, - * status?: string, + * 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 @@ -30,20 +30,20 @@ final class AdditionalInfo implements BaseModel /** * 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 fa8713b..e800558 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php @@ -15,11 +15,11 @@ /** * @phpstan-type HoldingsShape = array{ - * aifs?: list, - * corporateBonds?: list, - * dematMutualFunds?: list, - * equities?: list, - * governmentSecurities?: list, + * aifs?: list|null, + * corporate_bonds?: list|null, + * demat_mutual_funds?: list|null, + * equities?: list|null, + * government_securities?: list|null, * } */ final class Holdings implements BaseModel @@ -31,25 +31,21 @@ final class Holdings implements BaseModel #[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 a5ff45a..f5b39f5 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php @@ -10,11 +10,11 @@ /** * @phpstan-type AifShape = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class Aif implements BaseModel @@ -25,8 +25,8 @@ final class Aif implements BaseModel /** * 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 4c815dc..0de214f 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond.php @@ -10,11 +10,11 @@ /** * @phpstan-type CorporateBondShape = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class CorporateBond implements BaseModel @@ -25,8 +25,8 @@ final class CorporateBond implements BaseModel /** * 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 072a276..dbc6a82 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund.php @@ -10,11 +10,11 @@ /** * @phpstan-type DematMutualFundShape = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class DematMutualFund implements BaseModel @@ -25,8 +25,8 @@ final class DematMutualFund implements BaseModel /** * 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 4ce5c46..b6eee88 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity.php @@ -10,11 +10,11 @@ /** * @phpstan-type EquityShape = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class Equity implements BaseModel @@ -25,8 +25,8 @@ final class Equity implements BaseModel /** * 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 be303b1..0d295bd 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity.php @@ -10,11 +10,11 @@ /** * @phpstan-type GovernmentSecurityShape = array{ - * additionalInfo?: mixed, - * isin?: string, - * name?: string, - * units?: float, - * value?: float, + * additional_info?: mixed, + * isin?: string|null, + * name?: string|null, + * units?: float|null, + * value?: float|null, * } */ final class GovernmentSecurity implements BaseModel @@ -25,8 +25,8 @@ final class GovernmentSecurity implements BaseModel /** * 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 index 940d72f..5b9ac2e 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/DematAccount/LinkedHolder.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string|null, pan?: string|null} */ final class LinkedHolder implements BaseModel { diff --git a/src/CasParser/UnifiedResponse/Insurance.php b/src/CasParser/UnifiedResponse/Insurance.php index a068cc5..336278f 100644 --- a/src/CasParser/UnifiedResponse/Insurance.php +++ b/src/CasParser/UnifiedResponse/Insurance.php @@ -11,7 +11,7 @@ /** * @phpstan-type InsuranceShape = array{ - * lifeInsurancePolicies?: list + * life_insurance_policies?: list|null * } */ final class Insurance implements BaseModel @@ -19,13 +19,9 @@ final class Insurance implements BaseModel /** @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 fd935e9..0734bdf 100644 --- a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php +++ b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php @@ -10,15 +10,15 @@ /** * @phpstan-type LifeInsurancePolicyShape = array{ - * additionalInfo?: mixed, - * lifeAssured?: string, - * policyName?: string, - * policyNumber?: string, - * premiumAmount?: float, - * premiumFrequency?: string, - * provider?: string, - * status?: string, - * sumAssured?: float, + * 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 @@ -29,38 +29,38 @@ final class LifeInsurancePolicy implements BaseModel /** * 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 679d124..272a2cd 100644 --- a/src/CasParser/UnifiedResponse/Investor.php +++ b/src/CasParser/UnifiedResponse/Investor.php @@ -10,13 +10,13 @@ /** * @phpstan-type InvestorShape = array{ - * address?: string, - * casID?: string, - * email?: string, - * mobile?: string, - * name?: string, - * pan?: string, - * pincode?: string, + * 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 @@ -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 71fca99..ab759db 100644 --- a/src/CasParser/UnifiedResponse/Meta.php +++ b/src/CasParser/UnifiedResponse/Meta.php @@ -12,9 +12,9 @@ /** * @phpstan-type MetaShape = array{ - * casType?: value-of, - * generatedAt?: \DateTimeInterface, - * statementPeriod?: StatementPeriod, + * cas_type?: value-of|null, + * generated_at?: \DateTimeInterface|null, + * statement_period?: StatementPeriod|null, * } */ final class Meta implements BaseModel @@ -25,19 +25,19 @@ final class Meta implements BaseModel /** * 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; - 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; + $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 5fc9522..d7b088b 100644 --- a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php +++ b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php @@ -10,7 +10,7 @@ /** * @phpstan-type StatementPeriodShape = array{ - * from?: \DateTimeInterface, to?: \DateTimeInterface + * from?: \DateTimeInterface|null, to?: \DateTimeInterface|null * } */ final class StatementPeriod implements BaseModel diff --git a/src/CasParser/UnifiedResponse/MutualFund.php b/src/CasParser/UnifiedResponse/MutualFund.php index 77d6544..d1448f7 100644 --- a/src/CasParser/UnifiedResponse/MutualFund.php +++ b/src/CasParser/UnifiedResponse/MutualFund.php @@ -13,13 +13,13 @@ /** * @phpstan-type MutualFundShape = array{ - * additionalInfo?: AdditionalInfo, - * amc?: string, - * folioNumber?: string, - * linkedHolders?: list, - * registrar?: string, - * schemes?: list, - * value?: float, + * 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 @@ -30,8 +30,8 @@ final class MutualFund implements BaseModel /** * Additional folio information. */ - #[Api('additional_info', optional: true)] - public ?AdditionalInfo $additionalInfo; + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; /** * Asset Management Company name. @@ -42,16 +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 $linkedHolders + * @var list|null $linked_holders */ - #[Api('linked_holders', list: LinkedHolder::class, optional: true)] - public ?array $linkedHolders; + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; /** * Registrar and Transfer Agent name. @@ -79,24 +79,24 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $linkedHolders + * @param list $linked_holders * @param list $schemes */ public static function with( - ?AdditionalInfo $additionalInfo = null, + ?AdditionalInfo $additional_info = null, ?string $amc = null, - ?string $folioNumber = null, - ?array $linkedHolders = 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 !== $linkedHolders && $obj->linkedHolders = $linkedHolders; + 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; @@ -110,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; } @@ -132,7 +132,7 @@ public function withAmc(string $amc): self public function withFolioNumber(string $folioNumber): self { $obj = clone $this; - $obj->folioNumber = $folioNumber; + $obj->folio_number = $folioNumber; return $obj; } @@ -145,7 +145,7 @@ public function withFolioNumber(string $folioNumber): self public function withLinkedHolders(array $linkedHolders): self { $obj = clone $this; - $obj->linkedHolders = $linkedHolders; + $obj->linked_holders = $linkedHolders; return $obj; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php index dfe2dac..1ff28f5 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php @@ -12,7 +12,7 @@ * Additional folio information. * * @phpstan-type AdditionalInfoShape = array{ - * kyc?: string, pan?: string, pankyc?: string + * kyc?: string|null, pan?: string|null, pankyc?: string|null * } */ final class AdditionalInfo implements BaseModel diff --git a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php index ba4a9f6..cf09088 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string|null, pan?: string|null} */ final class LinkedHolder implements BaseModel { diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php index ec58b72..666a2b6 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php @@ -14,17 +14,17 @@ /** * @phpstan-type SchemeShape = array{ - * additionalInfo?: AdditionalInfo, - * cost?: float, - * gain?: Gain, - * isin?: string, - * name?: string, - * nav?: float, - * nominees?: list, - * transactions?: list, - * type?: value-of, - * units?: float, - * value?: float, + * 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 @@ -35,8 +35,8 @@ final class Scheme implements BaseModel /** * 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; @@ -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; } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php index 383c960..7ba0897 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php @@ -12,11 +12,11 @@ * Additional information specific to the scheme. * * @phpstan-type AdditionalInfoShape = array{ - * advisor?: string, - * amfi?: string, - * closeUnits?: float, - * openUnits?: float, - * rtaCode?: string, + * advisor?: string|null, + * amfi?: string|null, + * close_units?: float|null, + * open_units?: float|null, + * rta_code?: string|null, * } */ final class AdditionalInfo implements BaseModel @@ -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 94cac52..9de949d 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type GainShape = array{absolute?: float, percentage?: float} + * @phpstan-type GainShape = array{absolute?: float|null, percentage?: float|null} */ final class Gain implements BaseModel { diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php index 331458b..2da3426 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php @@ -10,14 +10,14 @@ /** * @phpstan-type TransactionShape = array{ - * amount?: float, - * balance?: float, - * date?: \DateTimeInterface, - * description?: string, - * dividendRate?: float, - * nav?: float, - * type?: string, - * units?: float, + * 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 @@ -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 index 666f586..5bdb79f 100644 --- a/src/CasParser/UnifiedResponse/Np.php +++ b/src/CasParser/UnifiedResponse/Np.php @@ -12,12 +12,12 @@ /** * @phpstan-type NpShape = array{ - * additionalInfo?: mixed, - * cra?: string, - * funds?: list, - * linkedHolders?: list, - * pran?: string, - * value?: float, + * additional_info?: mixed, + * cra?: string|null, + * funds?: list|null, + * linked_holders?: list|null, + * pran?: string|null, + * value?: float|null, * } */ final class Np implements BaseModel @@ -28,8 +28,8 @@ final class Np implements BaseModel /** * Additional information specific to the NPS account. */ - #[Api('additional_info', optional: true)] - public mixed $additionalInfo; + #[Api(optional: true)] + public mixed $additional_info; /** * Central Record Keeping Agency name. @@ -44,10 +44,10 @@ final class Np implements BaseModel /** * List of account holders linked to this NPS account. * - * @var list|null $linkedHolders + * @var list|null $linked_holders */ - #[Api('linked_holders', list: LinkedHolder::class, optional: true)] - public ?array $linkedHolders; + #[Api(list: LinkedHolder::class, optional: true)] + public ?array $linked_holders; /** * Permanent Retirement Account Number (PRAN). @@ -72,22 +72,22 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param list $funds - * @param list $linkedHolders + * @param list $linked_holders */ public static function with( - mixed $additionalInfo = null, + mixed $additional_info = null, ?string $cra = null, ?array $funds = null, - ?array $linkedHolders = null, + ?array $linked_holders = null, ?string $pran = null, ?float $value = null, ): self { $obj = new self; - null !== $additionalInfo && $obj->additionalInfo = $additionalInfo; + null !== $additional_info && $obj->additional_info = $additional_info; null !== $cra && $obj->cra = $cra; null !== $funds && $obj->funds = $funds; - null !== $linkedHolders && $obj->linkedHolders = $linkedHolders; + null !== $linked_holders && $obj->linked_holders = $linked_holders; null !== $pran && $obj->pran = $pran; null !== $value && $obj->value = $value; @@ -100,7 +100,7 @@ public static function with( public function withAdditionalInfo(mixed $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } @@ -135,7 +135,7 @@ public function withFunds(array $funds): self public function withLinkedHolders(array $linkedHolders): self { $obj = clone $this; - $obj->linkedHolders = $linkedHolders; + $obj->linked_holders = $linkedHolders; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Np/Fund.php b/src/CasParser/UnifiedResponse/Np/Fund.php index 727ad14..24351fc 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund.php +++ b/src/CasParser/UnifiedResponse/Np/Fund.php @@ -11,12 +11,12 @@ /** * @phpstan-type FundShape = array{ - * additionalInfo?: AdditionalInfo, - * cost?: float, - * name?: string, - * nav?: float, - * units?: float, - * value?: float, + * additional_info?: AdditionalInfo|null, + * cost?: float|null, + * name?: string|null, + * nav?: float|null, + * units?: float|null, + * value?: float|null, * } */ final class Fund implements BaseModel @@ -27,8 +27,8 @@ final class Fund implements BaseModel /** * Additional information specific to the NPS fund. */ - #[Api('additional_info', optional: true)] - public ?AdditionalInfo $additionalInfo; + #[Api(optional: true)] + public ?AdditionalInfo $additional_info; /** * Cost of investment. @@ -71,7 +71,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?AdditionalInfo $additionalInfo = null, + ?AdditionalInfo $additional_info = null, ?float $cost = null, ?string $name = null, ?float $nav = null, @@ -80,7 +80,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 !== $name && $obj->name = $name; null !== $nav && $obj->nav = $nav; @@ -96,7 +96,7 @@ public static function with( public function withAdditionalInfo(AdditionalInfo $additionalInfo): self { $obj = clone $this; - $obj->additionalInfo = $additionalInfo; + $obj->additional_info = $additionalInfo; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php index 79a16db..e14ee64 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php @@ -11,7 +11,9 @@ /** * Additional information specific to the NPS fund. * - * @phpstan-type AdditionalInfoShape = array{manager?: string, tier?: float|null} + * @phpstan-type AdditionalInfoShape = array{ + * manager?: string|null, tier?: float|null + * } */ final class AdditionalInfo implements BaseModel { diff --git a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php index 07b6856..ade9223 100644 --- a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type LinkedHolderShape = array{name?: string, pan?: string} + * @phpstan-type LinkedHolderShape = array{name?: string|null, pan?: string|null} */ final class LinkedHolder implements BaseModel { diff --git a/src/CasParser/UnifiedResponse/Summary.php b/src/CasParser/UnifiedResponse/Summary.php index 99771b2..68f5e5f 100644 --- a/src/CasParser/UnifiedResponse/Summary.php +++ b/src/CasParser/UnifiedResponse/Summary.php @@ -10,7 +10,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type SummaryShape = array{accounts?: Accounts, totalValue?: float} + * @phpstan-type SummaryShape = array{ + * accounts?: Accounts|null, total_value?: float|null + * } */ final class Summary implements BaseModel { @@ -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 ce5d3ee..1663b4e 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts.php @@ -14,7 +14,10 @@ /** * @phpstan-type AccountsShape = array{ - * demat?: Demat, insurance?: Insurance, mutualFunds?: MutualFunds, nps?: Nps + * demat?: Demat|null, + * insurance?: Insurance|null, + * mutual_funds?: MutualFunds|null, + * nps?: Nps|null, * } */ final class Accounts implements BaseModel @@ -28,8 +31,8 @@ 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; @@ -47,14 +50,14 @@ 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; @@ -79,7 +82,7 @@ public function withInsurance(Insurance $insurance): self public function withMutualFunds(MutualFunds $mutualFunds): self { $obj = clone $this; - $obj->mutualFunds = $mutualFunds; + $obj->mutual_funds = $mutualFunds; return $obj; } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php index 77e37ca..6aac885 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type DematShape = array{count?: int, totalValue?: float} + * @phpstan-type DematShape = array{count?: int|null, total_value?: float|null} */ final class Demat implements BaseModel { @@ -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 ec2d5b4..55a4cec 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type InsuranceShape = array{count?: int, totalValue?: float} + * @phpstan-type InsuranceShape = array{count?: int|null, total_value?: float|null} */ final class Insurance implements BaseModel { @@ -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 08bdf24..2bd2d57 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php @@ -9,7 +9,9 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type MutualFundsShape = array{count?: int, totalValue?: float} + * @phpstan-type MutualFundsShape = array{ + * count?: int|null, total_value?: float|null + * } */ final class MutualFunds implements BaseModel { @@ -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 index ce9d152..d1e08d8 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php @@ -9,7 +9,7 @@ use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type NpsShape = array{count?: int, totalValue?: float} + * @phpstan-type NpsShape = array{count?: int|null, total_value?: float|null} */ final class Nps implements BaseModel { @@ -25,8 +25,8 @@ final class Nps implements BaseModel /** * Total value of NPS 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/Client.php b/src/Client.php index 8469878..afc8ce5 100644 --- a/src/Client.php +++ b/src/Client.php @@ -61,7 +61,7 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) $this->casGenerator = new CasGeneratorService($this); } - /** @return array */ + /** @return array */ protected function authHeaders(): array { return $this->apiKey ? ['x-api-key' => $this->apiKey] : []; diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index e907bda..973279c 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -24,8 +24,8 @@ * @phpstan-type normalized_request = array{ * method: string, * path: string, - * query: array, - * headers: array>, + * query: array, + * headers: array>, * body: mixed, * } */ @@ -36,7 +36,7 @@ abstract class BaseClient /** * @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, @@ -102,7 +102,7 @@ public function request( return Util::decodeContent($rsp); } - /** @return array */ + /** @return array */ abstract protected function authHeaders(): array; protected function getNormalizedOS(): string @@ -159,15 +159,15 @@ protected function getNormalizedArchitecture(): string * @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, @@ -189,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, @@ -276,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, diff --git a/src/Core/Util.php b/src/Core/Util.php index 8ff5dd1..4717564 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -26,7 +26,7 @@ final class Util public const JSONL_CONTENT_TYPE = '/^application\/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)/'; /** - * @return array + * @return array */ public static function get_object_vars(object $object1): array { @@ -36,10 +36,10 @@ public static function get_object_vars(object $object1): array /** * @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 1fd8c90..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; @@ -87,8 +87,8 @@ public static function parse(RequestOptions|array|null ...$options): self } /** - * @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 a706431..f20cc7d 100644 --- a/src/ServiceContracts/CasGeneratorContract.php +++ b/src/ServiceContracts/CasGeneratorContract.php @@ -4,46 +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\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) + * @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 - * - * @throws APIException - */ - public function generateCasRaw( - array $params, - ?RequestOptions $requestOptions = null - ): CasGeneratorGenerateCasResponse; } diff --git a/src/ServiceContracts/CasParserContract.php b/src/ServiceContracts/CasParserContract.php index 977b15d..2c02ea7 100644 --- a/src/ServiceContracts/CasParserContract.php +++ b/src/ServiceContracts/CasParserContract.php @@ -4,123 +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\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 + * @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 - * - * @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 + * @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 - * - * @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 + * @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 - * - * @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 + * @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 - * - * @throws APIException - */ - public function smartParseRaw( - array $params, - ?RequestOptions $requestOptions = null - ): UnifiedResponse; } diff --git a/src/Services/CasGeneratorService.php b/src/Services/CasGeneratorService.php index 1a4227e..6392643 100644 --- a/src/Services/CasGeneratorService.php +++ b/src/Services/CasGeneratorService.php @@ -5,15 +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\RequestOptions; use CasParser\ServiceContracts\CasGeneratorContract; -use const CasParser\Core\OMIT as omit; - final class CasGeneratorService implements CasGeneratorContract { /** @@ -27,50 +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) + * @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 - * - * @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 b0a900d..9915576 100644 --- a/src/Services/CasParserService.php +++ b/src/Services/CasParserService.php @@ -14,8 +14,6 @@ use CasParser\RequestOptions; use CasParser\ServiceContracts\CasParserContract; -use const CasParser\Core\OMIT as omit; - final class CasParserService implements CasParserContract { /** @@ -29,39 +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 + * @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 - * - * @throws APIException - */ - public function camsKfintechRaw( - array $params, - ?RequestOptions $requestOptions = null ): UnifiedResponse { [$parsed, $options] = CasParserCamsKfintechParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -80,39 +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 + * @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 - * - * @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; @@ -131,39 +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 + * @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 - * - * @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; @@ -182,39 +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 + * @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 - * - * @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 } From c124b7bdd9b7d6f7bbef3d386f9eb4038a6b20f3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 03:31:44 +0000 Subject: [PATCH 12/15] chore(internal): codegen related update --- src/CasGenerator/CasGeneratorGenerateCasParams.php | 2 +- src/CasParser/CasParserCamsKfintechParams.php | 2 +- src/CasParser/CasParserCdslParams.php | 2 +- src/CasParser/CasParserNsdlParams.php | 2 +- src/CasParser/CasParserSmartParseParams.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index 062a4be..133346f 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -14,7 +14,7 @@ * 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. * - * @see CasParser\CasGenerator->generateCas + * @see CasParser\Services\CasGeneratorService::generateCas() * * @phpstan-type CasGeneratorGenerateCasParamsShape = array{ * email: string, diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index 575b586..e615964 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -13,7 +13,7 @@ * 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. * - * @see CasParser\CasParser->camsKfintech + * @see CasParser\Services\CasParserService::camsKfintech() * * @phpstan-type CasParserCamsKfintechParamsShape = array{ * password?: string, pdf_file?: string, pdf_url?: string diff --git a/src/CasParser/CasParserCdslParams.php b/src/CasParser/CasParserCdslParams.php index 2d7bfae..33f8d03 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -13,7 +13,7 @@ * 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. * - * @see CasParser\CasParser->cdsl + * @see CasParser\Services\CasParserService::cdsl() * * @phpstan-type CasParserCdslParamsShape = array{ * password?: string, pdf_file?: string, pdf_url?: string diff --git a/src/CasParser/CasParserNsdlParams.php b/src/CasParser/CasParserNsdlParams.php index 8e8d831..4b8b2dc 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -13,7 +13,7 @@ * 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. * - * @see CasParser\CasParser->nsdl + * @see CasParser\Services\CasParserService::nsdl() * * @phpstan-type CasParserNsdlParamsShape = array{ * password?: string, pdf_file?: string, pdf_url?: string diff --git a/src/CasParser/CasParserSmartParseParams.php b/src/CasParser/CasParserSmartParseParams.php index eb3911a..c67e47d 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -13,7 +13,7 @@ * 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. * - * @see CasParser\CasParser->smartParse + * @see CasParser\Services\CasParserService::smartParse() * * @phpstan-type CasParserSmartParseParamsShape = array{ * password?: string, pdf_file?: string, pdf_url?: string From 6b7a99682bfce707850bfddeb41d2474f109ba83 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 03:32:44 +0000 Subject: [PATCH 13/15] fix: rename invalid types --- src/Core/Util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/Util.php b/src/Core/Util.php index 4717564..6cf0465 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -28,9 +28,9 @@ final class Util /** * @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); } /** From 90a131ad218e94a908056b01fb8425ab8783bbd4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 Jan 2026 23:18:06 +0000 Subject: [PATCH 14/15] feat(api): api update --- .stats.yml | 4 +- LICENSE | 2 +- README.md | 25 +- composer.json | 1 + release-please-config.json | 2 +- scripts/lint | 2 +- .../CasGeneratorGenerateCasParams.php | 97 ++++---- .../CasGeneratorGenerateCasResponse.php | 32 ++- src/CasParser/CasParserCamsKfintechParams.php | 46 ++-- src/CasParser/CasParserCdslParams.php | 46 ++-- src/CasParser/CasParserNsdlParams.php | 46 ++-- src/CasParser/CasParserSmartParseParams.php | 46 ++-- src/CasParser/UnifiedResponse.php | 160 ++++++------ .../UnifiedResponse/DematAccount.php | 174 +++++++------ .../DematAccount/AdditionalInfo.php | 118 ++++----- .../UnifiedResponse/DematAccount/Holdings.php | 110 +++++---- .../DematAccount/Holdings/Aif.php | 101 +++++--- .../Holdings/Aif/AdditionalInfo.php | 78 ++++++ .../DematAccount/Holdings/Aif/Transaction.php | 233 ++++++++++++++++++ .../Aif/Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../Holdings/Aif/Transaction/Type.php | 43 ++++ .../DematAccount/Holdings/CorporateBond.php | 101 +++++--- .../Holdings/CorporateBond/AdditionalInfo.php | 78 ++++++ .../Holdings/CorporateBond/Transaction.php | 233 ++++++++++++++++++ .../Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../CorporateBond/Transaction/Type.php | 43 ++++ .../DematAccount/Holdings/DematMutualFund.php | 101 +++++--- .../DematMutualFund/AdditionalInfo.php | 78 ++++++ .../Holdings/DematMutualFund/Transaction.php | 233 ++++++++++++++++++ .../Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../DematMutualFund/Transaction/Type.php | 43 ++++ .../DematAccount/Holdings/Equity.php | 101 +++++--- .../Holdings/Equity/AdditionalInfo.php | 78 ++++++ .../Holdings/Equity/Transaction.php | 233 ++++++++++++++++++ .../Equity/Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../Holdings/Equity/Transaction/Type.php | 43 ++++ .../Holdings/GovernmentSecurity.php | 101 +++++--- .../GovernmentSecurity/AdditionalInfo.php | 78 ++++++ .../GovernmentSecurity/Transaction.php | 233 ++++++++++++++++++ .../Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../GovernmentSecurity/Transaction/Type.php | 43 ++++ .../DematAccount/LinkedHolder.php | 26 +- src/CasParser/UnifiedResponse/Insurance.php | 30 +-- .../Insurance/LifeInsurancePolicy.php | 142 +++++------ src/CasParser/UnifiedResponse/Investor.php | 82 +++--- src/CasParser/UnifiedResponse/Meta.php | 69 +++--- .../UnifiedResponse/Meta/StatementPeriod.php | 44 ++-- src/CasParser/UnifiedResponse/MutualFund.php | 118 ++++----- .../MutualFund/AdditionalInfo.php | 36 +-- .../MutualFund/LinkedHolder.php | 26 +- .../UnifiedResponse/MutualFund/Scheme.php | 160 ++++++------ .../MutualFund/Scheme/AdditionalInfo.php | 86 +++---- .../MutualFund/Scheme/Gain.php | 26 +- .../MutualFund/Scheme/Transaction.php | 185 ++++++++------ .../Scheme/Transaction/AdditionalInfo.php | 179 ++++++++++++++ .../MutualFund/Scheme/Transaction/Type.php | 43 ++++ src/CasParser/UnifiedResponse/Np.php | 93 +++---- src/CasParser/UnifiedResponse/Np/Fund.php | 83 ++++--- .../Np/Fund/AdditionalInfo.php | 26 +- .../UnifiedResponse/Np/LinkedHolder.php | 26 +- src/CasParser/UnifiedResponse/Summary.php | 43 ++-- .../UnifiedResponse/Summary/Accounts.php | 94 ++++--- .../Summary/Accounts/Demat.php | 32 +-- .../Summary/Accounts/Insurance.php | 32 +-- .../Summary/Accounts/MutualFunds.php | 32 +-- .../UnifiedResponse/Summary/Accounts/Nps.php | 32 +-- src/Client.php | 13 +- src/Core/Attributes/Optional.php | 35 +++ src/Core/Attributes/{Api.php => Required.php} | 23 +- src/Core/BaseClient.php | 110 +++------ src/Core/Concerns/ResponseProxy.php | 101 ++++++++ src/Core/Concerns/SdkEnum.php | 3 +- src/Core/Concerns/SdkModel.php | 54 ++-- src/Core/Concerns/SdkPage.php | 34 +-- src/Core/Concerns/SdkParams.php | 9 +- src/Core/Concerns/SdkResponse.php | 29 --- src/Core/Concerns/SdkUnion.php | 3 +- src/Core/Contracts/BasePage.php | 19 -- src/Core/Contracts/BaseResponse.php | 21 ++ src/Core/Contracts/BaseStream.php | 1 + src/Core/Conversion.php | 50 ++-- src/Core/Conversion/Concerns/ArrayOf.php | 19 +- .../Contracts/ResponseConverter.php | 18 -- src/Core/Conversion/DumpState.php | 5 + src/Core/Conversion/EnumOf.php | 21 +- src/Core/Conversion/ListOf.php | 3 +- src/Core/Conversion/ModelOf.php | 39 +-- src/Core/Conversion/PropertyInfo.php | 13 +- src/Core/Conversion/UnionOf.php | 35 ++- src/Core/Exceptions/APITimeoutException.php | 2 +- src/Core/Implementation/RawResponse.php | 106 ++++++++ src/Core/Util.php | 104 +++++++- src/RequestOptions.php | 118 ++++----- src/ServiceContracts/CasGeneratorContract.php | 16 +- .../CasGeneratorRawContract.php | 28 +++ src/ServiceContracts/CasParserContract.php | 36 ++- src/ServiceContracts/CasParserRawContract.php | 73 ++++++ src/Services/CasGeneratorRawService.php | 61 +++++ src/Services/CasGeneratorService.php | 58 +++-- src/Services/CasParserRawService.php | 157 ++++++++++++ src/Services/CasParserService.php | 127 +++++----- src/Version.php | 9 + tests/Core/{TestModel.php => ModelTest.php} | 72 ++---- tests/Core/UtilTest.php | 90 +++++++ tests/Services/CasGeneratorTest.php | 33 +-- tests/Services/CasParserTest.php | 21 +- 106 files changed, 5764 insertions(+), 1831 deletions(-) create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/Type.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/Type.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/Type.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/Type.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/Type.php create mode 100644 src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/AdditionalInfo.php create mode 100644 src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/Type.php create mode 100644 src/Core/Attributes/Optional.php rename src/Core/Attributes/{Api.php => Required.php} (77%) create mode 100644 src/Core/Concerns/ResponseProxy.php delete mode 100644 src/Core/Concerns/SdkResponse.php create mode 100644 src/Core/Contracts/BaseResponse.php delete mode 100644 src/Core/Conversion/Contracts/ResponseConverter.php create mode 100644 src/Core/Implementation/RawResponse.php create mode 100644 src/ServiceContracts/CasGeneratorRawContract.php create mode 100644 src/ServiceContracts/CasParserRawContract.php create mode 100644 src/Services/CasGeneratorRawService.php create mode 100644 src/Services/CasParserRawService.php create mode 100644 src/Version.php rename tests/Core/{TestModel.php => ModelTest.php} (68%) create mode 100644 tests/Core/UtilTest.php diff --git a/.stats.yml b/.stats.yml index 06e7614..48b33b3 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-9eaed98ce5934f11e901cef376a28257d2c196bd3dba7c690babc6741a730ded.yml -openapi_spec_hash: b76e4e830c4d03ba4cf9429bb9fb9c8a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-38618cc5c938e87eeacf4893d6a6ba4e6ef7da390e6283dc7b50b484a7b97165.yml +openapi_spec_hash: b9e439ecee904ded01aa34efdee88856 config_hash: cb5d75abef6264b5d86448caf7295afa diff --git a/LICENSE b/LICENSE index f1756ce..6bbb512 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Cas Parser + Copyright 2026 Cas Parser Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index d3c1a94..0373ccf 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,11 @@ Parameters with a default value must be set by name. use CasParser\Client; -$client = new Client(apiKey: getenv("CAS_PARSER_API_KEY") ?: "My API Key"); +$client = new Client(apiKey: getenv('CAS_PARSER_API_KEY') ?: 'My API Key'); -$unifiedResponse = $client->casParser->smartParse([]); +$unifiedResponse = $client->casParser->smartParse( + password: 'ABCDF', pdfURL: 'https://your-cas-pdf-url-here.com' +); var_dump($unifiedResponse->demat_accounts); ``` @@ -71,11 +73,11 @@ 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()); -} catch (RateLimitError $_) { +} catch (RateLimitError $e) { echo "A 429 status code was received; we should back off a bit.", PHP_EOL; } catch (APIStatusError $e) { echo "Another non-200-range status code was received", PHP_EOL; @@ -118,7 +120,9 @@ $client = new Client(maxRetries: 0); // Or, configure per-request: $result = $client->casParser->smartParse( - [], RequestOptions::with(maxRetries: 5) + password: 'ABCDF', + pdfURL: 'https://you-cas-pdf-url-here.com', + requestOptions: RequestOptions::with(maxRetries: 5), ); ``` @@ -138,11 +142,12 @@ Note: the `extra*` parameters of the same name overrides the documented paramete use CasParser\RequestOptions; $unifiedResponse = $client->casParser->smartParse( - [], - RequestOptions::with( - extraQueryParams: ["my_query_parameter" => "value"], - extraBodyParams: ["my_body_parameter" => "value"], - extraHeaders: ["my-header" => "value"], + password: 'ABCDF', + pdfURL: 'https://you-cas-pdf-url-here.com', + requestOptions: RequestOptions::with( + extraQueryParams: ['my_query_parameter' => 'value'], + extraBodyParams: ['my_body_parameter' => 'value'], + extraHeaders: ['my-header' => 'value'], ), ); ``` diff --git a/composer.json b/composer.json index 1a19d72..d5990da 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "autoload": { "files": [ "src/Core.php", + "src/Version.php", "src/Client.php" ], "psr-4": { diff --git a/release-please-config.json b/release-please-config.json index 5c15181..83bea62 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -62,6 +62,6 @@ "release-type": "php", "extra-files": [ "README.md", - "src/Client.php" + "src/Version.php" ] } \ No newline at end of file diff --git a/scripts/lint b/scripts/lint index 13f2f01..211ce90 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=2G +exec -- ./vendor/bin/phpstan analyse --memory-limit=12G diff --git a/src/CasGenerator/CasGeneratorGenerateCasParams.php b/src/CasGenerator/CasGeneratorGenerateCasParams.php index 133346f..3a7cdec 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasParams.php +++ b/src/CasGenerator/CasGeneratorGenerateCasParams.php @@ -5,7 +5,8 @@ namespace CasParser\CasGenerator; use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; +use CasParser\Core\Attributes\Required; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Concerns\SdkParams; use CasParser\Core\Contracts\BaseModel; @@ -18,11 +19,11 @@ * * @phpstan-type CasGeneratorGenerateCasParamsShape = array{ * email: string, - * from_date: string, + * fromDate: string, * password: string, - * to_date: string, - * cas_authority?: CasAuthority|value-of, - * pan_no?: string, + * toDate: string, + * casAuthority?: null|CasAuthority|value-of, + * panNo?: string|null, * } */ final class CasGeneratorGenerateCasParams implements BaseModel @@ -34,40 +35,40 @@ final class CasGeneratorGenerateCasParams implements BaseModel /** * Email address to receive the CAS document. */ - #[Api] + #[Required] public string $email; /** * Start date for the CAS period (format YYYY-MM-DD). */ - #[Api] - public string $from_date; + #[Required('from_date')] + public string $fromDate; /** * Password to protect the generated CAS PDF. */ - #[Api] + #[Required] public string $password; /** * End date for the CAS period (format YYYY-MM-DD). */ - #[Api] - public string $to_date; + #[Required('to_date')] + public string $toDate; /** * CAS authority to generate the document from (currently only kfintech is supported). * - * @var value-of|null $cas_authority + * @var value-of|null $casAuthority */ - #[Api(enum: CasAuthority::class, optional: true)] - public ?string $cas_authority; + #[Optional('cas_authority', enum: CasAuthority::class)] + public ?string $casAuthority; /** * PAN number (optional for some CAS authorities). */ - #[Api(optional: true)] - public ?string $pan_no; + #[Optional('pan_no')] + public ?string $panNo; /** * `new CasGeneratorGenerateCasParams()` is missing required properties by the API. @@ -75,7 +76,7 @@ final class CasGeneratorGenerateCasParams implements BaseModel * To enforce required parameters use * ``` * CasGeneratorGenerateCasParams::with( - * email: ..., from_date: ..., password: ..., to_date: ... + * email: ..., fromDate: ..., password: ..., toDate: ... * ) * ``` * @@ -99,27 +100,27 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param CasAuthority|value-of $cas_authority + * @param CasAuthority|value-of|null $casAuthority */ public static function with( string $email, - string $from_date, + string $fromDate, string $password, - string $to_date, - CasAuthority|string|null $cas_authority = null, - ?string $pan_no = null, + string $toDate, + CasAuthority|string|null $casAuthority = null, + ?string $panNo = null, ): self { - $obj = new self; + $self = new self; - $obj->email = $email; - $obj->from_date = $from_date; - $obj->password = $password; - $obj->to_date = $to_date; + $self['email'] = $email; + $self['fromDate'] = $fromDate; + $self['password'] = $password; + $self['toDate'] = $toDate; - null !== $cas_authority && $obj['cas_authority'] = $cas_authority; - null !== $pan_no && $obj->pan_no = $pan_no; + null !== $casAuthority && $self['casAuthority'] = $casAuthority; + null !== $panNo && $self['panNo'] = $panNo; - return $obj; + return $self; } /** @@ -127,10 +128,10 @@ public static function with( */ public function withEmail(string $email): self { - $obj = clone $this; - $obj->email = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -138,10 +139,10 @@ public function withEmail(string $email): self */ public function withFromDate(string $fromDate): self { - $obj = clone $this; - $obj->from_date = $fromDate; + $self = clone $this; + $self['fromDate'] = $fromDate; - return $obj; + return $self; } /** @@ -149,10 +150,10 @@ public function withFromDate(string $fromDate): self */ public function withPassword(string $password): self { - $obj = clone $this; - $obj->password = $password; + $self = clone $this; + $self['password'] = $password; - return $obj; + return $self; } /** @@ -160,10 +161,10 @@ public function withPassword(string $password): self */ public function withToDate(string $toDate): self { - $obj = clone $this; - $obj->to_date = $toDate; + $self = clone $this; + $self['toDate'] = $toDate; - return $obj; + return $self; } /** @@ -173,10 +174,10 @@ public function withToDate(string $toDate): self */ public function withCasAuthority(CasAuthority|string $casAuthority): self { - $obj = clone $this; - $obj['cas_authority'] = $casAuthority; + $self = clone $this; + $self['casAuthority'] = $casAuthority; - return $obj; + return $self; } /** @@ -184,9 +185,9 @@ public function withCasAuthority(CasAuthority|string $casAuthority): self */ public function withPanNo(string $panNo): self { - $obj = clone $this; - $obj->pan_no = $panNo; + $self = clone $this; + $self['panNo'] = $panNo; - return $obj; + return $self; } } diff --git a/src/CasGenerator/CasGeneratorGenerateCasResponse.php b/src/CasGenerator/CasGeneratorGenerateCasResponse.php index fc9e495..365bf25 100644 --- a/src/CasGenerator/CasGeneratorGenerateCasResponse.php +++ b/src/CasGenerator/CasGeneratorGenerateCasResponse.php @@ -4,28 +4,24 @@ namespace CasParser\CasGenerator; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; -use CasParser\Core\Concerns\SdkResponse; use CasParser\Core\Contracts\BaseModel; -use CasParser\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type CasGeneratorGenerateCasResponseShape = array{ * msg?: string|null, status?: string|null * } */ -final class CasGeneratorGenerateCasResponse implements BaseModel, ResponseConverter +final class CasGeneratorGenerateCasResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api(optional: true)] + #[Optional] public ?string $msg; - #[Api(optional: true)] + #[Optional] public ?string $status; public function __construct() @@ -40,27 +36,27 @@ public function __construct() */ public static function with(?string $msg = null, ?string $status = null): self { - $obj = new self; + $self = new self; - null !== $msg && $obj->msg = $msg; - null !== $status && $obj->status = $status; + null !== $msg && $self['msg'] = $msg; + null !== $status && $self['status'] = $status; - return $obj; + return $self; } public function withMsg(string $msg): self { - $obj = clone $this; - $obj->msg = $msg; + $self = clone $this; + $self['msg'] = $msg; - return $obj; + return $self; } public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } } diff --git a/src/CasParser/CasParserCamsKfintechParams.php b/src/CasParser/CasParserCamsKfintechParams.php index e615964..a894855 100644 --- a/src/CasParser/CasParserCamsKfintechParams.php +++ b/src/CasParser/CasParserCamsKfintechParams.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Concerns\SdkParams; use CasParser\Core\Contracts\BaseModel; @@ -16,7 +16,7 @@ * @see CasParser\Services\CasParserService::camsKfintech() * * @phpstan-type CasParserCamsKfintechParamsShape = array{ - * password?: string, pdf_file?: string, pdf_url?: string + * password?: string|null, pdfFile?: string|null, pdfURL?: string|null * } */ final class CasParserCamsKfintechParams implements BaseModel @@ -28,20 +28,20 @@ final class CasParserCamsKfintechParams implements BaseModel /** * Password for the PDF file (if required). */ - #[Api(optional: true)] + #[Optional] public ?string $password; /** * Base64 encoded CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_file; + #[Optional('pdf_file')] + public ?string $pdfFile; /** * URL to the CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_url; + #[Optional('pdf_url')] + public ?string $pdfURL; public function __construct() { @@ -55,16 +55,16 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdf_file = null, - ?string $pdf_url = null + ?string $pdfFile = null, + ?string $pdfURL = null ): self { - $obj = new self; + $self = new self; - null !== $password && $obj->password = $password; - null !== $pdf_file && $obj->pdf_file = $pdf_file; - null !== $pdf_url && $obj->pdf_url = $pdf_url; + null !== $password && $self['password'] = $password; + null !== $pdfFile && $self['pdfFile'] = $pdfFile; + null !== $pdfURL && $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } /** @@ -72,10 +72,10 @@ public static function with( */ public function withPassword(string $password): self { - $obj = clone $this; - $obj->password = $password; + $self = clone $this; + $self['password'] = $password; - return $obj; + return $self; } /** @@ -83,10 +83,10 @@ public function withPassword(string $password): self */ public function withPdfFile(string $pdfFile): self { - $obj = clone $this; - $obj->pdf_file = $pdfFile; + $self = clone $this; + $self['pdfFile'] = $pdfFile; - return $obj; + return $self; } /** @@ -94,9 +94,9 @@ public function withPdfFile(string $pdfFile): self */ public function withPdfURL(string $pdfURL): self { - $obj = clone $this; - $obj->pdf_url = $pdfURL; + $self = clone $this; + $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } } diff --git a/src/CasParser/CasParserCdslParams.php b/src/CasParser/CasParserCdslParams.php index 33f8d03..0756764 100644 --- a/src/CasParser/CasParserCdslParams.php +++ b/src/CasParser/CasParserCdslParams.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Concerns\SdkParams; use CasParser\Core\Contracts\BaseModel; @@ -16,7 +16,7 @@ * @see CasParser\Services\CasParserService::cdsl() * * @phpstan-type CasParserCdslParamsShape = array{ - * password?: string, pdf_file?: string, pdf_url?: string + * password?: string|null, pdfFile?: string|null, pdfURL?: string|null * } */ final class CasParserCdslParams implements BaseModel @@ -28,20 +28,20 @@ final class CasParserCdslParams implements BaseModel /** * Password for the PDF file (if required). */ - #[Api(optional: true)] + #[Optional] public ?string $password; /** * Base64 encoded CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_file; + #[Optional('pdf_file')] + public ?string $pdfFile; /** * URL to the CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_url; + #[Optional('pdf_url')] + public ?string $pdfURL; public function __construct() { @@ -55,16 +55,16 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdf_file = null, - ?string $pdf_url = null + ?string $pdfFile = null, + ?string $pdfURL = null ): self { - $obj = new self; + $self = new self; - null !== $password && $obj->password = $password; - null !== $pdf_file && $obj->pdf_file = $pdf_file; - null !== $pdf_url && $obj->pdf_url = $pdf_url; + null !== $password && $self['password'] = $password; + null !== $pdfFile && $self['pdfFile'] = $pdfFile; + null !== $pdfURL && $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } /** @@ -72,10 +72,10 @@ public static function with( */ public function withPassword(string $password): self { - $obj = clone $this; - $obj->password = $password; + $self = clone $this; + $self['password'] = $password; - return $obj; + return $self; } /** @@ -83,10 +83,10 @@ public function withPassword(string $password): self */ public function withPdfFile(string $pdfFile): self { - $obj = clone $this; - $obj->pdf_file = $pdfFile; + $self = clone $this; + $self['pdfFile'] = $pdfFile; - return $obj; + return $self; } /** @@ -94,9 +94,9 @@ public function withPdfFile(string $pdfFile): self */ public function withPdfURL(string $pdfURL): self { - $obj = clone $this; - $obj->pdf_url = $pdfURL; + $self = clone $this; + $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } } diff --git a/src/CasParser/CasParserNsdlParams.php b/src/CasParser/CasParserNsdlParams.php index 4b8b2dc..6221f30 100644 --- a/src/CasParser/CasParserNsdlParams.php +++ b/src/CasParser/CasParserNsdlParams.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Concerns\SdkParams; use CasParser\Core\Contracts\BaseModel; @@ -16,7 +16,7 @@ * @see CasParser\Services\CasParserService::nsdl() * * @phpstan-type CasParserNsdlParamsShape = array{ - * password?: string, pdf_file?: string, pdf_url?: string + * password?: string|null, pdfFile?: string|null, pdfURL?: string|null * } */ final class CasParserNsdlParams implements BaseModel @@ -28,20 +28,20 @@ final class CasParserNsdlParams implements BaseModel /** * Password for the PDF file (if required). */ - #[Api(optional: true)] + #[Optional] public ?string $password; /** * Base64 encoded CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_file; + #[Optional('pdf_file')] + public ?string $pdfFile; /** * URL to the CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_url; + #[Optional('pdf_url')] + public ?string $pdfURL; public function __construct() { @@ -55,16 +55,16 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdf_file = null, - ?string $pdf_url = null + ?string $pdfFile = null, + ?string $pdfURL = null ): self { - $obj = new self; + $self = new self; - null !== $password && $obj->password = $password; - null !== $pdf_file && $obj->pdf_file = $pdf_file; - null !== $pdf_url && $obj->pdf_url = $pdf_url; + null !== $password && $self['password'] = $password; + null !== $pdfFile && $self['pdfFile'] = $pdfFile; + null !== $pdfURL && $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } /** @@ -72,10 +72,10 @@ public static function with( */ public function withPassword(string $password): self { - $obj = clone $this; - $obj->password = $password; + $self = clone $this; + $self['password'] = $password; - return $obj; + return $self; } /** @@ -83,10 +83,10 @@ public function withPassword(string $password): self */ public function withPdfFile(string $pdfFile): self { - $obj = clone $this; - $obj->pdf_file = $pdfFile; + $self = clone $this; + $self['pdfFile'] = $pdfFile; - return $obj; + return $self; } /** @@ -94,9 +94,9 @@ public function withPdfFile(string $pdfFile): self */ public function withPdfURL(string $pdfURL): self { - $obj = clone $this; - $obj->pdf_url = $pdfURL; + $self = clone $this; + $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } } diff --git a/src/CasParser/CasParserSmartParseParams.php b/src/CasParser/CasParserSmartParseParams.php index c67e47d..eae6497 100644 --- a/src/CasParser/CasParserSmartParseParams.php +++ b/src/CasParser/CasParserSmartParseParams.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Concerns\SdkParams; use CasParser\Core\Contracts\BaseModel; @@ -16,7 +16,7 @@ * @see CasParser\Services\CasParserService::smartParse() * * @phpstan-type CasParserSmartParseParamsShape = array{ - * password?: string, pdf_file?: string, pdf_url?: string + * password?: string|null, pdfFile?: string|null, pdfURL?: string|null * } */ final class CasParserSmartParseParams implements BaseModel @@ -28,20 +28,20 @@ final class CasParserSmartParseParams implements BaseModel /** * Password for the PDF file (if required). */ - #[Api(optional: true)] + #[Optional] public ?string $password; /** * Base64 encoded CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_file; + #[Optional('pdf_file')] + public ?string $pdfFile; /** * URL to the CAS PDF file. */ - #[Api(optional: true)] - public ?string $pdf_url; + #[Optional('pdf_url')] + public ?string $pdfURL; public function __construct() { @@ -55,16 +55,16 @@ public function __construct() */ public static function with( ?string $password = null, - ?string $pdf_file = null, - ?string $pdf_url = null + ?string $pdfFile = null, + ?string $pdfURL = null ): self { - $obj = new self; + $self = new self; - null !== $password && $obj->password = $password; - null !== $pdf_file && $obj->pdf_file = $pdf_file; - null !== $pdf_url && $obj->pdf_url = $pdf_url; + null !== $password && $self['password'] = $password; + null !== $pdfFile && $self['pdfFile'] = $pdfFile; + null !== $pdfURL && $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } /** @@ -72,10 +72,10 @@ public static function with( */ public function withPassword(string $password): self { - $obj = clone $this; - $obj->password = $password; + $self = clone $this; + $self['password'] = $password; - return $obj; + return $self; } /** @@ -83,10 +83,10 @@ public function withPassword(string $password): self */ public function withPdfFile(string $pdfFile): self { - $obj = clone $this; - $obj->pdf_file = $pdfFile; + $self = clone $this; + $self['pdfFile'] = $pdfFile; - return $obj; + return $self; } /** @@ -94,9 +94,9 @@ public function withPdfFile(string $pdfFile): self */ public function withPdfURL(string $pdfURL): self { - $obj = clone $this; - $obj->pdf_url = $pdfURL; + $self = clone $this; + $self['pdfURL'] = $pdfURL; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse.php b/src/CasParser/UnifiedResponse.php index 5de1d90..238d50d 100644 --- a/src/CasParser/UnifiedResponse.php +++ b/src/CasParser/UnifiedResponse.php @@ -11,56 +11,60 @@ use CasParser\CasParser\UnifiedResponse\MutualFund; use CasParser\CasParser\UnifiedResponse\Np; use CasParser\CasParser\UnifiedResponse\Summary; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; -use CasParser\Core\Concerns\SdkResponse; use CasParser\Core\Contracts\BaseModel; -use CasParser\Core\Conversion\Contracts\ResponseConverter; /** + * @phpstan-import-type DematAccountShape from \CasParser\CasParser\UnifiedResponse\DematAccount + * @phpstan-import-type InsuranceShape from \CasParser\CasParser\UnifiedResponse\Insurance + * @phpstan-import-type InvestorShape from \CasParser\CasParser\UnifiedResponse\Investor + * @phpstan-import-type MetaShape from \CasParser\CasParser\UnifiedResponse\Meta + * @phpstan-import-type MutualFundShape from \CasParser\CasParser\UnifiedResponse\MutualFund + * @phpstan-import-type NpShape from \CasParser\CasParser\UnifiedResponse\Np + * @phpstan-import-type SummaryShape from \CasParser\CasParser\UnifiedResponse\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, + * dematAccounts?: list|null, + * insurance?: null|Insurance|InsuranceShape, + * investor?: null|Investor|InvestorShape, + * meta?: null|Meta|MetaShape, + * mutualFunds?: list|null, + * nps?: list|null, + * summary?: null|Summary|SummaryShape, * } */ -final class UnifiedResponse implements BaseModel, ResponseConverter +final class UnifiedResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; + /** @var list|null $dematAccounts */ + #[Optional('demat_accounts', list: DematAccount::class)] + public ?array $dematAccounts; - /** @var list|null $demat_accounts */ - #[Api(list: DematAccount::class, optional: true)] - public ?array $demat_accounts; - - #[Api(optional: true)] + #[Optional] public ?Insurance $insurance; - #[Api(optional: true)] + #[Optional] public ?Investor $investor; - #[Api(optional: true)] + #[Optional] public ?Meta $meta; - /** @var list|null $mutual_funds */ - #[Api(list: MutualFund::class, optional: true)] - public ?array $mutual_funds; + /** @var list|null $mutualFunds */ + #[Optional('mutual_funds', list: MutualFund::class)] + public ?array $mutualFunds; /** * List of NPS accounts. * * @var list|null $nps */ - #[Api(list: Np::class, optional: true)] + #[Optional(list: Np::class)] public ?array $nps; - #[Api(optional: true)] + #[Optional] public ?Summary $summary; public function __construct() @@ -73,96 +77,112 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $demat_accounts - * @param list $mutual_funds - * @param list $nps + * @param list|null $dematAccounts + * @param Insurance|InsuranceShape|null $insurance + * @param Investor|InvestorShape|null $investor + * @param Meta|MetaShape|null $meta + * @param list|null $mutualFunds + * @param list|null $nps + * @param Summary|SummaryShape|null $summary */ public static function with( - ?array $demat_accounts = null, - ?Insurance $insurance = null, - ?Investor $investor = null, - ?Meta $meta = null, - ?array $mutual_funds = null, + ?array $dematAccounts = null, + Insurance|array|null $insurance = null, + Investor|array|null $investor = null, + Meta|array|null $meta = null, + ?array $mutualFunds = null, ?array $nps = null, - ?Summary $summary = null, + Summary|array|null $summary = null, ): self { - $obj = new self; + $self = new self; - null !== $demat_accounts && $obj->demat_accounts = $demat_accounts; - null !== $insurance && $obj->insurance = $insurance; - null !== $investor && $obj->investor = $investor; - null !== $meta && $obj->meta = $meta; - null !== $mutual_funds && $obj->mutual_funds = $mutual_funds; - null !== $nps && $obj->nps = $nps; - null !== $summary && $obj->summary = $summary; + null !== $dematAccounts && $self['dematAccounts'] = $dematAccounts; + null !== $insurance && $self['insurance'] = $insurance; + null !== $investor && $self['investor'] = $investor; + null !== $meta && $self['meta'] = $meta; + null !== $mutualFunds && $self['mutualFunds'] = $mutualFunds; + null !== $nps && $self['nps'] = $nps; + null !== $summary && $self['summary'] = $summary; - return $obj; + return $self; } /** - * @param list $dematAccounts + * @param list $dematAccounts */ public function withDematAccounts(array $dematAccounts): self { - $obj = clone $this; - $obj->demat_accounts = $dematAccounts; + $self = clone $this; + $self['dematAccounts'] = $dematAccounts; - return $obj; + return $self; } - public function withInsurance(Insurance $insurance): self + /** + * @param Insurance|InsuranceShape $insurance + */ + public function withInsurance(Insurance|array $insurance): self { - $obj = clone $this; - $obj->insurance = $insurance; + $self = clone $this; + $self['insurance'] = $insurance; - return $obj; + return $self; } - public function withInvestor(Investor $investor): self + /** + * @param Investor|InvestorShape $investor + */ + public function withInvestor(Investor|array $investor): self { - $obj = clone $this; - $obj->investor = $investor; + $self = clone $this; + $self['investor'] = $investor; - return $obj; + return $self; } - public function withMeta(Meta $meta): self + /** + * @param Meta|MetaShape $meta + */ + public function withMeta(Meta|array $meta): self { - $obj = clone $this; - $obj->meta = $meta; + $self = clone $this; + $self['meta'] = $meta; - return $obj; + return $self; } /** - * @param list $mutualFunds + * @param list $mutualFunds */ public function withMutualFunds(array $mutualFunds): self { - $obj = clone $this; - $obj->mutual_funds = $mutualFunds; + $self = clone $this; + $self['mutualFunds'] = $mutualFunds; - return $obj; + return $self; } /** * List of NPS accounts. * - * @param list $nps + * @param list $nps */ public function withNps(array $nps): self { - $obj = clone $this; - $obj->nps = $nps; + $self = clone $this; + $self['nps'] = $nps; - return $obj; + return $self; } - public function withSummary(Summary $summary): self + /** + * @param Summary|SummaryShape $summary + */ + public function withSummary(Summary|array $summary): self { - $obj = clone $this; - $obj->summary = $summary; + $self = clone $this; + $self['summary'] = $summary; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount.php b/src/CasParser/UnifiedResponse/DematAccount.php index 5901828..27961d4 100644 --- a/src/CasParser/UnifiedResponse/DematAccount.php +++ b/src/CasParser/UnifiedResponse/DematAccount.php @@ -8,20 +8,24 @@ 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\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\DematAccount\AdditionalInfo + * @phpstan-import-type HoldingsShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings + * @phpstan-import-type LinkedHolderShape from \CasParser\CasParser\UnifiedResponse\DematAccount\LinkedHolder + * * @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, + * additionalInfo?: null|AdditionalInfo|AdditionalInfoShape, + * boID?: string|null, + * clientID?: string|null, + * dematType?: null|DematType|value-of, + * dpID?: string|null, + * dpName?: string|null, + * holdings?: null|Holdings|HoldingsShape, + * linkedHolders?: list|null, * value?: float|null, * } */ @@ -33,56 +37,56 @@ final class DematAccount implements BaseModel /** * Additional information specific to the demat account type. */ - #[Api(optional: true)] - public ?AdditionalInfo $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * Beneficiary Owner ID (primarily for CDSL). */ - #[Api(optional: true)] - public ?string $bo_id; + #[Optional('bo_id')] + public ?string $boID; /** * Client ID. */ - #[Api(optional: true)] - public ?string $client_id; + #[Optional('client_id')] + public ?string $clientID; /** * Type of demat account. * - * @var value-of|null $demat_type + * @var value-of|null $dematType */ - #[Api(enum: DematType::class, optional: true)] - public ?string $demat_type; + #[Optional('demat_type', enum: DematType::class)] + public ?string $dematType; /** * Depository Participant ID. */ - #[Api(optional: true)] - public ?string $dp_id; + #[Optional('dp_id')] + public ?string $dpID; /** * Depository Participant name. */ - #[Api(optional: true)] - public ?string $dp_name; + #[Optional('dp_name')] + public ?string $dpName; - #[Api(optional: true)] + #[Optional] public ?Holdings $holdings; /** * List of account holders linked to this demat account. * - * @var list|null $linked_holders + * @var list|null $linkedHolders */ - #[Api(list: LinkedHolder::class, optional: true)] - public ?array $linked_holders; + #[Optional('linked_holders', list: LinkedHolder::class)] + public ?array $linkedHolders; /** * Total value of the demat account. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -95,44 +99,49 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param DematType|value-of $demat_type - * @param list $linked_holders + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param DematType|value-of|null $dematType + * @param Holdings|HoldingsShape|null $holdings + * @param list|null $linkedHolders */ public static function with( - ?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, + AdditionalInfo|array|null $additionalInfo = null, + ?string $boID = null, + ?string $clientID = null, + DematType|string|null $dematType = null, + ?string $dpID = null, + ?string $dpName = null, + Holdings|array|null $holdings = null, + ?array $linkedHolders = null, ?float $value = null, ): self { - $obj = new self; - - 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; + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $boID && $self['boID'] = $boID; + null !== $clientID && $self['clientID'] = $clientID; + null !== $dematType && $self['dematType'] = $dematType; + null !== $dpID && $self['dpID'] = $dpID; + null !== $dpName && $self['dpName'] = $dpName; + null !== $holdings && $self['holdings'] = $holdings; + null !== $linkedHolders && $self['linkedHolders'] = $linkedHolders; + null !== $value && $self['value'] = $value; + + return $self; } /** * Additional information specific to the demat account type. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(AdditionalInfo $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -140,10 +149,10 @@ public function withAdditionalInfo(AdditionalInfo $additionalInfo): self */ public function withBoID(string $boID): self { - $obj = clone $this; - $obj->bo_id = $boID; + $self = clone $this; + $self['boID'] = $boID; - return $obj; + return $self; } /** @@ -151,10 +160,10 @@ public function withBoID(string $boID): self */ public function withClientID(string $clientID): self { - $obj = clone $this; - $obj->client_id = $clientID; + $self = clone $this; + $self['clientID'] = $clientID; - return $obj; + return $self; } /** @@ -164,10 +173,10 @@ public function withClientID(string $clientID): self */ public function withDematType(DematType|string $dematType): self { - $obj = clone $this; - $obj['demat_type'] = $dematType; + $self = clone $this; + $self['dematType'] = $dematType; - return $obj; + return $self; } /** @@ -175,10 +184,10 @@ public function withDematType(DematType|string $dematType): self */ public function withDpID(string $dpID): self { - $obj = clone $this; - $obj->dp_id = $dpID; + $self = clone $this; + $self['dpID'] = $dpID; - return $obj; + return $self; } /** @@ -186,31 +195,34 @@ public function withDpID(string $dpID): self */ public function withDpName(string $dpName): self { - $obj = clone $this; - $obj->dp_name = $dpName; + $self = clone $this; + $self['dpName'] = $dpName; - return $obj; + return $self; } - public function withHoldings(Holdings $holdings): self + /** + * @param Holdings|HoldingsShape $holdings + */ + public function withHoldings(Holdings|array $holdings): self { - $obj = clone $this; - $obj->holdings = $holdings; + $self = clone $this; + $self['holdings'] = $holdings; - return $obj; + return $self; } /** * List of account holders linked to this demat account. * - * @param list $linkedHolders + * @param list $linkedHolders */ public function withLinkedHolders(array $linkedHolders): self { - $obj = clone $this; - $obj->linked_holders = $linkedHolders; + $self = clone $this; + $self['linkedHolders'] = $linkedHolders; - return $obj; + return $self; } /** @@ -218,9 +230,9 @@ public function withLinkedHolders(array $linkedHolders): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php index 38fbb27..0e7de05 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/DematAccount/AdditionalInfo.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\DematAccount; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -12,12 +12,12 @@ * Additional information specific to the demat account type. * * @phpstan-type AdditionalInfoShape = array{ - * bo_status?: string|null, - * bo_sub_status?: string|null, - * bo_type?: string|null, + * boStatus?: string|null, + * boSubStatus?: string|null, + * boType?: string|null, * bsda?: string|null, * email?: string|null, - * linked_pans?: list|null, + * linkedPans?: list|null, * nominee?: string|null, * status?: string|null, * } @@ -30,51 +30,51 @@ final class AdditionalInfo implements BaseModel /** * Beneficiary Owner status (CDSL). */ - #[Api(optional: true)] - public ?string $bo_status; + #[Optional('bo_status')] + public ?string $boStatus; /** * Beneficiary Owner sub-status (CDSL). */ - #[Api(optional: true)] - public ?string $bo_sub_status; + #[Optional('bo_sub_status')] + public ?string $boSubStatus; /** * Beneficiary Owner type (CDSL). */ - #[Api(optional: true)] - public ?string $bo_type; + #[Optional('bo_type')] + public ?string $boType; /** * Basic Services Demat Account status (CDSL). */ - #[Api(optional: true)] + #[Optional] public ?string $bsda; /** * Email associated with the demat account (CDSL). */ - #[Api(optional: true)] + #[Optional] public ?string $email; /** * List of linked PAN numbers (NSDL). * - * @var list|null $linked_pans + * @var list|null $linkedPans */ - #[Api(list: 'string', optional: true)] - public ?array $linked_pans; + #[Optional('linked_pans', list: 'string')] + public ?array $linkedPans; /** * Nominee details (CDSL). */ - #[Api(optional: true)] + #[Optional] public ?string $nominee; /** * Account status (CDSL). */ - #[Api(optional: true)] + #[Optional] public ?string $status; public function __construct() @@ -87,30 +87,30 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $linked_pans + * @param list|null $linkedPans */ public static function with( - ?string $bo_status = null, - ?string $bo_sub_status = null, - ?string $bo_type = null, + ?string $boStatus = null, + ?string $boSubStatus = null, + ?string $boType = null, ?string $bsda = null, ?string $email = null, - ?array $linked_pans = null, + ?array $linkedPans = null, ?string $nominee = null, ?string $status = null, ): self { - $obj = new self; - - 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 !== $linked_pans && $obj->linked_pans = $linked_pans; - null !== $nominee && $obj->nominee = $nominee; - null !== $status && $obj->status = $status; - - return $obj; + $self = new self; + + null !== $boStatus && $self['boStatus'] = $boStatus; + null !== $boSubStatus && $self['boSubStatus'] = $boSubStatus; + null !== $boType && $self['boType'] = $boType; + null !== $bsda && $self['bsda'] = $bsda; + null !== $email && $self['email'] = $email; + null !== $linkedPans && $self['linkedPans'] = $linkedPans; + null !== $nominee && $self['nominee'] = $nominee; + null !== $status && $self['status'] = $status; + + return $self; } /** @@ -118,10 +118,10 @@ public static function with( */ public function withBoStatus(string $boStatus): self { - $obj = clone $this; - $obj->bo_status = $boStatus; + $self = clone $this; + $self['boStatus'] = $boStatus; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withBoStatus(string $boStatus): self */ public function withBoSubStatus(string $boSubStatus): self { - $obj = clone $this; - $obj->bo_sub_status = $boSubStatus; + $self = clone $this; + $self['boSubStatus'] = $boSubStatus; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withBoSubStatus(string $boSubStatus): self */ public function withBoType(string $boType): self { - $obj = clone $this; - $obj->bo_type = $boType; + $self = clone $this; + $self['boType'] = $boType; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withBoType(string $boType): self */ public function withBsda(string $bsda): self { - $obj = clone $this; - $obj->bsda = $bsda; + $self = clone $this; + $self['bsda'] = $bsda; - return $obj; + return $self; } /** @@ -162,10 +162,10 @@ public function withBsda(string $bsda): self */ public function withEmail(string $email): self { - $obj = clone $this; - $obj->email = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -175,10 +175,10 @@ public function withEmail(string $email): self */ public function withLinkedPans(array $linkedPans): self { - $obj = clone $this; - $obj->linked_pans = $linkedPans; + $self = clone $this; + $self['linkedPans'] = $linkedPans; - return $obj; + return $self; } /** @@ -186,10 +186,10 @@ public function withLinkedPans(array $linkedPans): self */ public function withNominee(string $nominee): self { - $obj = clone $this; - $obj->nominee = $nominee; + $self = clone $this; + $self['nominee'] = $nominee; - return $obj; + return $self; } /** @@ -197,9 +197,9 @@ public function withNominee(string $nominee): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php index e800558..7e286f0 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings.php @@ -9,17 +9,23 @@ use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\DematMutualFund; use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Equity; use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\GovernmentSecurity; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AifShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Aif + * @phpstan-import-type CorporateBondShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\CorporateBond + * @phpstan-import-type DematMutualFundShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\DematMutualFund + * @phpstan-import-type EquityShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Equity + * @phpstan-import-type GovernmentSecurityShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\GovernmentSecurity + * * @phpstan-type HoldingsShape = array{ - * aifs?: list|null, - * corporate_bonds?: list|null, - * demat_mutual_funds?: list|null, - * equities?: list|null, - * government_securities?: list|null, + * aifs?: list|null, + * corporateBonds?: list|null, + * dematMutualFunds?: list|null, + * equities?: list|null, + * governmentSecurities?: list|null, * } */ final class Holdings implements BaseModel @@ -28,24 +34,24 @@ final class Holdings implements BaseModel use SdkModel; /** @var list|null $aifs */ - #[Api(list: Aif::class, optional: true)] + #[Optional(list: Aif::class)] public ?array $aifs; - /** @var list|null $corporate_bonds */ - #[Api(list: CorporateBond::class, optional: true)] - public ?array $corporate_bonds; + /** @var list|null $corporateBonds */ + #[Optional('corporate_bonds', list: CorporateBond::class)] + public ?array $corporateBonds; - /** @var list|null $demat_mutual_funds */ - #[Api(list: DematMutualFund::class, optional: true)] - public ?array $demat_mutual_funds; + /** @var list|null $dematMutualFunds */ + #[Optional('demat_mutual_funds', list: DematMutualFund::class)] + public ?array $dematMutualFunds; /** @var list|null $equities */ - #[Api(list: Equity::class, optional: true)] + #[Optional(list: Equity::class)] public ?array $equities; - /** @var list|null $government_securities */ - #[Api(list: GovernmentSecurity::class, optional: true)] - public ?array $government_securities; + /** @var list|null $governmentSecurities */ + #[Optional('government_securities', list: GovernmentSecurity::class)] + public ?array $governmentSecurities; public function __construct() { @@ -57,82 +63,82 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $aifs - * @param list $corporate_bonds - * @param list $demat_mutual_funds - * @param list $equities - * @param list $government_securities + * @param list|null $aifs + * @param list|null $corporateBonds + * @param list|null $dematMutualFunds + * @param list|null $equities + * @param list|null $governmentSecurities */ public static function with( ?array $aifs = null, - ?array $corporate_bonds = null, - ?array $demat_mutual_funds = null, + ?array $corporateBonds = null, + ?array $dematMutualFunds = null, ?array $equities = null, - ?array $government_securities = null, + ?array $governmentSecurities = null, ): self { - $obj = new self; + $self = new self; - null !== $aifs && $obj->aifs = $aifs; - 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 !== $government_securities && $obj->government_securities = $government_securities; + null !== $aifs && $self['aifs'] = $aifs; + null !== $corporateBonds && $self['corporateBonds'] = $corporateBonds; + null !== $dematMutualFunds && $self['dematMutualFunds'] = $dematMutualFunds; + null !== $equities && $self['equities'] = $equities; + null !== $governmentSecurities && $self['governmentSecurities'] = $governmentSecurities; - return $obj; + return $self; } /** - * @param list $aifs + * @param list $aifs */ public function withAifs(array $aifs): self { - $obj = clone $this; - $obj->aifs = $aifs; + $self = clone $this; + $self['aifs'] = $aifs; - return $obj; + return $self; } /** - * @param list $corporateBonds + * @param list $corporateBonds */ public function withCorporateBonds(array $corporateBonds): self { - $obj = clone $this; - $obj->corporate_bonds = $corporateBonds; + $self = clone $this; + $self['corporateBonds'] = $corporateBonds; - return $obj; + return $self; } /** - * @param list $dematMutualFunds + * @param list $dematMutualFunds */ public function withDematMutualFunds(array $dematMutualFunds): self { - $obj = clone $this; - $obj->demat_mutual_funds = $dematMutualFunds; + $self = clone $this; + $self['dematMutualFunds'] = $dematMutualFunds; - return $obj; + return $self; } /** - * @param list $equities + * @param list $equities */ public function withEquities(array $equities): self { - $obj = clone $this; - $obj->equities = $equities; + $self = clone $this; + $self['equities'] = $equities; - return $obj; + return $self; } /** - * @param list $governmentSecurities + * @param list $governmentSecurities */ public function withGovernmentSecurities(array $governmentSecurities): self { - $obj = clone $this; - $obj->government_securities = $governmentSecurities; + $self = clone $this; + $self['governmentSecurities'] = $governmentSecurities; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php index f5b39f5..b90689a 100644 --- a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif.php @@ -4,15 +4,21 @@ namespace CasParser\CasParser\UnifiedResponse\DematAccount\Holdings; -use CasParser\Core\Attributes\Api; +use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Aif\AdditionalInfo; +use CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Aif\Transaction; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Aif\AdditionalInfo + * @phpstan-import-type TransactionShape from \CasParser\CasParser\UnifiedResponse\DematAccount\Holdings\Aif\Transaction + * * @phpstan-type AifShape = array{ - * additional_info?: mixed, + * additionalInfo?: null|AdditionalInfo|AdditionalInfoShape, * isin?: string|null, * name?: string|null, + * transactions?: list|null, * units?: float|null, * value?: float|null, * } @@ -25,31 +31,39 @@ final class Aif implements BaseModel /** * Additional information specific to the AIF. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * ISIN code of the AIF. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Name of the AIF. */ - #[Api(optional: true)] + #[Optional] public ?string $name; + /** + * List of transactions for this holding (beta). + * + * @var list|null $transactions + */ + #[Optional(list: Transaction::class)] + public ?array $transactions; + /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -61,34 +75,42 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $transactions */ public static function with( - mixed $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $isin = null, ?string $name = null, + ?array $transactions = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $transactions && $self['transactions'] = $transactions; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the AIF. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(mixed $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -96,10 +118,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -107,10 +129,23 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * List of transactions for this holding (beta). + * + * @param list $transactions + */ + public function withTransactions(array $transactions): self + { + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -118,10 +153,10 @@ public function withName(string $name): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -129,9 +164,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/AdditionalInfo.php new file mode 100644 index 0000000..809fdd3 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Closing balance units for the statement period (beta). + */ + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; + + /** + * Opening balance units for the statement period (beta). + */ + #[Optional('open_units', nullable: true)] + public ?float $openUnits; + + 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( + ?float $closeUnits = null, + ?float $openUnits = null + ): self { + $self = new self; + + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + + return $self; + } + + /** + * Closing balance units for the statement period (beta). + */ + public function withCloseUnits(?float $closeUnits): self + { + $self = clone $this; + $self['closeUnits'] = $closeUnits; + + return $self; + } + + /** + * Opening balance units for the statement period (beta). + */ + public function withOpenUnits(?float $openUnits): self + { + $self = clone $this; + $self['openUnits'] = $openUnits; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction.php new file mode 100644 index 0000000..2733719 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction.php @@ -0,0 +1,233 @@ +, + * units?: float|null, + * } + */ +final class Transaction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional transaction-specific fields that vary by source. + */ + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] + public ?float $amount; + + /** + * Balance units after transaction. + */ + #[Optional] + public ?float $balance; + + /** + * Transaction date (YYYY-MM-DD). + */ + #[Optional] + public ?string $date; + + /** + * Transaction description/particulars. + */ + #[Optional] + public ?string $description; + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; + + /** + * NAV/price per unit on transaction date. + */ + #[Optional(nullable: true)] + public ?float $nav; + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Number of units involved in transaction. + */ + #[Optional] + public ?float $units; + + 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 AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type + */ + public static function with( + AdditionalInfo|array|null $additionalInfo = null, + ?float $amount = null, + ?float $balance = null, + ?string $date = null, + ?string $description = null, + ?float $dividendRate = null, + ?float $nav = null, + Type|string|null $type = null, + ?float $units = null, + ): self { + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; + } + + /** + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo + */ + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self + { + $self = clone $this; + $self['amount'] = $amount; + + return $self; + } + + /** + * Balance units after transaction. + */ + public function withBalance(float $balance): self + { + $self = clone $this; + $self['balance'] = $balance; + + return $self; + } + + /** + * Transaction date (YYYY-MM-DD). + */ + public function withDate(string $date): self + { + $self = clone $this; + $self['date'] = $date; + + return $self; + } + + /** + * Transaction description/particulars. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + public function withDividendRate(?float $dividendRate): self + { + $self = clone $this; + $self['dividendRate'] = $dividendRate; + + return $self; + } + + /** + * NAV/price per unit on transaction date. + */ + public function withNav(?float $nav): self + { + $self = clone $this; + $self['nav'] = $nav; + + return $self; + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Number of units involved in transaction. + */ + public function withUnits(float $units): self + { + $self = clone $this; + $self['units'] = $units; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..9ee6611 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/Type.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/Type.php new file mode 100644 index 0000000..4274cfa --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Aif/Transaction/Type.php @@ -0,0 +1,43 @@ +|null, * units?: float|null, * value?: float|null, * } @@ -25,31 +31,39 @@ final class CorporateBond implements BaseModel /** * Additional information specific to the corporate bond. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * ISIN code of the corporate bond. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Name of the corporate bond. */ - #[Api(optional: true)] + #[Optional] public ?string $name; + /** + * List of transactions for this holding (beta). + * + * @var list|null $transactions + */ + #[Optional(list: Transaction::class)] + public ?array $transactions; + /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -61,34 +75,42 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $transactions */ public static function with( - mixed $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $isin = null, ?string $name = null, + ?array $transactions = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $transactions && $self['transactions'] = $transactions; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the corporate bond. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(mixed $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -96,10 +118,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -107,10 +129,23 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * List of transactions for this holding (beta). + * + * @param list $transactions + */ + public function withTransactions(array $transactions): self + { + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -118,10 +153,10 @@ public function withName(string $name): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -129,9 +164,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/AdditionalInfo.php new file mode 100644 index 0000000..c757708 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Closing balance units for the statement period (beta). + */ + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; + + /** + * Opening balance units for the statement period (beta). + */ + #[Optional('open_units', nullable: true)] + public ?float $openUnits; + + 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( + ?float $closeUnits = null, + ?float $openUnits = null + ): self { + $self = new self; + + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + + return $self; + } + + /** + * Closing balance units for the statement period (beta). + */ + public function withCloseUnits(?float $closeUnits): self + { + $self = clone $this; + $self['closeUnits'] = $closeUnits; + + return $self; + } + + /** + * Opening balance units for the statement period (beta). + */ + public function withOpenUnits(?float $openUnits): self + { + $self = clone $this; + $self['openUnits'] = $openUnits; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction.php new file mode 100644 index 0000000..816f7c6 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction.php @@ -0,0 +1,233 @@ +, + * units?: float|null, + * } + */ +final class Transaction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional transaction-specific fields that vary by source. + */ + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] + public ?float $amount; + + /** + * Balance units after transaction. + */ + #[Optional] + public ?float $balance; + + /** + * Transaction date (YYYY-MM-DD). + */ + #[Optional] + public ?string $date; + + /** + * Transaction description/particulars. + */ + #[Optional] + public ?string $description; + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; + + /** + * NAV/price per unit on transaction date. + */ + #[Optional(nullable: true)] + public ?float $nav; + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Number of units involved in transaction. + */ + #[Optional] + public ?float $units; + + 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 AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type + */ + public static function with( + AdditionalInfo|array|null $additionalInfo = null, + ?float $amount = null, + ?float $balance = null, + ?string $date = null, + ?string $description = null, + ?float $dividendRate = null, + ?float $nav = null, + Type|string|null $type = null, + ?float $units = null, + ): self { + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; + } + + /** + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo + */ + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self + { + $self = clone $this; + $self['amount'] = $amount; + + return $self; + } + + /** + * Balance units after transaction. + */ + public function withBalance(float $balance): self + { + $self = clone $this; + $self['balance'] = $balance; + + return $self; + } + + /** + * Transaction date (YYYY-MM-DD). + */ + public function withDate(string $date): self + { + $self = clone $this; + $self['date'] = $date; + + return $self; + } + + /** + * Transaction description/particulars. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + public function withDividendRate(?float $dividendRate): self + { + $self = clone $this; + $self['dividendRate'] = $dividendRate; + + return $self; + } + + /** + * NAV/price per unit on transaction date. + */ + public function withNav(?float $nav): self + { + $self = clone $this; + $self['nav'] = $nav; + + return $self; + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Number of units involved in transaction. + */ + public function withUnits(float $units): self + { + $self = clone $this; + $self['units'] = $units; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..9c2471c --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/Type.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/Type.php new file mode 100644 index 0000000..9d43419 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/CorporateBond/Transaction/Type.php @@ -0,0 +1,43 @@ +|null, * units?: float|null, * value?: float|null, * } @@ -25,31 +31,39 @@ final class DematMutualFund implements BaseModel /** * Additional information specific to the mutual fund. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * ISIN code of the mutual fund. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Name of the mutual fund. */ - #[Api(optional: true)] + #[Optional] public ?string $name; + /** + * List of transactions for this holding (beta). + * + * @var list|null $transactions + */ + #[Optional(list: Transaction::class)] + public ?array $transactions; + /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -61,34 +75,42 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $transactions */ public static function with( - mixed $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $isin = null, ?string $name = null, + ?array $transactions = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $transactions && $self['transactions'] = $transactions; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the mutual fund. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(mixed $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -96,10 +118,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -107,10 +129,23 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * List of transactions for this holding (beta). + * + * @param list $transactions + */ + public function withTransactions(array $transactions): self + { + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -118,10 +153,10 @@ public function withName(string $name): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -129,9 +164,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/AdditionalInfo.php new file mode 100644 index 0000000..d7e3ae7 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Closing balance units for the statement period (beta). + */ + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; + + /** + * Opening balance units for the statement period (beta). + */ + #[Optional('open_units', nullable: true)] + public ?float $openUnits; + + 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( + ?float $closeUnits = null, + ?float $openUnits = null + ): self { + $self = new self; + + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + + return $self; + } + + /** + * Closing balance units for the statement period (beta). + */ + public function withCloseUnits(?float $closeUnits): self + { + $self = clone $this; + $self['closeUnits'] = $closeUnits; + + return $self; + } + + /** + * Opening balance units for the statement period (beta). + */ + public function withOpenUnits(?float $openUnits): self + { + $self = clone $this; + $self['openUnits'] = $openUnits; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction.php new file mode 100644 index 0000000..4d35f0b --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction.php @@ -0,0 +1,233 @@ +, + * units?: float|null, + * } + */ +final class Transaction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional transaction-specific fields that vary by source. + */ + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] + public ?float $amount; + + /** + * Balance units after transaction. + */ + #[Optional] + public ?float $balance; + + /** + * Transaction date (YYYY-MM-DD). + */ + #[Optional] + public ?string $date; + + /** + * Transaction description/particulars. + */ + #[Optional] + public ?string $description; + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; + + /** + * NAV/price per unit on transaction date. + */ + #[Optional(nullable: true)] + public ?float $nav; + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Number of units involved in transaction. + */ + #[Optional] + public ?float $units; + + 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 AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type + */ + public static function with( + AdditionalInfo|array|null $additionalInfo = null, + ?float $amount = null, + ?float $balance = null, + ?string $date = null, + ?string $description = null, + ?float $dividendRate = null, + ?float $nav = null, + Type|string|null $type = null, + ?float $units = null, + ): self { + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; + } + + /** + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo + */ + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self + { + $self = clone $this; + $self['amount'] = $amount; + + return $self; + } + + /** + * Balance units after transaction. + */ + public function withBalance(float $balance): self + { + $self = clone $this; + $self['balance'] = $balance; + + return $self; + } + + /** + * Transaction date (YYYY-MM-DD). + */ + public function withDate(string $date): self + { + $self = clone $this; + $self['date'] = $date; + + return $self; + } + + /** + * Transaction description/particulars. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + public function withDividendRate(?float $dividendRate): self + { + $self = clone $this; + $self['dividendRate'] = $dividendRate; + + return $self; + } + + /** + * NAV/price per unit on transaction date. + */ + public function withNav(?float $nav): self + { + $self = clone $this; + $self['nav'] = $nav; + + return $self; + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Number of units involved in transaction. + */ + public function withUnits(float $units): self + { + $self = clone $this; + $self['units'] = $units; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..76de736 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/Type.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/Type.php new file mode 100644 index 0000000..271e274 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/DematMutualFund/Transaction/Type.php @@ -0,0 +1,43 @@ +|null, * units?: float|null, * value?: float|null, * } @@ -25,31 +31,39 @@ final class Equity implements BaseModel /** * Additional information specific to the equity. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * ISIN code of the equity. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Name of the equity. */ - #[Api(optional: true)] + #[Optional] public ?string $name; + /** + * List of transactions for this holding (beta). + * + * @var list|null $transactions + */ + #[Optional(list: Transaction::class)] + public ?array $transactions; + /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -61,34 +75,42 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $transactions */ public static function with( - mixed $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $isin = null, ?string $name = null, + ?array $transactions = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $transactions && $self['transactions'] = $transactions; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the equity. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(mixed $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -96,10 +118,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -107,10 +129,23 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * List of transactions for this holding (beta). + * + * @param list $transactions + */ + public function withTransactions(array $transactions): self + { + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -118,10 +153,10 @@ public function withName(string $name): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -129,9 +164,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/AdditionalInfo.php new file mode 100644 index 0000000..bdbfce2 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Closing balance units for the statement period (beta). + */ + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; + + /** + * Opening balance units for the statement period (beta). + */ + #[Optional('open_units', nullable: true)] + public ?float $openUnits; + + 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( + ?float $closeUnits = null, + ?float $openUnits = null + ): self { + $self = new self; + + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + + return $self; + } + + /** + * Closing balance units for the statement period (beta). + */ + public function withCloseUnits(?float $closeUnits): self + { + $self = clone $this; + $self['closeUnits'] = $closeUnits; + + return $self; + } + + /** + * Opening balance units for the statement period (beta). + */ + public function withOpenUnits(?float $openUnits): self + { + $self = clone $this; + $self['openUnits'] = $openUnits; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction.php new file mode 100644 index 0000000..54cbeaa --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction.php @@ -0,0 +1,233 @@ +, + * units?: float|null, + * } + */ +final class Transaction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional transaction-specific fields that vary by source. + */ + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] + public ?float $amount; + + /** + * Balance units after transaction. + */ + #[Optional] + public ?float $balance; + + /** + * Transaction date (YYYY-MM-DD). + */ + #[Optional] + public ?string $date; + + /** + * Transaction description/particulars. + */ + #[Optional] + public ?string $description; + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; + + /** + * NAV/price per unit on transaction date. + */ + #[Optional(nullable: true)] + public ?float $nav; + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Number of units involved in transaction. + */ + #[Optional] + public ?float $units; + + 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 AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type + */ + public static function with( + AdditionalInfo|array|null $additionalInfo = null, + ?float $amount = null, + ?float $balance = null, + ?string $date = null, + ?string $description = null, + ?float $dividendRate = null, + ?float $nav = null, + Type|string|null $type = null, + ?float $units = null, + ): self { + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; + } + + /** + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo + */ + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self + { + $self = clone $this; + $self['amount'] = $amount; + + return $self; + } + + /** + * Balance units after transaction. + */ + public function withBalance(float $balance): self + { + $self = clone $this; + $self['balance'] = $balance; + + return $self; + } + + /** + * Transaction date (YYYY-MM-DD). + */ + public function withDate(string $date): self + { + $self = clone $this; + $self['date'] = $date; + + return $self; + } + + /** + * Transaction description/particulars. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + public function withDividendRate(?float $dividendRate): self + { + $self = clone $this; + $self['dividendRate'] = $dividendRate; + + return $self; + } + + /** + * NAV/price per unit on transaction date. + */ + public function withNav(?float $nav): self + { + $self = clone $this; + $self['nav'] = $nav; + + return $self; + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Number of units involved in transaction. + */ + public function withUnits(float $units): self + { + $self = clone $this; + $self['units'] = $units; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..7469063 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/Type.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/Type.php new file mode 100644 index 0000000..2cfd870 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/Equity/Transaction/Type.php @@ -0,0 +1,43 @@ +|null, * units?: float|null, * value?: float|null, * } @@ -25,31 +31,39 @@ final class GovernmentSecurity implements BaseModel /** * Additional information specific to the government security. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * ISIN code of the government security. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Name of the government security. */ - #[Api(optional: true)] + #[Optional] public ?string $name; + /** + * List of transactions for this holding (beta). + * + * @var list|null $transactions + */ + #[Optional(list: Transaction::class)] + public ?array $transactions; + /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -61,34 +75,42 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $transactions */ public static function with( - mixed $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $isin = null, ?string $name = null, + ?array $transactions = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $transactions && $self['transactions'] = $transactions; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the government security. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(mixed $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -96,10 +118,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -107,10 +129,23 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * List of transactions for this holding (beta). + * + * @param list $transactions + */ + public function withTransactions(array $transactions): self + { + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -118,10 +153,10 @@ public function withName(string $name): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -129,9 +164,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/AdditionalInfo.php new file mode 100644 index 0000000..c47a554 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/AdditionalInfo.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Closing balance units for the statement period (beta). + */ + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; + + /** + * Opening balance units for the statement period (beta). + */ + #[Optional('open_units', nullable: true)] + public ?float $openUnits; + + 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( + ?float $closeUnits = null, + ?float $openUnits = null + ): self { + $self = new self; + + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + + return $self; + } + + /** + * Closing balance units for the statement period (beta). + */ + public function withCloseUnits(?float $closeUnits): self + { + $self = clone $this; + $self['closeUnits'] = $closeUnits; + + return $self; + } + + /** + * Opening balance units for the statement period (beta). + */ + public function withOpenUnits(?float $openUnits): self + { + $self = clone $this; + $self['openUnits'] = $openUnits; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction.php new file mode 100644 index 0000000..919d937 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction.php @@ -0,0 +1,233 @@ +, + * units?: float|null, + * } + */ +final class Transaction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Additional transaction-specific fields that vary by source. + */ + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] + public ?float $amount; + + /** + * Balance units after transaction. + */ + #[Optional] + public ?float $balance; + + /** + * Transaction date (YYYY-MM-DD). + */ + #[Optional] + public ?string $date; + + /** + * Transaction description/particulars. + */ + #[Optional] + public ?string $description; + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; + + /** + * NAV/price per unit on transaction date. + */ + #[Optional(nullable: true)] + public ?float $nav; + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Number of units involved in transaction. + */ + #[Optional] + public ?float $units; + + 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 AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type + */ + public static function with( + AdditionalInfo|array|null $additionalInfo = null, + ?float $amount = null, + ?float $balance = null, + ?string $date = null, + ?string $description = null, + ?float $dividendRate = null, + ?float $nav = null, + Type|string|null $type = null, + ?float $units = null, + ): self { + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; + } + + /** + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo + */ + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self + { + $self = clone $this; + $self['amount'] = $amount; + + return $self; + } + + /** + * Balance units after transaction. + */ + public function withBalance(float $balance): self + { + $self = clone $this; + $self['balance'] = $balance; + + return $self; + } + + /** + * Transaction date (YYYY-MM-DD). + */ + public function withDate(string $date): self + { + $self = clone $this; + $self['date'] = $date; + + return $self; + } + + /** + * Transaction description/particulars. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions). + */ + public function withDividendRate(?float $dividendRate): self + { + $self = clone $this; + $self['dividendRate'] = $dividendRate; + + return $self; + } + + /** + * NAV/price per unit on transaction date. + */ + public function withNav(?float $nav): self + { + $self = clone $this; + $self['nav'] = $nav; + + return $self; + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Number of units involved in transaction. + */ + public function withUnits(float $units): self + { + $self = clone $this; + $self['units'] = $units; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..e2bd8e6 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/Type.php b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/Type.php new file mode 100644 index 0000000..f1d3888 --- /dev/null +++ b/src/CasParser/UnifiedResponse/DematAccount/Holdings/GovernmentSecurity/Transaction/Type.php @@ -0,0 +1,43 @@ +name = $name; - null !== $pan && $obj->pan = $pan; + null !== $name && $self['name'] = $name; + null !== $pan && $self['pan'] = $pan; - return $obj; + return $self; } /** @@ -53,10 +53,10 @@ public static function with(?string $name = null, ?string $pan = null): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -64,9 +64,9 @@ public function withName(string $name): self */ public function withPan(string $pan): self { - $obj = clone $this; - $obj->pan = $pan; + $self = clone $this; + $self['pan'] = $pan; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Insurance.php b/src/CasParser/UnifiedResponse/Insurance.php index 336278f..db1ded5 100644 --- a/src/CasParser/UnifiedResponse/Insurance.php +++ b/src/CasParser/UnifiedResponse/Insurance.php @@ -5,13 +5,15 @@ namespace CasParser\CasParser\UnifiedResponse; use CasParser\CasParser\UnifiedResponse\Insurance\LifeInsurancePolicy; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type LifeInsurancePolicyShape from \CasParser\CasParser\UnifiedResponse\Insurance\LifeInsurancePolicy + * * @phpstan-type InsuranceShape = array{ - * life_insurance_policies?: list|null + * lifeInsurancePolicies?: list|null * } */ final class Insurance implements BaseModel @@ -19,9 +21,9 @@ final class Insurance implements BaseModel /** @use SdkModel */ use SdkModel; - /** @var list|null $life_insurance_policies */ - #[Api(list: LifeInsurancePolicy::class, optional: true)] - public ?array $life_insurance_policies; + /** @var list|null $lifeInsurancePolicies */ + #[Optional('life_insurance_policies', list: LifeInsurancePolicy::class)] + public ?array $lifeInsurancePolicies; public function __construct() { @@ -33,26 +35,26 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $life_insurance_policies + * @param list|null $lifeInsurancePolicies */ - public static function with(?array $life_insurance_policies = null): self + public static function with(?array $lifeInsurancePolicies = null): self { - $obj = new self; + $self = new self; - null !== $life_insurance_policies && $obj->life_insurance_policies = $life_insurance_policies; + null !== $lifeInsurancePolicies && $self['lifeInsurancePolicies'] = $lifeInsurancePolicies; - return $obj; + return $self; } /** - * @param list $lifeInsurancePolicies + * @param list $lifeInsurancePolicies */ public function withLifeInsurancePolicies( array $lifeInsurancePolicies ): self { - $obj = clone $this; - $obj->life_insurance_policies = $lifeInsurancePolicies; + $self = clone $this; + $self['lifeInsurancePolicies'] = $lifeInsurancePolicies; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php index 0734bdf..a7a464d 100644 --- a/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php +++ b/src/CasParser/UnifiedResponse/Insurance/LifeInsurancePolicy.php @@ -4,21 +4,21 @@ namespace CasParser\CasParser\UnifiedResponse\Insurance; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** * @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, + * additionalInfo?: mixed, + * lifeAssured?: string|null, + * policyName?: string|null, + * policyNumber?: string|null, + * premiumAmount?: float|null, + * premiumFrequency?: string|null, * provider?: string|null, * status?: string|null, - * sum_assured?: float|null, + * sumAssured?: float|null, * } */ final class LifeInsurancePolicy implements BaseModel @@ -29,56 +29,56 @@ final class LifeInsurancePolicy implements BaseModel /** * Additional information specific to the policy. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public mixed $additionalInfo; /** * Name of the life assured. */ - #[Api(optional: true)] - public ?string $life_assured; + #[Optional('life_assured')] + public ?string $lifeAssured; /** * Name of the insurance policy. */ - #[Api(optional: true)] - public ?string $policy_name; + #[Optional('policy_name')] + public ?string $policyName; /** * Insurance policy number. */ - #[Api(optional: true)] - public ?string $policy_number; + #[Optional('policy_number')] + public ?string $policyNumber; /** * Premium amount. */ - #[Api(optional: true)] - public ?float $premium_amount; + #[Optional('premium_amount')] + public ?float $premiumAmount; /** * Frequency of premium payment (e.g., Annual, Monthly). */ - #[Api(optional: true)] - public ?string $premium_frequency; + #[Optional('premium_frequency')] + public ?string $premiumFrequency; /** * Insurance company name. */ - #[Api(optional: true)] + #[Optional] public ?string $provider; /** * Status of the policy (e.g., Active, Lapsed). */ - #[Api(optional: true)] + #[Optional] public ?string $status; /** * Sum assured amount. */ - #[Api(optional: true)] - public ?float $sum_assured; + #[Optional('sum_assured')] + public ?float $sumAssured; public function __construct() { @@ -91,29 +91,29 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - mixed $additional_info = null, - ?string $life_assured = null, - ?string $policy_name = null, - ?string $policy_number = null, - ?float $premium_amount = null, - ?string $premium_frequency = null, + mixed $additionalInfo = null, + ?string $lifeAssured = null, + ?string $policyName = null, + ?string $policyNumber = null, + ?float $premiumAmount = null, + ?string $premiumFrequency = null, ?string $provider = null, ?string $status = null, - ?float $sum_assured = null, + ?float $sumAssured = null, ): self { - $obj = new self; - - 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 !== $sum_assured && $obj->sum_assured = $sum_assured; - - return $obj; + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $lifeAssured && $self['lifeAssured'] = $lifeAssured; + null !== $policyName && $self['policyName'] = $policyName; + null !== $policyNumber && $self['policyNumber'] = $policyNumber; + null !== $premiumAmount && $self['premiumAmount'] = $premiumAmount; + null !== $premiumFrequency && $self['premiumFrequency'] = $premiumFrequency; + null !== $provider && $self['provider'] = $provider; + null !== $status && $self['status'] = $status; + null !== $sumAssured && $self['sumAssured'] = $sumAssured; + + return $self; } /** @@ -121,10 +121,10 @@ public static function with( */ public function withAdditionalInfo(mixed $additionalInfo): self { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -132,10 +132,10 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withLifeAssured(string $lifeAssured): self { - $obj = clone $this; - $obj->life_assured = $lifeAssured; + $self = clone $this; + $self['lifeAssured'] = $lifeAssured; - return $obj; + return $self; } /** @@ -143,10 +143,10 @@ public function withLifeAssured(string $lifeAssured): self */ public function withPolicyName(string $policyName): self { - $obj = clone $this; - $obj->policy_name = $policyName; + $self = clone $this; + $self['policyName'] = $policyName; - return $obj; + return $self; } /** @@ -154,10 +154,10 @@ public function withPolicyName(string $policyName): self */ public function withPolicyNumber(string $policyNumber): self { - $obj = clone $this; - $obj->policy_number = $policyNumber; + $self = clone $this; + $self['policyNumber'] = $policyNumber; - return $obj; + return $self; } /** @@ -165,10 +165,10 @@ public function withPolicyNumber(string $policyNumber): self */ public function withPremiumAmount(float $premiumAmount): self { - $obj = clone $this; - $obj->premium_amount = $premiumAmount; + $self = clone $this; + $self['premiumAmount'] = $premiumAmount; - return $obj; + return $self; } /** @@ -176,10 +176,10 @@ public function withPremiumAmount(float $premiumAmount): self */ public function withPremiumFrequency(string $premiumFrequency): self { - $obj = clone $this; - $obj->premium_frequency = $premiumFrequency; + $self = clone $this; + $self['premiumFrequency'] = $premiumFrequency; - return $obj; + return $self; } /** @@ -187,10 +187,10 @@ public function withPremiumFrequency(string $premiumFrequency): self */ public function withProvider(string $provider): self { - $obj = clone $this; - $obj->provider = $provider; + $self = clone $this; + $self['provider'] = $provider; - return $obj; + return $self; } /** @@ -198,10 +198,10 @@ public function withProvider(string $provider): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj->status = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -209,9 +209,9 @@ public function withStatus(string $status): self */ public function withSumAssured(float $sumAssured): self { - $obj = clone $this; - $obj->sum_assured = $sumAssured; + $self = clone $this; + $self['sumAssured'] = $sumAssured; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Investor.php b/src/CasParser/UnifiedResponse/Investor.php index 272a2cd..888699c 100644 --- a/src/CasParser/UnifiedResponse/Investor.php +++ b/src/CasParser/UnifiedResponse/Investor.php @@ -4,14 +4,14 @@ namespace CasParser\CasParser\UnifiedResponse; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** * @phpstan-type InvestorShape = array{ * address?: string|null, - * cas_id?: string|null, + * casID?: string|null, * email?: string|null, * mobile?: string|null, * name?: string|null, @@ -27,43 +27,43 @@ final class Investor implements BaseModel /** * Address of the investor. */ - #[Api(optional: true)] + #[Optional] public ?string $address; /** * CAS ID of the investor (only for NSDL and CDSL). */ - #[Api(optional: true)] - public ?string $cas_id; + #[Optional('cas_id')] + public ?string $casID; /** * Email address of the investor. */ - #[Api(optional: true)] + #[Optional] public ?string $email; /** * Mobile number of the investor. */ - #[Api(optional: true)] + #[Optional] public ?string $mobile; /** * Name of the investor. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** * PAN (Permanent Account Number) of the investor. */ - #[Api(optional: true)] + #[Optional] public ?string $pan; /** * Postal code of the investor's address. */ - #[Api(optional: true)] + #[Optional] public ?string $pincode; public function __construct() @@ -78,24 +78,24 @@ public function __construct() */ public static function with( ?string $address = null, - ?string $cas_id = null, + ?string $casID = null, ?string $email = null, ?string $mobile = null, ?string $name = null, ?string $pan = null, ?string $pincode = null, ): self { - $obj = new self; + $self = new self; - null !== $address && $obj->address = $address; - null !== $cas_id && $obj->cas_id = $cas_id; - null !== $email && $obj->email = $email; - null !== $mobile && $obj->mobile = $mobile; - null !== $name && $obj->name = $name; - null !== $pan && $obj->pan = $pan; - null !== $pincode && $obj->pincode = $pincode; + null !== $address && $self['address'] = $address; + null !== $casID && $self['casID'] = $casID; + null !== $email && $self['email'] = $email; + null !== $mobile && $self['mobile'] = $mobile; + null !== $name && $self['name'] = $name; + null !== $pan && $self['pan'] = $pan; + null !== $pincode && $self['pincode'] = $pincode; - return $obj; + return $self; } /** @@ -103,10 +103,10 @@ public static function with( */ public function withAddress(string $address): self { - $obj = clone $this; - $obj->address = $address; + $self = clone $this; + $self['address'] = $address; - return $obj; + return $self; } /** @@ -114,10 +114,10 @@ public function withAddress(string $address): self */ public function withCasID(string $casID): self { - $obj = clone $this; - $obj->cas_id = $casID; + $self = clone $this; + $self['casID'] = $casID; - return $obj; + return $self; } /** @@ -125,10 +125,10 @@ public function withCasID(string $casID): self */ public function withEmail(string $email): self { - $obj = clone $this; - $obj->email = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -136,10 +136,10 @@ public function withEmail(string $email): self */ public function withMobile(string $mobile): self { - $obj = clone $this; - $obj->mobile = $mobile; + $self = clone $this; + $self['mobile'] = $mobile; - return $obj; + return $self; } /** @@ -147,10 +147,10 @@ public function withMobile(string $mobile): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -158,10 +158,10 @@ public function withName(string $name): self */ public function withPan(string $pan): self { - $obj = clone $this; - $obj->pan = $pan; + $self = clone $this; + $self['pan'] = $pan; - return $obj; + return $self; } /** @@ -169,9 +169,9 @@ public function withPan(string $pan): self */ public function withPincode(string $pincode): self { - $obj = clone $this; - $obj->pincode = $pincode; + $self = clone $this; + $self['pincode'] = $pincode; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Meta.php b/src/CasParser/UnifiedResponse/Meta.php index ab759db..8ac9067 100644 --- a/src/CasParser/UnifiedResponse/Meta.php +++ b/src/CasParser/UnifiedResponse/Meta.php @@ -6,15 +6,17 @@ use CasParser\CasParser\UnifiedResponse\Meta\CasType; use CasParser\CasParser\UnifiedResponse\Meta\StatementPeriod; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type StatementPeriodShape from \CasParser\CasParser\UnifiedResponse\Meta\StatementPeriod + * * @phpstan-type MetaShape = array{ - * cas_type?: value-of|null, - * generated_at?: \DateTimeInterface|null, - * statement_period?: StatementPeriod|null, + * casType?: null|CasType|value-of, + * generatedAt?: \DateTimeInterface|null, + * statementPeriod?: null|StatementPeriod|StatementPeriodShape, * } */ final class Meta implements BaseModel @@ -25,19 +27,19 @@ final class Meta implements BaseModel /** * Type of CAS detected and processed. * - * @var value-of|null $cas_type + * @var value-of|null $casType */ - #[Api(enum: CasType::class, optional: true)] - public ?string $cas_type; + #[Optional('cas_type', enum: CasType::class)] + public ?string $casType; /** * Timestamp when the response was generated. */ - #[Api(optional: true)] - public ?\DateTimeInterface $generated_at; + #[Optional('generated_at')] + public ?\DateTimeInterface $generatedAt; - #[Api(optional: true)] - public ?StatementPeriod $statement_period; + #[Optional('statement_period')] + public ?StatementPeriod $statementPeriod; public function __construct() { @@ -49,20 +51,21 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param CasType|value-of $cas_type + * @param CasType|value-of|null $casType + * @param StatementPeriod|StatementPeriodShape|null $statementPeriod */ public static function with( - CasType|string|null $cas_type = null, - ?\DateTimeInterface $generated_at = null, - ?StatementPeriod $statement_period = null, + CasType|string|null $casType = null, + ?\DateTimeInterface $generatedAt = null, + StatementPeriod|array|null $statementPeriod = null, ): self { - $obj = new self; + $self = new self; - null !== $cas_type && $obj['cas_type'] = $cas_type; - null !== $generated_at && $obj->generated_at = $generated_at; - null !== $statement_period && $obj->statement_period = $statement_period; + null !== $casType && $self['casType'] = $casType; + null !== $generatedAt && $self['generatedAt'] = $generatedAt; + null !== $statementPeriod && $self['statementPeriod'] = $statementPeriod; - return $obj; + return $self; } /** @@ -72,10 +75,10 @@ public static function with( */ public function withCasType(CasType|string $casType): self { - $obj = clone $this; - $obj['cas_type'] = $casType; + $self = clone $this; + $self['casType'] = $casType; - return $obj; + return $self; } /** @@ -83,17 +86,21 @@ public function withCasType(CasType|string $casType): self */ public function withGeneratedAt(\DateTimeInterface $generatedAt): self { - $obj = clone $this; - $obj->generated_at = $generatedAt; + $self = clone $this; + $self['generatedAt'] = $generatedAt; - return $obj; + return $self; } - public function withStatementPeriod(StatementPeriod $statementPeriod): self - { - $obj = clone $this; - $obj->statement_period = $statementPeriod; + /** + * @param StatementPeriod|StatementPeriodShape $statementPeriod + */ + public function withStatementPeriod( + StatementPeriod|array $statementPeriod + ): self { + $self = clone $this; + $self['statementPeriod'] = $statementPeriod; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php index d7b088b..4d9b0e4 100644 --- a/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php +++ b/src/CasParser/UnifiedResponse/Meta/StatementPeriod.php @@ -4,14 +4,12 @@ namespace CasParser\CasParser\UnifiedResponse\Meta; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type StatementPeriodShape = array{ - * from?: \DateTimeInterface|null, to?: \DateTimeInterface|null - * } + * @phpstan-type StatementPeriodShape = array{from?: string|null, to?: string|null} */ final class StatementPeriod implements BaseModel { @@ -21,14 +19,14 @@ final class StatementPeriod implements BaseModel /** * Start date of the statement period. */ - #[Api(optional: true)] - public ?\DateTimeInterface $from; + #[Optional] + public ?string $from; /** * End date of the statement period. */ - #[Api(optional: true)] - public ?\DateTimeInterface $to; + #[Optional] + public ?string $to; public function __construct() { @@ -40,37 +38,35 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with( - ?\DateTimeInterface $from = null, - ?\DateTimeInterface $to = null - ): self { - $obj = new self; + public static function with(?string $from = null, ?string $to = null): self + { + $self = new self; - null !== $from && $obj->from = $from; - null !== $to && $obj->to = $to; + null !== $from && $self['from'] = $from; + null !== $to && $self['to'] = $to; - return $obj; + return $self; } /** * Start date of the statement period. */ - public function withFrom(\DateTimeInterface $from): self + public function withFrom(string $from): self { - $obj = clone $this; - $obj->from = $from; + $self = clone $this; + $self['from'] = $from; - return $obj; + return $self; } /** * End date of the statement period. */ - public function withTo(\DateTimeInterface $to): self + public function withTo(string $to): self { - $obj = clone $this; - $obj->to = $to; + $self = clone $this; + $self['to'] = $to; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund.php b/src/CasParser/UnifiedResponse/MutualFund.php index d1448f7..393c248 100644 --- a/src/CasParser/UnifiedResponse/MutualFund.php +++ b/src/CasParser/UnifiedResponse/MutualFund.php @@ -7,18 +7,22 @@ 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\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\MutualFund\AdditionalInfo + * @phpstan-import-type LinkedHolderShape from \CasParser\CasParser\UnifiedResponse\MutualFund\LinkedHolder + * @phpstan-import-type SchemeShape from \CasParser\CasParser\UnifiedResponse\MutualFund\Scheme + * * @phpstan-type MutualFundShape = array{ - * additional_info?: AdditionalInfo|null, + * additionalInfo?: null|AdditionalInfo|AdditionalInfoShape, * amc?: string|null, - * folio_number?: string|null, - * linked_holders?: list|null, + * folioNumber?: string|null, + * linkedHolders?: list|null, * registrar?: string|null, - * schemes?: list|null, + * schemes?: list|null, * value?: float|null, * } */ @@ -30,43 +34,43 @@ final class MutualFund implements BaseModel /** * Additional folio information. */ - #[Api(optional: true)] - public ?AdditionalInfo $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * Asset Management Company name. */ - #[Api(optional: true)] + #[Optional] public ?string $amc; /** * Folio number. */ - #[Api(optional: true)] - public ?string $folio_number; + #[Optional('folio_number')] + public ?string $folioNumber; /** * List of account holders linked to this mutual fund folio. * - * @var list|null $linked_holders + * @var list|null $linkedHolders */ - #[Api(list: LinkedHolder::class, optional: true)] - public ?array $linked_holders; + #[Optional('linked_holders', list: LinkedHolder::class)] + public ?array $linkedHolders; /** * Registrar and Transfer Agent name. */ - #[Api(optional: true)] + #[Optional] public ?string $registrar; /** @var list|null $schemes */ - #[Api(list: Scheme::class, optional: true)] + #[Optional(list: Scheme::class)] public ?array $schemes; /** * Total value of the folio. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -79,40 +83,44 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $linked_holders - * @param list $schemes + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param list|null $linkedHolders + * @param list|null $schemes */ public static function with( - ?AdditionalInfo $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?string $amc = null, - ?string $folio_number = null, - ?array $linked_holders = null, + ?string $folioNumber = null, + ?array $linkedHolders = null, ?string $registrar = null, ?array $schemes = null, ?float $value = null, ): self { - $obj = new self; + $self = new self; - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $amc && $obj->amc = $amc; - 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; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amc && $self['amc'] = $amc; + null !== $folioNumber && $self['folioNumber'] = $folioNumber; + null !== $linkedHolders && $self['linkedHolders'] = $linkedHolders; + null !== $registrar && $self['registrar'] = $registrar; + null !== $schemes && $self['schemes'] = $schemes; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional folio information. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(AdditionalInfo $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -120,10 +128,10 @@ public function withAdditionalInfo(AdditionalInfo $additionalInfo): self */ public function withAmc(string $amc): self { - $obj = clone $this; - $obj->amc = $amc; + $self = clone $this; + $self['amc'] = $amc; - return $obj; + return $self; } /** @@ -131,23 +139,23 @@ public function withAmc(string $amc): self */ public function withFolioNumber(string $folioNumber): self { - $obj = clone $this; - $obj->folio_number = $folioNumber; + $self = clone $this; + $self['folioNumber'] = $folioNumber; - return $obj; + return $self; } /** * List of account holders linked to this mutual fund folio. * - * @param list $linkedHolders + * @param list $linkedHolders */ public function withLinkedHolders(array $linkedHolders): self { - $obj = clone $this; - $obj->linked_holders = $linkedHolders; + $self = clone $this; + $self['linkedHolders'] = $linkedHolders; - return $obj; + return $self; } /** @@ -155,21 +163,21 @@ public function withLinkedHolders(array $linkedHolders): self */ public function withRegistrar(string $registrar): self { - $obj = clone $this; - $obj->registrar = $registrar; + $self = clone $this; + $self['registrar'] = $registrar; - return $obj; + return $self; } /** - * @param list $schemes + * @param list $schemes */ public function withSchemes(array $schemes): self { - $obj = clone $this; - $obj->schemes = $schemes; + $self = clone $this; + $self['schemes'] = $schemes; - return $obj; + return $self; } /** @@ -177,9 +185,9 @@ public function withSchemes(array $schemes): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php index 1ff28f5..9eea13a 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/AdditionalInfo.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\MutualFund; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -23,19 +23,19 @@ final class AdditionalInfo implements BaseModel /** * KYC status of the folio. */ - #[Api(optional: true)] + #[Optional] public ?string $kyc; /** * PAN associated with the folio. */ - #[Api(optional: true)] + #[Optional] public ?string $pan; /** * PAN KYC status. */ - #[Api(optional: true)] + #[Optional] public ?string $pankyc; public function __construct() @@ -53,13 +53,13 @@ public static function with( ?string $pan = null, ?string $pankyc = null ): self { - $obj = new self; + $self = new self; - null !== $kyc && $obj->kyc = $kyc; - null !== $pan && $obj->pan = $pan; - null !== $pankyc && $obj->pankyc = $pankyc; + null !== $kyc && $self['kyc'] = $kyc; + null !== $pan && $self['pan'] = $pan; + null !== $pankyc && $self['pankyc'] = $pankyc; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with( */ public function withKYC(string $kyc): self { - $obj = clone $this; - $obj->kyc = $kyc; + $self = clone $this; + $self['kyc'] = $kyc; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public function withKYC(string $kyc): self */ public function withPan(string $pan): self { - $obj = clone $this; - $obj->pan = $pan; + $self = clone $this; + $self['pan'] = $pan; - return $obj; + return $self; } /** @@ -89,9 +89,9 @@ public function withPan(string $pan): self */ public function withPankyc(string $pankyc): self { - $obj = clone $this; - $obj->pankyc = $pankyc; + $self = clone $this; + $self['pankyc'] = $pankyc; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php index cf09088..69a3f4f 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/MutualFund/LinkedHolder.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\MutualFund; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class LinkedHolder implements BaseModel /** * Name of the account holder. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** * PAN of the account holder. */ - #[Api(optional: true)] + #[Optional] public ?string $pan; public function __construct() @@ -40,12 +40,12 @@ public function __construct() */ public static function with(?string $name = null, ?string $pan = null): self { - $obj = new self; + $self = new self; - null !== $name && $obj->name = $name; - null !== $pan && $obj->pan = $pan; + null !== $name && $self['name'] = $name; + null !== $pan && $self['pan'] = $pan; - return $obj; + return $self; } /** @@ -53,10 +53,10 @@ public static function with(?string $name = null, ?string $pan = null): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -64,9 +64,9 @@ public function withName(string $name): self */ public function withPan(string $pan): self { - $obj = clone $this; - $obj->pan = $pan; + $self = clone $this; + $self['pan'] = $pan; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php index 666a2b6..76d3378 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme.php @@ -8,21 +8,25 @@ use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Gain; use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction; use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Type; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\AdditionalInfo + * @phpstan-import-type GainShape from \CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Gain + * @phpstan-import-type TransactionShape from \CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction + * * @phpstan-type SchemeShape = array{ - * additional_info?: AdditionalInfo|null, + * additionalInfo?: null|\CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\AdditionalInfo|AdditionalInfoShape, * cost?: float|null, - * gain?: Gain|null, + * gain?: null|Gain|GainShape, * isin?: string|null, * name?: string|null, * nav?: float|null, * nominees?: list|null, - * transactions?: list|null, - * type?: value-of|null, + * transactions?: list|null, + * type?: null|Type|value-of, * units?: float|null, * value?: float|null, * } @@ -35,34 +39,34 @@ final class Scheme implements BaseModel /** * Additional information specific to the scheme. */ - #[Api(optional: true)] - public ?AdditionalInfo $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * Cost of investment. */ - #[Api(optional: true)] + #[Optional] public ?float $cost; - #[Api(optional: true)] + #[Optional] public ?Gain $gain; /** * ISIN code of the scheme. */ - #[Api(optional: true)] + #[Optional] public ?string $isin; /** * Scheme name. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** * Net Asset Value per unit. */ - #[Api(optional: true)] + #[Optional] public ?float $nav; /** @@ -70,11 +74,11 @@ final class Scheme implements BaseModel * * @var list|null $nominees */ - #[Api(list: 'string', optional: true)] + #[Optional(list: 'string')] public ?array $nominees; /** @var list|null $transactions */ - #[Api(list: Transaction::class, optional: true)] + #[Optional(list: Transaction::class)] public ?array $transactions; /** @@ -82,19 +86,19 @@ final class Scheme implements BaseModel * * @var value-of|null $type */ - #[Api(enum: Type::class, optional: true)] + #[Optional(enum: Type::class)] public ?string $type; /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -107,14 +111,16 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $nominees - * @param list $transactions - * @param Type|value-of $type + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Gain|GainShape|null $gain + * @param list|null $nominees + * @param list|null $transactions + * @param Type|value-of|null $type */ public static function with( - ?AdditionalInfo $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?float $cost = null, - ?Gain $gain = null, + Gain|array|null $gain = null, ?string $isin = null, ?string $name = null, ?float $nav = null, @@ -124,32 +130,35 @@ public static function with( ?float $units = null, ?float $value = null, ): self { - $obj = new self; - - null !== $additional_info && $obj->additional_info = $additional_info; - null !== $cost && $obj->cost = $cost; - null !== $gain && $obj->gain = $gain; - null !== $isin && $obj->isin = $isin; - null !== $name && $obj->name = $name; - null !== $nav && $obj->nav = $nav; - null !== $nominees && $obj->nominees = $nominees; - null !== $transactions && $obj->transactions = $transactions; - null !== $type && $obj['type'] = $type; - null !== $units && $obj->units = $units; - null !== $value && $obj->value = $value; - - return $obj; + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $cost && $self['cost'] = $cost; + null !== $gain && $self['gain'] = $gain; + null !== $isin && $self['isin'] = $isin; + null !== $name && $self['name'] = $name; + null !== $nav && $self['nav'] = $nav; + null !== $nominees && $self['nominees'] = $nominees; + null !== $transactions && $self['transactions'] = $transactions; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; + + return $self; } /** * Additional information specific to the scheme. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(AdditionalInfo $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -157,18 +166,21 @@ public function withAdditionalInfo(AdditionalInfo $additionalInfo): self */ public function withCost(float $cost): self { - $obj = clone $this; - $obj->cost = $cost; + $self = clone $this; + $self['cost'] = $cost; - return $obj; + return $self; } - public function withGain(Gain $gain): self + /** + * @param Gain|GainShape $gain + */ + public function withGain(Gain|array $gain): self { - $obj = clone $this; - $obj->gain = $gain; + $self = clone $this; + $self['gain'] = $gain; - return $obj; + return $self; } /** @@ -176,10 +188,10 @@ public function withGain(Gain $gain): self */ public function withIsin(string $isin): self { - $obj = clone $this; - $obj->isin = $isin; + $self = clone $this; + $self['isin'] = $isin; - return $obj; + return $self; } /** @@ -187,10 +199,10 @@ public function withIsin(string $isin): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -198,10 +210,10 @@ public function withName(string $name): self */ public function withNav(float $nav): self { - $obj = clone $this; - $obj->nav = $nav; + $self = clone $this; + $self['nav'] = $nav; - return $obj; + return $self; } /** @@ -211,21 +223,21 @@ public function withNav(float $nav): self */ public function withNominees(array $nominees): self { - $obj = clone $this; - $obj->nominees = $nominees; + $self = clone $this; + $self['nominees'] = $nominees; - return $obj; + return $self; } /** - * @param list $transactions + * @param list $transactions */ public function withTransactions(array $transactions): self { - $obj = clone $this; - $obj->transactions = $transactions; + $self = clone $this; + $self['transactions'] = $transactions; - return $obj; + return $self; } /** @@ -235,10 +247,10 @@ public function withTransactions(array $transactions): self */ public function withType(Type|string $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } /** @@ -246,10 +258,10 @@ public function withType(Type|string $type): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -257,9 +269,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php index 7ba0897..0ec6859 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/AdditionalInfo.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\MutualFund\Scheme; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -14,9 +14,9 @@ * @phpstan-type AdditionalInfoShape = array{ * advisor?: string|null, * amfi?: string|null, - * close_units?: float|null, - * open_units?: float|null, - * rta_code?: string|null, + * closeUnits?: float|null, + * openUnits?: float|null, + * rtaCode?: string|null, * } */ final class AdditionalInfo implements BaseModel @@ -27,32 +27,32 @@ final class AdditionalInfo implements BaseModel /** * Financial advisor name (CAMS/KFintech). */ - #[Api(optional: true)] + #[Optional] public ?string $advisor; /** * AMFI code for the scheme (CAMS/KFintech). */ - #[Api(optional: true)] + #[Optional] public ?string $amfi; /** - * Closing balance units (CAMS/KFintech). + * Closing balance units for the statement period. */ - #[Api(optional: true)] - public ?float $close_units; + #[Optional('close_units', nullable: true)] + public ?float $closeUnits; /** - * Opening balance units (CAMS/KFintech). + * Opening balance units for the statement period. */ - #[Api(optional: true)] - public ?float $open_units; + #[Optional('open_units', nullable: true)] + public ?float $openUnits; /** * RTA code for the scheme (CAMS/KFintech). */ - #[Api(optional: true)] - public ?string $rta_code; + #[Optional('rta_code')] + public ?string $rtaCode; public function __construct() { @@ -67,19 +67,19 @@ public function __construct() public static function with( ?string $advisor = null, ?string $amfi = null, - ?float $close_units = null, - ?float $open_units = null, - ?string $rta_code = null, + ?float $closeUnits = null, + ?float $openUnits = null, + ?string $rtaCode = null, ): self { - $obj = new self; + $self = new self; - null !== $advisor && $obj->advisor = $advisor; - null !== $amfi && $obj->amfi = $amfi; - null !== $close_units && $obj->close_units = $close_units; - null !== $open_units && $obj->open_units = $open_units; - null !== $rta_code && $obj->rta_code = $rta_code; + null !== $advisor && $self['advisor'] = $advisor; + null !== $amfi && $self['amfi'] = $amfi; + null !== $closeUnits && $self['closeUnits'] = $closeUnits; + null !== $openUnits && $self['openUnits'] = $openUnits; + null !== $rtaCode && $self['rtaCode'] = $rtaCode; - return $obj; + return $self; } /** @@ -87,10 +87,10 @@ public static function with( */ public function withAdvisor(string $advisor): self { - $obj = clone $this; - $obj->advisor = $advisor; + $self = clone $this; + $self['advisor'] = $advisor; - return $obj; + return $self; } /** @@ -98,32 +98,32 @@ public function withAdvisor(string $advisor): self */ public function withAmfi(string $amfi): self { - $obj = clone $this; - $obj->amfi = $amfi; + $self = clone $this; + $self['amfi'] = $amfi; - return $obj; + return $self; } /** - * Closing balance units (CAMS/KFintech). + * Closing balance units for the statement period. */ - public function withCloseUnits(float $closeUnits): self + public function withCloseUnits(?float $closeUnits): self { - $obj = clone $this; - $obj->close_units = $closeUnits; + $self = clone $this; + $self['closeUnits'] = $closeUnits; - return $obj; + return $self; } /** - * Opening balance units (CAMS/KFintech). + * Opening balance units for the statement period. */ - public function withOpenUnits(float $openUnits): self + public function withOpenUnits(?float $openUnits): self { - $obj = clone $this; - $obj->open_units = $openUnits; + $self = clone $this; + $self['openUnits'] = $openUnits; - return $obj; + return $self; } /** @@ -131,9 +131,9 @@ public function withOpenUnits(float $openUnits): self */ public function withRtaCode(string $rtaCode): self { - $obj = clone $this; - $obj->rta_code = $rtaCode; + $self = clone $this; + $self['rtaCode'] = $rtaCode; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php index 9de949d..c01c4a0 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Gain.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\MutualFund\Scheme; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class Gain implements BaseModel /** * Absolute gain or loss. */ - #[Api(optional: true)] + #[Optional] public ?float $absolute; /** * Percentage gain or loss. */ - #[Api(optional: true)] + #[Optional] public ?float $percentage; public function __construct() @@ -42,12 +42,12 @@ public static function with( ?float $absolute = null, ?float $percentage = null ): self { - $obj = new self; + $self = new self; - null !== $absolute && $obj->absolute = $absolute; - null !== $percentage && $obj->percentage = $percentage; + null !== $absolute && $self['absolute'] = $absolute; + null !== $percentage && $self['percentage'] = $percentage; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withAbsolute(float $absolute): self { - $obj = clone $this; - $obj->absolute = $absolute; + $self = clone $this; + $self['absolute'] = $absolute; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withAbsolute(float $absolute): self */ public function withPercentage(float $percentage): self { - $obj = clone $this; - $obj->percentage = $percentage; + $self = clone $this; + $self['percentage'] = $percentage; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php index 2da3426..26ee653 100644 --- a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction.php @@ -4,19 +4,26 @@ namespace CasParser\CasParser\UnifiedResponse\MutualFund\Scheme; -use CasParser\Core\Attributes\Api; +use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\AdditionalInfo; +use CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\Type; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * Unified transaction schema for all holding types (MF folios, equities, bonds, etc.). + * + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\AdditionalInfo + * * @phpstan-type TransactionShape = array{ + * additionalInfo?: null|\CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\AdditionalInfo|AdditionalInfoShape, * amount?: float|null, * balance?: float|null, - * date?: \DateTimeInterface|null, + * date?: string|null, * description?: string|null, - * dividend_rate?: float|null, + * dividendRate?: float|null, * nav?: float|null, - * type?: string|null, + * type?: null|\CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\Type|value-of<\CasParser\CasParser\UnifiedResponse\MutualFund\Scheme\Transaction\Type>, * units?: float|null, * } */ @@ -26,51 +33,61 @@ final class Transaction implements BaseModel use SdkModel; /** - * Transaction amount. + * Additional transaction-specific fields that vary by source. */ - #[Api(optional: true)] + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + #[Optional(nullable: true)] public ?float $amount; /** * Balance units after transaction. */ - #[Api(optional: true)] + #[Optional] public ?float $balance; /** - * Transaction date. + * Transaction date (YYYY-MM-DD). */ - #[Api(optional: true)] - public ?\DateTimeInterface $date; + #[Optional] + public ?string $date; /** - * Transaction description. + * Transaction description/particulars. */ - #[Api(optional: true)] + #[Optional] public ?string $description; /** - * Dividend rate (for dividend transactions). + * Dividend rate (for DIVIDEND_PAYOUT transactions). */ - #[Api(optional: true)] - public ?float $dividend_rate; + #[Optional('dividend_rate', nullable: true)] + public ?float $dividendRate; /** - * NAV on transaction date. + * NAV/price per unit on transaction date. */ - #[Api(optional: true)] + #[Optional(nullable: true)] public ?float $nav; /** - * Transaction type detected based on description. Possible values are PURCHASE,PURCHASE_SIP,REDEMPTION,SWITCH_IN,SWITCH_IN_MERGER,SWITCH_OUT,SWITCH_OUT_MERGER,DIVIDEND_PAYOUT,DIVIDEND_REINVESTMENT,SEGREGATION,STAMP_DUTY_TAX,TDS_TAX,STT_TAX,MISC. If dividend_rate is present, then possible values are dividend_rate is applicable only for DIVIDEND_PAYOUT and DIVIDEND_REINVESTMENT. + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @var value-of|null $type */ - #[Api(optional: true)] + #[Optional( + enum: Type::class, + )] public ?string $type; /** - * Number of units involved. + * Number of units involved in transaction. */ - #[Api(optional: true)] + #[Optional] public ?float $units; public function __construct() @@ -82,40 +99,59 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo + * @param Type|value-of|null $type */ public static function with( + AdditionalInfo|array|null $additionalInfo = null, ?float $amount = null, ?float $balance = null, - ?\DateTimeInterface $date = null, + ?string $date = null, ?string $description = null, - ?float $dividend_rate = null, + ?float $dividendRate = null, ?float $nav = null, - ?string $type = null, + Type|string|null $type = null, ?float $units = null, ): self { - $obj = new self; - - null !== $amount && $obj->amount = $amount; - null !== $balance && $obj->balance = $balance; - null !== $date && $obj->date = $date; - null !== $description && $obj->description = $description; - null !== $dividend_rate && $obj->dividend_rate = $dividend_rate; - null !== $nav && $obj->nav = $nav; - null !== $type && $obj->type = $type; - null !== $units && $obj->units = $units; - - return $obj; + $self = new self; + + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $amount && $self['amount'] = $amount; + null !== $balance && $self['balance'] = $balance; + null !== $date && $self['date'] = $date; + null !== $description && $self['description'] = $description; + null !== $dividendRate && $self['dividendRate'] = $dividendRate; + null !== $nav && $self['nav'] = $nav; + null !== $type && $self['type'] = $type; + null !== $units && $self['units'] = $units; + + return $self; } /** - * Transaction amount. + * Additional transaction-specific fields that vary by source. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAmount(float $amount): self + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo, + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; + + return $self; + } + + /** + * Transaction amount in currency (computed from units × price/NAV). + */ + public function withAmount(?float $amount): self { - $obj = clone $this; - $obj->amount = $amount; + $self = clone $this; + $self['amount'] = $amount; - return $obj; + return $self; } /** @@ -123,75 +159,78 @@ public function withAmount(float $amount): self */ public function withBalance(float $balance): self { - $obj = clone $this; - $obj->balance = $balance; + $self = clone $this; + $self['balance'] = $balance; - return $obj; + return $self; } /** - * Transaction date. + * Transaction date (YYYY-MM-DD). */ - public function withDate(\DateTimeInterface $date): self + public function withDate(string $date): self { - $obj = clone $this; - $obj->date = $date; + $self = clone $this; + $self['date'] = $date; - return $obj; + return $self; } /** - * Transaction description. + * Transaction description/particulars. */ public function withDescription(string $description): self { - $obj = clone $this; - $obj->description = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** - * Dividend rate (for dividend transactions). + * Dividend rate (for DIVIDEND_PAYOUT transactions). */ - public function withDividendRate(float $dividendRate): self + public function withDividendRate(?float $dividendRate): self { - $obj = clone $this; - $obj->dividend_rate = $dividendRate; + $self = clone $this; + $self['dividendRate'] = $dividendRate; - return $obj; + return $self; } /** - * NAV on transaction date. + * NAV/price per unit on transaction date. */ - public function withNav(float $nav): self + public function withNav(?float $nav): self { - $obj = clone $this; - $obj->nav = $nav; + $self = clone $this; + $self['nav'] = $nav; - return $obj; + return $self; } /** - * Transaction type detected based on description. Possible values are PURCHASE,PURCHASE_SIP,REDEMPTION,SWITCH_IN,SWITCH_IN_MERGER,SWITCH_OUT,SWITCH_OUT_MERGER,DIVIDEND_PAYOUT,DIVIDEND_REINVESTMENT,SEGREGATION,STAMP_DUTY_TAX,TDS_TAX,STT_TAX,MISC. If dividend_rate is present, then possible values are dividend_rate is applicable only for DIVIDEND_PAYOUT and DIVIDEND_REINVESTMENT. + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @param Type|value-of $type */ - public function withType(string $type): self - { - $obj = clone $this; - $obj->type = $type; + public function withType( + Type|string $type, + ): self { + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } /** - * Number of units involved. + * Number of units involved in transaction. */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/AdditionalInfo.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/AdditionalInfo.php new file mode 100644 index 0000000..950c7b6 --- /dev/null +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/AdditionalInfo.php @@ -0,0 +1,179 @@ + */ + use SdkModel; + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + #[Optional('capital_withdrawal')] + public ?float $capitalWithdrawal; + + /** + * Units credited (demat transactions). + */ + #[Optional] + public ?float $credit; + + /** + * Units debited (demat transactions). + */ + #[Optional] + public ?float $debit; + + /** + * Income distribution amount (CDSL MF transactions). + */ + #[Optional('income_distribution')] + public ?float $incomeDistribution; + + /** + * Order/transaction reference number (demat transactions). + */ + #[Optional('order_no')] + public ?string $orderNo; + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + #[Optional] + public ?float $price; + + /** + * Stamp duty charged. + */ + #[Optional('stamp_duty')] + public ?float $stampDuty; + + 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( + ?float $capitalWithdrawal = null, + ?float $credit = null, + ?float $debit = null, + ?float $incomeDistribution = null, + ?string $orderNo = null, + ?float $price = null, + ?float $stampDuty = null, + ): self { + $self = new self; + + null !== $capitalWithdrawal && $self['capitalWithdrawal'] = $capitalWithdrawal; + null !== $credit && $self['credit'] = $credit; + null !== $debit && $self['debit'] = $debit; + null !== $incomeDistribution && $self['incomeDistribution'] = $incomeDistribution; + null !== $orderNo && $self['orderNo'] = $orderNo; + null !== $price && $self['price'] = $price; + null !== $stampDuty && $self['stampDuty'] = $stampDuty; + + return $self; + } + + /** + * Capital withdrawal amount (CDSL MF transactions). + */ + public function withCapitalWithdrawal(float $capitalWithdrawal): self + { + $self = clone $this; + $self['capitalWithdrawal'] = $capitalWithdrawal; + + return $self; + } + + /** + * Units credited (demat transactions). + */ + public function withCredit(float $credit): self + { + $self = clone $this; + $self['credit'] = $credit; + + return $self; + } + + /** + * Units debited (demat transactions). + */ + public function withDebit(float $debit): self + { + $self = clone $this; + $self['debit'] = $debit; + + return $self; + } + + /** + * Income distribution amount (CDSL MF transactions). + */ + public function withIncomeDistribution(float $incomeDistribution): self + { + $self = clone $this; + $self['incomeDistribution'] = $incomeDistribution; + + return $self; + } + + /** + * Order/transaction reference number (demat transactions). + */ + public function withOrderNo(string $orderNo): self + { + $self = clone $this; + $self['orderNo'] = $orderNo; + + return $self; + } + + /** + * Price per unit (NSDL/CDSL MF transactions). + */ + public function withPrice(float $price): self + { + $self = clone $this; + $self['price'] = $price; + + return $self; + } + + /** + * Stamp duty charged. + */ + public function withStampDuty(float $stampDuty): self + { + $self = clone $this; + $self['stampDuty'] = $stampDuty; + + return $self; + } +} diff --git a/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/Type.php b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/Type.php new file mode 100644 index 0000000..d251575 --- /dev/null +++ b/src/CasParser/UnifiedResponse/MutualFund/Scheme/Transaction/Type.php @@ -0,0 +1,43 @@ +|null, - * linked_holders?: list|null, + * funds?: list|null, + * linkedHolders?: list|null, * pran?: string|null, * value?: float|null, * } @@ -28,37 +31,37 @@ final class Np implements BaseModel /** * Additional information specific to the NPS account. */ - #[Api(optional: true)] - public mixed $additional_info; + #[Optional('additional_info')] + public mixed $additionalInfo; /** * Central Record Keeping Agency name. */ - #[Api(optional: true)] + #[Optional] public ?string $cra; /** @var list|null $funds */ - #[Api(list: Fund::class, optional: true)] + #[Optional(list: Fund::class)] public ?array $funds; /** * List of account holders linked to this NPS account. * - * @var list|null $linked_holders + * @var list|null $linkedHolders */ - #[Api(list: LinkedHolder::class, optional: true)] - public ?array $linked_holders; + #[Optional('linked_holders', list: LinkedHolder::class)] + public ?array $linkedHolders; /** * Permanent Retirement Account Number (PRAN). */ - #[Api(optional: true)] + #[Optional] public ?string $pran; /** * Total value of the NPS account. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -71,27 +74,27 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $funds - * @param list $linked_holders + * @param list|null $funds + * @param list|null $linkedHolders */ public static function with( - mixed $additional_info = null, + mixed $additionalInfo = null, ?string $cra = null, ?array $funds = null, - ?array $linked_holders = null, + ?array $linkedHolders = null, ?string $pran = null, ?float $value = null, ): self { - $obj = new self; + $self = 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; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $cra && $self['cra'] = $cra; + null !== $funds && $self['funds'] = $funds; + null !== $linkedHolders && $self['linkedHolders'] = $linkedHolders; + null !== $pran && $self['pran'] = $pran; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** @@ -99,10 +102,10 @@ public static function with( */ public function withAdditionalInfo(mixed $additionalInfo): self { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -110,34 +113,34 @@ public function withAdditionalInfo(mixed $additionalInfo): self */ public function withCra(string $cra): self { - $obj = clone $this; - $obj->cra = $cra; + $self = clone $this; + $self['cra'] = $cra; - return $obj; + return $self; } /** - * @param list $funds + * @param list $funds */ public function withFunds(array $funds): self { - $obj = clone $this; - $obj->funds = $funds; + $self = clone $this; + $self['funds'] = $funds; - return $obj; + return $self; } /** * List of account holders linked to this NPS account. * - * @param list $linkedHolders + * @param list $linkedHolders */ public function withLinkedHolders(array $linkedHolders): self { - $obj = clone $this; - $obj->linked_holders = $linkedHolders; + $self = clone $this; + $self['linkedHolders'] = $linkedHolders; - return $obj; + return $self; } /** @@ -145,10 +148,10 @@ public function withLinkedHolders(array $linkedHolders): self */ public function withPran(string $pran): self { - $obj = clone $this; - $obj->pran = $pran; + $self = clone $this; + $self['pran'] = $pran; - return $obj; + return $self; } /** @@ -156,9 +159,9 @@ public function withPran(string $pran): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Np/Fund.php b/src/CasParser/UnifiedResponse/Np/Fund.php index 24351fc..3dd4122 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund.php +++ b/src/CasParser/UnifiedResponse/Np/Fund.php @@ -5,13 +5,15 @@ namespace CasParser\CasParser\UnifiedResponse\Np; use CasParser\CasParser\UnifiedResponse\Np\Fund\AdditionalInfo; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AdditionalInfoShape from \CasParser\CasParser\UnifiedResponse\Np\Fund\AdditionalInfo + * * @phpstan-type FundShape = array{ - * additional_info?: AdditionalInfo|null, + * additionalInfo?: null|AdditionalInfo|AdditionalInfoShape, * cost?: float|null, * name?: string|null, * nav?: float|null, @@ -27,37 +29,37 @@ final class Fund implements BaseModel /** * Additional information specific to the NPS fund. */ - #[Api(optional: true)] - public ?AdditionalInfo $additional_info; + #[Optional('additional_info')] + public ?AdditionalInfo $additionalInfo; /** * Cost of investment. */ - #[Api(optional: true)] + #[Optional] public ?float $cost; /** * Name of the NPS fund. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** * Net Asset Value per unit. */ - #[Api(optional: true)] + #[Optional] public ?float $nav; /** * Number of units held. */ - #[Api(optional: true)] + #[Optional] public ?float $units; /** * Current market value of the holding. */ - #[Api(optional: true)] + #[Optional] public ?float $value; public function __construct() @@ -69,36 +71,41 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param AdditionalInfo|AdditionalInfoShape|null $additionalInfo */ public static function with( - ?AdditionalInfo $additional_info = null, + AdditionalInfo|array|null $additionalInfo = null, ?float $cost = null, ?string $name = null, ?float $nav = null, ?float $units = null, ?float $value = null, ): self { - $obj = new self; + $self = 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; + null !== $additionalInfo && $self['additionalInfo'] = $additionalInfo; + null !== $cost && $self['cost'] = $cost; + null !== $name && $self['name'] = $name; + null !== $nav && $self['nav'] = $nav; + null !== $units && $self['units'] = $units; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** * Additional information specific to the NPS fund. + * + * @param AdditionalInfo|AdditionalInfoShape $additionalInfo */ - public function withAdditionalInfo(AdditionalInfo $additionalInfo): self - { - $obj = clone $this; - $obj->additional_info = $additionalInfo; + public function withAdditionalInfo( + AdditionalInfo|array $additionalInfo + ): self { + $self = clone $this; + $self['additionalInfo'] = $additionalInfo; - return $obj; + return $self; } /** @@ -106,10 +113,10 @@ public function withAdditionalInfo(AdditionalInfo $additionalInfo): self */ public function withCost(float $cost): self { - $obj = clone $this; - $obj->cost = $cost; + $self = clone $this; + $self['cost'] = $cost; - return $obj; + return $self; } /** @@ -117,10 +124,10 @@ public function withCost(float $cost): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -128,10 +135,10 @@ public function withName(string $name): self */ public function withNav(float $nav): self { - $obj = clone $this; - $obj->nav = $nav; + $self = clone $this; + $self['nav'] = $nav; - return $obj; + return $self; } /** @@ -139,10 +146,10 @@ public function withNav(float $nav): self */ public function withUnits(float $units): self { - $obj = clone $this; - $obj->units = $units; + $self = clone $this; + $self['units'] = $units; - return $obj; + return $self; } /** @@ -150,9 +157,9 @@ public function withUnits(float $units): self */ public function withValue(float $value): self { - $obj = clone $this; - $obj->value = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php index e14ee64..f7d3ce5 100644 --- a/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php +++ b/src/CasParser/UnifiedResponse/Np/Fund/AdditionalInfo.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\Np\Fund; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -23,13 +23,13 @@ final class AdditionalInfo implements BaseModel /** * Fund manager name. */ - #[Api(optional: true)] + #[Optional] public ?string $manager; /** * NPS tier (Tier I or Tier II). */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?float $tier; public function __construct() @@ -46,12 +46,12 @@ public static function with( ?string $manager = null, ?float $tier = null ): self { - $obj = new self; + $self = new self; - null !== $manager && $obj->manager = $manager; - null !== $tier && $obj->tier = $tier; + null !== $manager && $self['manager'] = $manager; + null !== $tier && $self['tier'] = $tier; - return $obj; + return $self; } /** @@ -59,10 +59,10 @@ public static function with( */ public function withManager(string $manager): self { - $obj = clone $this; - $obj->manager = $manager; + $self = clone $this; + $self['manager'] = $manager; - return $obj; + return $self; } /** @@ -70,9 +70,9 @@ public function withManager(string $manager): self */ public function withTier(?float $tier): self { - $obj = clone $this; - $obj->tier = $tier; + $self = clone $this; + $self['tier'] = $tier; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php index ade9223..65f3765 100644 --- a/src/CasParser/UnifiedResponse/Np/LinkedHolder.php +++ b/src/CasParser/UnifiedResponse/Np/LinkedHolder.php @@ -4,7 +4,7 @@ namespace CasParser\CasParser\UnifiedResponse\Np; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class LinkedHolder implements BaseModel /** * Name of the account holder. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** * PAN of the account holder. */ - #[Api(optional: true)] + #[Optional] public ?string $pan; public function __construct() @@ -40,12 +40,12 @@ public function __construct() */ public static function with(?string $name = null, ?string $pan = null): self { - $obj = new self; + $self = new self; - null !== $name && $obj->name = $name; - null !== $pan && $obj->pan = $pan; + null !== $name && $self['name'] = $name; + null !== $pan && $self['pan'] = $pan; - return $obj; + return $self; } /** @@ -53,10 +53,10 @@ public static function with(?string $name = null, ?string $pan = null): self */ public function withName(string $name): self { - $obj = clone $this; - $obj->name = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -64,9 +64,9 @@ public function withName(string $name): self */ public function withPan(string $pan): self { - $obj = clone $this; - $obj->pan = $pan; + $self = clone $this; + $self['pan'] = $pan; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary.php b/src/CasParser/UnifiedResponse/Summary.php index 68f5e5f..9865595 100644 --- a/src/CasParser/UnifiedResponse/Summary.php +++ b/src/CasParser/UnifiedResponse/Summary.php @@ -5,13 +5,15 @@ namespace CasParser\CasParser\UnifiedResponse; use CasParser\CasParser\UnifiedResponse\Summary\Accounts; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type AccountsShape from \CasParser\CasParser\UnifiedResponse\Summary\Accounts + * * @phpstan-type SummaryShape = array{ - * accounts?: Accounts|null, total_value?: float|null + * accounts?: null|Accounts|AccountsShape, totalValue?: float|null * } */ final class Summary implements BaseModel @@ -19,14 +21,14 @@ final class Summary implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api(optional: true)] + #[Optional] public ?Accounts $accounts; /** * Total portfolio value across all accounts. */ - #[Api(optional: true)] - public ?float $total_value; + #[Optional('total_value')] + public ?float $totalValue; public function __construct() { @@ -37,25 +39,30 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param Accounts|AccountsShape|null $accounts */ public static function with( - ?Accounts $accounts = null, - ?float $total_value = null + Accounts|array|null $accounts = null, + ?float $totalValue = null ): self { - $obj = new self; + $self = new self; - null !== $accounts && $obj->accounts = $accounts; - null !== $total_value && $obj->total_value = $total_value; + null !== $accounts && $self['accounts'] = $accounts; + null !== $totalValue && $self['totalValue'] = $totalValue; - return $obj; + return $self; } - public function withAccounts(Accounts $accounts): self + /** + * @param Accounts|AccountsShape $accounts + */ + public function withAccounts(Accounts|array $accounts): self { - $obj = clone $this; - $obj->accounts = $accounts; + $self = clone $this; + $self['accounts'] = $accounts; - return $obj; + return $self; } /** @@ -63,9 +70,9 @@ public function withAccounts(Accounts $accounts): self */ public function withTotalValue(float $totalValue): self { - $obj = clone $this; - $obj->total_value = $totalValue; + $self = clone $this; + $self['totalValue'] = $totalValue; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts.php b/src/CasParser/UnifiedResponse/Summary/Accounts.php index 1663b4e..9e4db59 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts.php @@ -8,16 +8,21 @@ 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\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** + * @phpstan-import-type DematShape from \CasParser\CasParser\UnifiedResponse\Summary\Accounts\Demat + * @phpstan-import-type InsuranceShape from \CasParser\CasParser\UnifiedResponse\Summary\Accounts\Insurance + * @phpstan-import-type MutualFundsShape from \CasParser\CasParser\UnifiedResponse\Summary\Accounts\MutualFunds + * @phpstan-import-type NpsShape from \CasParser\CasParser\UnifiedResponse\Summary\Accounts\Nps + * * @phpstan-type AccountsShape = array{ - * demat?: Demat|null, - * insurance?: Insurance|null, - * mutual_funds?: MutualFunds|null, - * nps?: Nps|null, + * demat?: null|Demat|DematShape, + * insurance?: null|Insurance|InsuranceShape, + * mutualFunds?: null|MutualFunds|MutualFundsShape, + * nps?: null|Nps|NpsShape, * } */ final class Accounts implements BaseModel @@ -25,16 +30,16 @@ final class Accounts implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api(optional: true)] + #[Optional] public ?Demat $demat; - #[Api(optional: true)] + #[Optional] public ?Insurance $insurance; - #[Api(optional: true)] - public ?MutualFunds $mutual_funds; + #[Optional('mutual_funds')] + public ?MutualFunds $mutualFunds; - #[Api(optional: true)] + #[Optional] public ?Nps $nps; public function __construct() @@ -46,52 +51,69 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param Demat|DematShape|null $demat + * @param Insurance|InsuranceShape|null $insurance + * @param MutualFunds|MutualFundsShape|null $mutualFunds + * @param Nps|NpsShape|null $nps */ public static function with( - ?Demat $demat = null, - ?Insurance $insurance = null, - ?MutualFunds $mutual_funds = null, - ?Nps $nps = null, + Demat|array|null $demat = null, + Insurance|array|null $insurance = null, + MutualFunds|array|null $mutualFunds = null, + Nps|array|null $nps = null, ): self { - $obj = new self; + $self = new self; - null !== $demat && $obj->demat = $demat; - null !== $insurance && $obj->insurance = $insurance; - null !== $mutual_funds && $obj->mutual_funds = $mutual_funds; - null !== $nps && $obj->nps = $nps; + null !== $demat && $self['demat'] = $demat; + null !== $insurance && $self['insurance'] = $insurance; + null !== $mutualFunds && $self['mutualFunds'] = $mutualFunds; + null !== $nps && $self['nps'] = $nps; - return $obj; + return $self; } - public function withDemat(Demat $demat): self + /** + * @param Demat|DematShape $demat + */ + public function withDemat(Demat|array $demat): self { - $obj = clone $this; - $obj->demat = $demat; + $self = clone $this; + $self['demat'] = $demat; - return $obj; + return $self; } - public function withInsurance(Insurance $insurance): self + /** + * @param Insurance|InsuranceShape $insurance + */ + public function withInsurance(Insurance|array $insurance): self { - $obj = clone $this; - $obj->insurance = $insurance; + $self = clone $this; + $self['insurance'] = $insurance; - return $obj; + return $self; } - public function withMutualFunds(MutualFunds $mutualFunds): self + /** + * @param MutualFunds|MutualFundsShape $mutualFunds + */ + public function withMutualFunds(MutualFunds|array $mutualFunds): self { - $obj = clone $this; - $obj->mutual_funds = $mutualFunds; + $self = clone $this; + $self['mutualFunds'] = $mutualFunds; - return $obj; + return $self; } - public function withNps(Nps $nps): self + /** + * @param Nps|NpsShape $nps + */ + public function withNps(Nps|array $nps): self { - $obj = clone $this; - $obj->nps = $nps; + $self = clone $this; + $self['nps'] = $nps; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php index 6aac885..45bee75 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Demat.php @@ -4,12 +4,12 @@ namespace CasParser\CasParser\UnifiedResponse\Summary\Accounts; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type DematShape = array{count?: int|null, total_value?: float|null} + * @phpstan-type DematShape = array{count?: int|null, totalValue?: float|null} */ final class Demat implements BaseModel { @@ -19,14 +19,14 @@ final class Demat implements BaseModel /** * Number of demat accounts. */ - #[Api(optional: true)] + #[Optional] public ?int $count; /** * Total value of demat accounts. */ - #[Api(optional: true)] - public ?float $total_value; + #[Optional('total_value')] + public ?float $totalValue; public function __construct() { @@ -40,14 +40,14 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $total_value = null + ?float $totalValue = null ): self { - $obj = new self; + $self = new self; - null !== $count && $obj->count = $count; - null !== $total_value && $obj->total_value = $total_value; + null !== $count && $self['count'] = $count; + null !== $totalValue && $self['totalValue'] = $totalValue; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withCount(int $count): self { - $obj = clone $this; - $obj->count = $count; + $self = clone $this; + $self['count'] = $count; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withCount(int $count): self */ public function withTotalValue(float $totalValue): self { - $obj = clone $this; - $obj->total_value = $totalValue; + $self = clone $this; + $self['totalValue'] = $totalValue; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php index 55a4cec..26fece6 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Insurance.php @@ -4,12 +4,12 @@ namespace CasParser\CasParser\UnifiedResponse\Summary\Accounts; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type InsuranceShape = array{count?: int|null, total_value?: float|null} + * @phpstan-type InsuranceShape = array{count?: int|null, totalValue?: float|null} */ final class Insurance implements BaseModel { @@ -19,14 +19,14 @@ final class Insurance implements BaseModel /** * Number of insurance policies. */ - #[Api(optional: true)] + #[Optional] public ?int $count; /** * Total value of insurance policies. */ - #[Api(optional: true)] - public ?float $total_value; + #[Optional('total_value')] + public ?float $totalValue; public function __construct() { @@ -40,14 +40,14 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $total_value = null + ?float $totalValue = null ): self { - $obj = new self; + $self = new self; - null !== $count && $obj->count = $count; - null !== $total_value && $obj->total_value = $total_value; + null !== $count && $self['count'] = $count; + null !== $totalValue && $self['totalValue'] = $totalValue; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withCount(int $count): self { - $obj = clone $this; - $obj->count = $count; + $self = clone $this; + $self['count'] = $count; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withCount(int $count): self */ public function withTotalValue(float $totalValue): self { - $obj = clone $this; - $obj->total_value = $totalValue; + $self = clone $this; + $self['totalValue'] = $totalValue; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php index 2bd2d57..3b91f0d 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/MutualFunds.php @@ -4,13 +4,13 @@ namespace CasParser\CasParser\UnifiedResponse\Summary\Accounts; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** * @phpstan-type MutualFundsShape = array{ - * count?: int|null, total_value?: float|null + * count?: int|null, totalValue?: float|null * } */ final class MutualFunds implements BaseModel @@ -21,14 +21,14 @@ final class MutualFunds implements BaseModel /** * Number of mutual fund folios. */ - #[Api(optional: true)] + #[Optional] public ?int $count; /** * Total value of mutual funds. */ - #[Api(optional: true)] - public ?float $total_value; + #[Optional('total_value')] + public ?float $totalValue; public function __construct() { @@ -42,14 +42,14 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $total_value = null + ?float $totalValue = null ): self { - $obj = new self; + $self = new self; - null !== $count && $obj->count = $count; - null !== $total_value && $obj->total_value = $total_value; + null !== $count && $self['count'] = $count; + null !== $totalValue && $self['totalValue'] = $totalValue; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withCount(int $count): self { - $obj = clone $this; - $obj->count = $count; + $self = clone $this; + $self['count'] = $count; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withCount(int $count): self */ public function withTotalValue(float $totalValue): self { - $obj = clone $this; - $obj->total_value = $totalValue; + $self = clone $this; + $self['totalValue'] = $totalValue; - return $obj; + return $self; } } diff --git a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php index d1e08d8..d407a09 100644 --- a/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php +++ b/src/CasParser/UnifiedResponse/Summary/Accounts/Nps.php @@ -4,12 +4,12 @@ namespace CasParser\CasParser\UnifiedResponse\Summary\Accounts; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; /** - * @phpstan-type NpsShape = array{count?: int|null, total_value?: float|null} + * @phpstan-type NpsShape = array{count?: int|null, totalValue?: float|null} */ final class Nps implements BaseModel { @@ -19,14 +19,14 @@ final class Nps implements BaseModel /** * Number of NPS accounts. */ - #[Api(optional: true)] + #[Optional] public ?int $count; /** * Total value of NPS accounts. */ - #[Api(optional: true)] - public ?float $total_value; + #[Optional('total_value')] + public ?float $totalValue; public function __construct() { @@ -40,14 +40,14 @@ public function __construct() */ public static function with( ?int $count = null, - ?float $total_value = null + ?float $totalValue = null ): self { - $obj = new self; + $self = new self; - null !== $count && $obj->count = $count; - null !== $total_value && $obj->total_value = $total_value; + null !== $count && $self['count'] = $count; + null !== $totalValue && $self['totalValue'] = $totalValue; - return $obj; + return $self; } /** @@ -55,10 +55,10 @@ public static function with( */ public function withCount(int $count): self { - $obj = clone $this; - $obj->count = $count; + $self = clone $this; + $self['count'] = $count; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public function withCount(int $count): self */ public function withTotalValue(float $totalValue): self { - $obj = clone $this; - $obj->total_value = $totalValue; + $self = clone $this; + $self['totalValue'] = $totalValue; - return $obj; + return $self; } } diff --git a/src/Client.php b/src/Client.php index afc8ce5..765ca70 100644 --- a/src/Client.php +++ b/src/Client.php @@ -5,6 +5,7 @@ namespace CasParser; use CasParser\Core\BaseClient; +use CasParser\Core\Util; use CasParser\Services\CasGeneratorService; use CasParser\Services\CasParserService; use Http\Discovery\Psr17FactoryDiscovery; @@ -40,21 +41,19 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) ); parent::__construct( - // x-release-please-start-version headers: [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', - 'User-Agent' => sprintf('CAS Parser/PHP %s', '0.0.1'), + 'User-Agent' => sprintf('CAS Parser/PHP %s', VERSION), 'X-Stainless-Lang' => 'php', 'X-Stainless-Package-Version' => '0.0.1', - 'X-Stainless-OS' => $this->getNormalizedOS(), - 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), - 'X-Stainless-Runtime' => 'php', + 'X-Stainless-Arch' => Util::machtype(), + 'X-Stainless-OS' => Util::ostype(), + 'X-Stainless-Runtime' => php_sapi_name(), 'X-Stainless-Runtime-Version' => phpversion(), ], - // x-release-please-end baseUrl: $baseUrl, - options: $options, + options: $options ); $this->casParser = new CasParserService($this); diff --git a/src/Core/Attributes/Optional.php b/src/Core/Attributes/Optional.php new file mode 100644 index 0000000..50d1e83 --- /dev/null +++ b/src/Core/Attributes/Optional.php @@ -0,0 +1,35 @@ +|Converter|string|null $type + * @param class-string<\BackedEnum>|Converter|null $enum + * @param class-string|Converter|null $union + * @param class-string|Converter|string|null $list + * @param class-string|Converter|string|null $map + */ + public function __construct( + ?string $apiName = null, + Converter|string|null $type = null, + Converter|string|null $enum = null, + Converter|string|null $union = null, + Converter|string|null $list = null, + Converter|string|null $map = null, + bool $nullable = false, + ) { + parent::__construct(apiName: $apiName, type: $type, enum: $enum, union: $union, list: $list, map: $map, nullable: $nullable); + $this->optional = true; + } +} diff --git a/src/Core/Attributes/Api.php b/src/Core/Attributes/Required.php similarity index 77% rename from src/Core/Attributes/Api.php rename to src/Core/Attributes/Required.php index c3f6875..589a017 100644 --- a/src/Core/Attributes/Api.php +++ b/src/Core/Attributes/Required.php @@ -14,11 +14,17 @@ * @internal */ #[\Attribute(\Attribute::TARGET_PROPERTY)] -final class Api +class Required { /** @var class-string|Converter|string|null */ public readonly Converter|string|null $type; + public readonly ?string $apiName; + + public bool $optional; + + public readonly bool $nullable; + /** @var array */ private static array $enumConverters = []; @@ -30,14 +36,13 @@ final class Api * @param class-string|Converter|string|null $map */ public function __construct( - public readonly ?string $apiName = null, + ?string $apiName = null, Converter|string|null $type = null, Converter|string|null $enum = null, Converter|string|null $union = null, Converter|string|null $list = null, Converter|string|null $map = null, - public readonly bool $nullable = false, - public readonly bool $optional = false, + bool $nullable = false, ) { $type ??= $union; if (null !== $list) { @@ -47,17 +52,21 @@ public function __construct( $type ??= new MapOf($map); } if (null !== $enum) { - $type ??= $enum instanceof Converter ? $enum : $this->getEnumConverter($enum); + $type ??= $enum instanceof Converter ? $enum : self::enumConverter($enum); } + $this->apiName = $apiName; $this->type = $type; + $this->optional = false; + $this->nullable = $nullable; } /** @property class-string<\BackedEnum> $enum */ - private function getEnumConverter(string $enum): Converter + private static function enumConverter(string $enum): Converter { if (!isset(self::$enumConverters[$enum])) { - $converter = new EnumOf(array_column($enum::cases(), 'value')); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + $converter = new EnumOf(array_column($enum::cases(), column_key: 'value')); self::$enumConverters[$enum] = $converter; } diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index 973279c..ab0aefa 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -5,11 +5,13 @@ namespace CasParser\Core; use CasParser\Core\Contracts\BasePage; +use CasParser\Core\Contracts\BaseResponse; use CasParser\Core\Contracts\BaseStream; use CasParser\Core\Conversion\Contracts\Converter; use CasParser\Core\Conversion\Contracts\ConverterSource; use CasParser\Core\Exceptions\APIConnectionException; use CasParser\Core\Exceptions\APIStatusException; +use CasParser\Core\Implementation\RawResponse; use CasParser\RequestOptions; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; @@ -41,6 +43,7 @@ abstract class BaseClient public function __construct( protected array $headers, string $baseUrl, + protected ?string $idempotencyHeader = null, protected RequestOptions $options = new RequestOptions, ) { assert(!is_null($this->options->uriFactory)); @@ -51,9 +54,12 @@ public function __construct( * @param string|list $path * @param array $query * @param array $headers - * @param class-string> $page - * @param class-string> $stream + * @param string|int|list|null $unwrap + * @param class-string>|null $page + * @param class-string>|null $stream * @param RequestOptions|array|null $options + * + * @return BaseResponse */ public function request( string $method, @@ -61,98 +67,38 @@ public function request( array $query = [], array $headers = [], mixed $body = null, + string|int|array|null $unwrap = null, string|Converter|ConverterSource|null $convert = null, ?string $page = null, ?string $stream = null, RequestOptions|array|null $options = [], - ): mixed { + ): BaseResponse { // @phpstan-ignore-next-line [$req, $opts] = $this->buildRequest(method: $method, path: $path, query: $query, headers: $headers, body: $body, opts: $options); - ['method' => $method, 'path' => $uri, 'headers' => $headers] = $req; + ['method' => $method, 'path' => $uri, 'headers' => $headers, 'body' => $data] = $req; assert(!is_null($opts->requestFactory)); $request = $opts->requestFactory->createRequest($method, uri: $uri); $request = Util::withSetHeaders($request, headers: $headers); - // @phpstan-ignore-next-line - $rsp = $this->sendRequest($opts, req: $request, data: $body, redirectCount: 0, retryCount: 0); - - if (!is_null($stream)) { - return new $stream( - convert: $convert, - request: $request, - response: $rsp - ); - } - - if (!is_null($page)) { - return new $page( - convert: $convert, - client: $this, - request: $req, - response: $rsp, - options: $opts, - ); - } - - if (!is_null($convert)) { - return Conversion::coerceResponse($convert, response: $rsp); - } + // @phpstan-ignore-next-line argument.type + $rsp = $this->sendRequest($opts, req: $request, data: $data, redirectCount: 0, retryCount: 0); - return Util::decodeContent($rsp); + // @phpstan-ignore-next-line argument.type + return new RawResponse(client: $this, request: $request, response: $rsp, options: $opts, requestInfo: $req, unwrap: $unwrap, stream: $stream, page: $page, convert: $convert ?? 'null'); } /** @return array */ abstract protected function authHeaders(): array; - protected function getNormalizedOS(): string - { - $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 + /** + * @internal + */ + protected function generateIdempotencyKey(): 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'; - } + $hex = bin2hex(random_bytes(32)); - return 'unknown'; + return "stainless-php-retry-{$hex}"; } /** @@ -192,15 +138,21 @@ protected function buildRequest( /** @var array $mergedQuery */ $mergedQuery = array_merge_recursive( $query, - $options->extraQueryParams ?? [], + $options->extraQueryParams ?? [] ); $uri = Util::joinUri($this->baseUrl, path: $parsedPath, query: $mergedQuery)->__toString(); + $idempotencyHeaders = $this->idempotencyHeader && !array_key_exists($this->idempotencyHeader, array: $headers) + ? [$this->idempotencyHeader => $this->generateIdempotencyKey()] + : []; /** @var array|null> $mergedHeaders */ - $mergedHeaders = [...$this->headers, + $mergedHeaders = [ + ...$this->headers, ...$this->authHeaders(), ...$headers, - ...($options->extraHeaders ?? []), ]; + ...($options->extraHeaders ?? []), + ...$idempotencyHeaders, + ]; $req = ['method' => strtoupper($method), 'path' => $uri, 'query' => $mergedQuery, 'headers' => $mergedHeaders, 'body' => $body]; @@ -287,8 +239,8 @@ protected function sendRequest( ): ResponseInterface { assert(null !== $opts->streamFactory && null !== $opts->transporter); + /** @var RequestInterface */ $req = $req->withHeader('X-Stainless-Retry-Count', strval($retryCount)); - $req = Util::withSetBody($opts->streamFactory, req: $req, body: $data); $rsp = null; diff --git a/src/Core/Concerns/ResponseProxy.php b/src/Core/Concerns/ResponseProxy.php new file mode 100644 index 0000000..b0ca8af --- /dev/null +++ b/src/Core/Concerns/ResponseProxy.php @@ -0,0 +1,101 @@ +response->getProtocolVersion(); + } + + public function withProtocolVersion(string $version): static + { + $self = clone $this; + $self->response = $this->response->withProtocolVersion($version); + + return $self; + } + + public function getHeaders(): array + { + return $this->response->getHeaders(); + } + + public function hasHeader(string $name): bool + { + return $this->response->hasHeader($name); + } + + public function getHeader(string $name): array + { + return $this->response->getHeader($name); + } + + public function getHeaderLine(string $name): string + { + return $this->response->getHeaderLine($name); + } + + public function withHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withHeader($name, value: $value); + + return $self; + } + + public function withAddedHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withAddedHeader($name, value: $value); + + return $self; + } + + public function withoutHeader(string $name): static + { + $self = clone $this; + $self->response = $this->response->withoutHeader($name); + + return $self; + } + + public function getBody(): StreamInterface + { + return $this->response->getBody(); + } + + public function withBody(StreamInterface $body): static + { + $self = clone $this; + $self->response = $this->response->withBody($body); + + return $self; + } + + public function getStatusCode(): int + { + return $this->response->getStatusCode(); + } + + public function withStatus(int $code, string $reasonPhrase = ''): static + { + $self = clone $this; + $self->response = $this->response->withstatus($code, reasonPhrase: $reasonPhrase); + + return $self; + } + + public function getReasonPhrase(): string + { + return $this->response->getReasonPhrase(); + } +} diff --git a/src/Core/Concerns/SdkEnum.php b/src/Core/Concerns/SdkEnum.php index 9941eaf..467116e 100644 --- a/src/Core/Concerns/SdkEnum.php +++ b/src/Core/Concerns/SdkEnum.php @@ -28,6 +28,7 @@ public static function converter(): Converter } } - return static::$converter = new EnumOf($acc); // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return static::$converter = new EnumOf($acc); } } diff --git a/src/Core/Concerns/SdkModel.php b/src/Core/Concerns/SdkModel.php index 3f0e929..a8548e1 100644 --- a/src/Core/Concerns/SdkModel.php +++ b/src/Core/Concerns/SdkModel.php @@ -32,7 +32,7 @@ trait SdkModel */ public function __serialize(): array { - $properties = $this->toProperties(); // @phpstan-ignore-line + $properties = $this->toProperties(); return array_map(static fn ($v) => self::serialize($v), array: $properties); } @@ -45,7 +45,8 @@ public function __serialize(): array public function __unserialize(array $data): void { foreach ($data as $key => $value) { - $this->offsetSet($key, value: $value); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + $this->offsetSet($key, value: $value); } } @@ -74,8 +75,6 @@ public function __toString(): string * a native class property, indicating an omitted value, * or a property overridden with an incongruent type * - * @return value-of - * * @throws \Exception */ public function __get(string $key): mixed @@ -94,7 +93,8 @@ public function __get(string $key): mixed // An optional property which was unset to be omitted from serialized is being accessed. // Return null to match user's expectations. - return null; // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return null; } /** @@ -104,7 +104,8 @@ public function __get(string $key): mixed */ public function toProperties(): array { - return [...Util::get_object_vars($this), ...$this->_data]; // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return [...Util::get_object_vars($this), ...$this->_data]; } /** @@ -114,7 +115,8 @@ public function toProperties(): array */ public function offsetExists(mixed $offset): bool { - if (!is_string($offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { throw new \InvalidArgumentException; } @@ -142,19 +144,24 @@ public function offsetExists(mixed $offset): bool */ public function &offsetGet(mixed $offset): mixed { - if (!is_string($offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { throw new \InvalidArgumentException; } - if (!$this->offsetExists($offset)) { // @phpstan-ignore-line - return null; // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!$this->offsetExists($offset)) { + // @phpstan-ignore-next-line return.type + return null; } if (array_key_exists($offset, array: $this->_data)) { - return $this->_data[$offset]; // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return $this->_data[$offset]; } - return $this->{$offset}; // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return $this->{$offset}; } /** @@ -164,7 +171,8 @@ public function &offsetGet(mixed $offset): mixed */ public function offsetSet(mixed $offset, mixed $value): void { - if (!is_string($offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { throw new \InvalidArgumentException; } @@ -174,13 +182,16 @@ public function offsetSet(mixed $offset, mixed $value): void $coerced = Conversion::coerce($type, value: $value, state: new CoerceState(translateNames: false)); - if (property_exists($this, property: $offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (property_exists($this, property: $offset)) { try { - $this->{$offset} = $coerced; // @phpstan-ignore-line + // @phpstan-ignore-next-line assign.propertyType + $this->{$offset} = $coerced; unset($this->_data[$offset]); return; - } catch (\TypeError) { // @phpstan-ignore-line + // @phpstan-ignore-next-line catch.neverThrown + } catch (\TypeError) { unset($this->{$offset}); } } @@ -195,11 +206,13 @@ public function offsetSet(mixed $offset, mixed $value): void */ public function offsetUnset(mixed $offset): void { - if (!is_string($offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { throw new \InvalidArgumentException; } - if (property_exists($this, property: $offset)) { // @phpstan-ignore-line + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (property_exists($this, property: $offset)) { unset($this->{$offset}); } @@ -213,7 +226,7 @@ public function offsetUnset(mixed $offset): void */ public function jsonSerialize(): array { - // @phpstan-ignore-next-line + // @phpstan-ignore-next-line argument.type return Conversion::dump(self::converter(), value: $this->__serialize()); } @@ -222,7 +235,8 @@ public function jsonSerialize(): array */ public static function fromArray(array $data): static { - return self::converter()->from($data); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + return self::converter()->from($data); } /** diff --git a/src/Core/Concerns/SdkPage.php b/src/Core/Concerns/SdkPage.php index 20e1c71..b46c41c 100644 --- a/src/Core/Concerns/SdkPage.php +++ b/src/Core/Concerns/SdkPage.php @@ -5,6 +5,7 @@ namespace CasParser\Core\Concerns; use CasParser\Client; +use CasParser\Core\Contracts\BaseResponse; use CasParser\Core\Conversion\Contracts\Converter; use CasParser\Core\Conversion\Contracts\ConverterSource; use CasParser\Core\Exceptions\APIStatusException; @@ -14,8 +15,6 @@ * @internal * * @template Item - * - * @phpstan-import-type normalized_request from \CasParser\Core\BaseClient */ trait SdkPage { @@ -23,13 +22,6 @@ trait SdkPage private Client $client; - /** - * normalized_request $request. - */ - private array $request; - - private RequestOptions $options; - /** * @return list */ @@ -37,12 +29,7 @@ abstract public function getItems(): array; public function hasNextPage(): bool { - $items = $this->getItems(); - if (empty($items)) { - return false; - } - - return null != $this->nextRequest(); + return !is_null($this->nextRequest()); } /** @@ -65,8 +52,12 @@ public function getNextPage(): static [$req, $opts] = $next; - // @phpstan-ignore-next-line - return $this->client->request(...$req, convert: $this->convert, page: $this::class, options: $opts); + // @phpstan-ignore-next-line argument.type + /** @var BaseResponse */ + $response = $this->client->request(...$req, convert: $this->convert, page: $this::class, options: $opts); + + // @phpstan-ignore-next-line return.type + return $response->parse(); } /** @@ -100,15 +91,6 @@ public function pagingEachItem(): \Generator } } - /** - * @internal - * - * @param array $data - * - * @return static - */ - abstract public static function fromArray(array $data): static; - /** * @internal * diff --git a/src/Core/Concerns/SdkParams.php b/src/Core/Concerns/SdkParams.php index 1010389..c93a9b2 100644 --- a/src/Core/Concerns/SdkParams.php +++ b/src/Core/Concerns/SdkParams.php @@ -15,23 +15,24 @@ trait SdkParams { /** - * @param array|self|null $params * @param array|RequestOptions|null $options * * @return array{array, RequestOptions} */ - public static function parseRequest(array|self|null $params, array|RequestOptions|null $options): array + public static function parseRequest(mixed $params, array|RequestOptions|null $options): array { $value = is_array($params) ? Util::array_filter_omit($params) : $params; $converter = self::converter(); $state = new DumpState; $dumped = (array) Conversion::dump($converter, value: $value, state: $state); - $opts = RequestOptions::parse($options); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + $opts = RequestOptions::parse($options); if (!$state->canRetry) { $opts->maxRetries = 0; } - return [$dumped, $opts]; // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return [$dumped, $opts]; } } diff --git a/src/Core/Concerns/SdkResponse.php b/src/Core/Concerns/SdkResponse.php deleted file mode 100644 index 95bf61f..0000000 --- a/src/Core/Concerns/SdkResponse.php +++ /dev/null @@ -1,29 +0,0 @@ -_rawResponse = $response; - $instance->__unserialize(Util::decodeContent($response)); // @phpstan-ignore-line - - return $instance; - } - - public function getRawResponse(): ?ResponseInterface - { - return $this->_rawResponse; - } -} diff --git a/src/Core/Concerns/SdkUnion.php b/src/Core/Concerns/SdkUnion.php index 6a073f8..b94173f 100644 --- a/src/Core/Concerns/SdkUnion.php +++ b/src/Core/Concerns/SdkUnion.php @@ -15,7 +15,7 @@ trait SdkUnion { private static Converter $converter; - public static function discriminator(): ?string // @phpstan-ignore-line + public static function discriminator(): ?string { return null; } @@ -34,7 +34,6 @@ public static function converter(): Converter return static::$converter; } - // @phpstan-ignore-next-line return static::$converter = new UnionOf(discriminator: static::discriminator(), variants: static::variants()); } } diff --git a/src/Core/Contracts/BasePage.php b/src/Core/Contracts/BasePage.php index c997b93..532e867 100644 --- a/src/Core/Contracts/BasePage.php +++ b/src/Core/Contracts/BasePage.php @@ -4,12 +4,6 @@ namespace CasParser\Core\Contracts; -use CasParser\Client; -use CasParser\Core\Conversion\Contracts\Converter; -use CasParser\Core\Conversion\Contracts\ConverterSource; -use CasParser\RequestOptions; -use Psr\Http\Message\ResponseInterface; - /** * @internal * @@ -21,19 +15,6 @@ */ interface BasePage extends \IteratorAggregate { - /** - * @internal - * - * @param normalized_request $request - */ - public function __construct( - Converter|ConverterSource|string $convert, - Client $client, - array $request, - RequestOptions $options, - ResponseInterface $response, - ); - public function hasNextPage(): bool; /** diff --git a/src/Core/Contracts/BaseResponse.php b/src/Core/Contracts/BaseResponse.php new file mode 100644 index 0000000..bd3f07b --- /dev/null +++ b/src/Core/Contracts/BaseResponse.php @@ -0,0 +1,21 @@ +dump($value, state: $state); } + if (is_a($value, class: \BackedEnum::class)) { + return $value->value; + } + if (is_a($value, class: \DateTimeInterface::class)) { - return $value->format(format: \DateTimeInterface::RFC3339); + return date_format($value, format: \DateTimeInterface::RFC3339); } if (is_a($value, class: \JsonSerializable::class)) { @@ -43,15 +45,6 @@ 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) { @@ -68,6 +61,26 @@ public static function coerce(Converter|ConverterSource|string $target, mixed $v return $target->coerce($value, state: $state); } + return self::tryConvert($target, value: $value, state: $state); + } + + public static function dump(Converter|ConverterSource|string $target, mixed $value, DumpState $state = new DumpState): mixed + { + if ($target instanceof Converter) { + return $target->dump($value, state: $state); + } + + if (is_a($target, class: ConverterSource::class, allow_string: true)) { + return $target::converter()->dump($value, state: $state); + } + + self::tryConvert($target, value: $value, state: $state); + + return self::dump_unknown($value, state: $state); + } + + private static function tryConvert(Converter|ConverterSource|string $target, mixed $value, CoerceState|DumpState $state): mixed + { switch ($target) { case 'mixed': ++$state->yes; @@ -163,17 +176,4 @@ public static function coerce(Converter|ConverterSource|string $target, mixed $v return $value; } } - - public static function dump(Converter|ConverterSource|string $target, mixed $value, DumpState $state = new DumpState): mixed - { - if ($target instanceof Converter) { - return $target->dump($value, state: $state); - } - - if (is_a($target, class: ConverterSource::class, allow_string: true)) { - return $target::converter()->dump($value, state: $state); - } - - return self::dump_unknown($value, state: $state); - } } diff --git a/src/Core/Conversion/Concerns/ArrayOf.php b/src/Core/Conversion/Concerns/ArrayOf.php index e711b11..9321b52 100644 --- a/src/Core/Conversion/Concerns/ArrayOf.php +++ b/src/Core/Conversion/Concerns/ArrayOf.php @@ -32,10 +32,11 @@ public function coerce(mixed $value, CoerceState $state): mixed if (!is_array($value)) { return $value; } + ++$state->yes; $acc = []; foreach ($value as $k => $v) { - if ($this->nullable && null === $v) { + if ($this->nullable && is_null($v)) { ++$state->yes; $acc[$k] = null; } else { @@ -51,15 +52,27 @@ public function dump(mixed $value, DumpState $state): mixed if (!is_array($value)) { return Conversion::dump_unknown($value, state: $state); } + ++$state->yes; if (empty($value)) { return $this->empty(); } - return array_map(fn ($v) => Conversion::dump($this->type, value: $v, state: $state), array: $value); + $acc = []; + foreach ($value as $k => $v) { + if ($this->nullable && is_null($v)) { + ++$state->yes; + $acc[$k] = null; + } else { + $acc[$k] = Conversion::dump($this->type, value: $v, state: $state); + } + } + + return $acc; } - private function empty(): array|object // @phpstan-ignore-line + // @phpstan-ignore-next-line missingType.iterableValue + private function empty(): array|object { return (object) []; } diff --git a/src/Core/Conversion/Contracts/ResponseConverter.php b/src/Core/Conversion/Contracts/ResponseConverter.php deleted file mode 100644 index 69ad591..0000000 --- a/src/Core/Conversion/Contracts/ResponseConverter.php +++ /dev/null @@ -1,18 +0,0 @@ -members, strict: true)) { - ++$state->yes; - } elseif ($this->type === gettype($value)) { - ++$state->maybe; - } else { - ++$state->no; - } + $this->tally($value, state: $state); return $value; } public function dump(mixed $value, DumpState $state): mixed { + $this->tally($value, state: $state); + return Conversion::dump_unknown($value, state: $state); } + + private function tally(mixed $value, CoerceState|DumpState $state): void + { + if (in_array($value, haystack: $this->members, strict: true)) { + ++$state->yes; + } elseif ($this->type === gettype($value)) { + ++$state->maybe; + } else { + ++$state->no; + } + } } diff --git a/src/Core/Conversion/ListOf.php b/src/Core/Conversion/ListOf.php index 8af6837..229d124 100644 --- a/src/Core/Conversion/ListOf.php +++ b/src/Core/Conversion/ListOf.php @@ -14,7 +14,8 @@ final class ListOf implements Converter { use ArrayOf; - private function empty(): array|object // @phpstan-ignore-line + // @phpstan-ignore-next-line missingType.iterableValue + private function empty(): array|object { return []; } diff --git a/src/Core/Conversion/ModelOf.php b/src/Core/Conversion/ModelOf.php index eaac34c..36669be 100644 --- a/src/Core/Conversion/ModelOf.php +++ b/src/Core/Conversion/ModelOf.php @@ -4,7 +4,8 @@ namespace CasParser\Core\Conversion; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; +use CasParser\Core\Attributes\Required; use CasParser\Core\Contracts\BaseModel; use CasParser\Core\Conversion; use CasParser\Core\Conversion\Contracts\Converter; @@ -27,7 +28,9 @@ public function __construct(public readonly \ReflectionClass $class) $properties = []; foreach ($this->class->getProperties() as $property) { - if (!empty($property->getAttributes(Api::class))) { + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; + + if (!empty($attributes)) { $name = $property->getName(); $properties[$name] = new PropertyInfo($property); } @@ -88,18 +91,8 @@ public function coerce(mixed $value, CoerceState $state): mixed $acc[$name] = $item; } - return $this->from($acc); // @phpstan-ignore-line - } - - /** - * @param array $data - */ - public function from(array $data): BaseModel - { - $instance = $this->class->newInstanceWithoutConstructor(); - $instance->__unserialize($data); // @phpstan-ignore-line - - return $instance; + // @phpstan-ignore-next-line return.type + return $this->from($acc); } public function dump(mixed $value, DumpState $state): mixed @@ -109,10 +102,12 @@ public function dump(mixed $value, DumpState $state): mixed } if (is_array($value)) { + ++$state->yes; $acc = []; foreach ($value as $name => $item) { if (array_key_exists($name, array: $this->properties)) { + ++$state->yes; $info = $this->properties[$name]; $acc[$info->apiName] = Conversion::dump($info->type, value: $item, state: $state); } else { @@ -120,9 +115,23 @@ public function dump(mixed $value, DumpState $state): mixed } } - return empty($acc) ? ((object) []) : $acc; + return empty($acc) ? ((object) $acc) : $acc; } + ++$state->no; + return Conversion::dump_unknown($value, state: $state); } + + /** + * @param array $data + */ + public function from(array $data): BaseModel + { + $instance = $this->class->newInstanceWithoutConstructor(); + // @phpstan-ignore-next-line + $instance->__unserialize($data); + + return $instance; + } } diff --git a/src/Core/Conversion/PropertyInfo.php b/src/Core/Conversion/PropertyInfo.php index 385627b..aea255b 100644 --- a/src/Core/Conversion/PropertyInfo.php +++ b/src/Core/Conversion/PropertyInfo.php @@ -4,7 +4,8 @@ namespace CasParser\Core\Conversion; -use CasParser\Core\Attributes\Api; +use CasParser\Core\Attributes\Optional; +use CasParser\Core\Attributes\Required; use CasParser\Core\Conversion\Contracts\Converter; use CasParser\Core\Conversion\Contracts\ConverterSource; @@ -28,9 +29,10 @@ public function __construct(public readonly \ReflectionProperty $property) $apiName = $property->getName(); $type = $property->getType(); $optional = false; + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; - foreach ($property->getAttributes(Api::class) as $attr) { - /** @var Api $attribute */ + foreach ($attributes as $attr) { + /** @var Required $attribute */ $attribute = $attr->newInstance(); $apiName = $attribute->apiName ?? $apiName; @@ -55,11 +57,12 @@ private static function parse(array|Converter|ConverterSource|\ReflectionType|st } if (is_array($type)) { - return new UnionOf($type); // @phpstan-ignore-line + // @phpstan-ignore-next-line return.type + return new UnionOf($type); } if ($type instanceof \ReflectionUnionType) { - // @phpstan-ignore-next-line + // @phpstan-ignore-next-line argument.type return new UnionOf(array_map(static fn ($t) => self::parse($t), array: $type->getTypes())); } diff --git a/src/Core/Conversion/UnionOf.php b/src/Core/Conversion/UnionOf.php index 0145ca1..d8852d4 100644 --- a/src/Core/Conversion/UnionOf.php +++ b/src/Core/Conversion/UnionOf.php @@ -65,17 +65,46 @@ public function coerce(mixed $value, CoerceState $state): mixed public function dump(mixed $value, DumpState $state): mixed { - if (null !== ($target = $this->resolveVariant(value: $value))) { + if (!is_null($target = $this->resolveVariant(value: $value))) { return Conversion::dump($target, value: $value, state: $state); } - foreach ($this->variants as $variant) { + $alternatives = []; + foreach ($this->variants as $_ => $variant) { + ++$state->branched; if ($value instanceof $variant) { return Conversion::dump($variant, value: $value, state: $state); } + + $newState = new DumpState; + $dumped = Conversion::dump($variant, value: $value, state: $newState); + if (($newState->no + $newState->maybe) === 0) { + $state->yes += $newState->yes; + + return $dumped; + } + if ($newState->maybe > 0) { + $alternatives[] = [[-$newState->yes, -$newState->maybe, $newState->no], $newState, $dumped]; + } } - return Conversion::dump_unknown($value, state: $state); + usort( + $alternatives, + static fn (array $a, array $b): int => $a[0][0] <=> $b[0][0] ?: $a[0][1] <=> $b[0][1] ?: $a[0][2] <=> $b[0][2] + ); + + if (empty($alternatives)) { + ++$state->no; + + return Conversion::dump_unknown($value, state: $state); + } + + [[,$newState, $best]] = $alternatives; + $state->yes += $newState->yes; + $state->maybe += $newState->maybe; + $state->no += $newState->no; + + return $best; } private function resolveVariant( diff --git a/src/Core/Exceptions/APITimeoutException.php b/src/Core/Exceptions/APITimeoutException.php index 5e9e4d3..999d529 100644 --- a/src/Core/Exceptions/APITimeoutException.php +++ b/src/Core/Exceptions/APITimeoutException.php @@ -10,7 +10,7 @@ class APITimeoutException extends APIConnectionException protected const DESC = 'CasParser API Timeout Exception'; public function __construct( - public RequestInterface $request, + RequestInterface $request, ?\Throwable $previous = null, string $message = 'Request timed out.', ) { diff --git a/src/Core/Implementation/RawResponse.php b/src/Core/Implementation/RawResponse.php new file mode 100644 index 0000000..e434c68 --- /dev/null +++ b/src/Core/Implementation/RawResponse.php @@ -0,0 +1,106 @@ + + * + * @phpstan-import-type normalized_request from \CasParser\Core\BaseClient + */ +class RawResponse implements BaseResponse +{ + use ResponseProxy; + + private mixed $decodedBody; + + /** @var R */ + private mixed $coercedResponse; + + private bool $decoded = false; + private bool $coerced = false; + + /** + * @param normalized_request $requestInfo + * @param list|string|int|null $unwrap + */ + public function __construct( + private BaseClient $client, + private RequestOptions $options, + private RequestInterface $request, + private ResponseInterface $response, + private array $requestInfo, + private array|string|int|null $unwrap, + private Converter|ConverterSource|string $convert, + private ?string $page, + private ?string $stream, + ) {} + + public function getRequest(): RequestInterface + { + return $this->request; + } + + public function parse(): mixed + { + if (!$this->coerced) { + if (!is_null($this->stream)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->stream( + convert: $this->convert, + request: $this->request, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } elseif (!is_null($this->page)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->page( + convert: $this->convert, + client: $this->client, + requestInfo: $this->requestInfo, + options: $this->options, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } else { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = Conversion::coerce( + $this->convert, + value: $this->getDecoded(), + ); + } + + $this->coerced = true; + } + + return $this->coercedResponse; + } + + private function getDecoded(): mixed + { + if (!$this->decoded) { + $decoded = Util::decodeContent($this->response); + if (!is_null($this->unwrap)) { + $decoded = Util::dig($decoded, key: $this->unwrap); + } + $this->decodedBody = $decoded; + $this->decoded = true; + } + + return $this->decodedBody; + } +} diff --git a/src/Core/Util.php b/src/Core/Util.php index 6cf0465..6a98bfa 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -33,6 +33,32 @@ public static function get_object_vars(object $object): array return get_object_vars($object); } + public static function machtype(): string + { + $arch = php_uname('m'); + + return match (true) { + str_contains($arch, 'aarch64'), str_contains($arch, 'arm64') => 'arm64', + str_contains($arch, 'x86_64'), str_contains($arch, 'amd64') => 'x64', + str_contains($arch, 'i386'), str_contains($arch, 'i686') => 'x32', + str_contains($arch, 'arm') => 'arm', + default => 'unknown', + }; + } + + public static function ostype(): string + { + return match ($os = strtolower(PHP_OS_FAMILY)) { + 'linux' => 'Linux', + 'darwin' => 'MacOS', + 'windows' => 'Windows', + 'solaris' => 'Solaris', + // @phpstan-ignore-next-line match.alwaysFalse + 'bsd', 'freebsd', 'openbsd' => 'BSD', + default => "Other:{$os}", + }; + } + /** * @template T * @@ -52,15 +78,52 @@ 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 { return array_filter($arr, fn ($v, $_) => OMIT !== $v, mode: ARRAY_FILTER_USE_BOTH); } + public static function strVal(mixed $value): string + { + if (is_bool($value)) { + return $value ? 'true' : 'false'; + } + + if (is_object($value) && is_a($value, class: \DateTimeInterface::class)) { + return date_format($value, format: \DateTimeInterface::RFC3339); + } + + // @phpstan-ignore-next-line argument.type + return strval($value); + } + + /** + * @param callable $callback + */ + public static function mapRecursive(mixed $callback, mixed $value): mixed + { + $mapped = match (true) { + is_array($value) => array_map(static fn ($v) => self::mapRecursive($callback, value: $v), $value), + default => $value, + }; + + return $callback($mapped); + } + + public static function removeNulls(mixed $value): mixed + { + $mapped = self::mapRecursive( + static fn ($vs) => is_array($vs) && !array_is_list($vs) ? array_filter($vs, callback: static fn ($v) => !is_null($v)) : $vs, + value: $value + ); + + return $mapped; + } + /** * @param string|int|list|callable $key */ @@ -101,8 +164,9 @@ public static function parsePath(string|array $path): string } [$template] = $path; + $mapped = array_map(static fn ($s) => rawurlencode(self::strVal($s)), array: array_slice($path, 1)); - return sprintf($template, ...array_map('rawurlencode', array: array_slice($path, 1))); + return sprintf($template, ...$mapped); } /** @@ -134,8 +198,14 @@ public static function joinUri( parse_str($base->getQuery(), $q1); parse_str($parsed['query'] ?? '', $q2); - $merged_query = array_merge_recursive($q1, $q2, $query); - $qs = http_build_query($merged_query, encoding_type: PHP_QUERY_RFC3986); + $mergedQuery = array_merge_recursive($q1, $q2, $query); + + /** @var array */ + $normalizedQuery = self::mapRecursive( + static fn ($v) => is_bool($v) || is_numeric($v) ? self::strVal($v) : $v, + value: $mergedQuery + ); + $qs = http_build_query($normalizedQuery, encoding_type: PHP_QUERY_RFC3986); return $base->withQuery($qs); } @@ -149,13 +219,12 @@ public static function withSetHeaders( ): RequestInterface { foreach ($headers as $name => $value) { if (is_null($value)) { + /** @var RequestInterface */ $req = $req->withoutHeader($name); } else { - $value = is_int($value) - ? (string) $value - : (is_array($value) - ? array_map(static fn ($v) => (string) $v, array: $value) - : $value); + $value = is_array($value) ? array_map(static fn ($v) => self::strVal($v), array: $value) : self::strVal($value); + + /** @var RequestInterface */ $req = $req->withHeader($name, $value); } } @@ -190,6 +259,7 @@ public static function withSetBody( mixed $body ): RequestInterface { if ($body instanceof StreamInterface) { + /** @var RequestInterface */ return $req->withBody($body); } @@ -199,6 +269,7 @@ public static function withSetBody( $encoded = json_encode($body, flags: self::JSON_ENCODE_FLAGS); $stream = $factory->createStream($encoded); + /** @var RequestInterface */ return $req->withBody($stream); } } @@ -208,12 +279,21 @@ public static function withSetBody( $encoded = implode('', iterator_to_array($gen)); $stream = $factory->createStream($encoded); + /** @var RequestInterface */ return $req->withHeader('Content-Type', "{$contentType}; boundary={$boundary}")->withBody($stream); } if (is_resource($body)) { $stream = $factory->createStreamFromResource($body); + /** @var RequestInterface */ + return $req->withBody($stream); + } + + if (is_string($body)) { + $stream = $factory->createStream($body); + + // @var RequestInterface return $req->withBody($stream); } @@ -370,7 +450,7 @@ private static function writeMultipartContent( } elseif (is_string($val) || is_numeric($val) || is_bool($val)) { yield sprintf($contentLine, $contentType ?? 'text/plain'); - yield (string) $val; + yield self::strVal($val); } else { yield sprintf($contentLine, $contentType ?? 'application/json'); @@ -396,7 +476,7 @@ private static function writeMultipartChunk( yield 'Content-Disposition: form-data'; if (!is_null($key)) { - $name = rawurlencode($key); + $name = rawurlencode(self::strVal($key)); yield "; name=\"{$name}\""; } diff --git a/src/RequestOptions.php b/src/RequestOptions.php index e8066fc..77d79bf 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -4,7 +4,8 @@ namespace CasParser; -use CasParser\Core\Attributes\Api as Property; +use CasParser\Core\Attributes\Optional; +use CasParser\Core\Attributes\Required as Property; use CasParser\Core\Concerns\SdkModel; use CasParser\Core\Contracts\BaseModel; use CasParser\Core\Implementation\Omit; @@ -49,26 +50,26 @@ final class RequestOptions implements BaseModel public float $maxRetryDelay = 8.0; /** @var array|null>|null $extraHeaders */ - #[Property(optional: true)] + #[Optional] public ?array $extraHeaders; /** @var array|null $extraQueryParams */ - #[Property(optional: true)] + #[Optional] public ?array $extraQueryParams; - #[Property(optional: true)] + #[Optional] public mixed $extraBodyParams; - #[Property(optional: true)] + #[Optional] public ?ClientInterface $transporter; - #[Property(optional: true)] + #[Optional] public ?UriFactoryInterface $uriFactory; - #[Property(optional: true)] + #[Optional] public ?StreamFactoryInterface $streamFactory; - #[Property(optional: true)] + #[Optional] public ?RequestFactoryInterface $requestFactory; public function __construct() @@ -83,7 +84,8 @@ public static function parse(RequestOptions|array|null ...$options): self { $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toProperties() : $o ?? [], array: $options); - return self::with(...array_merge(...$parsed)); // @phpstan-ignore-line + // @phpstan-ignore-next-line argument.type + return self::with(...array_merge(...$parsed)); } /** @@ -104,53 +106,55 @@ public static function with( ?StreamFactoryInterface $streamFactory = null, ?RequestFactoryInterface $requestFactory = null, ): self { - $obj = new self; - - null !== $timeout && $obj->timeout = $timeout; - null !== $maxRetries && $obj->maxRetries = $maxRetries; - null !== $initialRetryDelay && $obj->initialRetryDelay = $initialRetryDelay; - null !== $maxRetryDelay && $obj->maxRetryDelay = $maxRetryDelay; - null !== $extraHeaders && $obj->extraHeaders = $extraHeaders; - null !== $extraQueryParams && $obj->extraQueryParams = $extraQueryParams; - omit !== $extraBodyParams && $obj->extraBodyParams = $extraBodyParams; - null !== $transporter && $obj->transporter = $transporter; - null !== $uriFactory && $obj->uriFactory = $uriFactory; - null !== $streamFactory && $obj->streamFactory = $streamFactory; - null !== $requestFactory && $obj->requestFactory = $requestFactory; - - return $obj; + $self = new self; + + null !== $timeout && $self->timeout = $timeout; + null !== $maxRetries && $self->maxRetries = $maxRetries; + null !== $initialRetryDelay && $self + ->initialRetryDelay = $initialRetryDelay + ; + null !== $maxRetryDelay && $self->maxRetryDelay = $maxRetryDelay; + null !== $extraHeaders && $self->extraHeaders = $extraHeaders; + null !== $extraQueryParams && $self->extraQueryParams = $extraQueryParams; + omit !== $extraBodyParams && $self->extraBodyParams = $extraBodyParams; + null !== $transporter && $self->transporter = $transporter; + null !== $uriFactory && $self->uriFactory = $uriFactory; + null !== $streamFactory && $self->streamFactory = $streamFactory; + null !== $requestFactory && $self->requestFactory = $requestFactory; + + return $self; } public function withTimeout(float $timeout): self { - $obj = clone $this; - $obj->timeout = $timeout; + $self = clone $this; + $self->timeout = $timeout; - return $obj; + return $self; } public function withMaxRetries(int $maxRetries): self { - $obj = clone $this; - $obj->maxRetries = $maxRetries; + $self = clone $this; + $self->maxRetries = $maxRetries; - return $obj; + return $self; } public function withInitialRetryDelay(float $initialRetryDelay): self { - $obj = clone $this; - $obj->initialRetryDelay = $initialRetryDelay; + $self = clone $this; + $self->initialRetryDelay = $initialRetryDelay; - return $obj; + return $self; } public function withMaxRetryDelay(float $maxRetryDelay): self { - $obj = clone $this; - $obj->maxRetryDelay = $maxRetryDelay; + $self = clone $this; + $self->maxRetryDelay = $maxRetryDelay; - return $obj; + return $self; } /** @@ -158,10 +162,10 @@ public function withMaxRetryDelay(float $maxRetryDelay): self */ public function withExtraHeaders(array $extraHeaders): self { - $obj = clone $this; - $obj->extraHeaders = $extraHeaders; + $self = clone $this; + $self->extraHeaders = $extraHeaders; - return $obj; + return $self; } /** @@ -169,51 +173,51 @@ public function withExtraHeaders(array $extraHeaders): self */ public function withExtraQueryParams(array $extraQueryParams): self { - $obj = clone $this; - $obj->extraQueryParams = $extraQueryParams; + $self = clone $this; + $self->extraQueryParams = $extraQueryParams; - return $obj; + return $self; } public function withExtraBodyParams(mixed $extraBodyParams): self { - $obj = clone $this; - $obj->extraBodyParams = $extraBodyParams; + $self = clone $this; + $self->extraBodyParams = $extraBodyParams; - return $obj; + return $self; } public function withTransporter(ClientInterface $transporter): self { - $obj = clone $this; - $obj->transporter = $transporter; + $self = clone $this; + $self->transporter = $transporter; - return $obj; + return $self; } public function withUriFactory(UriFactoryInterface $uriFactory): self { - $obj = clone $this; - $obj->uriFactory = $uriFactory; + $self = clone $this; + $self->uriFactory = $uriFactory; - return $obj; + return $self; } public function withStreamFactory( StreamFactoryInterface $streamFactory ): self { - $obj = clone $this; - $obj->streamFactory = $streamFactory; + $self = clone $this; + $self->streamFactory = $streamFactory; - return $obj; + return $self; } public function withRequestFactory( RequestFactoryInterface $requestFactory ): self { - $obj = clone $this; - $obj->requestFactory = $requestFactory; + $self = clone $this; + $self->requestFactory = $requestFactory; - return $obj; + return $self; } } diff --git a/src/ServiceContracts/CasGeneratorContract.php b/src/ServiceContracts/CasGeneratorContract.php index f20cc7d..6202572 100644 --- a/src/ServiceContracts/CasGeneratorContract.php +++ b/src/ServiceContracts/CasGeneratorContract.php @@ -4,7 +4,7 @@ namespace CasParser\ServiceContracts; -use CasParser\CasGenerator\CasGeneratorGenerateCasParams; +use CasParser\CasGenerator\CasGeneratorGenerateCasParams\CasAuthority; use CasParser\CasGenerator\CasGeneratorGenerateCasResponse; use CasParser\Core\Exceptions\APIException; use CasParser\RequestOptions; @@ -14,12 +14,22 @@ interface CasGeneratorContract /** * @api * - * @param array|CasGeneratorGenerateCasParams $params + * @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 'kfintech'|'cams'|'cdsl'|'nsdl'|CasAuthority $casAuthority CAS authority to generate the document from (currently only kfintech is supported) + * @param string $panNo PAN number (optional for some CAS authorities) * * @throws APIException */ public function generateCas( - array|CasGeneratorGenerateCasParams $params, + string $email, + string $fromDate, + string $password, + string $toDate, + string|CasAuthority $casAuthority = 'kfintech', + ?string $panNo = null, ?RequestOptions $requestOptions = null, ): CasGeneratorGenerateCasResponse; } diff --git a/src/ServiceContracts/CasGeneratorRawContract.php b/src/ServiceContracts/CasGeneratorRawContract.php new file mode 100644 index 0000000..af9fcd2 --- /dev/null +++ b/src/ServiceContracts/CasGeneratorRawContract.php @@ -0,0 +1,28 @@ +|CasGeneratorGenerateCasParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function generateCas( + array|CasGeneratorGenerateCasParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/CasParserContract.php b/src/ServiceContracts/CasParserContract.php index 2c02ea7..5179c9c 100644 --- a/src/ServiceContracts/CasParserContract.php +++ b/src/ServiceContracts/CasParserContract.php @@ -4,10 +4,6 @@ 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\RequestOptions; @@ -17,48 +13,64 @@ interface CasParserContract /** * @api * - * @param array|CasParserCamsKfintechParams $params + * @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 * * @throws APIException */ public function camsKfintech( - array|CasParserCamsKfintechParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array|CasParserCdslParams $params + * @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 * * @throws APIException */ public function cdsl( - array|CasParserCdslParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array|CasParserNsdlParams $params + * @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 * * @throws APIException */ public function nsdl( - array|CasParserNsdlParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse; /** * @api * - * @param array|CasParserSmartParseParams $params + * @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 * * @throws APIException */ public function smartParse( - array|CasParserSmartParseParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse; } diff --git a/src/ServiceContracts/CasParserRawContract.php b/src/ServiceContracts/CasParserRawContract.php new file mode 100644 index 0000000..dfd941e --- /dev/null +++ b/src/ServiceContracts/CasParserRawContract.php @@ -0,0 +1,73 @@ +|CasParserCamsKfintechParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function camsKfintech( + array|CasParserCamsKfintechParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|CasParserCdslParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function cdsl( + array|CasParserCdslParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|CasParserNsdlParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function nsdl( + array|CasParserNsdlParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|CasParserSmartParseParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function smartParse( + array|CasParserSmartParseParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse; +} diff --git a/src/Services/CasGeneratorRawService.php b/src/Services/CasGeneratorRawService.php new file mode 100644 index 0000000..1e59fed --- /dev/null +++ b/src/Services/CasGeneratorRawService.php @@ -0,0 +1,61 @@ + + * + * @throws APIException + */ + public function generateCas( + array|CasGeneratorGenerateCasParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CasGeneratorGenerateCasParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/generate', + body: (object) $parsed, + options: $options, + convert: CasGeneratorGenerateCasResponse::class, + ); + } +} diff --git a/src/Services/CasGeneratorService.php b/src/Services/CasGeneratorService.php index 6392643..5d505eb 100644 --- a/src/Services/CasGeneratorService.php +++ b/src/Services/CasGeneratorService.php @@ -4,19 +4,28 @@ 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\Util; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasGeneratorContract; final class CasGeneratorService implements CasGeneratorContract { + /** + * @api + */ + public CasGeneratorRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new CasGeneratorRawService($client); + } /** * @api @@ -24,33 +33,38 @@ 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 array{ - * email: string, - * from_date: string, - * password: string, - * to_date: string, - * cas_authority?: "kfintech"|"cams"|"cdsl"|"nsdl", - * pan_no?: string, - * }|CasGeneratorGenerateCasParams $params + * @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 'kfintech'|'cams'|'cdsl'|'nsdl'|CasAuthority $casAuthority CAS authority to generate the document from (currently only kfintech is supported) + * @param string $panNo PAN number (optional for some CAS authorities) * * @throws APIException */ public function generateCas( - array|CasGeneratorGenerateCasParams $params, + string $email, + string $fromDate, + string $password, + string $toDate, + string|CasAuthority $casAuthority = 'kfintech', + ?string $panNo = null, ?RequestOptions $requestOptions = null, ): CasGeneratorGenerateCasResponse { - [$parsed, $options] = CasGeneratorGenerateCasParams::parseRequest( - $params, - $requestOptions, + $params = Util::removeNulls( + [ + 'email' => $email, + 'fromDate' => $fromDate, + 'password' => $password, + 'toDate' => $toDate, + 'casAuthority' => $casAuthority, + 'panNo' => $panNo, + ], ); - // @phpstan-ignore-next-line; - return $this->client->request( - method: 'post', - path: 'v4/generate', - body: (object) $parsed, - options: $options, - convert: CasGeneratorGenerateCasResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->generateCas(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Services/CasParserRawService.php b/src/Services/CasParserRawService.php new file mode 100644 index 0000000..7f05f33 --- /dev/null +++ b/src/Services/CasParserRawService.php @@ -0,0 +1,157 @@ + + * + * @throws APIException + */ + public function camsKfintech( + array|CasParserCamsKfintechParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CasParserCamsKfintechParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/cams_kfintech/parse', + body: (object) $parsed, + options: $options, + convert: UnifiedResponse::class, + ); + } + + /** + * @api + * + * 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 array{ + * password?: string, pdfFile?: string, pdfURL?: string + * }|CasParserCdslParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function cdsl( + array|CasParserCdslParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = CasParserCdslParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/cdsl/parse', + body: (object) $parsed, + options: $options, + convert: UnifiedResponse::class, + ); + } + + /** + * @api + * + * 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 array{ + * password?: string, pdfFile?: string, pdfURL?: string + * }|CasParserNsdlParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function nsdl( + array|CasParserNsdlParams $params, + ?RequestOptions $requestOptions = null + ): BaseResponse { + [$parsed, $options] = CasParserNsdlParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/nsdl/parse', + body: (object) $parsed, + options: $options, + convert: UnifiedResponse::class, + ); + } + + /** + * @api + * + * 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 array{ + * password?: string, pdfFile?: string, pdfURL?: string + * }|CasParserSmartParseParams $params + * + * @return BaseResponse + * + * @throws APIException + */ + public function smartParse( + array|CasParserSmartParseParams $params, + ?RequestOptions $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CasParserSmartParseParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/smart/parse', + body: (object) $parsed, + options: $options, + convert: UnifiedResponse::class, + ); + } +} diff --git a/src/Services/CasParserService.php b/src/Services/CasParserService.php index 9915576..13ce1f7 100644 --- a/src/Services/CasParserService.php +++ b/src/Services/CasParserService.php @@ -4,22 +4,27 @@ namespace CasParser\Services; -use CasParser\CasParser\CasParserCamsKfintechParams; -use CasParser\CasParser\CasParserCdslParams; -use CasParser\CasParser\CasParserNsdlParams; -use CasParser\CasParser\CasParserSmartParseParams; use CasParser\CasParser\UnifiedResponse; use CasParser\Client; use CasParser\Core\Exceptions\APIException; +use CasParser\Core\Util; use CasParser\RequestOptions; use CasParser\ServiceContracts\CasParserContract; final class CasParserService implements CasParserContract { + /** + * @api + */ + public CasParserRawService $raw; + /** * @internal */ - public function __construct(private Client $client) {} + public function __construct(private Client $client) + { + $this->raw = new CasParserRawService($client); + } /** * @api @@ -27,29 +32,26 @@ 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 array{ - * password?: string, pdf_file?: string, pdf_url?: string - * }|CasParserCamsKfintechParams $params + * @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 * * @throws APIException */ public function camsKfintech( - array|CasParserCamsKfintechParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse { - [$parsed, $options] = CasParserCamsKfintechParams::parseRequest( - $params, - $requestOptions, + $params = Util::removeNulls( + ['password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL] ); - // @phpstan-ignore-next-line; - return $this->client->request( - method: 'post', - path: 'v4/cams_kfintech/parse', - body: (object) $parsed, - options: $options, - convert: UnifiedResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->camsKfintech(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -58,29 +60,26 @@ public function camsKfintech( * 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 array{ - * password?: string, pdf_file?: string, pdf_url?: string - * }|CasParserCdslParams $params + * @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 * * @throws APIException */ public function cdsl( - array|CasParserCdslParams $params, - ?RequestOptions $requestOptions = null + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, + ?RequestOptions $requestOptions = null, ): UnifiedResponse { - [$parsed, $options] = CasParserCdslParams::parseRequest( - $params, - $requestOptions, + $params = Util::removeNulls( + ['password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL] ); - // @phpstan-ignore-next-line; - return $this->client->request( - method: 'post', - path: 'v4/cdsl/parse', - body: (object) $parsed, - options: $options, - convert: UnifiedResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->cdsl(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -89,29 +88,26 @@ public function cdsl( * 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 array{ - * password?: string, pdf_file?: string, pdf_url?: string - * }|CasParserNsdlParams $params + * @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 * * @throws APIException */ public function nsdl( - array|CasParserNsdlParams $params, - ?RequestOptions $requestOptions = null + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, + ?RequestOptions $requestOptions = null, ): UnifiedResponse { - [$parsed, $options] = CasParserNsdlParams::parseRequest( - $params, - $requestOptions, + $params = Util::removeNulls( + ['password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL] ); - // @phpstan-ignore-next-line; - return $this->client->request( - method: 'post', - path: 'v4/nsdl/parse', - body: (object) $parsed, - options: $options, - convert: UnifiedResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->nsdl(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } /** @@ -120,28 +116,25 @@ public function nsdl( * 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 array{ - * password?: string, pdf_file?: string, pdf_url?: string - * }|CasParserSmartParseParams $params + * @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 * * @throws APIException */ public function smartParse( - array|CasParserSmartParseParams $params, + ?string $password = null, + ?string $pdfFile = null, + ?string $pdfURL = null, ?RequestOptions $requestOptions = null, ): UnifiedResponse { - [$parsed, $options] = CasParserSmartParseParams::parseRequest( - $params, - $requestOptions, + $params = Util::removeNulls( + ['password' => $password, 'pdfFile' => $pdfFile, 'pdfURL' => $pdfURL] ); - // @phpstan-ignore-next-line; - return $this->client->request( - method: 'post', - path: 'v4/smart/parse', - body: (object) $parsed, - options: $options, - convert: UnifiedResponse::class, - ); + // @phpstan-ignore-next-line argument.type + $response = $this->raw->smartParse(params: $params, requestOptions: $requestOptions); + + return $response->parse(); } } diff --git a/src/Version.php b/src/Version.php new file mode 100644 index 0000000..995289a --- /dev/null +++ b/src/Version.php @@ -0,0 +1,9 @@ +> */ use SdkModel; - #[Api] + #[Required] public string $name; - #[Api('age_years')] + #[Required('age_years')] public int $ageYears; /** @var list|null */ - #[Api(optional: true)] + #[Optional] public ?array $friends; - #[Api] + #[Required] public ?string $owner; /** @@ -42,7 +43,7 @@ public function __construct( $this->ageYears = $ageYears; $this->owner = $owner; - null != $friends && $this->friends = $friends; + null !== $friends && $this['friends'] = $friends; } } @@ -52,16 +53,12 @@ public function __construct( * @coversNothing */ #[CoversNothing] -class TestModelTest extends TestCase +class ModelTest extends TestCase { #[Test] public function testBasicGetAndSet(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $this->assertEquals(12, $model->ageYears); ++$model->ageYears; @@ -71,11 +68,7 @@ public function testBasicGetAndSet(): void #[Test] public function testNullAccess(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $this->assertNull($model->owner); $this->assertNull($model->friends); } @@ -83,11 +76,7 @@ public function testNullAccess(): void #[Test] public function testArrayGetAndSet(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $model->friends ??= []; $this->assertEquals([], $model->friends); $model->friends[] = 'Alice'; @@ -97,16 +86,8 @@ public function testArrayGetAndSet(): void #[Test] public function testDiscernsBetweenNullAndUnset(): void { - $modelUnsetFriends = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); - $modelNullFriends = new TestModel( - name: 'bob', - ageYears: 12, - owner: null, - ); + $modelUnsetFriends = new Dog(name: 'Bob', ageYears: 12, owner: null); + $modelNullFriends = new Dog(name: 'bob', ageYears: 12, owner: null); $modelNullFriends->friends = null; $this->assertEquals(12, $modelUnsetFriends->ageYears); @@ -125,11 +106,7 @@ public function testDiscernsBetweenNullAndUnset(): void #[Test] public function testIssetOnOmittedProperties(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $this->assertFalse(isset($model->owner)); $this->assertFalse(isset($model->friends)); } @@ -137,12 +114,7 @@ public function testIssetOnOmittedProperties(): void #[Test] public function testSerializeBasicModel(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: 'Eve', - friends: ['Alice', 'Charlie'], - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: 'Eve', friends: ['Alice', 'Charlie']); $this->assertEquals( '{"name":"Bob","age_years":12,"friends":["Alice","Charlie"],"owner":"Eve"}', json_encode($model) @@ -152,11 +124,7 @@ public function testSerializeBasicModel(): void #[Test] public function testSerializeModelWithOmittedProperties(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $this->assertEquals( '{"name":"Bob","age_years":12,"owner":null}', json_encode($model) @@ -166,11 +134,7 @@ public function testSerializeModelWithOmittedProperties(): void #[Test] public function testSerializeModelWithExplicitNull(): void { - $model = new TestModel( - name: 'Bob', - ageYears: 12, - owner: null, - ); + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); $model->friends = null; $this->assertEquals( '{"name":"Bob","age_years":12,"friends":null,"owner":null}', diff --git a/tests/Core/UtilTest.php b/tests/Core/UtilTest.php new file mode 100644 index 0000000..2134876 --- /dev/null +++ b/tests/Core/UtilTest.php @@ -0,0 +1,90 @@ + $v, + ], + [ + ['a' => null, 'b' => [null, null], 'c' => ['d' => null, 'e' => 0], 'f' => ['g' => null]], + ['b' => [null, null], 'c' => ['e' => 0], 'f' => []], + static fn ($vs) => is_array($vs) && !array_is_list($vs) ? array_filter($vs, callback: static fn ($v) => !is_null($v)) : $vs, + ], + [ + ['a' => null, 'b' => 2, 'c' => true, 'd' => [1, 2]], + ['a' => null, 'b' => '2', 'c' => true, 'd' => ['1', '2']], + static fn ($v) => is_bool($v) || is_numeric($v) ? Util::strVal($v) : $v, + ], + ]; + + foreach ($cases as [$input, $expected, $xform]) { + $actual = Util::mapRecursive($xform, value: $input); + $this->assertEquals($expected, $actual); + } + } + + #[Test] + public function testJoinUri(): void + { + $factory = Psr17FactoryDiscovery::findUriFactory(); + $base = $factory->createUri('http://localhost'); + $cases = [ + [ + '', + [], + 'http://localhost', + ], + [ + 'dog', + [], + 'http://localhost/dog', + ], + [ + '', + ['dog' => 'dog'], + 'http://localhost?dog=dog', + ], + [ + '', + ['dog' => ['dog']], + 'http://localhost?dog[0]=dog', + ], + [ + '', + ['dog' => [true, false]], + 'http://localhost?dog[0]=true&dog[1]=false', + ], + [ + '', + ['dog' => ['dog' => ['dog']]], + 'http://localhost?dog[dog][0]=dog', + ], + ]; + + foreach ($cases as [$path, $query, $output]) { + $expected = $factory->createUri($output); + $actual = Util::joinUri($base, path: $path, query: $query); + $this->assertEquals($expected, $actual); + } + } +} diff --git a/tests/Services/CasGeneratorTest.php b/tests/Services/CasGeneratorTest.php index 58aa931..9b82933 100644 --- a/tests/Services/CasGeneratorTest.php +++ b/tests/Services/CasGeneratorTest.php @@ -2,6 +2,7 @@ namespace Tests\Services; +use CasParser\CasGenerator\CasGeneratorGenerateCasResponse; use CasParser\Client; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; @@ -33,14 +34,15 @@ public function testGenerateCas(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casGenerator->generateCas([ - 'email' => 'user@example.com', - 'from_date' => '2023-01-01', - 'password' => 'Abcdefghi12$', - 'to_date' => '2023-12-31', - ]); + $result = $this->client->casGenerator->generateCas( + email: 'user@example.com', + fromDate: '2023-01-01', + password: 'Abcdefghi12$', + toDate: '2023-12-31', + ); - $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CasGeneratorGenerateCasResponse::class, $result); } #[Test] @@ -50,13 +52,16 @@ public function testGenerateCasWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->casGenerator->generateCas([ - 'email' => 'user@example.com', - 'from_date' => '2023-01-01', - 'password' => 'Abcdefghi12$', - 'to_date' => '2023-12-31', - ]); + $result = $this->client->casGenerator->generateCas( + email: 'user@example.com', + fromDate: '2023-01-01', + password: 'Abcdefghi12$', + toDate: '2023-12-31', + casAuthority: 'kfintech', + panNo: 'ABCDE1234F', + ); - $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CasGeneratorGenerateCasResponse::class, $result); } } diff --git a/tests/Services/CasParserTest.php b/tests/Services/CasParserTest.php index 7b66bf4..b16e886 100644 --- a/tests/Services/CasParserTest.php +++ b/tests/Services/CasParserTest.php @@ -2,6 +2,7 @@ namespace Tests\Services; +use CasParser\CasParser\UnifiedResponse; use CasParser\Client; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; @@ -33,9 +34,10 @@ 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 + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UnifiedResponse::class, $result); } #[Test] @@ -45,9 +47,10 @@ 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 + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UnifiedResponse::class, $result); } #[Test] @@ -57,9 +60,10 @@ 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 + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UnifiedResponse::class, $result); } #[Test] @@ -69,8 +73,9 @@ 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 + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UnifiedResponse::class, $result); } } From b15afa4b7123d33f1c8748dba9ebdae05c339005 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 Jan 2026 23:18:21 +0000 Subject: [PATCH 15/15] release: 0.3.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ src/Version.php | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) 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/CHANGELOG.md b/CHANGELOG.md index 57b6fa7..097e303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ # Changelog +## 0.3.0 (2026-01-01) + +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 ([90a131a](https://github.com/CASParser/cas-parser-php/commit/90a131ad218e94a908056b01fb8425ab8783bbd4)) +* **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/src/Version.php b/src/Version.php index 995289a..e05c34e 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace CasParser; // x-release-please-start-version -const VERSION = '0.0.1'; +const VERSION = '0.3.0'; // x-release-please-end