<?php
declare(strict_types=1);
namespace App\Controller\Api\Society;
use App\Controller\Api\Society\Shared\Game\SharedNextGameEndpoint;
use App\Controller\Api\Society\Auth\Service\FirebaseTokenInvalidException;
use App\Controller\Api\Society\Auth\Service\LogoutSessionEndpoint;
use App\Controller\Api\Society\Auth\Service\NextApiSessionException;
use App\Controller\Api\Society\Auth\Service\RefreshTokenEndpoint;
use App\Controller\Api\Society\Auth\Service\RegisterConfirmEndpoint;
use App\Controller\Api\Society\Auth\Service\SearchPlayerByLicenseEndpoint;
use App\Controller\Api\Society\Auth\Service\SessionStateEndpoint;
use App\Controller\Api\Society\Auth\Service\SocietyPhoneChangeService;
use App\Controller\Api\Society\Auth\Service\SocietyAuthV2Service;
use App\Controller\Api\Society\Auth\Service\SocietyV2RegistrationEndpoint;
use App\Controller\Api\Society\Auth\Service\UnregisterAccountEndpoint;
use App\Controller\Api\Society\Card\Service\ECardEndpoint;
use App\Controller\Api\Society\Card\Service\CardMarkedCandidatesEndpoint;
use App\Controller\Api\Society\Card\Service\CreateCardMarkedAssignmentEndpoint;
use App\Controller\Api\Society\Card\Service\LogResultEndpoint;
use App\Controller\Api\Society\Card\Service\SaveCardResultsEndpoint;
use App\Controller\Api\Society\Card\Service\SubmitCardEndpoint;
use App\Controller\Api\Society\Classification\Service\ClassificationDetailEndpoint;
use App\Controller\Api\Society\Classification\Service\ClassificationListEndpoint;
use App\Controller\Api\Society\Classification\Service\NextcaddyClassificationDetailEndpoint;
use App\Controller\Api\Society\Classification\Service\NextcaddyClassificationListEndpoint;
use App\Controller\Api\Society\Classified\Service\ClassifiedResultsEndpoint;
use App\Controller\Api\Society\Classified\Service\NextcaddyClassifiedResultsEndpoint;
use App\Controller\Api\Society\Booking\Service\CancelBookingEndpoint;
use App\Controller\Api\Society\Booking\Service\ConfirmBookingEndpoint;
use App\Controller\Api\Society\Booking\Service\CreateBookingEndpoint;
use App\Controller\Api\Society\Booking\Service\CreatePaymentSessionEndpoint;
use App\Controller\Api\Society\Booking\Service\GetBookingEndpoint;
use App\Controller\Api\Society\Booking\Service\ListBookingsEndpoint;
use App\Controller\Api\Society\Booking\Service\PreviewBookingCancellationEndpoint;
use App\Controller\Api\Society\Booking\Service\SearchBookableClubsEndpoint;
use App\Controller\Api\Society\Booking\Service\SearchBookingAvailabilityEndpoint;
use App\Controller\Api\Society\Booking\Service\SearchBookingsEndpoint;
use App\Controller\Api\Society\Club\Service\ClubListEndpoint;
use App\Controller\Api\Society\Competitions\Service\AvailableInscriptionsEndpoint;
use App\Controller\Api\Society\Competitions\Service\CompetitionScorecardEndpoint;
use App\Controller\Api\Society\Competitions\Service\CompetitionShowEndpoint;
use App\Controller\Api\Society\Competitions\Service\CreateRfcCompetitionEndpoint;
use App\Controller\Api\Society\Competitions\Service\SendRfcCardsEndpoint;
use App\Controller\Api\Society\Competitions\Service\FutureCompetitionsEndpoint as NextcaddyFutureCompetitionsEndpoint;
use App\Controller\Api\Society\Competitions\Service\PlayedCompetitionsEndpoint as NextcaddyPlayedCompetitionsEndpoint;
use App\Controller\Api\Society\Contact\Service\CreateContactMessageEndpoint;
use App\Controller\Api\Society\Course\Service\CoursesByClubEndpoint;
use App\Controller\Api\Society\Course\Service\CourseTeesByCourseEndpoint;
use App\Controller\Api\Society\Feed\Service\CreateFeedCommentEndpoint;
use App\Controller\Api\Society\Feed\Service\CreateFeedPostEndpoint;
use App\Controller\Api\Society\Feed\Service\DeleteFeedCommentEndpoint;
use App\Controller\Api\Society\Feed\Service\DeleteFeedPostEndpoint;
use App\Controller\Api\Society\Feed\Service\FeedCommentRepliesEndpoint;
use App\Controller\Api\Society\Feed\Service\FeedCommentsListEndpoint;
use App\Controller\Api\Society\Feed\Service\FeedListEndpoint;
use App\Controller\Api\Society\Feed\Service\FeedPostDetailEndpoint;
use App\Controller\Api\Society\Feed\Service\UpdateFeedCommentEndpoint;
use App\Controller\Api\Society\Feed\Service\UpdateFeedPostEndpoint;
use App\Controller\Api\Society\Feed\Service\UserFeedListEndpoint;
use App\Controller\Api\Society\Follow\Service\AcceptFollowRequestEndpoint;
use App\Controller\Api\Society\Follow\Service\BlockedUsersListEndpoint;
use App\Controller\Api\Society\Follow\Service\BlockFollowUserEndpoint;
use App\Controller\Api\Society\Follow\Service\CancelFollowRequestEndpoint;
use App\Controller\Api\Society\Follow\Service\DiscoverFollowUsersEndpoint;
use App\Controller\Api\Society\Follow\Service\FollowersListEndpoint;
use App\Controller\Api\Society\Follow\Service\FollowingListEndpoint;
use App\Controller\Api\Society\Follow\Service\FollowingPlayingTodayEndpoint;
use App\Controller\Api\Society\Follow\Service\FollowUserEndpoint;
use App\Controller\Api\Society\Follow\Service\FriendsListEndpoint;
use App\Controller\Api\Society\Follow\Service\PendingReceivedFollowRequestsEndpoint;
use App\Controller\Api\Society\Follow\Service\PendingSentFollowRequestsEndpoint;
use App\Controller\Api\Society\Follow\Service\RejectFollowRequestEndpoint;
use App\Controller\Api\Society\Follow\Service\RemoveFollowerEndpoint;
use App\Controller\Api\Society\Follow\Service\UnblockFollowUserEndpoint;
use App\Controller\Api\Society\Follow\Service\UnfollowUserEndpoint;
use App\Controller\Api\Society\Shared\Exception\ApiEndpointException;
use App\Controller\Api\Society\Shared\Logging\SocietyExceptionLogger;
use App\Controller\Api\Society\Match\Service\MatchLivescoringEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyAvailableFriendsEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyByCodeEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyClosestEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyCreateEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyDeleteEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyDetailEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyEditEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyInscriptionEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyListEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyLivescoringEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlyParticipantHandicapsRefreshEndpoint;
use App\Controller\Api\Society\Friendly\Service\FriendlySlotsAvailableEndpoint;
use App\Controller\Api\Society\Match\Service\ReadMatchResults;
use App\Controller\Api\Society\Notification\Service\DeleteAllNotificationsEndpoint;
use App\Controller\Api\Society\Notification\Service\DeleteNotificationEndpoint;
use App\Controller\Api\Society\Notification\Service\GetUnreadNotificationCountEndpoint;
use App\Controller\Api\Society\Notification\Service\ListNotificationHistoryEndpoint;
use App\Controller\Api\Society\Notification\Service\MarkAllNotificationsReadEndpoint;
use App\Controller\Api\Society\Notification\Service\MarkNotificationReadByDispatchEndpoint;
use App\Controller\Api\Society\Notification\Service\MarkNotificationReadEndpoint;
use App\Controller\Api\Society\Notification\Service\RegisterNotificationDeviceEndpoint;
use App\Controller\Api\Society\Notification\Service\UnregisterNotificationDeviceEndpoint;
use App\Controller\Api\Society\Notification\Service\GetNotificationPreferencesEndpoint;
use App\Controller\Api\Society\Notification\Service\UpdateNotificationPreferencesEndpoint;
use App\Controller\Api\Society\General\Service\FormatsByModalityEndpoint;
use App\Controller\Api\Society\Info\Service\SocietyAppInfoData;
use App\Controller\Api\Society\InformationPanel\Service\InformationPanelEndpoint;
use App\Controller\Api\Society\Participant\Service\DeleteParticipantEndpoint;
use App\Controller\Api\Society\ProAm\Service\GetProAmConfigEndpoint;
use App\Controller\Api\Society\ProAm\Service\ProAmProfessionalEndpoint;
use App\Controller\Api\Society\ProAm\Service\UpdateProAmConfigEndpoint;
use App\Controller\Api\Society\Profile\Service\PlayerCoursePlayingHandicapsEndpoint;
use App\Controller\Api\Society\Profile\Service\RfegHandicapRoundsEndpoint;
use App\Controller\Api\Society\Profile\Service\UserHandicapRefreshEndpoint;
use App\Controller\Api\Society\Profile\Service\UserProfileDetailEndpoint;
use App\Controller\Api\Society\Profile\Service\UserProfileInfoEndpoint;
use App\Controller\Api\Society\Profile\Service\UserProfileUpdateEndpoint;
use App\Controller\Api\Society\Profile\Service\SocietyV2ProfileLifecycleEndpoint;
use App\Controller\Api\Society\Player\Service\PlayerLicenseCourseTeesEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingByDataEndpoint;
use App\Controller\Api\Society\Ranking\Service\PlayerVisibleRankingsEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingClassifiedNxtDetailEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingDetailEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingLeaderboardEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingNxtDetailEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingUserDetailEndpoint;
use App\Controller\Api\Society\Ranking\Service\RankingsSharedEndpoint;
use App\Controller\Api\Society\Ranking\Service\UserRankingsEndpoint;
use App\Controller\Api\Society\Round\Service\FinalizeRoundEndpoint;
use App\Controller\Api\Society\Schedule\Service\AddScheduleGroupPlayerEndpoint;
use App\Controller\Api\Society\Schedule\Service\CreateScheduleEndpoint;
use App\Controller\Api\Society\Schedule\Service\CreateScheduleGroupEndpoint;
use App\Controller\Api\Society\Schedule\Service\CreateScheduleLayoutEndpoint;
use App\Controller\Api\Society\Schedule\Service\DeleteScheduleEndpoint;
use App\Controller\Api\Society\Schedule\Service\DeleteScheduleGroupEndpoint;
use App\Controller\Api\Society\Schedule\Service\DeleteScheduleGroupPlayerEndpoint;
use App\Controller\Api\Society\Schedule\Service\ListSchedulesEndpoint;
use App\Controller\Api\Society\Schedule\Service\MoveScheduleGroupPlayerEndpoint;
use App\Controller\Api\Society\Schedule\Service\PublishScheduleEndpoint;
use App\Controller\Api\Society\Schedule\Service\SaveScheduleLayoutEndpoint;
use App\Controller\Api\Society\Schedule\Service\ScheduleDetailEndpoint;
use App\Controller\Api\Society\Schedule\Service\ScheduleShowEndpoint;
use App\Controller\Api\Society\Schedule\Service\UnpublishScheduleEndpoint;
use App\Controller\Api\Society\Schedule\Service\UpdateScheduleGroupEndpoint;
use App\Controller\Api\Society\Shared\Response\SocietyErrorMessageTranslator;
use App\Controller\Api\Society\Shared\Service\FutureCompetitionsEndpoint;
use App\Controller\Api\Society\Shared\Service\OpenInscriptionCompetitionsEndpoint;
use App\Controller\Api\Society\Shared\Service\PlayedCompetitionsEndpoint;
use App\Controller\Api\Society\Shared\Service\SearchCompetitionsEndpoint;
use App\Controller\Api\Society\Shared\Service\UserCompetitionsEndpoint;
use App\Controller\Api\Society\Statistics\Service\CompetitionsByClubStatsEndpoint;
use App\Controller\Api\Society\Statistics\Service\HcpEvolutionEndpoint;
use App\Controller\Api\Society\Statistics\Service\PlayedResultsStatsEndpoint;
use App\Controller\Api\Society\Statistics\Service\StatisticsEndpoint;
use App\Controller\Api\Society\User\Service\DeleteSocietyUserEndpoint;
use App\Repository\Society\UserRepository as SocietyUserRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/next-api/society")
*/
final class SocietyApiController extends AbstractController
{
public function __construct(
private readonly SocietyErrorMessageTranslator $societyErrorMessageTranslator,
private readonly SocietyExceptionLogger $societyExceptionLogger
)
{
}
/**
* @Route("/me", name="next_api_society_me", methods={"GET"})
*/
public function me(Request $request): JsonResponse
{
try {
$response = [
'userId' => (int)$request->attributes->get('resolvedUserId', 0),
'playerId' => (int)$request->attributes->get('resolvedPlayerId', 0),
'societyUserId' => (int)$request->attributes->get('resolvedSocietyUserId', 0),
'societyNxtUserId' => (int)$request->attributes->get('resolvedSocietyNxtUserId', 0),
'player' => $request->attributes->get('resolvedPlayer'),
];
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/me", name="next_api_society_me_delete", methods={"DELETE"})
*/
public function deleteMe(Request $request, DeleteSocietyUserEndpoint $deleteSocietyUserEndpoint): JsonResponse
{
try {
$response = $deleteSocietyUserEndpoint->__invoke(
(int)$request->attributes->get('resolvedSocietyUserId', 0),
(string)$request->attributes->get('firebaseUserId', ''),
(string)$request->attributes->get('phoneFromToken', '')
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/info", name="next_api_society_app_info", methods={"GET"})
*/
public function appInfo(SocietyAppInfoData $societyAppInfoData): Response
{
try {
$viewData = $societyAppInfoData->__invoke();
} catch (\RuntimeException $exception) {
return new Response($exception->getMessage(), Response::HTTP_NOT_FOUND);
}
return $this->render('api/nextcaddy_app/info.html.twig', $viewData);
}
/**
* @Route("/auth/token/generate", name="next_api_society_auth_token_generate", methods={"GET"})
*/
public function generateToken(): JsonResponse
{
return new JsonResponse([
'error' => 'auth-v2-required',
'message' => 'Update the app to use Play authentication v2.',
], Response::HTTP_GONE);
}
/**
* @Route("/auth/token/refresh", name="next_api_society_auth_token_refresh", methods={"POST"})
*/
public function refreshToken(Request $request, RefreshTokenEndpoint $refreshTokenEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $refreshTokenEndpoint->__invoke($payload));
}
/**
* @Route("/auth/session/state", name="next_api_society_auth_session_state", methods={"GET"})
*/
public function sessionState(Request $request, SessionStateEndpoint $sessionStateEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $sessionStateEndpoint->__invoke(
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', '')
));
}
/** @Route("/auth/v2/accounts", name="next_api_society_auth_v2_accounts", methods={"GET"}) */
public function societyAuthV2Accounts(Request $request, SocietyAuthV2Service $service): JsonResponse|Response
{
$claims = (array) $request->attributes->get('firebaseTokenClaims', []);
return $this->runSocietyJsonEndpoint(fn(): array => $service->accounts(
(string) ($claims['aud'] ?? ''),
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', '')
));
}
/** @Route("/auth/v2/sessions", name="next_api_society_auth_v2_session_create", methods={"POST"}) */
public function createSocietyAuthV2Session(Request $request, SocietyAuthV2Service $service): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$nxtUserId = filter_var($payload['nxtUserId'] ?? null, FILTER_VALIDATE_INT);
$playerId = filter_var($payload['playerId'] ?? null, FILTER_VALIDATE_INT);
if (false === $nxtUserId || false === $playerId || $nxtUserId <= 0 || $playerId <= 0) {
return $this->societyErrorResponse('invalid-request', Response::HTTP_BAD_REQUEST, 'The "nxtUserId" and "playerId" fields are required.');
}
$claims = (array) $request->attributes->get('firebaseTokenClaims', []);
return $this->runSocietyJsonEndpoint(fn(): array => $service->createSession(
(string) ($claims['aud'] ?? ''),
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', ''),
(int) $nxtUserId,
(int) $playerId
));
}
/** @Route("/auth/v2/sessions/current", name="next_api_society_auth_v2_session_current", methods={"GET"}) */
public function currentSocietyAuthV2Session(Request $request, SocietyAuthV2Service $service): JsonResponse|Response
{
$token = (string) $request->attributes->get('societyV2Token', '');
return $this->runSocietyJsonEndpoint(fn(): array => $service->current($token));
}
/** @Route("/auth/v2/sessions/refresh", name="next_api_society_auth_v2_session_refresh", methods={"POST"}) */
public function refreshSocietyAuthV2Session(Request $request, SocietyAuthV2Service $service): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $service->refresh((string) ($payload['refreshToken'] ?? '')));
}
/** @Route("/auth/v2/sessions/logout", name="next_api_society_auth_v2_session_logout", methods={"POST"}) */
public function logoutSocietyAuthV2Session(Request $request, SocietyAuthV2Service $service): JsonResponse|Response
{
$token = (string) $request->attributes->get('societyV2Token', '');
return $this->runSocietyJsonEndpoint(fn(): array => $service->logout($token));
}
/** @Route("/auth/v2/registration/verify", name="next_api_society_auth_v2_registration_verify", methods={"POST"}) */
public function verifySocietyAuthV2Registration(Request $request, SocietyV2RegistrationEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$claims = (array) $request->attributes->get('firebaseTokenClaims', []);
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->verify(
(string) ($claims['aud'] ?? ''),
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', ''),
$payload
));
}
/** @Route("/auth/v2/registration/confirm", name="next_api_society_auth_v2_registration_confirm", methods={"POST"}) */
public function confirmSocietyAuthV2Registration(Request $request, SocietyV2RegistrationEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->confirm($payload));
}
/** @Route("/auth/v2/phone-changes", name="next_api_society_phone_change", methods={"POST"}) */
public function beginSocietyPhoneChange(Request $request, SocietyPhoneChangeService $service): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $service->begin(
(array) $request->attributes->get('societyV2Context', []),
(string) ($payload['phone'] ?? ''),
(string) ($payload['phoneCountry'] ?? 'es')
));
}
/** @Route("/auth/v2/phone-changes/confirm", name="next_api_society_phone_change_confirm", methods={"POST"}) */
public function confirmSocietyPhoneChange(Request $request, SocietyPhoneChangeService $service): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $service->confirm(
(string) ($payload['changeToken'] ?? ''),
(string) ($payload['firebaseToken'] ?? '')
));
}
/** @Route("/auth/v2/profile/contact", name="next_api_society_auth_v2_profile_contact", methods={"PATCH"}) */
public function updateSocietyAuthV2ProfileContact(Request $request, SocietyV2ProfileLifecycleEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->updateContact(
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedPlayerId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$payload
));
}
/** @Route("/auth/v2/profile", name="next_api_society_auth_v2_profile_delete", methods={"DELETE"}) */
public function unlinkSocietyAuthV2Profile(Request $request, SocietyV2ProfileLifecycleEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->unlink(
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedPlayerId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/auth/session/search-license", name="next_api_society_auth_session_search_license", methods={"POST"})
*/
public function searchPlayerByLicense(Request $request, SearchPlayerByLicenseEndpoint $searchPlayerByLicenseEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $searchPlayerByLicenseEndpoint->__invoke($payload));
}
/**
* @Route("/auth/session/register-confirm", name="next_api_society_auth_session_register_confirm", methods={"POST"})
*/
public function registerConfirm(Request $request, RegisterConfirmEndpoint $registerConfirmEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $registerConfirmEndpoint->__invoke(
$payload,
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', '')
));
}
/**
* @Route("/auth/session/logout", name="next_api_society_auth_session_logout", methods={"POST"})
*/
public function logoutSession(Request $request, LogoutSessionEndpoint $logoutSessionEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $logoutSessionEndpoint->__invoke(
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', '')
));
}
/**
* @Route("/auth/session/unregister", name="next_api_society_auth_session_unregister", methods={"POST"})
*/
public function unregisterAccount(Request $request, UnregisterAccountEndpoint $unregisterAccountEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $unregisterAccountEndpoint->__invoke(
(string) $request->attributes->get('firebaseUserId', ''),
(string) $request->attributes->get('phoneFromToken', ''),
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/notifications/devices/register", name="next_api_society_notification_device_register", methods={"POST"})
*/
public function registerNotificationDevice(Request $request, RegisterNotificationDeviceEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$payload
));
}
/**
* @Route("/notifications/devices/unregister", name="next_api_society_notification_device_unregister", methods={"POST"})
*/
public function unregisterNotificationDevice(Request $request, UnregisterNotificationDeviceEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$payload
));
}
/**
* @Route("/notifications/preferences", name="next_api_society_notification_preferences_get", methods={"GET"})
*/
public function getNotificationPreferences(Request $request, GetNotificationPreferencesEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/notifications/preferences", name="next_api_society_notification_preferences_update", methods={"PUT"})
*/
public function updateNotificationPreferences(Request $request, UpdateNotificationPreferencesEndpoint $endpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$payload
));
}
/**
* @Route("/notifications", name="next_api_society_notification_history", methods={"GET"})
*/
public function notificationHistory(Request $request, ListNotificationHistoryEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
(int) $request->query->get('page', 1),
(int) $request->query->get('pageSize', 20)
));
}
/**
* @Route("/notifications", name="next_api_society_notification_delete_all", methods={"DELETE"})
*/
public function deleteAllNotifications(Request $request, DeleteAllNotificationsEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/notifications/{notificationId}", name="next_api_society_notification_delete", methods={"DELETE"}, requirements={"notificationId"="\d+"})
*/
public function deleteNotification(
int $notificationId,
Request $request,
DeleteNotificationEndpoint $endpoint
): JsonResponse|Response {
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$notificationId
));
}
/**
* @Route("/notifications/unread-count", name="next_api_society_notification_unread_count", methods={"GET"})
*/
public function unreadNotificationCount(Request $request, GetUnreadNotificationCountEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/notifications/read-all", name="next_api_society_notification_read_all", methods={"PUT"})
*/
public function markAllNotificationsRead(Request $request, MarkAllNotificationsReadEndpoint $endpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/notifications/dispatch/{dispatchId}/read", name="next_api_society_notification_dispatch_read", methods={"PUT"}, requirements={"dispatchId"="\d+"})
*/
public function markNotificationReadByDispatch(
int $dispatchId,
Request $request,
MarkNotificationReadByDispatchEndpoint $endpoint
): JsonResponse|Response {
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$dispatchId
));
}
/**
* @Route("/notifications/{notificationId}/read", name="next_api_society_notification_read", methods={"PUT"}, requirements={"notificationId"="\d+"})
*/
public function markNotificationRead(
int $notificationId,
Request $request,
MarkNotificationReadEndpoint $endpoint
): JsonResponse|Response {
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$notificationId
));
}
/**
* @Route("/profile/info", name="next_api_society_profile_info", methods={"POST"})
*/
public function profileInfo(Request $request, UserProfileInfoEndpoint $userProfileInfoEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
if ('society-v2' === (string) $request->attributes->get('authMode', '')) {
return $this->runSocietyJsonEndpoint(fn(): array => $userProfileInfoEndpoint->forSocietyV2(
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedPlayerId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0),
(string) ($payload['locale'] ?? 'es')
));
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $userProfileInfoEndpoint->__invoke($payload));
}
/**
* @Route("/profile/handicap/refresh", name="next_api_society_profile_handicap_refresh", methods={"POST"})
*/
public function profileHandicapRefresh(Request $request, UserHandicapRefreshEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $endpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/profile/detail/{id}", name="next_api_society_profile_detail", methods={"GET"}, requirements={"id"="\d+"})
*/
public function profileDetail(int $id, Request $request, UserProfileDetailEndpoint $userProfileDetailEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $userProfileDetailEndpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$id
));
}
/**
* @Route("/profile/playing-handicaps", name="next_api_society_profile_playing_handicaps", methods={"POST"})
*/
public function profilePlayingHandicaps(Request $request, PlayerCoursePlayingHandicapsEndpoint $playerCoursePlayingHandicapsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
$isSocietyV2 = 'society-v2' === (string) $request->attributes->get('authMode', '');
$selectedPlayerId = $isSocietyV2 ? (int) $request->attributes->get('resolvedPlayerId', 0) : null;
$selectedSocietyUserId = $isSocietyV2 ? (int) $request->attributes->get('resolvedSocietyUserId', 0) : null;
return $this->runSocietyJsonEndpoint(fn(): array => $playerCoursePlayingHandicapsEndpoint->__invoke($payload, $selectedPlayerId, $selectedSocietyUserId));
}
/**
* @Route("/profile/rfeg-handicap-rounds", name="next_api_society_profile_rfeg_handicap_rounds", methods={"POST"})
*/
public function profileRfegHandicapRounds(Request $request, RfegHandicapRoundsEndpoint $rfegHandicapRoundsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
$isSocietyV2 = 'society-v2' === (string) $request->attributes->get('authMode', '');
$selectedPlayerId = $isSocietyV2 ? (int) $request->attributes->get('resolvedPlayerId', 0) : null;
$selectedSocietyUserId = $isSocietyV2 ? (int) $request->attributes->get('resolvedSocietyUserId', 0) : null;
return $this->runSocietyJsonEndpoint(function () use ($rfegHandicapRoundsEndpoint, $payload, $selectedPlayerId, $selectedSocietyUserId): array {
$response = $rfegHandicapRoundsEndpoint->__invoke($payload, $selectedPlayerId, $selectedSocietyUserId);
return [
'_statusCode' => (int) $response['statusCode'],
'data' => $response['data'],
];
}, Response::HTTP_OK);
}
/**
* @Route("/profile/update", name="next_api_society_profile_update", methods={"POST"})
*/
public function profileUpdate(Request $request, UserProfileUpdateEndpoint $userProfileUpdateEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$isSocietyV2 = 'society-v2' === (string) $request->attributes->get('authMode', '');
if (!$isSocietyV2) {
$payload = $this->injectResolvedUserId($request, $payload);
$payload['firebaseUserId'] = (string) $request->attributes->get('firebaseUserId', '');
$payload['phoneFromToken'] = (string) $request->attributes->get('phoneFromToken', '');
}
return $this->runSocietyJsonEndpoint(function () use ($userProfileUpdateEndpoint, $payload, $request, $isSocietyV2): array {
$response = $isSocietyV2
? $userProfileUpdateEndpoint->updateForSocietyV2(
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedPlayerId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$payload
)
: $userProfileUpdateEndpoint->__invoke($payload);
return [
'_statusCode' => (int) $response['statusCode'],
'success' => $response['success'],
'hasChanges' => $response['hasChanges'],
'errors' => $response['errors'],
'data' => $response['data'],
];
});
}
/**
* @Route("/general/formats-by-modality", name="next_api_society_general_formats_by_modality", methods={"GET"})
*/
public function formatsByModality(Request $request, FormatsByModalityEndpoint $formatsByModalityEndpoint): JsonResponse
{
try {
$response = $formatsByModalityEndpoint->__invoke((int)$request->query->get('modality', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/classification/{id}", name="next_api_society_classification_detail", methods={"GET"}, requirements={"id"="\d+"})
*/
public function classificationDetail(int $id, Request $request, ClassificationDetailEndpoint $classificationDetailEndpoint): JsonResponse
{
try {
$response = $classificationDetailEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/classification/{classificationId}/classified/{classifiedId}/results", name="next_api_society_classification_classified_results", methods={"GET"}, requirements={"classificationId"="\d+", "classifiedId"="\d+"})
*/
public function classifiedsResults(int $classificationId, int $classifiedId, ClassifiedResultsEndpoint $classifiedResultEndpoint): JsonResponse
{
try {
$response = $classifiedResultEndpoint->__invoke($classificationId, $classifiedId);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/nextcaddy/classification/{id}", name="next_api_society_nextcaddy_classification_show", methods={"GET"})
*/
public function nextcaddyClassificationShow($id, NextcaddyClassificationDetailEndpoint $classificationShowEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $classificationShowEndpoint->__invoke($id));
}
/**
* @Route("/nextcaddy/classification/{classificationId}/classified/{classifiedId}/results", name="next_api_society_nextcaddy_classification_classified_results", methods={"GET"}, requirements={"classificationId"="\d+", "classifiedId"="\d+"})
*/
public function nextcaddyClassifiedResults($classificationId, $classifiedId, NextcaddyClassifiedResultsEndpoint $classifiedResultsEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $classifiedResultsEndpoint->__invoke($classificationId, $classifiedId)['data']);
}
/**
* @Route("/matches/{source}/{matchId}/results", name="next_api_society_match_results", methods={"GET"}, requirements={"source"="competition|friendly", "matchId"="\d+"})
*/
public function matchResults(
string $source,
int $matchId,
Request $request,
ReadMatchResults $matchResultsEndpoint
): JsonResponse
{
$response = $this->runSocietyJsonEndpoint(fn(): array => $matchResultsEndpoint->__invoke(
$source,
$matchId,
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all(),
'society-v2' === $request->attributes->get('authMode')
));
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
return $response;
}
/**
* @Route("/matches/{source}/{matchId}/livescoring", name="next_api_society_match_livescoring", methods={"GET"}, requirements={"source"="competition|friendly", "matchId"="\d+"})
*/
public function matchLivescoring(
string $source,
string $matchId,
Request $request,
MatchLivescoringEndpoint $endpoint
): JsonResponse|Response {
$query = $request->query->all();
$response = $this->runSocietyJsonEndpoint(fn(): array => $endpoint(
$source,
$matchId,
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$query['roundId'] ?? null,
'society-v2' === $request->attributes->get('authMode')
));
$response->headers->set('Cache-Control', 'private, no-store, max-age=0');
return $response;
}
/**
* @Route("/card/ecard/participant/{participant}/round/{round}", name="next_api_society_card_ecard", methods={"GET", "POST"}, requirements={"participant"="\d+", "round"="\d+"})
*/
public function eCard(int $participant, int $round, Request $request, ECardEndpoint $eCardEndpoint): JsonResponse|Response
{
try {
$response = $eCardEndpoint->__invoke(
$participant,
$round,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/round/{roundId}/pro-am/config", name="next_api_society_pro_am_config_get", methods={"GET"}, requirements={"roundId"="\d+"})
*/
public function proAmConfig(int $roundId, Request $request, GetProAmConfigEndpoint $getProAmConfigEndpoint): JsonResponse
{
try {
$response = $getProAmConfigEndpoint->__invoke($roundId, (int) $request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/round/{roundId}/pro-am/config", name="next_api_society_pro_am_config_update", methods={"PUT"}, requirements={"roundId"="\d+"})
*/
public function updateProAmConfig(int $roundId, Request $request, UpdateProAmConfigEndpoint $updateProAmConfigEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
try {
$response = $updateProAmConfigEndpoint->__invoke($roundId, (int) $request->attributes->get('resolvedSocietyUserId', 0), $payload);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/round/{roundId}/team/{teamId}/professional", name="next_api_society_pro_am_professional_update", methods={"PUT"}, requirements={"roundId"="\d+", "teamId"="\d+"})
*/
public function updateProAmProfessional(int $roundId, int $teamId, Request $request, ProAmProfessionalEndpoint $proAmProfessionalEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
try {
$response = $proAmProfessionalEndpoint->__invoke($roundId, $teamId, (int) $request->attributes->get('resolvedSocietyUserId', 0), $payload);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/card/marked-candidates/participant/{participant}/round/{round}", name="next_api_society_card_marked_candidates", methods={"GET"}, requirements={"participant"="\d+", "round"="\d+"})
*/
public function cardMarkedCandidates(int $participant, int $round, Request $request, CardMarkedCandidatesEndpoint $cardMarkedCandidatesEndpoint): JsonResponse
{
try {
$response = $cardMarkedCandidatesEndpoint->__invoke($participant, $round, (int) $request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/card/marked-assignment", name="next_api_society_card_marked_assignment", methods={"POST"})
*/
public function cardMarkedAssignment(Request $request, CreateCardMarkedAssignmentEndpoint $createCardMarkedAssignmentEndpoint): JsonResponse
{
try {
$response = $createCardMarkedAssignmentEndpoint->__invoke($request, (int) $request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/card/save-card-results", name="next_api_society_save_card_results", methods={"POST"})
*/
public function saveCardResults(Request $request, SaveCardResultsEndpoint $saveCardResultsEndpoint): JsonResponse
{
try {
$response = $saveCardResultsEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/card/submit-card", name="next_api_society_submit_card", methods={"POST"})
*/
public function submitCard(Request $request, SubmitCardEndpoint $submitCardEndpoint): JsonResponse
{
try {
$response = $submitCardEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/card/log-result", name="next_api_society_show_log_result", methods={"POST"})
*/
public function logResults(Request $request, LogResultEndpoint $logResultEndpoint): Response
{
try {
$response = $logResultEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/statistics", name="next_api_society_statistics", methods={"GET"})
*/
public function statistics(Request $request, StatisticsEndpoint $statisticsEndpoint): JsonResponse
{
try {
$response = $statisticsEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
'society-v2' === (string) $request->attributes->get('authMode', '')
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/stats/hcp-evolution", name="next_api_society_stats_hcp_evolution", methods={"POST"})
*/
public function hcpEvolution(Request $request, HcpEvolutionEndpoint $hcpEvolutionEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $hcpEvolutionEndpoint->__invoke($payload));
}
/**
* @Route("/stats/played-results", name="next_api_society_stats_played_results", methods={"POST"})
*/
public function playedResults(Request $request, PlayedResultsStatsEndpoint $playedResultsStatsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $playedResultsStatsEndpoint->__invoke($payload));
}
/**
* @Route("/stats/competitions-by-club", name="next_api_society_stats_competitions_by_club", methods={"POST"})
*/
public function competitionsByClub(Request $request, CompetitionsByClubStatsEndpoint $competitionsByClubStatsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $competitionsByClubStatsEndpoint->__invoke($payload));
}
/**
* @Route("/club/list", name="next_api_society_club_list", methods={"GET"})
*/
public function clubList(Request $request, ClubListEndpoint $clubListEndpoint): JsonResponse
{
try {
$response = $clubListEndpoint->__invoke($request);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/reservations/clubs", name="next_api_society_booking_clubs", methods={"GET"})
*/
public function bookingClubs(Request $request, SearchBookableClubsEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($request));
}
/**
* @Route("/reservations/availability", name="next_api_society_booking_availability", methods={"GET"})
*/
public function bookingAvailability(Request $request, SearchBookingAvailabilityEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($request));
}
/**
* @Route("/reservations", name="next_api_society_booking_list", methods={"GET"})
*/
public function bookings(Request $request, ListBookingsEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$request
));
}
/**
* @Route("/reservations/search", name="next_api_society_booking_search", methods={"GET"})
*/
public function searchBookings(Request $request, SearchBookingsEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
$request
));
}
/**
* @Route("/reservations", name="next_api_society_booking_create", methods={"POST"})
*/
public function createBooking(Request $request, CreateBookingEndpoint $endpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
(string) $request->headers->get('Idempotency-Key', ''),
$payload
), Response::HTTP_CREATED);
}
/**
* @Route("/reservations/{id}", name="next_api_society_booking_detail", methods={"GET"}, requirements={"id"="\d+"})
*/
public function bookingDetail(int $id, Request $request, GetBookingEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($id, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
}
/**
* @Route("/reservations/{id}/payment-session", name="next_api_society_booking_payment_session", methods={"POST"}, requirements={"id"="\d+"})
*/
public function bookingPaymentSession(int $id, Request $request, CreatePaymentSessionEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($id, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
}
/**
* @Route("/reservations/{id}/confirm", name="next_api_society_booking_confirm", methods={"POST"}, requirements={"id"="\d+"})
*/
public function confirmBooking(int $id, Request $request, ConfirmBookingEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($id, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
}
/**
* @Route("/reservations/{id}/cancel-preview", name="next_api_society_booking_cancel_preview", methods={"POST"}, requirements={"id"="\d+"})
*/
public function previewBookingCancellation(int $id, Request $request, PreviewBookingCancellationEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($id, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
}
/**
* @Route("/reservations/{id}/cancel", name="next_api_society_booking_cancel", methods={"POST"}, requirements={"id"="\d+"})
*/
public function cancelBooking(int $id, Request $request, CancelBookingEndpoint $endpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn (): array => $endpoint($id, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
}
/**
* @Route("/course/club/{club}", name="next_api_society_course_by_club", methods={"GET"})
*/
public function coursesByClub(string $club, CoursesByClubEndpoint $coursesByClubEndpoint): JsonResponse
{
try {
$response = $coursesByClubEndpoint->__invoke($club);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/course/{course}/tees", name="next_api_society_course_tees", methods={"GET"})
*/
public function courseTees(string $course, CourseTeesByCourseEndpoint $courseTeesByCourseEndpoint): JsonResponse
{
try {
$response = $courseTeesByCourseEndpoint->__invoke($course);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/player/license-course-tees", name="next_api_society_player_license_course_tees", methods={"POST"})
*/
public function playerLicenseCourseTees(Request $request, PlayerLicenseCourseTeesEndpoint $playerLicenseCourseTeesEndpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $playerLicenseCourseTeesEndpoint->__invoke(
$payload,
(int) $request->attributes->get('resolvedPlayerId', 0)
));
}
/**
* @Route("/rfc/competition", name="next_api_society_rfc_competition_create", methods={"POST"})
*/
public function createRfcCompetition(Request $request, CreateRfcCompetitionEndpoint $createRfcCompetitionEndpoint): JsonResponse|Response
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $createRfcCompetitionEndpoint->__invoke(
$payload,
(int) $request->attributes->get('resolvedPlayerId', 0)
));
}
/**
* @Route("/rfc/competition/{id}/cards", name="next_api_society_rfc_cards_send", methods={"POST"}, requirements={"id"="\d+"})
*/
public function sendRfcCards(int $id, Request $request, SendRfcCardsEndpoint $sendRfcCardsEndpoint): JsonResponse|Response
{
return $this->runSocietyJsonEndpoint(fn(): array => $sendRfcCardsEndpoint->__invoke(
$id,
(int) $request->attributes->get('resolvedPlayerId', 0)
));
}
/**
* @Route("/competitions/played", name="next_api_society_competitions_played_by_players", methods={"POST"})
*/
public function nextcaddyPlayedCompetitions(Request $request, NextcaddyPlayedCompetitionsEndpoint $playedCompetitionsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $playedCompetitionsEndpoint->__invoke($payload));
}
/**
* @Route("/competitions/future-by-player", name="next_api_society_competitions_future_by_player", methods={"POST"})
*/
public function nextcaddyFutureCompetitions(Request $request, NextcaddyFutureCompetitionsEndpoint $futureCompetitionsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $futureCompetitionsEndpoint->__invoke($payload));
}
/**
* @Route("/competitions/inscriptions/available", name="next_api_society_competitions_available_inscriptions", methods={"POST"})
*/
public function availableInscriptions(Request $request, AvailableInscriptionsEndpoint $availableInscriptionsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $availableInscriptionsEndpoint->__invoke($payload));
}
/**
* @Route("/competitions/scorecard", name="next_api_society_competitions_scorecard", methods={"POST"})
*/
public function competitionScorecard(Request $request, CompetitionScorecardEndpoint $competitionScorecardEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $competitionScorecardEndpoint->__invoke($payload));
}
/**
* @Route("/competitions/show", name="next_api_society_competitions_show", methods={"POST"})
*/
public function competitionShow(Request $request, CompetitionShowEndpoint $competitionShowEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $competitionShowEndpoint->__invoke(
$payload,
(int) $request->attributes->get('resolvedUserId', 0),
(int) $request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/competitions/{id}/classifications", name="next_api_society_competitions_classifications", methods={"GET"})
*/
public function nextcaddyClassificationsByCompetition($id, NextcaddyClassificationListEndpoint $classificationListEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $classificationListEndpoint->__invoke($id));
}
/**
* @Route("/info/{type}", name="next_api_society_info", methods={"GET"})
*/
public function info(string $type, InformationPanelEndpoint $informationPanelEndpoint): JsonResponse
{
try {
$response = $informationPanelEndpoint->__invoke($type);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/ranking", name="next_api_society_ranking_by_data", methods={"GET"})
*/
public function rankingByData(Request $request, RankingByDataEndpoint $rankingByDataEndpoint): JsonResponse
{
try {
$response = $rankingByDataEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/ranking/{id}", name="next_api_society_ranking_detail", methods={"GET"})
*/
public function rankingDetail($id, Request $request, RankingDetailEndpoint $rankingDetailEndpoint): JsonResponse
{
try {
$response = $rankingDetailEndpoint->__invoke(
$id,
(int) $request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/ranking/{rankingId}/user/{id}", name="next_api_society_ranking_user_detail", methods={"GET"})
*/
public function rankingUserDetail($rankingId, $id, RankingUserDetailEndpoint $rankingUserDetailEndpoint): JsonResponse
{
try {
$response = $rankingUserDetailEndpoint->__invoke((int)$rankingId, (int)$id);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/rankings/visible-by-player", name="next_api_society_rankings_visible_by_player", methods={"POST"})
*/
public function visibleRankingsByPlayer(Request $request, PlayerVisibleRankingsEndpoint $playerVisibleRankingsEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
$payload = $this->injectResolvedUserId($request, $payload);
return $this->runSocietyJsonEndpoint(fn(): array => $playerVisibleRankingsEndpoint->__invoke($payload));
}
/**
* @Route("/rankings/leaderboard", name="next_api_society_rankings_leaderboard", methods={"POST"})
*/
public function rankingLeaderboard(Request $request, RankingLeaderboardEndpoint $rankingLeaderboardEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $rankingLeaderboardEndpoint->__invoke($payload));
}
/**
* @Route("/nextcaddy/ranking/{id}", name="next_api_society_nextcaddy_ranking_detail", methods={"GET"})
*/
public function nextcaddyRankingDetail($id, Request $request, RankingNxtDetailEndpoint $rankingNxtDetailEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $rankingNxtDetailEndpoint->__invoke(
(int) $id,
(int) $request->attributes->get('resolvedUserId', 0)
));
}
/**
* @Route("/nextcaddy/ranking/{rankingId}/classified/{id}", name="next_api_society_nextcaddy_ranking_classified_detail", methods={"GET"})
*/
public function nextcaddyRankingClassifiedDetail($rankingId, $id, RankingClassifiedNxtDetailEndpoint $rankingClassifiedNxtDetailEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $rankingClassifiedNxtDetailEndpoint->__invoke((int) $rankingId, (int) $id));
}
/**
* @Route("/shared/competitions", name="next_api_society_shared_competitions_search", methods={"GET"})
*/
public function sharedCompetitionsSearch(Request $request, SearchCompetitionsEndpoint $searchCompetitionsEndpoint): JsonResponse
{
try {
$response = $searchCompetitionsEndpoint->__invoke($request->query->all());
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/shared/competitions/future", name="next_api_society_shared_competitions_future", methods={"GET"})
*/
public function sharedCompetitionsFuture(Request $request, FutureCompetitionsEndpoint $futureCompetitionsEndpoint): JsonResponse
{
try {
$response = $futureCompetitionsEndpoint->__invoke(
(int)$request->attributes->get('resolvedUserId', 0),
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/shared/competitions/played", name="next_api_society_shared_competitions_played", methods={"GET"})
*/
public function sharedCompetitionsPlayed(Request $request, PlayedCompetitionsEndpoint $playedCompetitionsEndpoint): JsonResponse
{
try {
$response = $playedCompetitionsEndpoint->__invoke(
(int)$request->attributes->get('resolvedUserId', 0),
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/shared/competitions/open-inscription", name="next_api_society_shared_competitions_open_inscription", methods={"GET"})
*/
public function sharedCompetitionsOpenInscription(Request $request, OpenInscriptionCompetitionsEndpoint $openInscriptionCompetitionsEndpoint): JsonResponse
{
try {
$response = $openInscriptionCompetitionsEndpoint->__invoke(
(int)$request->attributes->get('resolvedUserId', 0),
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/user/{id}/competitions", name="next_api_society_user_competitions", methods={"GET"}, requirements={"id"="\d+"})
*/
public function userCompetitions(int $id, Request $request, UserCompetitionsEndpoint $userCompetitionsEndpoint): JsonResponse
{
try {
$response = $userCompetitionsEndpoint->__invoke($id, $request->query->all());
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/user/{id}/rankings", name="next_api_society_user_rankings", methods={"GET"}, requirements={"id"="\d+"})
*/
public function userRankings(int $id, Request $request, UserRankingsEndpoint $userRankingsEndpoint): JsonResponse
{
try {
$response = $userRankingsEndpoint->__invoke($id, $request->query->all());
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/shared/rankings", name="next_api_society_shared_rankings", methods={"GET"})
*/
public function sharedRankings(Request $request, RankingsSharedEndpoint $rankingsSharedEndpoint): JsonResponse
{
try {
$response = $rankingsSharedEndpoint->__invoke(
(int)$request->attributes->get('resolvedUserId', 0),
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/participant/{id}", name="next_api_society_participant_delete", methods={"DELETE"}, requirements={"id"="\d+"})
*/
public function deleteParticipant(int $id, Request $request, DeleteParticipantEndpoint $deleteParticipantEndpoint): JsonResponse
{
$replacementParticipantId = (int)$request->request->get('replacementParticipantId', $request->query->get('replacementParticipantId', 0));
try {
$response = $deleteParticipantEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$replacementParticipantId > 0 ? $replacementParticipantId : null
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/contact", name="next_api_society_contact", methods={"POST"})
*/
public function contact(Request $request, CreateContactMessageEndpoint $createContactMessageEndpoint): JsonResponse
{
try {
$response = $createContactMessageEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed", name="next_api_society_feed_list", methods={"GET"})
*/
public function feed(Request $request, FeedListEndpoint $feedListEndpoint): JsonResponse
{
try {
$response = $feedListEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/user/{id}/feed", name="next_api_society_user_feed_list", methods={"GET"}, requirements={"id"="\d+"})
*/
public function userFeed(int $id, Request $request, UserFeedListEndpoint $userFeedListEndpoint): JsonResponse
{
try {
$response = $userFeedListEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$id
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/post", name="next_api_society_feed_post_create", methods={"POST"})
*/
public function createFeedPost(Request $request, CreateFeedPostEndpoint $createFeedPostEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $createFeedPostEndpoint->__invoke(
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_CREATED);
}
/**
* @Route("/feed/post/{id}", name="next_api_society_feed_post_detail", methods={"GET"}, requirements={"id"="\d+"})
*/
public function feedPost(int $id, Request $request, FeedPostDetailEndpoint $feedPostDetailEndpoint): JsonResponse
{
try {
$response = $feedPostDetailEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/post/{id}", name="next_api_society_feed_post_update", methods={"POST"}, requirements={"id"="\d+"})
*/
public function updateFeedPost(int $id, Request $request, UpdateFeedPostEndpoint $updateFeedPostEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $updateFeedPostEndpoint->__invoke(
$id,
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/post/{id}", name="next_api_society_feed_post_delete", methods={"DELETE"}, requirements={"id"="\d+"})
*/
public function deleteFeedPost(int $id, Request $request, DeleteFeedPostEndpoint $deleteFeedPostEndpoint): JsonResponse
{
try {
$response = $deleteFeedPostEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/post/{id}/comments", name="next_api_society_feed_comments_list", methods={"GET"}, requirements={"id"="\d+"})
*/
public function feedComments(int $id, Request $request, FeedCommentsListEndpoint $feedCommentsListEndpoint): JsonResponse
{
try {
$response = $feedCommentsListEndpoint->__invoke(
$id,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/comment/{id}/replies", name="next_api_society_feed_comment_replies", methods={"GET"}, requirements={"id"="\d+"})
*/
public function feedCommentReplies(int $id, Request $request, FeedCommentRepliesEndpoint $feedCommentRepliesEndpoint): JsonResponse
{
try {
$response = $feedCommentRepliesEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/post/{id}/comments", name="next_api_society_feed_comment_create", methods={"POST"}, requirements={"id"="\d+"})
*/
public function createFeedComment(int $id, Request $request, CreateFeedCommentEndpoint $createFeedCommentEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $createFeedCommentEndpoint->__invoke(
$id,
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_CREATED);
}
/**
* @Route("/feed/comment/{id}", name="next_api_society_feed_comment_update", methods={"POST"}, requirements={"id"="\d+"})
*/
public function updateFeedComment(int $id, Request $request, UpdateFeedCommentEndpoint $updateFeedCommentEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $updateFeedCommentEndpoint->__invoke(
$id,
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/feed/comment/{id}", name="next_api_society_feed_comment_delete", methods={"DELETE"}, requirements={"id"="\d+"})
*/
public function deleteFeedComment(int $id, Request $request, DeleteFeedCommentEndpoint $deleteFeedCommentEndpoint): JsonResponse
{
try {
$response = $deleteFeedCommentEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/round/{id}/finalize", name="next_api_society_round_finalize", methods={"POST"}, requirements={"id"="\d+"})
*/
public function finalizeRound(int $id, Request $request, FinalizeRoundEndpoint $finalizeRoundEndpoint): JsonResponse
{
try {
$response = $finalizeRoundEndpoint->__invoke(
$id,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/livescoring", name="next_api_society_friendly_livescoring", methods={"GET"}, requirements={"id"="\d+"})
*/
public function friendlyLivescoring(int $id, Request $request, FriendlyLivescoringEndpoint $friendlyLivescoringEndpoint): Response
{
try {
$response = $friendlyLivescoringEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/classifications", name="next_api_society_friendly_classifications", methods={"GET"}, requirements={"id"="\d+"})
*/
public function friendlyClassifications(int $id, Request $request, ClassificationListEndpoint $classificationListEndpoint): JsonResponse
{
try {
$response = $classificationListEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/schedule/show", name="next_api_society_schedule_show", methods={"POST"})
*/
public function scheduleShow(Request $request, ScheduleShowEndpoint $scheduleShowEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->invalidJsonResponse();
}
return $this->runSocietyJsonEndpoint(fn(): array => $scheduleShowEndpoint->__invoke($payload));
}
/**
* @Route("/friendly/{friendlyId}/schedule", name="next_api_society_schedule_create", methods={"POST"}, requirements={"friendlyId"="\d+"})
*/
public function createSchedule(int $friendlyId, Request $request, CreateScheduleEndpoint $createScheduleEndpoint): JsonResponse
{
try {
$response = $createScheduleEndpoint->__invoke(
$friendlyId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}", name="next_api_society_schedule_delete", methods={"DELETE"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function deleteSchedule(int $friendlyId, int $scheduleId, Request $request, DeleteScheduleEndpoint $deleteScheduleEndpoint): JsonResponse
{
try {
$response = $deleteScheduleEndpoint->__invoke(
$friendlyId,
$scheduleId,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/layout", name="next_api_society_schedule_layout_create", methods={"POST"}, requirements={"friendlyId"="\d+"})
*/
public function createScheduleLayout(int $friendlyId, Request $request, CreateScheduleLayoutEndpoint $createScheduleLayoutEndpoint): JsonResponse
{
try {
$response = $createScheduleLayoutEndpoint->__invoke(
$friendlyId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule", name="next_api_society_schedule_list", methods={"GET"}, requirements={"friendlyId"="\d+"})
*/
public function listSchedules(int $friendlyId, Request $request, ListSchedulesEndpoint $listSchedulesEndpoint): JsonResponse
{
try {
$response = $listSchedulesEndpoint->__invoke(
$friendlyId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}/group", name="next_api_society_schedule_group_create", methods={"POST"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function createScheduleGroup(int $friendlyId, int $scheduleId, Request $request, CreateScheduleGroupEndpoint $createScheduleGroupEndpoint): JsonResponse
{
try {
$response = $createScheduleGroupEndpoint->__invoke(
$friendlyId,
$scheduleId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/group/{groupId}", name="next_api_society_schedule_group_update", methods={"PUT", "PATCH"}, requirements={"friendlyId"="\d+", "groupId"="\d+"})
*/
public function updateScheduleGroup(int $friendlyId, int $groupId, Request $request, UpdateScheduleGroupEndpoint $updateScheduleGroupEndpoint): JsonResponse
{
try {
$response = $updateScheduleGroupEndpoint->__invoke(
$friendlyId,
$groupId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/group/{groupId}/player", name="next_api_society_schedule_group_player_add", methods={"POST"}, requirements={"friendlyId"="\d+", "groupId"="\d+"})
*/
public function addScheduleGroupPlayer(int $friendlyId, int $groupId, Request $request, AddScheduleGroupPlayerEndpoint $addScheduleGroupPlayerEndpoint): JsonResponse
{
try {
$response = $addScheduleGroupPlayerEndpoint->__invoke(
$friendlyId,
$groupId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/group/{groupId}", name="next_api_society_schedule_group_delete", methods={"DELETE"}, requirements={"friendlyId"="\d+", "groupId"="\d+"})
*/
public function deleteScheduleGroup(int $friendlyId, int $groupId, Request $request, DeleteScheduleGroupEndpoint $deleteScheduleGroupEndpoint): JsonResponse
{
try {
$response = $deleteScheduleGroupEndpoint->__invoke(
$friendlyId,
$groupId,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/group/{groupId}/player/{playerScheduleId}", name="next_api_society_schedule_group_player_delete", methods={"DELETE"}, requirements={"friendlyId"="\d+", "groupId"="\d+", "playerScheduleId"="\d+"})
*/
public function deleteScheduleGroupPlayer(int $friendlyId, int $groupId, int $playerScheduleId, Request $request, DeleteScheduleGroupPlayerEndpoint $deleteScheduleGroupPlayerEndpoint): JsonResponse
{
try {
$response = $deleteScheduleGroupPlayerEndpoint->__invoke(
$friendlyId,
$groupId,
$playerScheduleId,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/player/{playerScheduleId}/move", name="next_api_society_schedule_player_move", methods={"POST"}, requirements={"friendlyId"="\d+", "playerScheduleId"="\d+"})
*/
public function moveScheduleGroupPlayer(int $friendlyId, int $playerScheduleId, Request $request, MoveScheduleGroupPlayerEndpoint $moveScheduleGroupPlayerEndpoint): JsonResponse
{
try {
$response = $moveScheduleGroupPlayerEndpoint->__invoke(
$friendlyId,
$playerScheduleId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}", name="next_api_society_schedule_detail", methods={"GET"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function scheduleDetail(int $friendlyId, int $scheduleId, Request $request, ScheduleDetailEndpoint $scheduleDetailEndpoint): JsonResponse
{
try {
$response = $scheduleDetailEndpoint->__invoke(
$friendlyId,
$scheduleId,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}/layout", name="next_api_society_schedule_layout_save", methods={"PUT"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function saveScheduleLayout(int $friendlyId, int $scheduleId, Request $request, SaveScheduleLayoutEndpoint $saveScheduleLayoutEndpoint): JsonResponse
{
try {
$response = $saveScheduleLayoutEndpoint->__invoke(
$friendlyId,
$scheduleId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}/publish", name="next_api_society_schedule_publish", methods={"POST"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function publishSchedule(int $friendlyId, int $scheduleId, Request $request, PublishScheduleEndpoint $publishScheduleEndpoint): JsonResponse
{
try {
$response = $publishScheduleEndpoint->__invoke(
$friendlyId,
$scheduleId,
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{friendlyId}/schedule/{scheduleId}/unpublish", name="next_api_society_schedule_unpublish", methods={"POST"}, requirements={"friendlyId"="\d+", "scheduleId"="\d+"})
*/
public function unpublishSchedule(int $friendlyId, int $scheduleId, Request $request, UnpublishScheduleEndpoint $unpublishScheduleEndpoint): JsonResponse
{
try {
$response = $unpublishScheduleEndpoint->__invoke(
$friendlyId,
$scheduleId,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/{id}", name="next_api_society_follow_user", methods={"POST"}, requirements={"id"="\d+"})
*/
public function followUser(int $id, Request $request, FollowUserEndpoint $followUserEndpoint): JsonResponse
{
try {
$response = $followUserEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/{id}", name="next_api_society_unfollow_user", methods={"DELETE"}, requirements={"id"="\d+"})
*/
public function unfollowUser(int $id, Request $request, UnfollowUserEndpoint $unfollowUserEndpoint): JsonResponse
{
try {
$response = $unfollowUserEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/request/{id}/cancel", name="next_api_society_follow_request_cancel", methods={"POST"}, requirements={"id"="\d+"})
*/
public function cancelFollowRequest(int $id, Request $request, CancelFollowRequestEndpoint $cancelFollowRequestEndpoint): JsonResponse
{
try {
$response = $cancelFollowRequestEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/request/{id}/accept", name="next_api_society_follow_request_accept", methods={"POST"}, requirements={"id"="\d+"})
*/
public function acceptFollowRequest(int $id, Request $request, AcceptFollowRequestEndpoint $acceptFollowRequestEndpoint): JsonResponse
{
try {
$response = $acceptFollowRequestEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/request/{id}/reject", name="next_api_society_follow_request_reject", methods={"POST"}, requirements={"id"="\d+"})
*/
public function rejectFollowRequest(int $id, Request $request, RejectFollowRequestEndpoint $rejectFollowRequestEndpoint): JsonResponse
{
try {
$response = $rejectFollowRequestEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/follower/{id}", name="next_api_society_follow_remove_follower", methods={"DELETE"}, requirements={"id"="\d+"})
*/
public function removeFollower(int $id, Request $request, RemoveFollowerEndpoint $removeFollowerEndpoint): JsonResponse
{
try {
$response = $removeFollowerEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/block/{id}", name="next_api_society_follow_block_user", methods={"POST"}, requirements={"id"="\d+"})
*/
public function blockFollowUser(int $id, Request $request, BlockFollowUserEndpoint $blockFollowUserEndpoint): JsonResponse
{
try {
$response = $blockFollowUserEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/unblock/{id}", name="next_api_society_follow_unblock_user", methods={"POST"}, requirements={"id"="\d+"})
*/
public function unblockFollowUser(int $id, Request $request, UnblockFollowUserEndpoint $unblockFollowUserEndpoint): JsonResponse
{
try {
$response = $unblockFollowUserEndpoint->__invoke($id, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/discover", name="next_api_society_follow_discover", methods={"GET"})
*/
public function discoverFollowUsers(Request $request, DiscoverFollowUsersEndpoint $discoverFollowUsersEndpoint): JsonResponse
{
try {
$response = $discoverFollowUsersEndpoint->__invoke($request, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/blocked", name="next_api_society_follow_blocked_list", methods={"GET"})
*/
public function blockedUsers(Request $request, BlockedUsersListEndpoint $blockedUsersListEndpoint): JsonResponse
{
try {
$response = $blockedUsersListEndpoint->__invoke($request, (int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/followers", name="next_api_society_followers_list", methods={"GET"})
*/
public function followers(Request $request, FollowersListEndpoint $followersListEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $followersListEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/follow/following", name="next_api_society_following_list", methods={"GET"})
*/
public function following(Request $request, FollowingListEndpoint $followingListEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $followingListEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/follow/friends", name="next_api_society_friends_list", methods={"GET"})
*/
public function friends(Request $request, FriendsListEndpoint $friendsListEndpoint): JsonResponse
{
return $this->runSocietyJsonEndpoint(fn(): array => $friendsListEndpoint->__invoke(
$request,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
));
}
/**
* @Route("/follow/playing-today", name="next_api_society_following_playing_today", methods={"GET"})
*/
public function followingPlayingToday(Request $request, FollowingPlayingTodayEndpoint $followingPlayingTodayEndpoint): JsonResponse
{
try {
$response = $followingPlayingTodayEndpoint->__invoke(
(int) $request->attributes->get('resolvedSocietyUserId', 0),
(int) $request->attributes->get('resolvedUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/requests/received", name="next_api_society_follow_requests_received", methods={"GET"})
*/
public function receivedFollowRequests(Request $request, PendingReceivedFollowRequestsEndpoint $pendingReceivedFollowRequestsEndpoint): JsonResponse
{
try {
$response = $pendingReceivedFollowRequestsEndpoint->__invoke((int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/follow/requests/sent", name="next_api_society_follow_requests_sent", methods={"GET"})
*/
public function sentFollowRequests(Request $request, PendingSentFollowRequestsEndpoint $pendingSentFollowRequestsEndpoint): JsonResponse
{
try {
$response = $pendingSentFollowRequestsEndpoint->__invoke((int)$request->attributes->get('resolvedSocietyUserId', 0));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendlies", name="next_api_society_friendlies_list", methods={"POST"})
*/
public function friendlies(Request $request, FriendlyListEndpoint $friendlyListEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $friendlyListEndpoint->__invoke(
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$payload
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/create", name="next_api_society_friendly_create", methods={"POST"})
*/
public function createFriendly(Request $request, FriendlyCreateEndpoint $friendlyCreateEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $friendlyCreateEndpoint->__invoke(
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_CREATED);
}
/**
* @Route("/friendly/edit/{id}", name="next_api_society_friendly_edit", methods={"POST"}, requirements={"id"="\d+"})
*/
public function editFriendly(int $id, Request $request, FriendlyEditEndpoint $friendlyEditEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $friendlyEditEndpoint->__invoke(
$id,
$payload,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/code", name="next_api_society_friendly_by_code", methods={"POST"})
*/
public function friendlyByCode(Request $request, FriendlyByCodeEndpoint $friendlyByCodeEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
try {
$response = $friendlyByCodeEndpoint->__invoke(
$payload,
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/delete/{id}", name="next_api_society_friendly_delete", methods={"POST"}, requirements={"id"="\d+"})
*/
public function deleteFriendly(int $id, Request $request, FriendlyDeleteEndpoint $friendlyDeleteEndpoint): JsonResponse
{
try {
$response = $friendlyDeleteEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/closest", name="next_api_society_friendly_closest", methods={"GET"})
*/
public function closestFriendlies(Request $request, FriendlyClosestEndpoint $friendlyClosestEndpoint): JsonResponse
{
try {
$response = $friendlyClosestEndpoint->__invoke(
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/shared/friendly/next", name="next_api_society_shared_next_friendly", methods={"GET"})
*/
public function sharedNextFriendly(Request $request, SharedNextGameEndpoint $sharedNextFriendlyEndpoint): JsonResponse
{
try {
$response = $sharedNextFriendlyEndpoint->__invoke(
(int)$request->attributes->get('resolvedUserId', 0),
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}", name="next_api_society_friendly_detail", methods={"GET"}, requirements={"id"="\d+"})
*/
public function detailFriendly(int $id, Request $request, FriendlyDetailEndpoint $friendlyDetailEndpoint): JsonResponse
{
try {
$response = $friendlyDetailEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
true,
(int)$request->attributes->get('resolvedUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/participants/handicaps", name="next_api_society_friendly_participant_handicaps", methods={"GET", "POST"}, requirements={"id"="\d+"})
*/
public function friendlyParticipantHandicaps(int $id, Request $request, \App\Controller\Api\Society\Friendly\Service\FriendlyParticipantHandicapsEndpoint $endpoint): JsonResponse
{
try {
$userId = (int) $request->attributes->get('resolvedSocietyUserId', 0);
if ($request->isMethod('GET')) return $this->endpointResponse($endpoint->editor($id, $userId));
$payload = $this->parseJsonPayload($request);
if (null === $payload) return $this->invalidJsonResponse();
return $this->endpointResponse($endpoint->save($id, $userId, $payload));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
}
/**
* @Route("/friendly/{id}/participants/{participantId}/handicaps/history", name="next_api_society_friendly_participant_handicaps_history", methods={"GET"}, requirements={"id"="\d+", "participantId"="\d+"})
*/
public function friendlyParticipantHandicapsHistory(int $id, int $participantId, Request $request, \App\Controller\Api\Society\Friendly\Service\FriendlyParticipantHandicapsEndpoint $endpoint): JsonResponse
{
try {
return $this->endpointResponse($endpoint->history($id, $participantId, (int) $request->attributes->get('resolvedSocietyUserId', 0)));
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
}
/**
* @Route("/friendly/{id}/participants/handicaps/refresh", name="next_api_society_friendly_participant_handicaps_refresh", methods={"POST"}, requirements={"id"="\d+"})
*/
public function refreshFriendlyParticipantHandicaps(
int $id,
Request $request,
FriendlyParticipantHandicapsRefreshEndpoint $endpoint
): JsonResponse
{
try {
$response = $endpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0)
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/slots-availables", name="next_api_society_friendly_slots_available", methods={"GET"}, requirements={"id"="\d+"})
*/
public function friendlySlotsAvailable(int $id, FriendlySlotsAvailableEndpoint $friendlySlotsAvailableEndpoint): JsonResponse
{
try {
$response = $friendlySlotsAvailableEndpoint->__invoke($id);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/available-friends", name="next_api_society_friendly_available_friends", methods={"GET"}, requirements={"id"="\d+"})
*/
public function friendlyAvailableFriends(int $id, Request $request, FriendlyAvailableFriendsEndpoint $friendlyAvailableFriendsEndpoint): JsonResponse
{
try {
$response = $friendlyAvailableFriendsEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$request->query->all()
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @Route("/friendly/{id}/inscription", name="next_api_society_friendly_inscription", methods={"POST"}, requirements={"id"="\d+"})
*/
public function friendlyInscription(int $id, Request $request, FriendlyInscriptionEndpoint $friendlyInscriptionEndpoint): JsonResponse
{
$payload = $this->parseJsonPayload($request);
if (null === $payload) {
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST);
}
if (!array_key_exists('userId', $payload) && $request->query->has('userId')) {
$payload['userId'] = $request->query->get('userId');
}
try {
$response = $friendlyInscriptionEndpoint->__invoke(
$id,
(int)$request->attributes->get('resolvedSocietyUserId', 0),
$payload
);
} catch (\Throwable $exception) {
return $this->endpointExceptionResponse($exception);
}
return $this->endpointResponse($response, Response::HTTP_OK);
}
/**
* @param array<string,mixed> $payload
* @return array<string,mixed>
*/
private function injectResolvedUserId(Request $request, array $payload): array
{
$resolvedUserId = (int) $request->attributes->get('resolvedUserId', 0);
if ($resolvedUserId <= 0) {
return $payload;
}
$payload['userId'] = $resolvedUserId;
$resolvedSocietyUserId = (int) $request->attributes->get('resolvedSocietyUserId', 0);
if ($resolvedSocietyUserId > 0) {
$payload['societyUserId'] = $resolvedSocietyUserId;
}
return $payload;
}
/**
* @param callable():array<string,mixed>|array<int,mixed>|Response $endpoint
*/
private function runSocietyJsonEndpoint(callable $endpoint, int $successStatusCode = Response::HTTP_OK): JsonResponse|Response
{
try {
$response = $endpoint();
} catch (ApiEndpointException $exception) {
return $this->apiExceptionResponse($exception);
} catch (NextApiSessionException $exception) {
return $this->sessionExceptionResponse($exception);
} catch (FirebaseTokenInvalidException) {
return $this->societyErrorResponse('firebase-token-invalid', Response::HTTP_UNAUTHORIZED, 'Refresh token is invalid.');
} catch (\InvalidArgumentException $exception) {
return $this->societyErrorResponse('invalid-request', Response::HTTP_BAD_REQUEST, $exception->getMessage());
} catch (\Throwable $exception) {
$this->societyExceptionLogger->critical($exception);
return $this->societyErrorResponse('internal-error', Response::HTTP_INTERNAL_SERVER_ERROR, 'Unable to process request.', $exception->getMessage());
}
return $this->endpointResponse($response, $successStatusCode);
}
private function endpointResponse(mixed $response, int $successStatusCode = Response::HTTP_OK): JsonResponse|Response
{
if ($response instanceof Response) {
return $response;
}
if (is_array($response) && isset($response['_statusCode'])) {
$successStatusCode = (int) $response['_statusCode'];
unset($response['_statusCode']);
}
return $this->json($response, $successStatusCode);
}
private function endpointExceptionResponse(\Throwable $exception): JsonResponse
{
if ($exception instanceof \App\Controller\Api\Society\Friendly\Data\CustomHandicapModeChangedException) {
return $this->json(['error' => 'CUSTOM_HANDICAP_MODE_CHANGED', 'message' => $exception->getMessage(), 'customHandicapEnabled' => $exception->friendly->isCustomHandicapEnabled(), 'customHandicapVersion' => $exception->friendly->getCustomHandicapVersion()], 409);
}
if ($exception instanceof ApiEndpointException) {
return $this->apiExceptionResponse($exception);
}
if ($exception instanceof \InvalidArgumentException) {
return $this->societyErrorResponse('invalid-request', Response::HTTP_BAD_REQUEST, $exception->getMessage());
}
$this->societyExceptionLogger->critical($exception);
return $this->societyErrorResponse('internal-error', Response::HTTP_INTERNAL_SERVER_ERROR);
}
private function apiExceptionResponse(ApiEndpointException $exception): JsonResponse
{
return $this->societyErrorResponse($exception->errorCode(), $exception->statusCode(), $exception->getMessage());
}
private function invalidJsonResponse(): JsonResponse
{
return $this->societyErrorResponse('invalid-json', Response::HTTP_BAD_REQUEST, 'Invalid JSON payload.');
}
private function sessionExceptionResponse(NextApiSessionException $exception): JsonResponse
{
$this->societyExceptionLogger->controlledResponse(
'' !== $exception->errorCode() ? $exception->errorCode() : 'session-error',
$exception->statusCode(),
$exception->getMessage()
);
$response = [
'error' => $exception->getMessage(),
];
if ('' !== $exception->errorCode()) {
$response['code'] = $exception->errorCode();
}
return $this->json($response, $exception->statusCode());
}
private function societyErrorResponse(string $errorCode, int $statusCode, string $fallbackMessage = ''): JsonResponse
{
$message = $this->societyErrorMessageTranslator->translate($errorCode, '' !== $fallbackMessage ? $fallbackMessage : $errorCode);
$this->societyExceptionLogger->controlledResponse($errorCode, $statusCode, $message);
return $this->json([
'error' => $errorCode,
'message' => $message,
], $statusCode);
}
/**
* @return array<string,mixed>|null
*/
private function parseJsonPayload(Request $request): ?array
{
$content = trim((string)$request->getContent());
if ('' === $content) {
return [];
}
$payload = json_decode($content, true);
return is_array($payload) ? $payload : null;
}
}