Skip to content

Commit 2892c8f

Browse files
feat(api): api update
1 parent 4fe2734 commit 2892c8f

9 files changed

Lines changed: 94 additions & 147 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d868ff00b7b07f6b6802b00f22fad531a91a76bb219a634f3f90fe488bd499ba.yml
3-
openapi_spec_hash: 20e9f2fc31feee78878cdf56e46dab60
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-78ef474b9e171a3eaa430a9dacdc2fa5c7f7d5f89147cb20573a355d3dbb9f0e.yml
3+
openapi_spec_hash: 11b6e43ef4ed724f9804c9d790a4faee
44
config_hash: 5509bb7a961ae2e79114b24c381606d4

src/InboundEmail/InboundEmailCreateParams.php

Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,27 @@
55
namespace CasParser\InboundEmail;
66

77
use CasParser\Core\Attributes\Optional;
8-
use CasParser\Core\Attributes\Required;
98
use CasParser\Core\Concerns\SdkModel;
109
use CasParser\Core\Concerns\SdkParams;
1110
use CasParser\Core\Contracts\BaseModel;
1211
use CasParser\InboundEmail\InboundEmailCreateParams\AllowedSource;
1312

1413
/**
15-
* Create a dedicated inbound email address for collecting CAS statements via email forwarding.
14+
* Create a dedicated inbound email address for collecting CAS statements
15+
* via email forwarding. When an investor forwards a CAS email to this
16+
* address, we verify the sender and make the file available to you.
1617
*
17-
* **How it works:**
18-
* 1. Create an inbound email with your webhook URL
19-
* 2. Display the email address to your user (e.g., "Forward your CAS to ie_xxx@import.casparser.in")
20-
* 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook
21-
*
22-
* **Webhook Delivery:**
23-
* - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile schema)
24-
* - Failed deliveries are retried automatically with exponential backoff
25-
*
26-
* **Inactivity:**
27-
* - Inbound emails with no activity in 30 days are marked inactive
28-
* - Active inbound emails remain operational indefinitely
18+
* `callback_url` is **optional**:
19+
* - **Set it** — we POST each parsed email to your webhook as it arrives.
20+
* - **Omit it** — retrieve files via `GET /v4/inbound-email/{id}/files`
21+
* without building a webhook consumer.
2922
*
3023
* @see CasParser\Services\InboundEmailService::create()
3124
*
3225
* @phpstan-type InboundEmailCreateParamsShape = array{
33-
* callbackURL: string,
3426
* alias?: string|null,
3527
* allowedSources?: list<AllowedSource|value-of<AllowedSource>>|null,
28+
* callbackURL?: string|null,
3629
* metadata?: array<string,string>|null,
3730
* reference?: string|null,
3831
* }
@@ -44,19 +37,10 @@ final class InboundEmailCreateParams implements BaseModel
4437
use SdkParams;
4538

4639
/**
47-
* Webhook URL where we POST email notifications.
48-
* Must be HTTPS in production (HTTP allowed for localhost during development).
49-
*/
50-
#[Required('callback_url')]
51-
public string $callbackURL;
52-
53-
/**
54-
* Optional custom email prefix for user-friendly addresses.
55-
* - Must be 3-32 characters
56-
* - Alphanumeric + hyphens only
57-
* - Must start and end with letter/number
58-
* - Example: `john-portfolio@import.casparser.in`
59-
* - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in`.
40+
* Optional custom email prefix (e.g.
41+
* `john-portfolio@import.casparser.in`). 3-32 chars,
42+
* alphanumeric + hyphens, must start/end with a letter or
43+
* number. If omitted, a random ID is generated.
6044
*/
6145
#[Optional]
6246
public ?string $alias;
@@ -73,6 +57,14 @@ final class InboundEmailCreateParams implements BaseModel
7357
#[Optional('allowed_sources', list: AllowedSource::class)]
7458
public ?array $allowedSources;
7559

