Skip to content
Merged
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,22 @@ $html = $lettermint->messages->html('message-id');
| `suppressions` | `list`, `iterate`, `create`, `delete` |
| `team` | `retrieve`, `update`, `usage`, `roles` |
| `team->members` | `list`, `iterate`, `retrieve`, `updateAssignment` |
| `team->invites` | `list`, `iterate`, `retrieve`, `create`, `update`, `revoke` |
| `webhooks` | `list`, `iterate`, `create`, `retrieve`, `update`, `delete`, `test`, `regenerateSecret` |
| `webhooks->deliveries` | `list($webhookId)`, `iterate($webhookId)`, `retrieve($webhookId, $deliveryId)`, `retry($webhookId, $deliveryId)` |
| (root) | `ping`, `analytics`, `analyticsPages`, `blockedFileTypes` |

`team->invites->create()` sends the invitation email; the team needs a free seat, and the Owner role cannot be assigned. `team->invites->update()` replaces the email, role and project access of a pending invite and sends a new email only when the address changes:

```php
$invite = $lettermint->team->invites->create([
'email' => 'jane@acme.com',
'role_id' => 'role-id',
'project_access' => ['scope' => 'selected', 'project_ids' => ['project-id']],
]);
$lettermint->team->invites->revoke($invite->id);
```

`webhooks->deliveries->retry()` sends a delivery's original payload to the webhook again now; when the delivery cannot be retried, it throws a `ConflictException` whose `errorCode` says why.

### Responses
Expand Down
21 changes: 19 additions & 2 deletions src/Internal/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function paginate(string $class, string $key, string $label, array $path
if ($cursorParam === null) {
throw new \LogicException("{$key} is not cursor-paginated.");
}
$this->useTeamToken($label, $operation['auth']);
$this->useTeamToken($label, self::auth($key));
$this->path($operation['path'], $label, $path);

return $this->pages($class, $key, $label, $path, $query, $cursorParam);
Expand Down Expand Up @@ -235,7 +235,7 @@ private function hydrate(string $class, string $label, int $status, mixed $data,
private function send(string $key, string $label, array $path, array $query, ?array $json, ?string $idempotencyKey, ?string $auth): array
{
$operation = Operations::ALL[$key];
$useTeam = $this->useTeamToken($label, $auth ?? $operation['auth']);
$useTeam = $this->useTeamToken($label, $auth ?? self::auth($key));
$url = $this->baseUrl.$this->path($operation['path'], $label, $path);
$queryString = Query::serialize($query);
if ($queryString !== '') {
Expand Down Expand Up @@ -289,6 +289,23 @@ private function send(string $key, string $label, array $path, array $query, ?ar
return $this->decode($operation['response']['type'], $label, $response, $text);
}

/**
* The token that an operation of the generated table accepts. PHPStan does
* not keep the literal type of a constant array as large as the table, so
* the value is narrowed here.
*
* @return 'either'|'sending'|'team'
*/
private static function auth(string $key): string
{
return match (Operations::ALL[$key]['auth']) {
'either' => 'either',
'sending' => 'sending',
'team' => 'team',
default => throw new \LogicException("{$key} has an unknown auth value."),
};
}

/**
* @param 'either'|'sending'|'team' $auth
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ final class Team extends Resource
/** Team members. */
public readonly TeamMembers $members;

/** Pending team invitations. */
public readonly TeamInvites $invites;

/**
* @internal Use $lettermint->team.
*/
public function __construct(Transport $transport)
{
parent::__construct($transport);
$this->members = new TeamMembers($transport);
$this->invites = new TeamInvites($transport);
}

/**
Expand Down
76 changes: 76 additions & 0 deletions src/Resources/TeamInvites.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

declare(strict_types=1);

namespace Lettermint\Resources;

use Generator;
use Lettermint\Types\ListTeamInvitesResponse;
use Lettermint\Types\MessageResponse;
use Lettermint\Types\TeamInviteData;

/**
* Pending team invitations. Needs the team token.
*
* @phpstan-import-type ListTeamInvitesQuery from \Lettermint\Types\ApiTypes
* @phpstan-import-type CreateTeamInviteData from \Lettermint\Types\ApiTypes
* @phpstan-import-type UpdateTeamInviteData from \Lettermint\Types\ApiTypes
*/
final class TeamInvites extends Resource
{
/**
* Lists pending invitations, one page at a time.
*
* @param ListTeamInvitesQuery $query
*/
public function list(array $query = []): ListTeamInvitesResponse
{
return $this->transport->object(ListTeamInvitesResponse::class, 'GET /team/invites', 'team.invites.list', query: $query);
}

/**
* Iterates over every pending invitation, following `next_cursor`.
*
* @param ListTeamInvitesQuery $query
* @return Generator<int, TeamInviteData, mixed, void>
*/
public function iterate(array $query = []): Generator
{
return $this->transport->paginate(ListTeamInvitesResponse::class, 'GET /team/invites', 'team.invites.iterate', query: $query);
}

public function retrieve(string $inviteId): TeamInviteData
{
return $this->transport->object(TeamInviteData::class, 'GET /team/invites/{inviteId}', 'team.invites.retrieve', ['inviteId' => $inviteId]);
}

/**
* Invites a person to the team and sends the invitation email. The team
* needs a free seat; the Owner role cannot be assigned.
*
* @param CreateTeamInviteData $body
*/
public function create(array $body): TeamInviteData
{
return $this->transport->object(TeamInviteData::class, 'POST /team/invites', 'team.invites.create', json: $body);
}

/**
* Replaces the email, role and project access of a pending invitation. A
* new invitation email is sent only when the email address changes.
*
* @param UpdateTeamInviteData $body
*/
public function update(string $inviteId, array $body): TeamInviteData
{
return $this->transport->object(TeamInviteData::class, 'PUT /team/invites/{inviteId}', 'team.invites.update', ['inviteId' => $inviteId], json: $body);
}

/**
* Revokes a pending invitation.
*/
public function revoke(string $inviteId): MessageResponse
{
return $this->transport->object(MessageResponse::class, 'DELETE /team/invites/{inviteId}', 'team.invites.revoke', ['inviteId' => $inviteId]);
}
}
4 changes: 2 additions & 2 deletions src/Types/AnalyticsBreakdownRow.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsCatalogueDimension.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsCatalogueGroupDimension.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsComparison.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsComparisonValues.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsFilterOperator.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsInterval.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMeta.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetaAlignment.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetaCollectionCompleteness.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetaComparison.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetaTimeBasis.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetric.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetricChange.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsMetricValues.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsPagination.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsRateBase.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsRateBases.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsResponse.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
4 changes: 2 additions & 2 deletions src/Types/AnalyticsResults.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Generated by lettermint/sdk-generator — do not edit.
// Spec: lettermint/lettermint@6ef4036dede6326ad2200b945e689e319faf4c0a (main)
// Spec: lettermint/lettermint@a14a098fd3173b67bc366163127ee3715457cd59 (main)
// sending-openapi.json SHA-256: 8d5e962e57d79ab08be52147c094657b681768f06940a76c8eec1b1e03df54cc
// team-openapi.json SHA-256: 4ba5b65756faa9db79e5b95e06414899af0a6e97766eed04656c1b778f28aef7
// team-openapi.json SHA-256: da4398ead370c9b61eadb4007087a6da945df3c609801325fd38fc780cc0e707
// Naming profile: next

declare(strict_types=1);
Expand Down
Loading
Loading