-
Notifications
You must be signed in to change notification settings - Fork 146
🌿 Fern Regeneration -- January 15, 2026 #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
726 changes: 420 additions & 306 deletions
reference.md
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
src/IpAllowlist/IpAllowlistClient.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| <?php | ||
|
|
||
| namespace Intercom\IpAllowlist; | ||
|
|
||
| use GuzzleHttp\ClientInterface; | ||
| use Intercom\Core\Client\RawClient; | ||
| use Intercom\Types\IpAllowlist; | ||
| use Intercom\Exceptions\IntercomException; | ||
| use Intercom\Exceptions\IntercomApiException; | ||
| use Intercom\Core\Json\JsonApiRequest; | ||
| use Intercom\Environments; | ||
| use Intercom\Core\Client\HttpMethod; | ||
| use JsonException; | ||
| use GuzzleHttp\Exception\RequestException; | ||
| use Psr\Http\Client\ClientExceptionInterface; | ||
|
|
||
| class IpAllowlistClient | ||
| { | ||
| /** | ||
| * @var array{ | ||
| * baseUrl?: string, | ||
| * client?: ClientInterface, | ||
| * maxRetries?: int, | ||
| * timeout?: float, | ||
| * headers?: array<string, string>, | ||
| * } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator | ||
| */ | ||
| private array $options; | ||
|
|
||
| /** | ||
| * @var RawClient $client | ||
| */ | ||
| private RawClient $client; | ||
|
|
||
| /** | ||
| * @param RawClient $client | ||
| * @param ?array{ | ||
| * baseUrl?: string, | ||
| * client?: ClientInterface, | ||
| * maxRetries?: int, | ||
| * timeout?: float, | ||
| * headers?: array<string, string>, | ||
| * } $options | ||
| */ | ||
| public function __construct( | ||
| RawClient $client, | ||
| ?array $options = null, | ||
| ) { | ||
| $this->client = $client; | ||
| $this->options = $options ?? []; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieve the current IP allowlist configuration for the workspace. | ||
| * | ||
| * @param ?array{ | ||
| * baseUrl?: string, | ||
| * maxRetries?: int, | ||
| * timeout?: float, | ||
| * headers?: array<string, string>, | ||
| * queryParameters?: array<string, mixed>, | ||
| * bodyProperties?: array<string, mixed>, | ||
| * } $options | ||
| * @return IpAllowlist | ||
| * @throws IntercomException | ||
| * @throws IntercomApiException | ||
| */ | ||
| public function getIpAllowlist(?array $options = null): IpAllowlist | ||
| { | ||
| $options = array_merge($this->options, $options ?? []); | ||
| try { | ||
| $response = $this->client->sendRequest( | ||
| new JsonApiRequest( | ||
| baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, | ||
| path: "ip_allowlist", | ||
| method: HttpMethod::GET, | ||
| ), | ||
| $options, | ||
| ); | ||
| $statusCode = $response->getStatusCode(); | ||
| if ($statusCode >= 200 && $statusCode < 400) { | ||
| $json = $response->getBody()->getContents(); | ||
| return IpAllowlist::fromJson($json); | ||
| } | ||
| } catch (JsonException $e) { | ||
| throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); | ||
| } catch (RequestException $e) { | ||
| $response = $e->getResponse(); | ||
| if ($response === null) { | ||
| throw new IntercomException(message: $e->getMessage(), previous: $e); | ||
| } | ||
| throw new IntercomApiException( | ||
| message: "API request failed", | ||
| statusCode: $response->getStatusCode(), | ||
| body: $response->getBody()->getContents(), | ||
| ); | ||
| } catch (ClientExceptionInterface $e) { | ||
| throw new IntercomException(message: $e->getMessage(), previous: $e); | ||
| } | ||
| throw new IntercomApiException( | ||
| message: 'API request failed', | ||
| statusCode: $statusCode, | ||
| body: $response->getBody()->getContents(), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Update the IP allowlist configuration for the workspace. | ||
| * | ||
| * {% admonition type="warning" name="Lockout Protection" %} | ||
| * The API will reject updates that would lock out the caller's IP address. Ensure your current IP is included in the allowlist when enabling the feature. | ||
| * {% /admonition %} | ||
| * | ||
| * @param IpAllowlist $request | ||
| * @param ?array{ | ||
| * baseUrl?: string, | ||
| * maxRetries?: int, | ||
| * timeout?: float, | ||
| * headers?: array<string, string>, | ||
| * queryParameters?: array<string, mixed>, | ||
| * bodyProperties?: array<string, mixed>, | ||
| * } $options | ||
| * @return IpAllowlist | ||
| * @throws IntercomException | ||
| * @throws IntercomApiException | ||
| */ | ||
| public function updateIpAllowlist(IpAllowlist $request, ?array $options = null): IpAllowlist | ||
| { | ||
| $options = array_merge($this->options, $options ?? []); | ||
| try { | ||
| $response = $this->client->sendRequest( | ||
| new JsonApiRequest( | ||
| baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, | ||
| path: "ip_allowlist", | ||
| method: HttpMethod::PUT, | ||
| body: $request, | ||
| ), | ||
| $options, | ||
| ); | ||
| $statusCode = $response->getStatusCode(); | ||
| if ($statusCode >= 200 && $statusCode < 400) { | ||
| $json = $response->getBody()->getContents(); | ||
| return IpAllowlist::fromJson($json); | ||
| } | ||
| } catch (JsonException $e) { | ||
| throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); | ||
| } catch (RequestException $e) { | ||
| $response = $e->getResponse(); | ||
| if ($response === null) { | ||
| throw new IntercomException(message: $e->getMessage(), previous: $e); | ||
| } | ||
| throw new IntercomApiException( | ||
| message: "API request failed", | ||
| statusCode: $response->getStatusCode(), | ||
| body: $response->getBody()->getContents(), | ||
| ); | ||
| } catch (ClientExceptionInterface $e) { | ||
| throw new IntercomException(message: $e->getMessage(), previous: $e); | ||
| } | ||
| throw new IntercomApiException( | ||
| message: 'API request failed', | ||
| statusCode: $statusCode, | ||
| body: $response->getBody()->getContents(), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
src/Types/IpAllowlist.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <?php | ||
|
|
||
| namespace Intercom\Types; | ||
|
|
||
| use Intercom\Core\Json\JsonSerializableType; | ||
| use Intercom\Core\Json\JsonProperty; | ||
| use Intercom\Core\Types\ArrayType; | ||
|
|
||
| /** | ||
| * IP allowlist settings for the workspace. | ||
| */ | ||
| class IpAllowlist extends JsonSerializableType | ||
| { | ||
| /** | ||
| * @var ?string $type String representing the object's type. Always has the value `ip_allowlist`. | ||
| */ | ||
| #[JsonProperty('type')] | ||
| private ?string $type; | ||
|
|
||
| /** | ||
| * @var ?bool $enabled Whether the IP allowlist is enabled for the workspace. | ||
| */ | ||
| #[JsonProperty('enabled')] | ||
| private ?bool $enabled; | ||
|
|
||
| /** | ||
| * List of allowed IP addresses and/or IP ranges in CIDR notation. | ||
| * Examples: | ||
| * - Single IP: `192.168.0.1` | ||
| * - IP range: `192.168.0.1/24` (allows 192.168.0.0 - 192.168.0.255) | ||
| * | ||
| * @var ?array<string> $ipAllowlist | ||
| */ | ||
| #[JsonProperty('ip_allowlist'), ArrayType(['string'])] | ||
| private ?array $ipAllowlist; | ||
|
|
||
| /** | ||
| * @param array{ | ||
| * type?: ?string, | ||
| * enabled?: ?bool, | ||
| * ipAllowlist?: ?array<string>, | ||
| * } $values | ||
| */ | ||
| public function __construct( | ||
| array $values = [], | ||
| ) { | ||
| $this->type = $values['type'] ?? null; | ||
| $this->enabled = $values['enabled'] ?? null; | ||
| $this->ipAllowlist = $values['ipAllowlist'] ?? null; | ||
| } | ||
|
|
||
| /** | ||
| * @return ?string | ||
| */ | ||
| public function getType(): ?string | ||
| { | ||
| return $this->type; | ||
| } | ||
|
|
||
| /** | ||
| * @param ?string $value | ||
| */ | ||
| public function setType(?string $value = null): self | ||
| { | ||
| $this->type = $value; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @return ?bool | ||
| */ | ||
| public function getEnabled(): ?bool | ||
| { | ||
| return $this->enabled; | ||
| } | ||
|
|
||
| /** | ||
| * @param ?bool $value | ||
| */ | ||
| public function setEnabled(?bool $value = null): self | ||
| { | ||
| $this->enabled = $value; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @return ?array<string> | ||
| */ | ||
| public function getIpAllowlist(): ?array | ||
| { | ||
| return $this->ipAllowlist; | ||
| } | ||
|
|
||
| /** | ||
| * @param ?array<string> $value | ||
| */ | ||
| public function setIpAllowlist(?array $value = null): self | ||
| { | ||
| $this->ipAllowlist = $value; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function __toString(): string | ||
| { | ||
| return $this->toJson(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.