diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMetricsApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMetricsApiController.php index 2e671c784..6d3b2e690 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMetricsApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMetricsApiController.php @@ -15,11 +15,13 @@ use App\ModelSerializers\SerializerUtils; use App\Rules\Boolean; use App\Services\Model\ISummitMetricService; +use Illuminate\Http\Response; use models\main\IMemberRepository; use models\oauth2\IResourceServerContext; use models\summit\ISummitMetricType; use models\summit\ISummitRepository; use ModelSerializers\SerializerRegistry; +use OpenApi\Attributes as OA; /** * Class OAuth2SummitMetricsApiController @@ -68,6 +70,41 @@ public function __construct * @param $event_id * @return mixed */ + #[OA\Put( + path: "/api/v1/summits/{id}/metrics/enter", + summary: "Record a metric entry (enter)", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\MediaType( + mediaType: "application/json", + schema: new OA\Schema(ref: "#/components/schemas/SummitMetricEnterRequest") + ) + ), + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function enter($summit_id) { return $this->processRequest(function () use ($summit_id) { @@ -101,6 +138,41 @@ public function enter($summit_id) * @param $event_id * @return mixed */ + #[OA\Post( + path: "/api/v1/summits/{id}/metrics/leave", + summary: "Record a metric exit (leave)", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\MediaType( + mediaType: "application/json", + schema: new OA\Schema(ref: "#/components/schemas/SummitMetricLeaveRequest") + ) + ), + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function leave($summit_id) { return $this->processRequest(function () use ($summit_id) { @@ -134,6 +206,48 @@ public function leave($summit_id) * @param $event_id * @return mixed */ + #[OA\Put( + path: "/api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/metrics/enter", + summary: "Record a metric entry to a specific event", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ), + new OA\Parameter( + name: "member_id", + in: "path", + required: true, + schema: new OA\Schema(type: "string", enum: ["me"]), + description: "The member id (must be 'me')" + ), + new OA\Parameter( + name: "event_id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The event id" + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function enterToEvent($summit_id, $member_id, $event_id) { return $this->processRequest(function () use ($summit_id, $member_id, $event_id) { @@ -162,6 +276,48 @@ public function enterToEvent($summit_id, $member_id, $event_id) * @param $event_id * @return mixed */ + #[OA\Post( + path: "/api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/metrics/leave", + summary: "Record a metric exit from a specific event", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ), + new OA\Parameter( + name: "member_id", + in: "path", + required: true, + schema: new OA\Schema(type: "string", enum: ["me"]), + description: "The member id (must be 'me')" + ), + new OA\Parameter( + name: "event_id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The event id" + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function leaveFromEvent($summit_id, $member_id, $event_id) { return $this->processRequest(function () use ($summit_id, $member_id, $event_id) { @@ -184,6 +340,41 @@ public function leaveFromEvent($summit_id, $member_id, $event_id) }); } + #[OA\Put( + path: "/api/v1/summits/{id}/metrics/onsite/enter", + summary: "Record an on-site metric entry (for attendees entering venue/room)", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\MediaType( + mediaType: "application/json", + schema: new OA\Schema(ref: "#/components/schemas/SummitMetricOnSiteEnterRequest") + ) + ), + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function onSiteEnter($summit_id) { return $this->processRequest(function () use ($summit_id) { @@ -213,7 +404,55 @@ public function onSiteEnter($summit_id) }); } - + #[OA\Get( + path: "/api/v1/summits/{id}/metrics/onsite/enter", + summary: "Check if on-site entry is allowed for an attendee (validation only, does not record entry)", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ), + new OA\Parameter( + name: "attendee_id", + in: "query", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The attendee id" + ), + new OA\Parameter( + name: "room_id", + in: "query", + required: false, + schema: new OA\Schema(type: "integer"), + description: "The room id" + ), + new OA\Parameter( + name: "event_id", + in: "query", + required: false, + schema: new OA\Schema(type: "integer"), + description: "The event id" + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function checkOnSiteEnter($summit_id) { return $this->processRequest(function () use ($summit_id) { @@ -240,6 +479,41 @@ public function checkOnSiteEnter($summit_id) }); } + #[OA\Post( + path: "/api/v1/summits/{id}/metrics/onsite/leave", + summary: "Record an on-site metric exit (for attendees leaving venue/room)", + security: [["Bearer" => []]], + tags: ["summit-metrics"], + parameters: [ + new OA\Parameter( + name: "id", + in: "path", + required: true, + schema: new OA\Schema(type: "integer"), + description: "The summit id" + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\MediaType( + mediaType: "application/json", + schema: new OA\Schema(ref: "#/components/schemas/SummitMetricOnSiteLeaveRequest") + ) + ), + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitMetric") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function onSiteLeave($summit_id) { return $this->processRequest(function () use ($summit_id) { @@ -265,4 +539,4 @@ public function onSiteLeave($summit_id) )); }); } -} \ No newline at end of file +} diff --git a/app/Swagger/SummitMetricsSchemas.php b/app/Swagger/SummitMetricsSchemas.php index 6b3e2f895..cdf886a49 100644 --- a/app/Swagger/SummitMetricsSchemas.php +++ b/app/Swagger/SummitMetricsSchemas.php @@ -4,4 +4,103 @@ use OpenApi\Attributes as OA; +// Summit Metrics Schemas + +#[OA\Schema( + schema: "SummitMetric", + type: "object", + properties: [ + new OA\Property(property: "id", type: "integer"), + new OA\Property(property: "member_first_name", type: "string", nullable: true), + new OA\Property(property: "member_last_name", type: "string", nullable: true), + new OA\Property(property: "member_pic", type: "string", nullable: true), + new OA\Property(property: "type", type: "string", enum: ["GENERAL", "LOBBY", "EVENT", "SPONSOR", "POSTER", "POSTERS", "ROOM"]), + new OA\Property(property: "ip", type: "string", nullable: true), + new OA\Property(property: "origin", type: "string", nullable: true), + new OA\Property(property: "browser", type: "string", nullable: true), + new OA\Property(property: "outgress_date", type: "integer", nullable: true), + new OA\Property(property: "ingress_date", type: "integer"), + new OA\Property(property: "created", type: "integer"), + new OA\Property(property: "last_edited", type: "integer") + ] +)] +class SummitMetric +{ +} + +#[OA\Schema( + schema: "SummitMetricEnterRequest", + type: "object", + required: ["type"], + properties: [ + new OA\Property(property: "type", type: "string", enum: ["GENERAL", "LOBBY", "EVENT", "SPONSOR", "POSTER", "POSTERS", "ROOM"]), + new OA\Property(property: "source_id", type: "integer", description: "ID of the source (event, sponsor, room, etc.)"), + new OA\Property(property: "location", type: "string", description: "Location information") + ] +)] +class SummitMetricEnterRequest +{ +} + +#[OA\Schema( + schema: "SummitMetricLeaveRequest", + type: "object", + required: ["type"], + properties: [ + new OA\Property(property: "type", type: "string", enum: ["GENERAL", "LOBBY", "EVENT", "SPONSOR", "POSTER", "POSTERS", "ROOM"]), + new OA\Property(property: "source_id", type: "integer", description: "ID of the source (event, sponsor, room, etc.)"), + new OA\Property(property: "location", type: "string", description: "Location information") + ] +)] +class SummitMetricLeaveRequest +{ +} + +#[OA\Schema( + schema: "SummitMetricOnSiteEnterRequest", + type: "object", + required: ["attendee_id"], + properties: [ + new OA\Property(property: "attendee_id", type: "integer"), + new OA\Property(property: "room_id", type: "integer"), + new OA\Property(property: "event_id", type: "integer"), + new OA\Property(property: "ticket_number", type: "string"), + new OA\Property(property: "required_access_levels", type: "array", items: new OA\Items(type: "integer")), + new OA\Property(property: "check_ingress", type: "boolean") + ] +)] +class SummitMetricOnSiteEnterRequest +{ +} + +#[OA\Schema( + schema: "SummitMetricOnSiteLeaveRequest", + type: "object", + required: ["attendee_id"], + properties: [ + new OA\Property(property: "attendee_id", type: "integer"), + new OA\Property(property: "room_id", type: "integer"), + new OA\Property(property: "event_id", type: "integer"), + new OA\Property(property: "required_access_levels", type: "array", items: new OA\Items(type: "integer")) + ] +)] +class SummitMetricOnSiteLeaveRequest +{ +} + +#[OA\Schema( + schema: "SummitMetricCheckOnSiteEnterRequest", + type: "object", + required: ["attendee_id"], + properties: [ + new OA\Property(property: "attendee_id", type: "integer"), + new OA\Property(property: "room_id", type: "integer"), + new OA\Property(property: "event_id", type: "integer") + ] +)] +class SummitMetricCheckOnSiteEnterRequest +{ +} + // +