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
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-5c6cdb8b7a2c0ba449927687bc378823ac947b26b7c2e6c379ae14668b73979a.yml
openapi_spec_hash: 6bc024b866f01da53e2cfd6e404157c7
config_hash: 5509bb7a961ae2e79114b24c381606d4
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.11.0 (2026-08-08)

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 ([2b43dbc](https://github.com/CASParser/cas-parser-php/commit/2b43dbcf6cfb7b88b74a1ae6315e41919a952457))

## 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
48 changes: 45 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 @@ -30,7 +31,9 @@
* @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 +48,20 @@ final class InboxConnectEmailParams implements BaseModel
#[Required('redirect_uri')]
public string $redirectUri;

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts
* - `outlook` - Microsoft accounts
*
* Any value other than `outlook` 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 +91,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 +120,25 @@ public function withRedirectUri(string $redirectUri): self
return $self;
}

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts
* - `outlook` - Microsoft accounts
*
* Any value other than `outlook` 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
21 changes: 21 additions & 0 deletions src/Inbox/InboxConnectEmailParams/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace CasParser\Inbox\InboxConnectEmailParams;

/**
* Mail provider to connect. Defaults to `gmail`.
*
* - `gmail` - Google accounts
* - `outlook` - Microsoft accounts
*
* Any value other than `outlook` is treated as `gmail`. The
* resolved provider is returned in the response.
*/
enum Provider: string
{
case GMAIL = 'gmail';

case OUTLOOK = 'outlook';
}
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
15 changes: 15 additions & 0 deletions src/Inbox/InboxConnectEmailResponse/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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';
}
9 changes: 9 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,21 @@ 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
* - `outlook` - Microsoft accounts
*
* Any value other than `outlook` 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
3 changes: 2 additions & 1 deletion 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 Down Expand Up @@ -104,7 +105,7 @@ public function checkConnectionStatus(
* **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls.
*
* @param array{
* redirectUri: string, state?: string
* redirectUri: string, provider?: Provider|value-of<Provider>, state?: string
* }|InboxConnectEmailParams $params
* @param RequestOpts|null $requestOptions
*
Expand Down
15 changes: 14 additions & 1 deletion src/Services/InboxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use CasParser\Core\Exceptions\APIException;
use CasParser\Core\Util;
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 @@ -94,18 +95,30 @@ public function checkConnectionStatus(
* **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls.
*
* @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
* - `outlook` - Microsoft accounts
*
* Any value other than `outlook` 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 {
$params = Util::removeNulls(
['redirectUri' => $redirectUri, 'state' => $state]
[
'redirectUri' => $redirectUri,
'provider' => $provider,
'state' => $state,
],
);

// @phpstan-ignore-next-line argument.type
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace CasParser;

// x-release-please-start-version
const VERSION = '0.10.0';
const VERSION = '0.11.0';
// x-release-please-end
3 changes: 2 additions & 1 deletion tests/Services/InboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function testConnectEmailWithOptionalParams(): void

$result = $this->client->inbox->connectEmail(
redirectUri: 'https://yourapp.com/oauth-callback',
state: 'abc123'
provider: 'outlook',
state: 'abc123',
);

// @phpstan-ignore-next-line method.alreadyNarrowedType
Expand Down