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
4 changes: 2 additions & 2 deletions src/Rest/ApplicationRoleConnectionMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApplicationRoleConnectionMetadata extends HttpResource
/**
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
*
* @return PromiseInterface<\Tempcord\Discord\Parts\ApplicationRoleConnectionMetadata>
* @return PromiseInterface<\Tempcord\Discord\Parts\ApplicationRoleConnectionMetadata[]>
*/
public function getRecords(string $applicationId): PromiseInterface
{
Expand All @@ -34,7 +34,7 @@ public function getRecords(string $applicationId): PromiseInterface
/**
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
*
* @return PromiseInterface<\Tempcord\Discord\Parts\ApplicationRoleConnectionMetadata>
* @return PromiseInterface<\Tempcord\Discord\Parts\ApplicationRoleConnectionMetadata[]>
*/
public function updateRecords(string $applicationId, array $params): PromiseInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rest/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function editChannelPermissions(
/**
* @see https://discord.com/developers/docs/resources/invite#invite-object
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Invite>
* @return PromiseInterface<\Tempcord\Discord\Parts\Invite[]>
*/
public function getChannelInvites(string $channelId): PromiseInterface
{
Expand Down
8 changes: 4 additions & 4 deletions src/Rest/Guild.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public function getBans(string $guildId): PromiseInterface
/**
* @see https://discord.com/developers/docs/resources/guild#get-guild-ban
*
* @return PromiseInterface<\Tempcord\Discord\Parts\GuildBan[]>
* @return PromiseInterface<\Tempcord\Discord\Parts\GuildBan>
*/
public function getBan(string $guildId, string $userId): PromiseInterface
{
Expand Down Expand Up @@ -659,7 +659,7 @@ public function beginPrune(string $guildId, array $params, ?string $reason = nul
/**
* @see https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
*
* @return PromiseInterface<\Tempcord\Discord\Parts\VoiceRegion>
* @return PromiseInterface<\Tempcord\Discord\Parts\VoiceRegion[]>
*/
public function getVoiceRegions(string $guildId): PromiseInterface
{
Expand Down Expand Up @@ -714,7 +714,7 @@ public function getUserVoiceState(string $guildId, string $userId): PromiseInter
/**
* @see https://discord.com/developers/docs/resources/guild#get-guild-invites
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Invite>
* @return PromiseInterface<\Tempcord\Discord\Parts\Invite[]>
*/
public function getInvites(string $guildId): PromiseInterface
{
Expand All @@ -732,7 +732,7 @@ public function getInvites(string $guildId): PromiseInterface
/**
* @see https://discord.com/developers/docs/resources/guild#get-guild-integrations
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Integration>
* @return PromiseInterface<\Tempcord\Discord\Parts\Integration[]>
*/
public function getIntegrations(string $guildId): PromiseInterface
{
Expand Down
6 changes: 3 additions & 3 deletions src/Rest/GuildScheduledEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function get(string $guildId, string $scheduledEventId, bool $withUserCou
$endpoint = Endpoint::bind(Endpoint::GUILD_SCHEDULED_EVENT, $guildId, $scheduledEventId);
$endpoint->addQuery('with_user_count', $withUserCount);

return $this->mapArrayPromise(
return $this->mapPromise(
$this->http->get(
$endpoint
),
Expand All @@ -54,7 +54,7 @@ public function get(string $guildId, string $scheduledEventId, bool $withUserCou
*/
public function create(string $guildId, array $params, ?string $reason = null): PromiseInterface
{
return $this->mapArrayPromise(
return $this->mapPromise(
$this->http->post(
Endpoint::bind(Endpoint::GUILD_SCHEDULED_EVENTS, $guildId),
$params,
Expand All @@ -70,7 +70,7 @@ public function create(string $guildId, array $params, ?string $reason = null):
*/
public function modify(string $guildId, string $scheduledEventId, array $params, ?string $reason = null): PromiseInterface
{
return $this->mapArrayPromise(
return $this->mapPromise(
$this->http->patch(
Endpoint::bind(Endpoint::GUILD_SCHEDULED_EVENT, $guildId, $scheduledEventId),
$params,
Expand Down
2 changes: 1 addition & 1 deletion src/Rest/GuildTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GuildTemplate extends HttpResource
{
/**
* @see https://discord.com/developers/docs/resources/guild-template#get-guild-templates
* @return PromiseInterface<\Tempcord\Discord\Parts\GuildTemplate>
* @return PromiseInterface<\Tempcord\Discord\Parts\GuildTemplate[]>
*/
public function list(string $guildId): PromiseInterface
{
Expand Down
8 changes: 4 additions & 4 deletions src/Rest/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function getGuildWebhooks(string $guildId)
/**
* @see https://discord.com/developers/docs/resources/webhook#get-webhook
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook[]>
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook>
*/
public function get(string $webhookId)
{
Expand All @@ -171,7 +171,7 @@ public function get(string $webhookId)
/**
* @see https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook[]>
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook>
*/
public function getWithToken(string $webhookId, string $token)
{
Expand All @@ -190,7 +190,7 @@ public function getWithToken(string $webhookId, string $token)
/**
* @see https://discord.com/developers/docs/resources/webhook#modify-webhook
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook[]>
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook>
*/
public function modify(string $webhookId, ModifyWebhookBuilder $builder, ?string $reason = null): PromiseInterface
{
Expand All @@ -210,7 +210,7 @@ public function modify(string $webhookId, ModifyWebhookBuilder $builder, ?string
/**
* @see https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
*
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook[]>
* @return PromiseInterface<\Tempcord\Discord\Parts\Webhook>
*/
public function modifyWithToken(string $webhookId, string $token, ModifyWebhookBuilder $builder, ?string $reason = null): PromiseInterface
{
Expand Down
92 changes: 92 additions & 0 deletions tests/Rest/GuildScheduledEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

namespace Tests\Tempcord\Discord\Rest;

use Tempcord\Discord\Parts\GuildScheduledEvent;
use Tempcord\Discord\Parts\GuildScheduledEventUser;
use Tempcord\Discord\Rest\GuildScheduledEvent as RestGuildScheduledEvent;

class GuildScheduledEventTest extends HttpHelperTestCase
{
protected string $httpItemClass = RestGuildScheduledEvent::class;

public static function httpBindingsProvider(): array
{
return [
'List scheduled events' => [
'method' => 'list',
'args' => ['::guild id::'],
'mockOptions' => [
'method' => 'get',
'return' => [(object) [], (object) []],
],
'validationOptions' => [
'returnType' => GuildScheduledEvent::class,
'array' => true,
'url' => 'guilds/::guild id::/scheduled-events?with_user_count=0',
]
],
/*
* These three answer with one event, not a list of them. Mapping
* the answer as an array handed a stdClass to a parameter declared
* array, so every call died on a TypeError before it could return.
*/
'Get scheduled event' => [
'method' => 'get',
'args' => ['::guild id::', '::event id::'],
'mockOptions' => [
'method' => 'get',
'return' => (object) ['id' => '::event id::'],
],
'validationOptions' => [
'returnType' => GuildScheduledEvent::class,
]
],
'Create scheduled event' => [
'method' => 'create',
'args' => ['::guild id::', ['name' => '::name::']],
'mockOptions' => [
'method' => 'post',
'return' => (object) ['id' => '::event id::'],
],
'validationOptions' => [
'returnType' => GuildScheduledEvent::class,
]
],
'Modify scheduled event' => [
'method' => 'modify',
'args' => ['::guild id::', '::event id::', ['name' => '::name::']],
'mockOptions' => [
'method' => 'patch',
'return' => (object) ['id' => '::event id::'],
],
'validationOptions' => [
'returnType' => GuildScheduledEvent::class,
]
],
'Delete scheduled event' => [
'method' => 'delete',
'args' => ['::guild id::', '::event id::'],
'mockOptions' => [
'method' => 'delete',
'return' => null,
],
'validationOptions' => []
],
'Get scheduled event users' => [
'method' => 'getUsers',
'args' => ['::guild id::', '::event id::'],
'mockOptions' => [
'method' => 'get',
'return' => [(object) [], (object) []],
],
'validationOptions' => [
'returnType' => GuildScheduledEventUser::class,
'array' => true,
]
],
];
}
}