Skip to content

Commit

Permalink
Updated doco
Browse files Browse the repository at this point in the history
  • Loading branch information
ok200paul committed Aug 19, 2024
1 parent 5228745 commit e6de001
Show file tree
Hide file tree
Showing 2 changed files with 347 additions and 1,544 deletions.
61 changes: 18 additions & 43 deletions app/Http/Controllers/Api/V1/ApiShopsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,9 @@ class ApiShopsController extends Controller
public static array $searchableFields = [
];

#[Endpoint(
title: 'GET /',
authenticated: true
)]
#[Authenticated]
#[Response(
status: 403,
description: 'Method Not Allowed',
)]
/**
* @hideFromAPIDocumentation
*/
public function index(): JsonResponse
{
$this->responseCode = 403;
Expand Down Expand Up @@ -99,7 +93,7 @@ public function store(): JsonResponse

$shopTeam = Team::where('name', $shopName)->first();

if (is_null($shopTeam)) {
if (!$shopTeam) {
$shopTeam = new Team();
$shopTeam->name = $shopName;
$shopTeam->save();
Expand All @@ -112,7 +106,7 @@ public function store(): JsonResponse

$shopUser = User::where('email', $userEmail)->first();

if (is_null($shopUser)) {
if (!$shopUser) {
$shopUser = new User();
$shopUser->email = $userEmail;
$shopUser->password = $userEmail;
Expand All @@ -126,7 +120,7 @@ public function store(): JsonResponse
*/
$shopTeamUser = TeamUser::where('team_id', $shopTeam->id)->where('user_id', $shopUser->id)->first();

if (is_null($shopTeamUser)) {
if (!$shopTeamUser) {
$shopTeamUser = new TeamUser();
$shopTeamUser->user_id = $shopUser->id;
$shopTeamUser->team_id = $shopTeam->id;
Expand All @@ -142,7 +136,9 @@ public function store(): JsonResponse
);

$this->message = ApiResponse::RESPONSE_SAVED->value . '. Here is the API Token for the user linked to this new team. It will only be displayed ONCE, so please store it in a secure manner.';
$this->data = $token->plainTextToken;
$this->data = [
'token' => $token->plainTextToken
];

}
catch (Exception $e) {
Expand All @@ -155,16 +151,9 @@ public function store(): JsonResponse
return $this->respond();
}

#[Endpoint(
title: 'GET /{id}',
description: 'Get shop with ID {id}',
authenticated: true
)]
#[Authenticated]
#[Response(
status: 403,
description: 'Method Not Allowed',
)]
/**
* @hideFromAPIDocumentation
*/
public function show(int $id)
{
$this->responseCode = 403;
Expand All @@ -173,16 +162,9 @@ public function show(int $id)
return $this->respond();
}

#[Endpoint(
title: 'PUT /{id}',
description: 'Update shop with ID {id}.',
authenticated: true
)]
#[Authenticated]
#[Response(
status: 403,
description: 'Method Not Allowed',
)]
/**
* @hideFromAPIDocumentation
*/
public function update(string $id)
{
$this->responseCode = 403;
Expand All @@ -191,16 +173,9 @@ public function update(string $id)
return $this->respond();
}

#[Endpoint(
title: 'DELETE /',
description: 'DELETE shop with ID {id}.',
authenticated: true
)]
#[Authenticated]
#[Response(
status: 403,
description: 'Method Not Allowed',
)]
/**
* @hideFromAPIDocumentation
*/
public function destroy(string $id)
{
$this->responseCode = 403;
Expand Down
Loading

0 comments on commit e6de001

Please sign in to comment.