FFXIV_Lodestone_Handler/app/Http/Controllers/LodestoneLinkController.php
2020-08-29 18:08:16 +02:00

103 lines
3.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Services\LodestoneApiService;
use App\Services\LodestoneCacheService;
use App\Services\LodestoneLinkingService;
use Illuminate\Http\Request;
class LodestoneLinkController extends Controller
{
private $lodestoneLinkingService;
private $lodestoneCacheService;
private $lodestoneApiService;
public function __construct(
LodestoneLinkingService $lodestoneLinkingService,
LodestoneCacheService $lodestoneCacheService,
LodestoneApiService $lodestoneApiService
)
{
$this->lodestoneLinkingService = $lodestoneLinkingService;
$this->lodestoneCacheService = $lodestoneCacheService;
$this->lodestoneApiService = $lodestoneApiService;
}
public function checkDiscordName(
string $server,
string $name,
int $discordUserId
) {
$lodestoneId = $this->lodestoneCacheService->getCharacterByName($server, $name, $this->lodestoneApiService)->lodestoneId;
return $this->lodestoneLinkingService->getLinkDiscord($lodestoneId, $discordUserId);
}
public function checkDiscordId(
int $lodestoneId,
int $discordUserId
) {
return $this->lodestoneLinkingService->getLinkDiscord($lodestoneId, $discordUserId);
}
public function checkWebsiteName(
string $server,
string $name,
string $hostname,
int $websiteUserId
) {
$lodestoneId = $this->lodestoneCacheService->getCharacterByName($server, $name, $this->lodestoneApiService)->lodestoneId;
return $this->lodestoneLinkingService->getLinkWebsite($lodestoneId, $hostname, $websiteUserId);
}
public function checkWebsiteId(
int $lodestoneId,
string $hostname,
int $websiteUserId
) {
return $this->lodestoneLinkingService->getLinkWebsite($lodestoneId, $hostname, $websiteUserId);
}
public function linkDiscordName(
string $server,
string $name,
int $discordUserId,
Request $request
) {
$lodestoneId = $this->lodestoneCacheService->getCharacterByName($server, $name, $this->lodestoneApiService)->lodestoneId;
return $this->lodestoneLinkingService->validateLinkDiscord($lodestoneId, $discordUserId, $request->post('code'));
}
public function linkDiscordId(
int $lodestoneId,
int $discordUserId,
Request $request
) {
return $this->lodestoneLinkingService->validateLinkDiscord($lodestoneId, $discordUserId, $request->post('code'));
}
public function linkWebsiteName(
string $server,
string $name,
string $hostname,
int $websiteUserId,
Request $request
) {
$lodestoneId = $this->lodestoneCacheService->getCharacterByName($server, $name, $this->lodestoneApiService)->lodestoneId;
return $this->lodestoneLinkingService->validateLinkWebsite($lodestoneId, $hostname, $websiteUserId, $request->post('code'));
}
public function linkWebsiteId(
int $lodestoneId,
string $hostname,
int $websiteUserId,
Request $request
) {
return $this->lodestoneLinkingService->validateLinkWebsite($lodestoneId, $hostname, $websiteUserId, $request->post('code'));
}
}