diff --git a/.release-please-manifest.json b/.release-please-manifest.json index da59f99..2aca35a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.0" + ".": "0.5.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 56f5a81..49508b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 17 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml -openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f -config_hash: 41c337f5cda03b13880617490f82bad0 +configured_endpoints: 21 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml +openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0 +config_hash: 4ab3e1ee76a463e0ed214541260ee12e diff --git a/CHANGELOG.md b/CHANGELOG.md index 63556f4..41daf9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.5.0 (2026-02-23) + +Full Changelog: [v0.4.0...v0.5.0](https://github.com/CASParser/cas-parser-php/compare/v0.4.0...v0.5.0) + +### Features + +* **api:** api update ([d8c85b9](https://github.com/CASParser/cas-parser-php/commit/d8c85b904f3df1c7242527d1dd66996d0e8cd6e8)) +* **api:** api update ([92b50de](https://github.com/CASParser/cas-parser-php/commit/92b50de8ea771c015e38a2635f1ee5c011156008)) +* **api:** api update ([c0fc7b8](https://github.com/CASParser/cas-parser-php/commit/c0fc7b8b4284930ca1d6eec4c58e88b026cf2da5)) +* **api:** manual updates ([83a811c](https://github.com/CASParser/cas-parser-php/commit/83a811cd2ac157f781caeabff6e8e0f4b757435e)) + + +### Chores + +* **internal:** remove mock server code ([e868489](https://github.com/CASParser/cas-parser-php/commit/e8684893f2f7c4ab6d75c2be56fc9f2d7c6a5323)) +* update mock server docs ([8a17bde](https://github.com/CASParser/cas-parser-php/commit/8a17bdee09cb200c74522cdf7ed35f8934ba4ecd)) + ## 0.4.0 (2026-02-14) Full Changelog: [v0.3.0...v0.4.0](https://github.com/CASParser/cas-parser-php/compare/v0.3.0...v0.4.0) diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6e..0000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index 4b777e0..63df137 100755 --- a/scripts/test +++ b/scripts/test @@ -4,52 +4,6 @@ set -e cd "$(dirname "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi exec -- ./vendor/bin/pest --colors=always diff --git a/src/AccessToken/AccessTokenCreateParams.php b/src/AccessToken/AccessTokenCreateParams.php index f433ba8..0d1e34d 100644 --- a/src/AccessToken/AccessTokenCreateParams.php +++ b/src/AccessToken/AccessTokenCreateParams.php @@ -14,6 +14,8 @@ * * **Use this endpoint from your backend** to create tokens that can be safely passed to frontend/SDK. * + * **Legacy path:** `/v1/access-token` (still supported) + * * Access tokens: * - Are prefixed with `at_` for easy identification * - Valid for up to 60 minutes diff --git a/src/Client.php b/src/Client.php index d9c6aff..cf8252a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -11,6 +11,7 @@ use CasParser\Services\CdslService; use CasParser\Services\ContractNoteService; use CasParser\Services\CreditsService; +use CasParser\Services\InboundEmailService; use CasParser\Services\InboxService; use CasParser\Services\KfintechService; use CasParser\Services\LogsService; @@ -83,6 +84,11 @@ class Client extends BaseClient */ public SmartService $smart; + /** + * @api + */ + public InboundEmailService $inboundEmail; + /** * @param RequestOpts|null $requestOptions */ @@ -134,6 +140,7 @@ public function __construct( $this->kfintech = new KfintechService($this); $this->nsdl = new NsdlService($this); $this->smart = new SmartService($this); + $this->inboundEmail = new InboundEmailService($this); } /** @return array */ diff --git a/src/InboundEmail/InboundEmailCreateParams.php b/src/InboundEmail/InboundEmailCreateParams.php new file mode 100644 index 0000000..ee42c80 --- /dev/null +++ b/src/InboundEmail/InboundEmailCreateParams.php @@ -0,0 +1,208 @@ +>|null, + * metadata?: array|null, + * reference?: string|null, + * } + */ +final class InboundEmailCreateParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Webhook URL where we POST email notifications. + * Must be HTTPS in production (HTTP allowed for localhost during development). + */ + #[Required('callback_url')] + public string $callbackURL; + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in`. + */ + #[Optional] + public ?string $alias; + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com. + * + * @var list>|null $allowedSources + */ + #[Optional('allowed_sources', list: AllowedSource::class)] + public ?array $allowedSources; + + /** + * Optional key-value pairs (max 10) to include in webhook payload. + * Useful for passing context like plan_type, campaign_id, etc. + * + * @var array|null $metadata + */ + #[Optional(map: 'string')] + public ?array $metadata; + + /** + * Your internal identifier (e.g., user_id, account_id). + * Returned in webhook payload for correlation. + */ + #[Optional] + public ?string $reference; + + /** + * `new InboundEmailCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * InboundEmailCreateParams::with(callbackURL: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new InboundEmailCreateParams)->withCallbackURL(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list>|null $allowedSources + * @param array|null $metadata + */ + public static function with( + string $callbackURL, + ?string $alias = null, + ?array $allowedSources = null, + ?array $metadata = null, + ?string $reference = null, + ): self { + $self = new self; + + $self['callbackURL'] = $callbackURL; + + null !== $alias && $self['alias'] = $alias; + null !== $allowedSources && $self['allowedSources'] = $allowedSources; + null !== $metadata && $self['metadata'] = $metadata; + null !== $reference && $self['reference'] = $reference; + + return $self; + } + + /** + * Webhook URL where we POST email notifications. + * Must be HTTPS in production (HTTP allowed for localhost during development). + */ + public function withCallbackURL(string $callbackURL): self + { + $self = clone $this; + $self['callbackURL'] = $callbackURL; + + return $self; + } + + /** + * Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in`. + */ + public function withAlias(string $alias): self + { + $self = clone $this; + $self['alias'] = $alias; + + return $self; + } + + /** + * Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com. + * + * @param list> $allowedSources + */ + public function withAllowedSources(array $allowedSources): self + { + $self = clone $this; + $self['allowedSources'] = $allowedSources; + + return $self; + } + + /** + * Optional key-value pairs (max 10) to include in webhook payload. + * Useful for passing context like plan_type, campaign_id, etc. + * + * @param array $metadata + */ + public function withMetadata(array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Your internal identifier (e.g., user_id, account_id). + * Returned in webhook payload for correlation. + */ + public function withReference(string $reference): self + { + $self = clone $this; + $self['reference'] = $reference; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailCreateParams/AllowedSource.php b/src/InboundEmail/InboundEmailCreateParams/AllowedSource.php new file mode 100644 index 0000000..938f1ac --- /dev/null +++ b/src/InboundEmail/InboundEmailCreateParams/AllowedSource.php @@ -0,0 +1,16 @@ + */ + use SdkModel; + + #[Optional] + public ?string $msg; + + #[Optional] + public ?string $status; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(?string $msg = null, ?string $status = null): self + { + $self = new self; + + null !== $msg && $self['msg'] = $msg; + null !== $status && $self['status'] = $status; + + return $self; + } + + public function withMsg(string $msg): self + { + $self = clone $this; + $self['msg'] = $msg; + + return $self; + } + + public function withStatus(string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailGetResponse.php b/src/InboundEmail/InboundEmailGetResponse.php new file mode 100644 index 0000000..5e76c16 --- /dev/null +++ b/src/InboundEmail/InboundEmailGetResponse.php @@ -0,0 +1,237 @@ +>|null, + * callbackURL?: string|null, + * createdAt?: \DateTimeInterface|null, + * email?: string|null, + * inboundEmailID?: string|null, + * metadata?: array|null, + * reference?: string|null, + * status?: null|Status|value-of, + * updatedAt?: \DateTimeInterface|null, + * } + */ +final class InboundEmailGetResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Accepted CAS providers (empty = all). + * + * @var list>|null $allowedSources + */ + #[Optional('allowed_sources', list: AllowedSource::class)] + public ?array $allowedSources; + + /** + * Webhook URL for email notifications. + */ + #[Optional('callback_url')] + public ?string $callbackURL; + + /** + * When the mailbox was created. + */ + #[Optional('created_at')] + public ?\DateTimeInterface $createdAt; + + /** + * The inbound email address to forward CAS statements to. + */ + #[Optional] + public ?string $email; + + /** + * Unique inbound email identifier. + */ + #[Optional('inbound_email_id')] + public ?string $inboundEmailID; + + /** + * Custom key-value metadata. + * + * @var array|null $metadata + */ + #[Optional(map: 'string')] + public ?array $metadata; + + /** + * Your internal reference identifier. + */ + #[Optional(nullable: true)] + public ?string $reference; + + /** + * Current mailbox status. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + /** + * When the mailbox was last updated. + */ + #[Optional('updated_at')] + public ?\DateTimeInterface $updatedAt; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list>|null $allowedSources + * @param array|null $metadata + * @param Status|value-of|null $status + */ + public static function with( + ?array $allowedSources = null, + ?string $callbackURL = null, + ?\DateTimeInterface $createdAt = null, + ?string $email = null, + ?string $inboundEmailID = null, + ?array $metadata = null, + ?string $reference = null, + Status|string|null $status = null, + ?\DateTimeInterface $updatedAt = null, + ): self { + $self = new self; + + null !== $allowedSources && $self['allowedSources'] = $allowedSources; + null !== $callbackURL && $self['callbackURL'] = $callbackURL; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $email && $self['email'] = $email; + null !== $inboundEmailID && $self['inboundEmailID'] = $inboundEmailID; + null !== $metadata && $self['metadata'] = $metadata; + null !== $reference && $self['reference'] = $reference; + null !== $status && $self['status'] = $status; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * Accepted CAS providers (empty = all). + * + * @param list> $allowedSources + */ + public function withAllowedSources(array $allowedSources): self + { + $self = clone $this; + $self['allowedSources'] = $allowedSources; + + return $self; + } + + /** + * Webhook URL for email notifications. + */ + public function withCallbackURL(string $callbackURL): self + { + $self = clone $this; + $self['callbackURL'] = $callbackURL; + + return $self; + } + + /** + * When the mailbox was created. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * The inbound email address to forward CAS statements to. + */ + public function withEmail(string $email): self + { + $self = clone $this; + $self['email'] = $email; + + return $self; + } + + /** + * Unique inbound email identifier. + */ + public function withInboundEmailID(string $inboundEmailID): self + { + $self = clone $this; + $self['inboundEmailID'] = $inboundEmailID; + + return $self; + } + + /** + * Custom key-value metadata. + * + * @param array $metadata + */ + public function withMetadata(array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Your internal reference identifier. + */ + public function withReference(?string $reference): self + { + $self = clone $this; + $self['reference'] = $reference; + + return $self; + } + + /** + * Current mailbox status. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * When the mailbox was last updated. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailGetResponse/AllowedSource.php b/src/InboundEmail/InboundEmailGetResponse/AllowedSource.php new file mode 100644 index 0000000..8c6cebd --- /dev/null +++ b/src/InboundEmail/InboundEmailGetResponse/AllowedSource.php @@ -0,0 +1,16 @@ + + * } + */ +final class InboundEmailListParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Maximum number of inbound emails to return. + */ + #[Optional] + public ?int $limit; + + /** + * Pagination offset. + */ + #[Optional] + public ?int $offset; + + /** + * Filter by status. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Status|value-of|null $status + */ + public static function with( + ?int $limit = null, + ?int $offset = null, + Status|string|null $status = null + ): self { + $self = new self; + + null !== $limit && $self['limit'] = $limit; + null !== $offset && $self['offset'] = $offset; + null !== $status && $self['status'] = $status; + + return $self; + } + + /** + * Maximum number of inbound emails to return. + */ + public function withLimit(int $limit): self + { + $self = clone $this; + $self['limit'] = $limit; + + return $self; + } + + /** + * Pagination offset. + */ + public function withOffset(int $offset): self + { + $self = clone $this; + $self['offset'] = $offset; + + return $self; + } + + /** + * Filter by status. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailListParams/Status.php b/src/InboundEmail/InboundEmailListParams/Status.php new file mode 100644 index 0000000..9515885 --- /dev/null +++ b/src/InboundEmail/InboundEmailListParams/Status.php @@ -0,0 +1,17 @@ +|null, + * limit?: int|null, + * offset?: int|null, + * status?: string|null, + * total?: int|null, + * } + */ +final class InboundEmailListResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var list|null $inboundEmails */ + #[Optional('inbound_emails', list: InboundEmail::class)] + public ?array $inboundEmails; + + #[Optional] + public ?int $limit; + + #[Optional] + public ?int $offset; + + #[Optional] + public ?string $status; + + /** + * Total number of inbound emails (for pagination). + */ + #[Optional] + public ?int $total; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list|null $inboundEmails + */ + public static function with( + ?array $inboundEmails = null, + ?int $limit = null, + ?int $offset = null, + ?string $status = null, + ?int $total = null, + ): self { + $self = new self; + + null !== $inboundEmails && $self['inboundEmails'] = $inboundEmails; + null !== $limit && $self['limit'] = $limit; + null !== $offset && $self['offset'] = $offset; + null !== $status && $self['status'] = $status; + null !== $total && $self['total'] = $total; + + return $self; + } + + /** + * @param list $inboundEmails + */ + public function withInboundEmails(array $inboundEmails): self + { + $self = clone $this; + $self['inboundEmails'] = $inboundEmails; + + return $self; + } + + public function withLimit(int $limit): self + { + $self = clone $this; + $self['limit'] = $limit; + + return $self; + } + + public function withOffset(int $offset): self + { + $self = clone $this; + $self['offset'] = $offset; + + return $self; + } + + public function withStatus(string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * Total number of inbound emails (for pagination). + */ + public function withTotal(int $total): self + { + $self = clone $this; + $self['total'] = $total; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailListResponse/InboundEmail.php b/src/InboundEmail/InboundEmailListResponse/InboundEmail.php new file mode 100644 index 0000000..5328b37 --- /dev/null +++ b/src/InboundEmail/InboundEmailListResponse/InboundEmail.php @@ -0,0 +1,237 @@ +>|null, + * callbackURL?: string|null, + * createdAt?: \DateTimeInterface|null, + * email?: string|null, + * inboundEmailID?: string|null, + * metadata?: array|null, + * reference?: string|null, + * status?: null|Status|value-of, + * updatedAt?: \DateTimeInterface|null, + * } + */ +final class InboundEmail implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Accepted CAS providers (empty = all). + * + * @var list>|null $allowedSources + */ + #[Optional('allowed_sources', list: AllowedSource::class)] + public ?array $allowedSources; + + /** + * Webhook URL for email notifications. + */ + #[Optional('callback_url')] + public ?string $callbackURL; + + /** + * When the mailbox was created. + */ + #[Optional('created_at')] + public ?\DateTimeInterface $createdAt; + + /** + * The inbound email address to forward CAS statements to. + */ + #[Optional] + public ?string $email; + + /** + * Unique inbound email identifier. + */ + #[Optional('inbound_email_id')] + public ?string $inboundEmailID; + + /** + * Custom key-value metadata. + * + * @var array|null $metadata + */ + #[Optional(map: 'string')] + public ?array $metadata; + + /** + * Your internal reference identifier. + */ + #[Optional(nullable: true)] + public ?string $reference; + + /** + * Current mailbox status. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + /** + * When the mailbox was last updated. + */ + #[Optional('updated_at')] + public ?\DateTimeInterface $updatedAt; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list>|null $allowedSources + * @param array|null $metadata + * @param Status|value-of|null $status + */ + public static function with( + ?array $allowedSources = null, + ?string $callbackURL = null, + ?\DateTimeInterface $createdAt = null, + ?string $email = null, + ?string $inboundEmailID = null, + ?array $metadata = null, + ?string $reference = null, + Status|string|null $status = null, + ?\DateTimeInterface $updatedAt = null, + ): self { + $self = new self; + + null !== $allowedSources && $self['allowedSources'] = $allowedSources; + null !== $callbackURL && $self['callbackURL'] = $callbackURL; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $email && $self['email'] = $email; + null !== $inboundEmailID && $self['inboundEmailID'] = $inboundEmailID; + null !== $metadata && $self['metadata'] = $metadata; + null !== $reference && $self['reference'] = $reference; + null !== $status && $self['status'] = $status; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * Accepted CAS providers (empty = all). + * + * @param list> $allowedSources + */ + public function withAllowedSources(array $allowedSources): self + { + $self = clone $this; + $self['allowedSources'] = $allowedSources; + + return $self; + } + + /** + * Webhook URL for email notifications. + */ + public function withCallbackURL(string $callbackURL): self + { + $self = clone $this; + $self['callbackURL'] = $callbackURL; + + return $self; + } + + /** + * When the mailbox was created. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * The inbound email address to forward CAS statements to. + */ + public function withEmail(string $email): self + { + $self = clone $this; + $self['email'] = $email; + + return $self; + } + + /** + * Unique inbound email identifier. + */ + public function withInboundEmailID(string $inboundEmailID): self + { + $self = clone $this; + $self['inboundEmailID'] = $inboundEmailID; + + return $self; + } + + /** + * Custom key-value metadata. + * + * @param array $metadata + */ + public function withMetadata(array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Your internal reference identifier. + */ + public function withReference(?string $reference): self + { + $self = clone $this; + $self['reference'] = $reference; + + return $self; + } + + /** + * Current mailbox status. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * When the mailbox was last updated. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailListResponse/InboundEmail/AllowedSource.php b/src/InboundEmail/InboundEmailListResponse/InboundEmail/AllowedSource.php new file mode 100644 index 0000000..31a4465 --- /dev/null +++ b/src/InboundEmail/InboundEmailListResponse/InboundEmail/AllowedSource.php @@ -0,0 +1,16 @@ +>|null, + * callbackURL?: string|null, + * createdAt?: \DateTimeInterface|null, + * email?: string|null, + * inboundEmailID?: string|null, + * metadata?: array|null, + * reference?: string|null, + * status?: null|Status|value-of, + * updatedAt?: \DateTimeInterface|null, + * } + */ +final class InboundEmailNewResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Accepted CAS providers (empty = all). + * + * @var list>|null $allowedSources + */ + #[Optional('allowed_sources', list: AllowedSource::class)] + public ?array $allowedSources; + + /** + * Webhook URL for email notifications. + */ + #[Optional('callback_url')] + public ?string $callbackURL; + + /** + * When the mailbox was created. + */ + #[Optional('created_at')] + public ?\DateTimeInterface $createdAt; + + /** + * The inbound email address to forward CAS statements to. + */ + #[Optional] + public ?string $email; + + /** + * Unique inbound email identifier. + */ + #[Optional('inbound_email_id')] + public ?string $inboundEmailID; + + /** + * Custom key-value metadata. + * + * @var array|null $metadata + */ + #[Optional(map: 'string')] + public ?array $metadata; + + /** + * Your internal reference identifier. + */ + #[Optional(nullable: true)] + public ?string $reference; + + /** + * Current mailbox status. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + /** + * When the mailbox was last updated. + */ + #[Optional('updated_at')] + public ?\DateTimeInterface $updatedAt; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param list>|null $allowedSources + * @param array|null $metadata + * @param Status|value-of|null $status + */ + public static function with( + ?array $allowedSources = null, + ?string $callbackURL = null, + ?\DateTimeInterface $createdAt = null, + ?string $email = null, + ?string $inboundEmailID = null, + ?array $metadata = null, + ?string $reference = null, + Status|string|null $status = null, + ?\DateTimeInterface $updatedAt = null, + ): self { + $self = new self; + + null !== $allowedSources && $self['allowedSources'] = $allowedSources; + null !== $callbackURL && $self['callbackURL'] = $callbackURL; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $email && $self['email'] = $email; + null !== $inboundEmailID && $self['inboundEmailID'] = $inboundEmailID; + null !== $metadata && $self['metadata'] = $metadata; + null !== $reference && $self['reference'] = $reference; + null !== $status && $self['status'] = $status; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * Accepted CAS providers (empty = all). + * + * @param list> $allowedSources + */ + public function withAllowedSources(array $allowedSources): self + { + $self = clone $this; + $self['allowedSources'] = $allowedSources; + + return $self; + } + + /** + * Webhook URL for email notifications. + */ + public function withCallbackURL(string $callbackURL): self + { + $self = clone $this; + $self['callbackURL'] = $callbackURL; + + return $self; + } + + /** + * When the mailbox was created. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * The inbound email address to forward CAS statements to. + */ + public function withEmail(string $email): self + { + $self = clone $this; + $self['email'] = $email; + + return $self; + } + + /** + * Unique inbound email identifier. + */ + public function withInboundEmailID(string $inboundEmailID): self + { + $self = clone $this; + $self['inboundEmailID'] = $inboundEmailID; + + return $self; + } + + /** + * Custom key-value metadata. + * + * @param array $metadata + */ + public function withMetadata(array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Your internal reference identifier. + */ + public function withReference(?string $reference): self + { + $self = clone $this; + $self['reference'] = $reference; + + return $self; + } + + /** + * Current mailbox status. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * When the mailbox was last updated. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } +} diff --git a/src/InboundEmail/InboundEmailNewResponse/AllowedSource.php b/src/InboundEmail/InboundEmailNewResponse/AllowedSource.php new file mode 100644 index 0000000..0b38841 --- /dev/null +++ b/src/InboundEmail/InboundEmailNewResponse/AllowedSource.php @@ -0,0 +1,16 @@ +> $allowedSources Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * @param array $metadata Optional key-value pairs (max 10) to include in webhook payload. + * Useful for passing context like plan_type, campaign_id, etc. + * @param string $reference Your internal identifier (e.g., user_id, account_id). + * Returned in webhook payload for correlation. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $callbackURL, + ?string $alias = null, + ?array $allowedSources = null, + ?array $metadata = null, + ?string $reference = null, + RequestOptions|array|null $requestOptions = null, + ): InboundEmailNewResponse; + + /** + * @api + * + * @param string $inboundEmailID Inbound Email ID (e.g., ie_a1b2c3d4e5f6) + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function retrieve( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): InboundEmailGetResponse; + + /** + * @api + * + * @param int $limit Maximum number of inbound emails to return + * @param int $offset Pagination offset + * @param Status|value-of $status Filter by status + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function list( + int $limit = 50, + int $offset = 0, + Status|string $status = 'all', + RequestOptions|array|null $requestOptions = null, + ): InboundEmailListResponse; + + /** + * @api + * + * @param string $inboundEmailID Inbound Email ID to delete + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): InboundEmailDeleteResponse; +} diff --git a/src/ServiceContracts/InboundEmailRawContract.php b/src/ServiceContracts/InboundEmailRawContract.php new file mode 100644 index 0000000..80f74dd --- /dev/null +++ b/src/ServiceContracts/InboundEmailRawContract.php @@ -0,0 +1,81 @@ +|InboundEmailCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|InboundEmailCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $inboundEmailID Inbound Email ID (e.g., ie_a1b2c3d4e5f6) + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|InboundEmailListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function list( + array|InboundEmailListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $inboundEmailID Inbound Email ID to delete + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/Services/AccessTokenRawService.php b/src/Services/AccessTokenRawService.php index a2a3bb0..ca67b74 100644 --- a/src/Services/AccessTokenRawService.php +++ b/src/Services/AccessTokenRawService.php @@ -30,6 +30,8 @@ public function __construct(private Client $client) {} * * **Use this endpoint from your backend** to create tokens that can be safely passed to frontend/SDK. * + * **Legacy path:** `/v1/access-token` (still supported) + * * Access tokens: * - Are prefixed with `at_` for easy identification * - Valid for up to 60 minutes @@ -55,7 +57,7 @@ public function create( // @phpstan-ignore-next-line return.type return $this->client->request( method: 'post', - path: 'v1/access-token', + path: 'v1/token', body: (object) $parsed, options: $options, convert: AccessTokenNewResponse::class, diff --git a/src/Services/AccessTokenService.php b/src/Services/AccessTokenService.php index fe0aade..489fe26 100644 --- a/src/Services/AccessTokenService.php +++ b/src/Services/AccessTokenService.php @@ -36,6 +36,8 @@ public function __construct(private Client $client) * * **Use this endpoint from your backend** to create tokens that can be safely passed to frontend/SDK. * + * **Legacy path:** `/v1/access-token` (still supported) + * * Access tokens: * - Are prefixed with `at_` for easy identification * - Valid for up to 60 minutes diff --git a/src/Services/CreditsRawService.php b/src/Services/CreditsRawService.php index a3432b2..60412fe 100644 --- a/src/Services/CreditsRawService.php +++ b/src/Services/CreditsRawService.php @@ -46,7 +46,7 @@ public function check( // @phpstan-ignore-next-line return.type return $this->client->request( method: 'post', - path: 'credits', + path: 'v1/credits', options: $requestOptions, convert: CreditCheckResponse::class, ); diff --git a/src/Services/InboundEmailRawService.php b/src/Services/InboundEmailRawService.php new file mode 100644 index 0000000..5bc07ba --- /dev/null +++ b/src/Services/InboundEmailRawService.php @@ -0,0 +1,168 @@ +>, + * metadata?: array, + * reference?: string, + * }|InboundEmailCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|InboundEmailCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = InboundEmailCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v4/inbound-email', + body: (object) $parsed, + options: $options, + convert: InboundEmailNewResponse::class, + ); + } + + /** + * @api + * + * Retrieve details of a specific mailbox including statistics. + * + * @param string $inboundEmailID Inbound Email ID (e.g., ie_a1b2c3d4e5f6) + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function retrieve( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v4/inbound-email/%1$s', $inboundEmailID], + options: $requestOptions, + convert: InboundEmailGetResponse::class, + ); + } + + /** + * @api + * + * List all mailboxes associated with your API key. + * Returns active and inactive mailboxes (deleted mailboxes are excluded). + * + * @param array{ + * limit?: int, offset?: int, status?: Status|value-of + * }|InboundEmailListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function list( + array|InboundEmailListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = InboundEmailListParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v4/inbound-email', + query: $parsed, + options: $options, + convert: InboundEmailListResponse::class, + ); + } + + /** + * @api + * + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after + * deletion will be rejected. + * + * @param string $inboundEmailID Inbound Email ID to delete + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v4/inbound-email/%1$s', $inboundEmailID], + options: $requestOptions, + convert: InboundEmailDeleteResponse::class, + ); + } +} diff --git a/src/Services/InboundEmailService.php b/src/Services/InboundEmailService.php new file mode 100644 index 0000000..5acee11 --- /dev/null +++ b/src/Services/InboundEmailService.php @@ -0,0 +1,171 @@ +raw = new InboundEmailRawService($client); + } + + /** + * @api + * + * Create a dedicated inbound email address for collecting CAS statements via email forwarding. + * + * **How it works:** + * 1. Create an inbound email with your webhook URL + * 2. Display the email address to your user (e.g., "Forward your CAS to ie_xxx@import.casparser.in") + * 3. When an investor forwards a CAS email, we verify the sender and deliver to your webhook + * + * **Webhook Delivery:** + * - We POST to your `callback_url` with JSON body containing files (matching EmailCASFile schema) + * - Failed deliveries are retried automatically with exponential backoff + * + * **Inactivity:** + * - Inbound emails with no activity in 30 days are marked inactive + * - Active inbound emails remain operational indefinitely + * + * @param string $callbackURL Webhook URL where we POST email notifications. + * Must be HTTPS in production (HTTP allowed for localhost during development). + * @param string $alias Optional custom email prefix for user-friendly addresses. + * - Must be 3-32 characters + * - Alphanumeric + hyphens only + * - Must start and end with letter/number + * - Example: `john-portfolio@import.casparser.in` + * - If omitted, generates random ID like `ie_abc123xyz@import.casparser.in` + * @param list> $allowedSources Filter emails by CAS provider. If omitted, accepts all providers. + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * @param array $metadata Optional key-value pairs (max 10) to include in webhook payload. + * Useful for passing context like plan_type, campaign_id, etc. + * @param string $reference Your internal identifier (e.g., user_id, account_id). + * Returned in webhook payload for correlation. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $callbackURL, + ?string $alias = null, + ?array $allowedSources = null, + ?array $metadata = null, + ?string $reference = null, + RequestOptions|array|null $requestOptions = null, + ): InboundEmailNewResponse { + $params = Util::removeNulls( + [ + 'callbackURL' => $callbackURL, + 'alias' => $alias, + 'allowedSources' => $allowedSources, + 'metadata' => $metadata, + 'reference' => $reference, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * Retrieve details of a specific mailbox including statistics. + * + * @param string $inboundEmailID Inbound Email ID (e.g., ie_a1b2c3d4e5f6) + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function retrieve( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): InboundEmailGetResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->retrieve($inboundEmailID, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * List all mailboxes associated with your API key. + * Returns active and inactive mailboxes (deleted mailboxes are excluded). + * + * @param int $limit Maximum number of inbound emails to return + * @param int $offset Pagination offset + * @param Status|value-of $status Filter by status + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function list( + int $limit = 50, + int $offset = 0, + Status|string $status = 'all', + RequestOptions|array|null $requestOptions = null, + ): InboundEmailListResponse { + $params = Util::removeNulls( + ['limit' => $limit, 'offset' => $offset, 'status' => $status] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * Permanently delete an inbound email address. It will stop accepting emails. + * + * **Note:** Deletion is immediate and cannot be undone. Any emails received after + * deletion will be rejected. + * + * @param string $inboundEmailID Inbound Email ID to delete + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $inboundEmailID, + RequestOptions|array|null $requestOptions = null + ): InboundEmailDeleteResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($inboundEmailID, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/LogsRawService.php b/src/Services/LogsRawService.php index 4048e37..a32f4e9 100644 --- a/src/Services/LogsRawService.php +++ b/src/Services/LogsRawService.php @@ -33,6 +33,8 @@ public function __construct(private Client $client) {} * Returns a list of API calls with timestamps, features used, status codes, and credits consumed. * Useful for monitoring usage patterns and debugging. * + * **Legacy path:** `/logs` (still supported) + * * @param array{ * endTime?: \DateTimeInterface, limit?: int, startTime?: \DateTimeInterface * }|LogCreateParams $params @@ -54,7 +56,7 @@ public function create( // @phpstan-ignore-next-line return.type return $this->client->request( method: 'post', - path: 'logs', + path: 'v1/usage', body: (object) $parsed, options: $options, convert: LogNewResponse::class, @@ -68,6 +70,8 @@ public function create( * * Useful for understanding which API features are being used most and tracking usage trends. * + * **Legacy path:** `/logs/summary` (still supported) + * * @param array{ * endTime?: \DateTimeInterface, startTime?: \DateTimeInterface * }|LogGetSummaryParams $params @@ -89,7 +93,7 @@ public function getSummary( // @phpstan-ignore-next-line return.type return $this->client->request( method: 'post', - path: 'logs/summary', + path: 'v1/usage/summary', body: (object) $parsed, options: $options, convert: LogGetSummaryResponse::class, diff --git a/src/Services/LogsService.php b/src/Services/LogsService.php index 03336f0..ce04094 100644 --- a/src/Services/LogsService.php +++ b/src/Services/LogsService.php @@ -38,6 +38,8 @@ public function __construct(private Client $client) * Returns a list of API calls with timestamps, features used, status codes, and credits consumed. * Useful for monitoring usage patterns and debugging. * + * **Legacy path:** `/logs` (still supported) + * * @param \DateTimeInterface $endTime End time filter (ISO 8601). Defaults to now. * @param int $limit Maximum number of logs to return * @param \DateTimeInterface $startTime Start time filter (ISO 8601). Defaults to 30 days ago. @@ -68,6 +70,8 @@ public function create( * * Useful for understanding which API features are being used most and tracking usage trends. * + * **Legacy path:** `/logs/summary` (still supported) + * * @param \DateTimeInterface $endTime End time filter (ISO 8601). Defaults to now. * @param \DateTimeInterface $startTime Start time filter (ISO 8601). Defaults to start of current month. * @param RequestOpts|null $requestOptions diff --git a/src/Services/VerifyTokenRawService.php b/src/Services/VerifyTokenRawService.php index f7504bb..fb94a32 100644 --- a/src/Services/VerifyTokenRawService.php +++ b/src/Services/VerifyTokenRawService.php @@ -40,7 +40,7 @@ public function verify( // @phpstan-ignore-next-line return.type return $this->client->request( method: 'post', - path: 'v1/verify-token', + path: 'v1/token/verify', options: $requestOptions, convert: VerifyTokenVerifyResponse::class, ); diff --git a/src/Version.php b/src/Version.php index cb6f277..6568f49 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace CasParser; // x-release-please-start-version -const VERSION = '0.4.0'; +const VERSION = '0.5.0'; // x-release-please-end diff --git a/tests/Services/AccessTokenTest.php b/tests/Services/AccessTokenTest.php index d46346f..bb5ae62 100644 --- a/tests/Services/AccessTokenTest.php +++ b/tests/Services/AccessTokenTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testCreate(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->accessToken->create(); diff --git a/tests/Services/CamsKfintechTest.php b/tests/Services/CamsKfintechTest.php index bd5095b..7febae0 100644 --- a/tests/Services/CamsKfintechTest.php +++ b/tests/Services/CamsKfintechTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testParse(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->camsKfintech->parse(); diff --git a/tests/Services/Cdsl/FetchTest.php b/tests/Services/Cdsl/FetchTest.php index 64a2678..5b044ff 100644 --- a/tests/Services/Cdsl/FetchTest.php +++ b/tests/Services/Cdsl/FetchTest.php @@ -33,7 +33,7 @@ protected function setUp(): void public function testRequestOtp(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->cdsl->fetch->requestOtp( @@ -50,7 +50,7 @@ public function testRequestOtp(): void public function testRequestOtpWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->cdsl->fetch->requestOtp( @@ -67,7 +67,7 @@ public function testRequestOtpWithOptionalParams(): void public function testVerifyOtp(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->cdsl->fetch->verifyOtp( @@ -83,7 +83,7 @@ public function testVerifyOtp(): void public function testVerifyOtpWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->cdsl->fetch->verifyOtp( diff --git a/tests/Services/CdslTest.php b/tests/Services/CdslTest.php index ba35fd5..de3b3ad 100644 --- a/tests/Services/CdslTest.php +++ b/tests/Services/CdslTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testParsePdf(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->cdsl->parsePdf(); diff --git a/tests/Services/ContractNoteTest.php b/tests/Services/ContractNoteTest.php index 57f171b..37b12c7 100644 --- a/tests/Services/ContractNoteTest.php +++ b/tests/Services/ContractNoteTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testParse(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->contractNote->parse(); diff --git a/tests/Services/CreditsTest.php b/tests/Services/CreditsTest.php index c658279..70e7b80 100644 --- a/tests/Services/CreditsTest.php +++ b/tests/Services/CreditsTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testCheck(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->credits->check(); diff --git a/tests/Services/InboundEmailTest.php b/tests/Services/InboundEmailTest.php new file mode 100644 index 0000000..bd12df6 --- /dev/null +++ b/tests/Services/InboundEmailTest.php @@ -0,0 +1,106 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->inboundEmail->create( + callbackURL: 'https://api.yourapp.com/webhooks/cas-email' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InboundEmailNewResponse::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->inboundEmail->create( + callbackURL: 'https://api.yourapp.com/webhooks/cas-email', + alias: 'john-portfolio', + allowedSources: ['cdsl', 'nsdl'], + metadata: ['plan' => 'premium', 'source' => 'onboarding'], + reference: 'user_12345', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InboundEmailNewResponse::class, $result); + } + + #[Test] + public function testRetrieve(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->inboundEmail->retrieve('ie_a1b2c3d4e5f6'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InboundEmailGetResponse::class, $result); + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->inboundEmail->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InboundEmailListResponse::class, $result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->inboundEmail->delete('inbound_email_id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InboundEmailDeleteResponse::class, $result); + } +} diff --git a/tests/Services/InboxTest.php b/tests/Services/InboxTest.php index 236a1aa..f7d2e8e 100644 --- a/tests/Services/InboxTest.php +++ b/tests/Services/InboxTest.php @@ -35,7 +35,7 @@ protected function setUp(): void public function testCheckConnectionStatus(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->checkConnectionStatus( @@ -50,7 +50,7 @@ public function testCheckConnectionStatus(): void public function testCheckConnectionStatusWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->checkConnectionStatus( @@ -65,7 +65,7 @@ public function testCheckConnectionStatusWithOptionalParams(): void public function testConnectEmail(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->connectEmail( @@ -80,7 +80,7 @@ public function testConnectEmail(): void public function testConnectEmailWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->connectEmail( @@ -96,7 +96,7 @@ public function testConnectEmailWithOptionalParams(): void public function testDisconnectEmail(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->disconnectEmail( @@ -111,7 +111,7 @@ public function testDisconnectEmail(): void public function testDisconnectEmailWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->disconnectEmail( @@ -126,7 +126,7 @@ public function testDisconnectEmailWithOptionalParams(): void public function testListCasFiles(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->listCasFiles(xInboxToken: 'x-inbox-token'); @@ -139,7 +139,7 @@ public function testListCasFiles(): void public function testListCasFilesWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->inbox->listCasFiles( diff --git a/tests/Services/KfintechTest.php b/tests/Services/KfintechTest.php index d181b1d..934dd0d 100644 --- a/tests/Services/KfintechTest.php +++ b/tests/Services/KfintechTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testGenerateCas(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->kfintech->generateCas( @@ -50,7 +50,7 @@ public function testGenerateCas(): void public function testGenerateCasWithOptionalParams(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->kfintech->generateCas( diff --git a/tests/Services/LogsTest.php b/tests/Services/LogsTest.php index fefa01f..1f4c4da 100644 --- a/tests/Services/LogsTest.php +++ b/tests/Services/LogsTest.php @@ -33,7 +33,7 @@ protected function setUp(): void public function testCreate(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->logs->create(); @@ -46,7 +46,7 @@ public function testCreate(): void public function testGetSummary(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->logs->getSummary(); diff --git a/tests/Services/NsdlTest.php b/tests/Services/NsdlTest.php index ba72197..e41f048 100644 --- a/tests/Services/NsdlTest.php +++ b/tests/Services/NsdlTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testParse(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->nsdl->parse(); diff --git a/tests/Services/SmartTest.php b/tests/Services/SmartTest.php index 95305b4..ab62d05 100644 --- a/tests/Services/SmartTest.php +++ b/tests/Services/SmartTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testParseCasPdf(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->smart->parseCasPdf(); diff --git a/tests/Services/VerifyTokenTest.php b/tests/Services/VerifyTokenTest.php index 16b7649..36549b1 100644 --- a/tests/Services/VerifyTokenTest.php +++ b/tests/Services/VerifyTokenTest.php @@ -32,7 +32,7 @@ protected function setUp(): void public function testVerify(): void { if (UnsupportedMockTests::$skip) { - $this->markTestSkipped('Prism tests are disabled'); + $this->markTestSkipped('Mock server tests are disabled'); } $result = $this->client->verifyToken->verify();