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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ jobs:
- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PACKAGIST_USERNAME: ${{ secrets.CAS_PARSER_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }}
PACKAGIST_SAFE_KEY: ${{ secrets.CAS_PARSER_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0"
".": "0.3.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml
openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-38618cc5c938e87eeacf4893d6a6ba4e6ef7da390e6283dc7b50b484a7b97165.yml
openapi_spec_hash: b9e439ecee904ded01aa34efdee88856
config_hash: cb5d75abef6264b5d86448caf7295afa
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand All @@ -75,7 +77,7 @@ try {
} 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;
Expand Down Expand Up @@ -117,9 +119,10 @@ use CasParser\RequestOptions;
$client = new Client(maxRetries: 0);

// Or, configure per-request:

$result = $client->casParser->smartParse(
requestOptions: RequestOptions::with(maxRetries: 5)
password: 'ABCDF',
pdfURL: 'https://you-cas-pdf-url-here.com',
requestOptions: RequestOptions::with(maxRetries: 5),
);
```

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

$unifiedResponse = $client->casParser->smartParse(
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"],
extraQueryParams: ['my_query_parameter' => 'value'],
extraBodyParams: ['my_body_parameter' => 'value'],
extraHeaders: ['my-header' => 'value'],
),
);

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

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

echo "==> Running PHPStan"
exec -- ./vendor/bin/phpstan analyse --memory-limit=1G
exec -- ./vendor/bin/phpstan analyse --memory-limit=12G
90 changes: 40 additions & 50 deletions src/CasGenerator/CasGeneratorGenerateCasParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,69 @@
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;

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

/**
* Email address to receive the CAS document.
*/
#[Api]
#[Required]
public string $email;

/**
* Start date for the CAS period (format YYYY-MM-DD).
*/
#[Api('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('to_date')]
#[Required('to_date')]
public string $toDate;

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

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

/**
Expand Down Expand Up @@ -110,7 +100,7 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param CasAuthority|value-of<CasAuthority> $casAuthority
* @param CasAuthority|value-of<CasAuthority>|null $casAuthority
*/
public static function with(
string $email,
Expand All @@ -120,61 +110,61 @@ public static function with(
CasAuthority|string|null $casAuthority = null,
?string $panNo = null,
): self {
$obj = new self;
$self = new self;

$obj->email = $email;
$obj->fromDate = $fromDate;
$obj->password = $password;
$obj->toDate = $toDate;
$self['email'] = $email;
$self['fromDate'] = $fromDate;
$self['password'] = $password;
$self['toDate'] = $toDate;

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

return $obj;
return $self;
}

/**
* Email address to receive the CAS document.
*/
public function withEmail(string $email): self
{
$obj = clone $this;
$obj->email = $email;
$self = clone $this;
$self['email'] = $email;

return $obj;
return $self;
}

/**
* Start date for the CAS period (format YYYY-MM-DD).
*/
public function withFromDate(string $fromDate): self
{
$obj = clone $this;
$obj->fromDate = $fromDate;
$self = clone $this;
$self['fromDate'] = $fromDate;

return $obj;
return $self;
}

/**
* Password to protect the generated CAS PDF.
*/
public function withPassword(string $password): self
{
$obj = clone $this;
$obj->password = $password;
$self = clone $this;
$self['password'] = $password;

return $obj;
return $self;
}

/**
* End date for the CAS period (format YYYY-MM-DD).
*/
public function withToDate(string $toDate): self
{
$obj = clone $this;
$obj->toDate = $toDate;
$self = clone $this;
$self['toDate'] = $toDate;

return $obj;
return $self;
}

/**
Expand All @@ -184,20 +174,20 @@ public function withToDate(string $toDate): self
*/
public function withCasAuthority(CasAuthority|string $casAuthority): self
{
$obj = clone $this;
$obj->casAuthority = $casAuthority instanceof CasAuthority ? $casAuthority->value : $casAuthority;
$self = clone $this;
$self['casAuthority'] = $casAuthority;

return $obj;
return $self;
}

/**
* PAN number (optional for some CAS authorities).
*/
public function withPanNo(string $panNo): self
{
$obj = clone $this;
$obj->panNo = $panNo;
$self = clone $this;
$self['panNo'] = $panNo;

return $obj;
return $self;
}
}
Loading