Skip to content

Commit 83a811c

Browse files
feat(api): manual updates
1 parent d8c85b9 commit 83a811c

55 files changed

Lines changed: 3887 additions & 20 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 12
1+
configured_endpoints: 21
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml
33
openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0
4-
config_hash: 41c337f5cda03b13880617490f82bad0
4+
config_hash: d54f39abb185904495bef7c5f8702746

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ $client = new Client(
4545
environment: 'environment_1',
4646
);
4747

48-
$unifiedResponse = $client->camsKfintech->parse();
48+
$response = $client->credits->check();
4949

50-
var_dump($unifiedResponse->demat_accounts);
50+
var_dump($response->enabled_features);
5151
```
5252

5353
### Value Objects
@@ -69,7 +69,7 @@ use CasParser\Core\Exceptions\RateLimitException;
6969
use CasParser\Core\Exceptions\APIStatusException;
7070

7171
try {
72-
$unifiedResponse = $client->camsKfintech->parse();
72+
$response = $client->credits->check();
7373
} catch (APIConnectionException $e) {
7474
echo "The server could not be reached", PHP_EOL;
7575
var_dump($e->getPrevious());
@@ -114,7 +114,7 @@ use CasParser\Client;
114114
$client = new Client(requestOptions: ['maxRetries' => 0]);
115115

116116
// Or, configure per-request:
117-
$result = $client->camsKfintech->parse(requestOptions: ['maxRetries' => 5]);
117+
$result = $client->credits->check(requestOptions: ['maxRetries' => 5]);
118118
```
119119

