55namespace CasParser \InboundEmail ;
66
77use CasParser \Core \Attributes \Optional ;
8- use CasParser \Core \Attributes \Required ;
98use CasParser \Core \Concerns \SdkModel ;
109use CasParser \Core \Concerns \SdkParams ;
1110use CasParser \Core \Contracts \BaseModel ;
1211use 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.
0 commit comments