Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
726 changes: 420 additions & 306 deletions reference.md

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/IntercomClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Intercom\DataExport\DataExportClient;
use Intercom\HelpCenters\HelpCentersClient;
use Intercom\InternalArticles\InternalArticlesClient;
use Intercom\IpAllowlist\IpAllowlistClient;
use Intercom\Companies\CompaniesClient;
use Intercom\Contacts\ContactsClient;
use Intercom\Notes\NotesClient;
Expand Down Expand Up @@ -78,6 +79,11 @@ class IntercomClient
*/
public InternalArticlesClient $internalArticles;

/**
* @var IpAllowlistClient $ipAllowlist
*/
public IpAllowlistClient $ipAllowlist;

/**
* @var CompaniesClient $companies
*/
Expand Down Expand Up @@ -223,8 +229,8 @@ public function __construct(
'Authorization' => "Bearer $token",
'X-Fern-Language' => 'PHP',
'X-Fern-SDK-Name' => 'Intercom',
'X-Fern-SDK-Version' => '6.0.0',
'User-Agent' => 'intercom/intercom-php/6.0.0',
'X-Fern-SDK-Version' => '0.0.464',
'User-Agent' => 'intercom/intercom-php/0.0.464',
'Intercom-Version' => '2.14',
];

Expand All @@ -247,6 +253,7 @@ public function __construct(
$this->dataExport = new DataExportClient($this->client, $this->options);
$this->helpCenters = new HelpCentersClient($this->client, $this->options);
$this->internalArticles = new InternalArticlesClient($this->client, $this->options);
$this->ipAllowlist = new IpAllowlistClient($this->client, $this->options);
$this->companies = new CompaniesClient($this->client, $this->options);
$this->contacts = new ContactsClient($this->client, $this->options);
$this->notes = new NotesClient($this->client, $this->options);
Expand Down
166 changes: 166 additions & 0 deletions src/IpAllowlist/IpAllowlistClient.php
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(),
);
}
}
7 changes: 6 additions & 1 deletion src/Types/ActivityLogActivityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum ActivityLogActivityType: string
case InboxAccessChange = "inbox_access_change";
case MacroCreation = "macro_creation";
case MacroDeletion = "macro_deletion";
case MacroUpdated = "macro_updated";
case MacroUpdate = "macro_update";
case MaliciousDomainsSettingChange = "malicious_domains_setting_change";
case MessageDeletion = "message_deletion";
case MessageStateChange = "message_state_change";
Expand All @@ -80,6 +80,11 @@ enum ActivityLogActivityType: string
case SeatChange = "seat_change";
case SeatRevoke = "seat_revoke";
case SecuritySettingsChange = "security_settings_change";
case SeriesCreation = "series_creation";
case SeriesDeletion = "series_deletion";
case SeriesSettingsUpdate = "series_settings_update";
case SeriesStatusChange = "series_status_change";
case SeriesUpdate = "series_update";
case StripInboundEmailLinksChange = "strip_inbound_email_links_change";
case TemporaryExpectationChange = "temporary_expectation_change";
case TeamAssignmentLimitChange = "team_assignment_limit_change";
Expand Down
110 changes: 110 additions & 0 deletions src/Types/IpAllowlist.php
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();
}
}
25 changes: 25 additions & 0 deletions src/Unstable/Contacts/Requests/UpdateContactRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class UpdateContactRequest extends JsonSerializableType
#[JsonProperty('unsubscribed_from_emails')]
private ?bool $unsubscribedFromEmails;

/**
* @var ?string $languageOverride A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null.
*/
#[JsonProperty('language_override')]
private ?string $languageOverride;

/**
* @var ?array<string, mixed> $customAttributes The custom attributes which are set for the contact
*/
Expand All @@ -92,6 +98,7 @@ class UpdateContactRequest extends JsonSerializableType
* lastSeenAt?: ?int,
* ownerId?: ?int,
* unsubscribedFromEmails?: ?bool,
* languageOverride?: ?string,
* customAttributes?: ?array<string, mixed>,
* } $values
*/
Expand All @@ -109,6 +116,7 @@ public function __construct(
$this->lastSeenAt = $values['lastSeenAt'] ?? null;
$this->ownerId = $values['ownerId'] ?? null;
$this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null;
$this->languageOverride = $values['languageOverride'] ?? null;
$this->customAttributes = $values['customAttributes'] ?? null;
}

Expand Down Expand Up @@ -299,6 +307,23 @@ public function setUnsubscribedFromEmails(?bool $value = null): self
return $this;
}

/**
* @return ?string
*/
public function getLanguageOverride(): ?string
{
return $this->languageOverride;
}

/**
* @param ?string $value
*/
public function setLanguageOverride(?string $value = null): self
{
$this->languageOverride = $value;
return $this;
}

/**
* @return ?array<string, mixed>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Unstable/Contacts/Traits/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ trait Contact
private ?int $lastEmailClickedAt;

/**
* @var ?string $languageOverride A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.
* @var ?string $languageOverride A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null.
*/
#[JsonProperty('language_override')]
private ?string $languageOverride;
Expand Down
Loading