120120
## Advanced concepts
@@ -130,7 +130,7 @@ Note: the `extra*` parameters of the same name overrides the documented paramete
130130
```php
131131
<?php
132132

133-
$unifiedResponse = $client->camsKfintech->parse(
133+
$response = $client->credits->check(
134134
requestOptions: [
135135
'extraQueryParams' => ['my_query_parameter' => 'value'],
136136
'extraBodyParams' => ['my_body_parameter' => 'value'],
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CasParser\AccessToken;
6+
7+
use CasParser\Core\Attributes\Optional;
8+
use CasParser\Core\Concerns\SdkModel;
9+
use CasParser\Core\Concerns\SdkParams;
10+
use CasParser\Core\Contracts\BaseModel;
11+
12+
/**
13+
* Generate a short-lived access token from your API key.
14+
*
15+
* **Use this endpoint from your backend** to create tokens that can be safely passed to frontend/SDK.
16+
*
17+
* **Legacy path:** `/v1/access-token` (still supported)
18+
*
19+
* Access tokens:
20+
* - Are prefixed with `at_` for easy identification
21+
* - Valid for up to 60 minutes
22+
* - Can be used in place of API keys on all v4 endpoints
23+
* - Cannot be used to generate other access tokens
24+
*
25+
* @see CasParser\Services\AccessTokenService::create()
26+
*
27+
* @phpstan-type AccessTokenCreateParamsShape = array{expiryMinutes?: int|null}
28+
*/
29+
final class AccessTokenCreateParams implements BaseModel
30+
{
31+
/** @use SdkModel<AccessTokenCreateParamsShape> */
32+
use SdkModel;
33+
use SdkParams;
34+
35+
/**
36+
* Token validity in minutes (max 60).
37+
*/
38+
#[Optional('expiry_minutes')]
39+
public ?int $expiryMinutes;
40+
41+
public function __construct()
42+
{
43+
$this->initialize();
44+
}
45+
46+
/**
47+
* Construct an instance from the required parameters.
48+
*
49+
* You must use named parameters to construct any parameters with a default value.
50+
*/
51+
public static function with(?int $expiryMinutes = null): self
52+
{
53+
$self = new self;
54+
55+
null !== $expiryMinutes && $self['expiryMinutes'] = $expiryMinutes;
56+
57+
return $self;
58+
}
59+
60+
/**
61+
* Token validity in minutes (max 60).
62+
*/
63+
public function withExpiryMinutes(int $expiryMinutes): self
64+
{
65+
$self = clone $this;
66+
$self['expiryMinutes'] = $expiryMinutes;
67+
68+
return $self;
69+
}
70+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CasParser\AccessToken;
6+
7+
use CasParser\Core\Attributes\Optional;
8+
use CasParser\Core\Concerns\SdkModel;
9+
use CasParser\Core\Contracts\BaseModel;
10+
11+
/**
12+
* @phpstan-type AccessTokenNewResponseShape = array{
13+
* accessToken?: string|null, expiresIn?: int|null, tokenType?: string|null
14+
* }
15+
*/
16+
final class AccessTokenNewResponse implements BaseModel
17+
{
18+
/** @use SdkModel<AccessTokenNewResponseShape> */
19+
use SdkModel;
20+
21+
/**
22+
* The at_ prefixed access token.
23+
*/
24+
#[Optional('access_token')]
25+
public ?string $accessToken;
26+
27+
/**
28+
* Token validity in seconds.
29+
*/
30+
#[Optional('expires_in')]
31+
public ?int $expiresIn;
32+
33+
/**
34+
* Always "api_key" - token is a drop-in replacement for x-api-key header.
35+
*/
36+
#[Optional('token_type')]
37+
public ?string $tokenType;
38+
39+
public function __construct()
40+
{
41+
$this->initialize();
42+
}
43+
44+
/**
45+
* Construct an instance from the required parameters.
46+
*
47+
* You must use named parameters to construct any parameters with a default value.
48+
*/
49+
public static function with(
50+
?string $accessToken = null,
51+
?int $expiresIn = null,
52+
?string $tokenType = null
53+
): self {
54+
$self = new self;
55+
56+
null !== $accessToken && $self['accessToken'] = $accessToken;
57+
null !== $expiresIn && $self['expiresIn'] = $expiresIn;
58+
null !== $tokenType && $self['tokenType'] = $tokenType;
59+
60+
return $self;
61+
}
62+
63+
/**
64+
* The at_ prefixed access token.
65+
*/
66+
public function withAccessToken(string $accessToken): self
67+
{
68+
$self = clone $this;
69+
$self['accessToken'] = $accessToken;
70+
71+
return $self;
72+
}
73+
74+
/**
75+
* Token validity in seconds.
76+
*/
77+
public function withExpiresIn(int $expiresIn): self
78+
{
79+
$self = clone $this;
80+
$self['expiresIn'] = $expiresIn;
81+
82+
return $self;
83+
}
84+
85+
/**
86+
* Always "api_key" - token is a drop-in replacement for x-api-key header.
87+
*/
88+
public function withTokenType(string $tokenType): self
89+
{
90+
$self = clone $this;
91+
$self['tokenType'] = $tokenType;
92+
93+
return $self;
94+
}
95+
}

src/Client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use CasParser\Services\CdslService;
1212
use CasParser\Services\ContractNoteService;
1313
use CasParser\Services\CreditsService;
14+
use CasParser\Services\InboundEmailService;
1415
use CasParser\Services\InboxService;
1516
use CasParser\Services\KfintechService;
1617
use CasParser\Services\LogsService;
@@ -83,6 +84,11 @@ class Client extends BaseClient
8384
*/
8485
public SmartService $smart;
8586

87+
/**
88+
* @api
89+
*/
90+
public InboundEmailService $inboundEmail;
91+
8692
/**
8793
* @param RequestOpts|null $requestOptions
8894
*/
@@ -134,6 +140,7 @@ public function __construct(
134140
$this->kfintech = new KfintechService($this);
135141
$this->nsdl = new NsdlService($this);
136142
$this->smart = new SmartService($this);
143+
$this->inboundEmail = new InboundEmailService($this);
137144
}
138145

139146
/** @return array<string,string> */

0 commit comments

Comments
 (0)