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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.10.0"
".": "0.11.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: 20
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser/cas-parser-cd8e042a9746bbe9bd180614fccc7597b85f4e8f6a29da6cd2f4cbf831fb2fbe.yml
openapi_spec_hash: e27c0d9cd8cdeb348c88e6c4e8777e39
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser/cas-parser-4d179917b01ea51a3325e7b37ecbbb60d0ba8f60381fe715ff3ec31284ca8042.yml
openapi_spec_hash: d027d37bd7051aa8c05fe1820c05b316
config_hash: 5509bb7a961ae2e79114b24c381606d4
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.11.0 (2026-08-14)

Full Changelog: [v0.10.0...v0.11.0](https://github.com/CASParser/cas-parser-php/compare/v0.10.0...v0.11.0)

### Features

* **api:** api update ([aaebadc](https://github.com/CASParser/cas-parser-php/commit/aaebadcb40240cbbe19d3c2cebb65dbd9d9f3e39))
* **api:** api update ([2b43dbc](https://github.com/CASParser/cas-parser-php/commit/2b43dbcf6cfb7b88b74a1ae6315e41919a952457))


### Chores

* **internal:** codegen related update ([2ab577d](https://github.com/CASParser/cas-parser-php/commit/2ab577dcc8902ab6a68c5066b1ffbc2c7660f6fc))

## 0.10.0 (2026-08-02)

Full Changelog: [v0.9.0...v0.10.0](https://github.com/CASParser/cas-parser-php/compare/v0.9.0...v0.10.0)
Expand Down
9 changes: 8 additions & 1 deletion src/Core/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use CasParser\Core\Exceptions\APIConnectionException;
use CasParser\Core\Exceptions\APIStatusException;
use CasParser\Core\Implementation\RawResponse;
use CasParser\Core\Implementation\StreamingHttpClient;
use CasParser\RequestOptions;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
Expand Down Expand Up @@ -249,7 +250,13 @@ protected function sendRequest(
$err = null;

try {
$rsp = $transporter->sendRequest($req);
if ($transporter instanceof StreamingHttpClient) {
$rsp = $transporter->sendRequest($req, timeout: $opts->timeout);
} elseif (is_a($transporter, '\GuzzleHttp\Client')) {
$rsp = $transporter->send($req, ['timeout' => $opts->timeout]);
} else {
$rsp = $transporter->sendRequest($req);
}
} catch (ClientExceptionInterface $e) {
$err = $e;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Core/Implementation/StreamingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ final class StreamingHttpClient implements ClientInterface
{
public function __construct(private ClientInterface $inner) {}

public function sendRequest(RequestInterface $request): ResponseInterface
public function sendRequest(RequestInterface $request, ?float $timeout = null): ResponseInterface
{
if (is_a($this->inner, '\GuzzleHttp\Client')) {
return $this->inner->send($request, ['stream' => true]);
$options = ['stream' => true];
if (null !== $timeout) {
$options['timeout'] = $timeout;
}

return $this->inner->send($request, $options);
}

return $this->inner->sendRequest($request);
Expand Down
66 changes: 63 additions & 3 deletions src/Inbox/InboxConnectEmailParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use CasParser\Core\Concerns\SdkModel;
use CasParser\Core\Concerns\SdkParams;
use CasParser\Core\Contracts\BaseModel;
use CasParser\Inbox\InboxConnectEmailParams\Provider;

/**
* Initiate OAuth flow to connect user's email inbox.
Expand All @@ -26,11 +27,17 @@
* - `state` - Your original state parameter
*
* **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls.
* The token is long-lived (it stores an encrypted refresh token), so a single OAuth
* connect gives ongoing access to both historical and future CAS statements in the
* user's inbox. Reuse the same token until the user revokes access via
* `/v4/inbox/disconnect` or their provider's account settings.
*
* @see CasParser\Services\InboxService::connectEmail()
*
* @phpstan-type InboxConnectEmailParamsShape = array{
* redirectUri: string, state?: string|null
* redirectUri: string,
* provider?: null|Provider|value-of<Provider>,
* state?: string|null,
* }
*/
final class InboxConnectEmailParams implements BaseModel
Expand All @@ -45,6 +52,27 @@ final class InboxConnectEmailParams implements BaseModel
#[Required('redirect_uri')]
public string $redirectUri;

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts: `@gmail.com` and Google
* Workspace domains.
* - `outlook` - personal Microsoft accounts: `@outlook.com`,
* `@hotmail.com`, `@live.com`, `@msn.com` and localised
* variants (`@hotmail.co.uk`, `@live.in`, `@hotmail.fr`).
* Any other address registered as a personal Microsoft
* account also works, including custom domains.
* - `zoho` - Zoho Mail accounts, including custom domains
* hosted on Zoho.
*
* Any unrecognised value is treated as `gmail`. The resolved
* provider is returned in the response.
*
* @var value-of<Provider>|null $provider
*/
#[Optional(enum: Provider::class)]
public ?string $provider;

/**
* State parameter for CSRF protection (returned in redirect).
*/
Expand Down Expand Up @@ -74,13 +102,19 @@ public function __construct()
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Provider|value-of<Provider>|null $provider
*/
public static function with(string $redirectUri, ?string $state = null): self
{
public static function with(
string $redirectUri,
Provider|string|null $provider = null,
?string $state = null
): self {
$self = new self;

$self['redirectUri'] = $redirectUri;

null !== $provider && $self['provider'] = $provider;
null !== $state && $self['state'] = $state;

return $self;
Expand All @@ -97,6 +131,32 @@ public function withRedirectUri(string $redirectUri): self
return $self;
}

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts: `@gmail.com` and Google
* Workspace domains.
* - `outlook` - personal Microsoft accounts: `@outlook.com`,
* `@hotmail.com`, `@live.com`, `@msn.com` and localised
* variants (`@hotmail.co.uk`, `@live.in`, `@hotmail.fr`).
* Any other address registered as a personal Microsoft
* account also works, including custom domains.
* - `zoho` - Zoho Mail accounts, including custom domains
* hosted on Zoho.
*
* Any unrecognised value is treated as `gmail`. The resolved
* provider is returned in the response.
*
* @param Provider|value-of<Provider> $provider
*/
public function withProvider(Provider|string $provider): self
{
$self = clone $this;
$self['provider'] = $provider;

return $self;
}

/**
* State parameter for CSRF protection (returned in redirect).
*/
Expand Down
30 changes: 30 additions & 0 deletions src/Inbox/InboxConnectEmailParams/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace CasParser\Inbox\InboxConnectEmailParams;

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts: `@gmail.com` and Google
* Workspace domains.
* - `outlook` - personal Microsoft accounts: `@outlook.com`,
* `@hotmail.com`, `@live.com`, `@msn.com` and localised
* variants (`@hotmail.co.uk`, `@live.in`, `@hotmail.fr`).
* Any other address registered as a personal Microsoft
* account also works, including custom domains.
* - `zoho` - Zoho Mail accounts, including custom domains
* hosted on Zoho.
*
* Any unrecognised value is treated as `gmail`. The resolved
* provider is returned in the response.
*/
enum Provider: string
{
case GMAIL = 'gmail';

case OUTLOOK = 'outlook';

case ZOHO = 'zoho';
}
33 changes: 31 additions & 2 deletions src/Inbox/InboxConnectEmailResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
use CasParser\Core\Attributes\Optional;
use CasParser\Core\Concerns\SdkModel;
use CasParser\Core\Contracts\BaseModel;
use CasParser\Inbox\InboxConnectEmailResponse\Provider;

/**
* @phpstan-type InboxConnectEmailResponseShape = array{
* expiresIn?: int|null, oauthURL?: string|null, status?: string|null
* expiresIn?: int|null,
* oauthURL?: string|null,
* provider?: null|Provider|value-of<Provider>,
* status?: string|null,
* }
*/
final class InboxConnectEmailResponse implements BaseModel
Expand All @@ -30,6 +34,14 @@ final class InboxConnectEmailResponse implements BaseModel
#[Optional('oauth_url')]
public ?string $oauthURL;

/**
* The provider this OAuth URL was generated for.
*
* @var value-of<Provider>|null $provider
*/
#[Optional(enum: Provider::class)]
public ?string $provider;

#[Optional]
public ?string $status;

Expand All @@ -42,16 +54,20 @@ public function __construct()
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Provider|value-of<Provider>|null $provider
*/
public static function with(
?int $expiresIn = null,
?string $oauthURL = null,
?string $status = null
Provider|string|null $provider = null,
?string $status = null,
): self {
$self = new self;

null !== $expiresIn && $self['expiresIn'] = $expiresIn;
null !== $oauthURL && $self['oauthURL'] = $oauthURL;
null !== $provider && $self['provider'] = $provider;
null !== $status && $self['status'] = $status;

return $self;
Expand Down Expand Up @@ -79,6 +95,19 @@ public function withOAuthURL(string $oauthURL): self
return $self;
}

/**
* The provider this OAuth URL was generated for.
*
* @param Provider|value-of<Provider> $provider
*/
public function withProvider(Provider|string $provider): self
{
$self = clone $this;
$self['provider'] = $provider;

return $self;
}

public function withStatus(string $status): self
{
$self = clone $this;
Expand Down
17 changes: 17 additions & 0 deletions src/Inbox/InboxConnectEmailResponse/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace CasParser\Inbox\InboxConnectEmailResponse;

/**
* The provider this OAuth URL was generated for.
*/
enum Provider: string
{
case GMAIL = 'gmail';

case OUTLOOK = 'outlook';

case ZOHO = 'zoho';
}
4 changes: 2 additions & 2 deletions src/Inbox/InboxListCasFilesResponse/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class File implements BaseModel

/**
* URL expiration time in seconds. Defaults vary by source:
* - Gmail Inbox Import: 86400 (24h)
* - Email Inbox Import (Gmail, Outlook, Zoho): 86400 (24h)
* - Inbound Email with `callback_url` set: 172800 (48h)
* - Inbound Email without `callback_url`: aligned with the session TTL (~30 min)
*/
Expand Down Expand Up @@ -141,7 +141,7 @@ public function withCasType(CasType|string $casType): self

/**
* URL expiration time in seconds. Defaults vary by source:
* - Gmail Inbox Import: 86400 (24h)
* - Email Inbox Import (Gmail, Outlook, Zoho): 86400 (24h)
* - Inbound Email with `callback_url` set: 172800 (48h)
* - Inbound Email without `callback_url`: aligned with the session TTL (~30 min)
*/
Expand Down
16 changes: 16 additions & 0 deletions src/ServiceContracts/InboxContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CasParser\Core\Exceptions\APIException;
use CasParser\Inbox\InboxCheckConnectionStatusResponse;
use CasParser\Inbox\InboxConnectEmailParams\Provider;
use CasParser\Inbox\InboxConnectEmailResponse;
use CasParser\Inbox\InboxDisconnectEmailResponse;
use CasParser\Inbox\InboxListCasFilesParams\CasType;
Expand Down Expand Up @@ -34,13 +35,28 @@ public function checkConnectionStatus(
* @api
*
* @param string $redirectUri Your callback URL to receive the inbox_token (must be http or https)
* @param Provider|value-of<Provider> $provider Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts: `@gmail.com` and Google
* Workspace domains.
* - `outlook` - personal Microsoft accounts: `@outlook.com`,
* `@hotmail.com`, `@live.com`, `@msn.com` and localised
* variants (`@hotmail.co.uk`, `@live.in`, `@hotmail.fr`).
* Any other address registered as a personal Microsoft
* account also works, including custom domains.
* - `zoho` - Zoho Mail accounts, including custom domains
* hosted on Zoho.
*
* Any unrecognised value is treated as `gmail`. The resolved
* provider is returned in the response.
* @param string $state State parameter for CSRF protection (returned in redirect)
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function connectEmail(
string $redirectUri,
Provider|string $provider = 'gmail',
?string $state = null,
RequestOptions|array|null $requestOptions = null,
): InboxConnectEmailResponse;
Expand Down
16 changes: 14 additions & 2 deletions src/Services/InboxRawService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use CasParser\Inbox\InboxCheckConnectionStatusParams;
use CasParser\Inbox\InboxCheckConnectionStatusResponse;
use CasParser\Inbox\InboxConnectEmailParams;
use CasParser\Inbox\InboxConnectEmailParams\Provider;
use CasParser\Inbox\InboxConnectEmailResponse;
use CasParser\Inbox\InboxDisconnectEmailParams;
use CasParser\Inbox\InboxDisconnectEmailResponse;
Expand All @@ -23,7 +24,14 @@
/**
* Endpoints for importing CAS files directly from user email inboxes.
*
* **Supported Providers:** Gmail (more coming soon)
* **Supported Providers:**
*
* - **Gmail** (`gmail`, default) — `@gmail.com` and Google Workspace domains
* - **Microsoft** (`outlook`) — personal Microsoft accounts: `@outlook.com`,
* `@hotmail.com`, `@live.com`, `@msn.com`, and localised variants such as
* `@hotmail.co.uk`, `@live.in`, `@hotmail.fr`. Any other address registered
* as a personal Microsoft account also works, including custom domains.
* - **Zoho Mail** (`zoho`) — Zoho-hosted mailboxes, including custom domains
*
* **How it works:**
* 1. Call `POST /v4/inbox/connect` to get an OAuth URL
Expand Down Expand Up @@ -102,9 +110,13 @@ public function checkConnectionStatus(
* - `state` - Your original state parameter
*
* **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls.
* The token is long-lived (it stores an encrypted refresh token), so a single OAuth
* connect gives ongoing access to both historical and future CAS statements in the
* user's inbox. Reuse the same token until the user revokes access via
* `/v4/inbox/disconnect` or their provider's account settings.
*
* @param array{
* redirectUri: string, state?: string
* redirectUri: string, provider?: Provider|value-of<Provider>, state?: string
* }|InboxConnectEmailParams $params
* @param RequestOpts|null $requestOptions
*
Expand Down
Loading