60+
/**
61+
* Optional webhook URL where we POST parsed emails. Must be
62+
* HTTPS in production (HTTP allowed for localhost). If omitted,
63+
* retrieve files via `GET /v4/inbound-email/{id}/files`.
64+
*/
65+
#[Optional('callback_url', nullable: true)]
66+
public ?string $callbackURL;
67+
7668
/**
7769
* Optional key-value pairs (max 10) to include in webhook payload.
7870
* Useful for passing context like plan_type, campaign_id, etc.
@@ -89,20 +81,6 @@ final class InboundEmailCreateParams implements BaseModel
8981
#[Optional]
9082
public ?string $reference;
9183

92-
/**
93-
* `new InboundEmailCreateParams()` is missing required properties by the API.
94-
*
95-
* To enforce required parameters use
96-
* ```
97-
* InboundEmailCreateParams::with(callbackURL: ...)
98-
* ```
99-
*
100-
* Otherwise ensure the following setters are called
101-
*
102-
* ```
103-
* (new InboundEmailCreateParams)->withCallbackURL(...)
104-
* ```
105-
*/
10684
public function __construct()
10785
{
10886
$this->initialize();
@@ -117,43 +95,28 @@ public function __construct()
11795
* @param array<string,string>|null $metadata
11896
*/
11997
public static function with(
120-
string $callbackURL,
12198
?string $alias = null,
12299
?array $allowedSources = null,
100+
?string $callbackURL = null,
123101
?array $metadata = null,
124102
?string $reference = null,
125103
): self {
126104
$self = new self;
127105

128-
$self['callbackURL'] = $callbackURL;
129-
130106
null !== $alias && $self['alias'] = $alias;
131107
null !== $allowedSources && $self['allowedSources'] = $allowedSources;
108+
null !== $callbackURL && $self['callbackURL'] = $callbackURL;
132109
null !== $metadata && $self['metadata'] = $metadata;
133110
null !== $reference && $self['reference'] = $reference;
134111

135112
return $self;
136113
}
137114

138115
/**
139-
* Webhook URL where we POST email notifications.
140-
* Must be HTTPS in production (HTTP allowed for localhost during development).
141-
*/
142-
public function withCallbackURL(string $callbackURL): self
143-
{
144-
$self = clone $this;
145-
$self['callbackURL'] = $callbackURL;
146-
147-
return $self;
148-
}
149-
150-
/**
151-
* Optional custom email prefix for user-friendly addresses.
152-
* - Must be 3-32 characters
153-
* - Alphanumeric + hyphens only
154-
* - Must start and end with letter/number
155-
* - Example: `john-portfolio@import.casparser.in`
156-
* - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in`.
116+
* Optional custom email prefix (e.g.
117+
* `john-portfolio@import.casparser.in`). 3-32 chars,
118+
* alphanumeric + hyphens, must start/end with a letter or
119+
* number. If omitted, a random ID is generated.
157120
*/
158121
public function withAlias(string $alias): self
159122
{
@@ -180,6 +143,19 @@ public function withAllowedSources(array $allowedSources): self
180143
return $self;
181144
}
182145

146+
/**
147+
* Optional webhook URL where we POST parsed emails. Must be
148+
* HTTPS in production (HTTP allowed for localhost). If omitted,
149+
* retrieve files via `GET /v4/inbound-email/{id}/files`.
150+
*/
151+
public function withCallbackURL(?string $callbackURL): self
152+
{
153+
$self = clone $this;
154+
$self['callbackURL'] = $callbackURL;
155+
156+
return $self;
157+
}
158+
183159
/**
184160
* Optional key-value pairs (max 10) to include in webhook payload.
185161
* Useful for passing context like plan_type, campaign_id, etc.

src/InboundEmail/InboundEmailGetResponse.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ final class InboundEmailGetResponse implements BaseModel
3939
public ?array $allowedSources;
4040

4141
/**
42-
* Webhook URL for email notifications.
42+
* Webhook URL for email notifications. `null` means files are only
43+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
4344
*/
44-
#[Optional('callback_url')]
45+
#[Optional('callback_url', nullable: true)]
4546
public ?string $callbackURL;
4647

4748
/**
@@ -144,9 +145,10 @@ public function withAllowedSources(array $allowedSources): self
144145
}
145146

146147
/**
147-
* Webhook URL for email notifications.
148+
* Webhook URL for email notifications. `null` means files are only
149+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
148150
*/
149-
public function withCallbackURL(string $callbackURL): self
151+
public function withCallbackURL(?string $callbackURL): self
150152
{
151153
$self = clone $this;
152154
$self['callbackURL'] = $callbackURL;

src/InboundEmail/InboundEmailListResponse/InboundEmail.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ final class InboundEmail implements BaseModel
3939
public ?array $allowedSources;
4040

4141
/**
42-
* Webhook URL for email notifications.
42+
* Webhook URL for email notifications. `null` means files are only
43+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
4344
*/
44-
#[Optional('callback_url')]
45+
#[Optional('callback_url', nullable: true)]
4546
public ?string $callbackURL;
4647

4748
/**
@@ -144,9 +145,10 @@ public function withAllowedSources(array $allowedSources): self
144145
}
145146

146147
/**
147-
* Webhook URL for email notifications.
148+
* Webhook URL for email notifications. `null` means files are only
149+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
148150
*/
149-
public function withCallbackURL(string $callbackURL): self
151+
public function withCallbackURL(?string $callbackURL): self
150152
{
151153
$self = clone $this;
152154
$self['callbackURL'] = $callbackURL;

src/InboundEmail/InboundEmailNewResponse.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ final class InboundEmailNewResponse implements BaseModel
3939
public ?array $allowedSources;
4040

4141
/**
42-
* Webhook URL for email notifications.
42+
* Webhook URL for email notifications. `null` means files are only
43+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
4344
*/
44-
#[Optional('callback_url')]
45+
#[Optional('callback_url', nullable: true)]
4546
public ?string $callbackURL;
4647

4748
/**
@@ -144,9 +145,10 @@ public function withAllowedSources(array $allowedSources): self
144145
}
145146

146147
/**
147-
* Webhook URL for email notifications.
148+
* Webhook URL for email notifications. `null` means files are only
149+
* retrievable via `GET /v4/inbound-email/{id}/files` (pull delivery).
148150
*/
149-
public function withCallbackURL(string $callbackURL): self
151+
public function withCallbackURL(?string $callbackURL): self
150152
{
151153
$self = clone $this;
152154
$self['callbackURL'] = $callbackURL;

src/ServiceContracts/InboundEmailContract.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ interface InboundEmailContract
2121
/**
2222
* @api
2323
*
24-
* @param string $callbackURL Webhook URL where we POST email notifications.
25-
* Must be HTTPS in production (HTTP allowed for localhost during development).
26-
* @param string $alias Optional custom email prefix for user-friendly addresses.
27-
* - Must be 3-32 characters
28-
* - Alphanumeric + hyphens only
29-
* - Must start and end with letter/number
30-
* - Example: `john-portfolio@import.casparser.in`
31-
* - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in`
24+
* @param string $alias Optional custom email prefix (e.g.
25+
* `john-portfolio@import.casparser.in`). 3-32 chars,
26+
* alphanumeric + hyphens, must start/end with a letter or
27+
* number. If omitted, a random ID is generated.
3228
* @param list<AllowedSource|value-of<AllowedSource>> $allowedSources Filter emails by CAS provider. If omitted, accepts all providers.
3329
* - `cdsl` → eCAS@cdslstatement.com
3430
* - `nsdl` → NSDL-CAS@nsdl.co.in
3531
* - `cams` → donotreply@camsonline.com
3632
* - `kfintech` → samfS@kfintech.com
33+
* @param string|null $callbackURL Optional webhook URL where we POST parsed emails. Must be
34+
* HTTPS in production (HTTP allowed for localhost). If omitted,
35+
* retrieve files via `GET /v4/inbound-email/{id}/files`.
3736
* @param array<string,string> $metadata Optional key-value pairs (max 10) to include in webhook payload.
3837
* Useful for passing context like plan_type, campaign_id, etc.
3938
* @param string $reference Your internal identifier (e.g., user_id, account_id).
@@ -43,9 +42,9 @@ interface InboundEmailContract
4342
* @throws APIException
4443
*/
4544
public function create(
46-
string $callbackURL,
4745
?string $alias = null,
4846
?array $allowedSources = null,
47+
?string $callbackURL = null,
4948
?array $metadata = null,
5049
?string $reference = null,
5150
RequestOptions|array|null $requestOptions = null,

src/Services/InboundEmailRawService.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,19 @@ public function __construct(private Client $client) {}
5353
/**
5454
* @api
5555
*
56-
* Create a dedicated inbound email address for collecting CAS statements via email forwarding.
56+
* Create a dedicated inbound email address for collecting CAS statements
57+
* via email forwarding. When an investor forwards a CAS email to this
58+
* address, we verify the sender and make the file available to you.
5759
*
58-
* **How it works:**
59-
* 1. Create an inbound email with your webhook URL
60-
* 2. Display the email address to your user (e.g., "Forward your CAS to ie_xxx@import.casparser.in")
61-
* 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook
62-
*
63-
* **Webhook Delivery:**
64-
* - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile schema)
65-
* - Failed deliveries are retried automatically with exponential backoff
66-
*
67-
* **Inactivity:**
68-
* - Inbound emails with no activity in 30 days are marked inactive
69-
* - Active inbound emails remain operational indefinitely
60+
* `callback_url` is **optional**:
61+
* - **Set it** — we POST each parsed email to your webhook as it arrives.
62+
* - **Omit it** — retrieve files via `GET /v4/inbound-email/{id}/files`
63+
* without building a webhook consumer.
7064
*
7165
* @param array{
72-
* callbackURL: string,
7366
* alias?: string,
7467
* allowedSources?: list<AllowedSource|value-of<AllowedSource>>,
68+
* callbackURL?: string|null,
7569
* metadata?: array<string,string>,
7670
* reference?: string,
7771
* }|InboundEmailCreateParams $params

0 commit comments

Comments
 (0)