Register post routes
This commit is contained in:
parent
0467120334
commit
9abdb56718
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Services\LodestoneApiService;
|
||||
use App\Services\LodestoneCacheService;
|
||||
use App\Services\LodestoneLinkingService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LodestoneLinkController extends Controller
|
||||
{
|
||||
@ -59,14 +60,43 @@ class LodestoneLinkController extends Controller
|
||||
return $this->lodestoneLinkingService->getLinkWebsite($lodestoneId, $hostname, $websiteUserId);
|
||||
}
|
||||
|
||||
public function linkDiscord(
|
||||
int $lodestoneId,
|
||||
int $discordUserId
|
||||
) {}
|
||||
public function linkDiscordName(
|
||||
string $server,
|
||||
string $name,
|
||||
int $discordUserId,
|
||||
Request $request
|
||||
) {
|
||||
$lodestoneId = $this->lodestoneCacheService->getCharacterByName($server, $name, $this->lodestoneApiService)->lodestoneId;
|
||||
|
||||
public function linkWebsite(
|
||||
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 $websiteId
|
||||
) {}
|
||||
int $websiteUserId,
|
||||
Request $request
|
||||
) {
|
||||
return $this->lodestoneLinkingService->validateLinkWebsite($lodestoneId, $hostname, $websiteUserId, $request->post('code'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,4 +95,18 @@ class LodestoneLinkingService
|
||||
'expires' => $linkCode->expires
|
||||
];
|
||||
}
|
||||
|
||||
public function validateLinkDiscord($lodestoneId, int $discordUserId, string $code)
|
||||
{
|
||||
return [
|
||||
'error' => 'Not yet implemented'
|
||||
];
|
||||
}
|
||||
|
||||
public function validateLinkWebsite($lodestoneId, string $hostname, int $websiteUserId, string $code)
|
||||
{
|
||||
return [
|
||||
'error' => 'Not yet implemented'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,10 @@ Route::prefix('api')->middleware(ApiAuthorization::class)->group(function() {
|
||||
Route::get('/check/id/{lodestoneId}/discord/{discordUserId}', 'LodestoneLinkController@checkDiscordId');
|
||||
Route::get('/check/id/{lodestoneId}/website/{hostname}/{websiteId}', 'LodestoneLinkController@checkWebsiteId');
|
||||
|
||||
Route::post('/{lodestoneId}/discord/{discordUserId}', 'LodestoneLinkController@linkDiscord');
|
||||
Route::post('/{lodestoneId}/website/{hostname}/{websiteId}', 'LodestoneLinkController@linkWebsite');
|
||||
Route::post('/id/{lodestoneId}/discord/{discordUserId}', 'LodestoneLinkController@linkDiscordId');
|
||||
Route::post('/id/{lodestoneId}/website/{hostname}/{websiteId}', 'LodestoneLinkController@linkWebsiteId');
|
||||
Route::post('/name/{server}/{name}/discord/{discordUserId}', 'LodestoneLinkController@linkDiscordName');
|
||||
Route::post('/name/{server}/{name}/website/{hostname}/{websiteId}', 'LodestoneLinkController@linkWebsiteName');
|
||||
});
|
||||
|
||||
Route::prefix('freeCompany')->group(function() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Controllers\LodestoneLinkController;
|
||||
use App\LinkCode;
|
||||
@ -24,32 +24,11 @@ class LodestoneLinkTest extends TestCase
|
||||
|
||||
private $discordUserId = 208258599565262848;
|
||||
|
||||
private $lodestoneLinkController;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$lodestoneCacheService = new LodestoneCacheService();
|
||||
$lodestoneApiService = new LodestoneApiService();
|
||||
$codeGeneratorService = new CodeGeneratorService();
|
||||
$lodestoneLinkingService = new LodestoneLinkingService(
|
||||
$codeGeneratorService,
|
||||
$lodestoneCacheService,
|
||||
$lodestoneApiService
|
||||
);
|
||||
|
||||
$this->lodestoneLinkController = new LodestoneLinkController(
|
||||
$lodestoneLinkingService,
|
||||
$lodestoneCacheService,
|
||||
$lodestoneApiService
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLinkCodeByDiscordAndId()
|
||||
{
|
||||
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||
|
||||
$response = $this->lodestoneLinkController->checkDiscordId($this->lodestoneId, $this->discordUserId);
|
||||
$response = $this->get('/api/v1/lodestone/link/check/id/'.$this->lodestoneId.'/discord/'.$this->discordUserId);
|
||||
|
||||
$this->assertDatabaseHas('link_codes', [
|
||||
'lodestoneId' => $this->lodestoneId,
|
||||
@ -61,7 +40,7 @@ class LodestoneLinkTest extends TestCase
|
||||
{
|
||||
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||
|
||||
$response = $this->lodestoneLinkController->checkDiscordName($this->server, $this->name, $this->discordUserId);
|
||||
$response = $this->get('/api/v1/lodestone/link/check/name/'.$this->server.'/'.$this->name.'/discord/'.$this->discordUserId);
|
||||
|
||||
$this->assertDatabaseHas('link_codes', [
|
||||
'lodestoneId' => $this->lodestoneId,
|
||||
@ -73,7 +52,7 @@ class LodestoneLinkTest extends TestCase
|
||||
{
|
||||
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||
|
||||
$response = $this->lodestoneLinkController->checkWebsiteId($this->lodestoneId, $this->websiteName, $this->websiteId);
|
||||
$response = $this->get('/api/v1/lodestone/link/check/id/'.$this->lodestoneId.'/website/'.$this->websiteName.'/'.$this->websiteId);
|
||||
|
||||
$this->assertDatabaseHas('link_codes', [
|
||||
'lodestoneId' => $this->lodestoneId,
|
||||
@ -85,7 +64,7 @@ class LodestoneLinkTest extends TestCase
|
||||
{
|
||||
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||
|
||||
$response = $this->lodestoneLinkController->checkWebsiteName($this->server, $this->name, $this->websiteName, $this->websiteId);
|
||||
$response = $this->get('/api/v1/lodestone/link/check/name/'.$this->server.'/'.$this->name.'/website/'.$this->websiteName.'/'.$this->websiteId);
|
||||
|
||||
$this->assertDatabaseHas('link_codes', [
|
||||
'lodestoneId' => $this->lodestoneId,
|
||||
Loading…
Reference in New Issue
Block a user