From 84d908e29276529fe6b5d445682fd466b41ead87 Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Wed, 28 Oct 2026 22:56:34 +0300 Subject: [PATCH] Prefix admin panel APIs and preserve customer API paths --- README.md | 2 +- db/query/notification.sql | 14 +- db/tests/notification-audiences.test.cjs | 32 + docs/api-audiences.md | 74 + docs/api-route-migration.json | 2006 ++ docs/docs.go | 15465 ++++++++-------- docs/swagger.json | 15465 ++++++++-------- docs/swagger.yaml | 10259 +++++----- gen/db/notification.sql.go | 103 +- internal/domain/notification_scope.go | 19 + internal/repository/notification.go | 31 +- internal/services/notification/service.go | 32 +- .../services/notification/service_get_test.go | 12 + internal/web_server/api_audience.go | 46 + internal/web_server/api_audience_test.go | 126 + internal/web_server/api_docs.go | 71 + internal/web_server/api_docs_test.go | 37 + internal/web_server/handlers/activity_logs.go | 4 +- internal/web_server/handlers/admin.go | 12 +- internal/web_server/handlers/admin_export.go | 6 +- .../web_server/handlers/analytics_handler.go | 2 +- internal/web_server/handlers/arifpay.go | 2 - internal/web_server/handlers/auth_handler.go | 12 +- internal/web_server/handlers/chapa.go | 1 - .../web_server/handlers/course_handler.go | 5 - .../handlers/exam_prep_assessment_handler.go | 16 + .../exam_prep_catalog_course_handler.go | 8 + .../handlers/exam_prep_lesson_handler.go | 8 + .../handlers/exam_prep_module_handler.go | 8 + .../handlers/exam_prep_practice_handler.go | 17 + .../handlers/exam_prep_unit_handler.go | 8 + internal/web_server/handlers/file_handler.go | 6 + .../web_server/handlers/issue_reporting.go | 10 +- .../web_server/handlers/lesson_handler.go | 6 - .../handlers/lms_persona_handler.go | 8 +- .../handlers/lms_progress_handler.go | 2 - .../handlers/lms_reorder_handler.go | 4 - .../web_server/handlers/module_handler.go | 5 - internal/web_server/handlers/mongoLogger.go | 2 +- .../handlers/notification_handler.go | 181 +- .../handlers/practice_full_update_handler.go | 4 +- .../web_server/handlers/practice_handler.go | 10 - .../web_server/handlers/program_handler.go | 5 - .../handlers/question_type_builder.go | 26 +- internal/web_server/handlers/questions.go | 42 +- internal/web_server/handlers/ratings.go | 3 + internal/web_server/handlers/rbac_handler.go | 20 +- .../web_server/handlers/referal_handlers.go | 38 + .../web_server/handlers/settings_handler.go | 15 + internal/web_server/handlers/subscriptions.go | 17 +- internal/web_server/handlers/team_handler.go | 24 +- .../handlers/team_invitation_handler.go | 12 +- .../handlers/team_password_reset_handler.go | 6 +- .../handlers/transaction_approver.go | 2 - internal/web_server/handlers/user.go | 36 +- .../handlers/video_engagement_handler.go | 6 +- internal/web_server/handlers/vimeo.go | 16 +- internal/web_server/middleware.go | 21 + internal/web_server/routes.go | 425 +- internal/web_server/routes_admin.go | 235 + internal/web_server/routes_client.go | 113 + internal/web_server/routes_integration.go | 14 + internal/web_server/ws/ws.go | 23 +- internal/web_server/ws/ws_test.go | 28 + 64 files changed, 24972 insertions(+), 20296 deletions(-) create mode 100644 db/tests/notification-audiences.test.cjs create mode 100644 docs/api-audiences.md create mode 100644 docs/api-route-migration.json create mode 100644 internal/domain/notification_scope.go create mode 100644 internal/web_server/api_audience.go create mode 100644 internal/web_server/api_audience_test.go create mode 100644 internal/web_server/api_docs.go create mode 100644 internal/web_server/api_docs_test.go create mode 100644 internal/web_server/routes_admin.go create mode 100644 internal/web_server/routes_client.go create mode 100644 internal/web_server/routes_integration.go create mode 100644 internal/web_server/ws/ws_test.go diff --git a/README.md b/README.md index fdf2558a..9002adfd 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ cmd/main.go | `internal/web_server` | Routes, middleware, validators, cron | | `db/query` + `db/migrations` | SQL source of truth; `sqlc generate` → `gen/db` | -API base path: **`/api/v1`** (see Swagger `@BasePath` and route groups). +API bases: **`/api/v1/admin`** for staff and **`/api/v1`** for customer web/mobile apps. See [API separation and migration](docs/api-audiences.md). --- diff --git a/db/query/notification.sql b/db/query/notification.sql index c4f70394..23da0060 100644 --- a/db/query/notification.sql +++ b/db/query/notification.sql @@ -41,18 +41,21 @@ FROM notifications; SELECT * FROM notifications WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type') ORDER BY created_at DESC LIMIT $2 OFFSET $3; -- name: GetUserNotificationCount :one SELECT COUNT(*) FROM notifications -WHERE user_id = $1; +WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type'); -- name: CountUnreadNotifications :one SELECT COUNT(*) FROM notifications WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND is_read = FALSE; -- name: MarkNotificationAsRead :one @@ -60,6 +63,7 @@ UPDATE notifications SET is_read = TRUE, read_at = NOW() WHERE id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND user_id = sqlc.arg('requester_id') RETURNING *; -- name: MarkAllUserNotificationsAsRead :exec @@ -67,6 +71,7 @@ UPDATE notifications SET is_read = TRUE, read_at = NOW() WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND is_read = FALSE; -- name: MarkNotificationAsUnread :one @@ -74,6 +79,7 @@ UPDATE notifications SET is_read = FALSE, read_at = NULL WHERE id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND user_id = sqlc.arg('requester_id') RETURNING *; -- name: MarkAllUserNotificationsAsUnread :exec @@ -81,21 +87,25 @@ UPDATE notifications SET is_read = FALSE, read_at = NULL WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND is_read = TRUE; -- name: DeleteUserNotifications :exec DELETE FROM notifications -WHERE user_id = $1; +WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type'); -- name: DeleteUserInAppNotification :execrows DELETE FROM notifications WHERE id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND user_id = $2 AND channel = 'in_app'; -- name: DeleteUserInAppNotificationsByIDs :execrows DELETE FROM notifications WHERE user_id = $1 + AND receiver_type = sqlc.arg('receiver_type') AND channel = 'in_app' AND id = ANY($2::BIGINT[]); diff --git a/db/tests/notification-audiences.test.cjs b/db/tests/notification-audiences.test.cjs new file mode 100644 index 00000000..a4797a51 --- /dev/null +++ b/db/tests/notification-audiences.test.cjs @@ -0,0 +1,32 @@ +const { createRequire } = require('node:module'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); +const assert = require('node:assert/strict'); +const load = process.env.REFERRAL_TEST_PACKAGE_JSON ? createRequire(process.env.REFERRAL_TEST_PACKAGE_JSON) : require; +const { PGlite } = load('@electric-sql/pglite'); +(async()=>{ + const db=new PGlite(); + try { + await db.exec(`CREATE TABLE notifications(id BIGINT PRIMARY KEY,user_id BIGINT,receiver_type TEXT,channel TEXT,is_read BOOLEAN DEFAULT FALSE,created_at TIMESTAMPTZ DEFAULT NOW(),read_at TIMESTAMPTZ); + INSERT INTO notifications(id,user_id,receiver_type,channel) VALUES (1,42,'user','in_app'),(2,42,'team_member','in_app'),(3,99,'user','in_app');`); + const source=readFileSync(path.join(__dirname,'../query/notification.sql'),'utf8'); + function sql(name){ + let statement=source.split('-- name: '+name+' :')[1].split('\n').slice(1).join('\n').split('-- name:')[0]; + const positional=[...statement.matchAll(/\$(\d+)/g)].map(match=>Number(match[1]));let next=Math.max(...positional)+1; + for(const argument of ['receiver_type','requester_id']){if(statement.includes("sqlc.arg('"+argument+"')")){statement=statement.replaceAll("sqlc.arg('"+argument+"')",'$'+next++);}} + return statement; + } + assert.deepEqual((await db.query(sql('GetUserNotifications'),[42,20,0,'user'])).rows.map(row=>row.id),[1]); + assert.deepEqual((await db.query(sql('GetUserNotifications'),[42,20,0,'team_member'])).rows.map(row=>row.id),[2]); + assert.equal((await db.query(sql('MarkNotificationAsRead'),[2,'user',42])).rows.length,0,'receiver collision'); + assert.equal((await db.query(sql('MarkNotificationAsRead'),[3,'user',42])).rows.length,0,'other customer'); + await db.query(sql('MarkAllUserNotificationsAsRead'),[42,'user']); + assert.equal((await db.query('SELECT is_read FROM notifications WHERE id=1')).rows[0].is_read,true); + assert.equal((await db.query('SELECT is_read FROM notifications WHERE id=2')).rows[0].is_read,false,'staff row unchanged'); + assert.equal(Number((await db.query(sql('CountUnreadNotifications'),[42,'team_member'])).rows[0].count),1); + assert.equal((await db.query(sql('DeleteUserInAppNotification'),[2,42,'user'])).affectedRows,0); + await db.query(sql('DeleteUserNotifications'),[42,'user']); + assert.deepEqual((await db.query('SELECT id FROM notifications ORDER BY id')).rows.map(row=>row.id),[2,3]); + console.log('Notification SQL audience isolation checks passed.'); + }finally{await db.close()} +})().catch(error=>{console.error(error);process.exitCode=1}); diff --git a/docs/api-audiences.md b/docs/api-audiences.md new file mode 100644 index 00000000..8259de2b --- /dev/null +++ b/docs/api-audiences.md @@ -0,0 +1,74 @@ +# Admin API prefix + +Only APIs used by the admin panel receive the `/admin` prefix, under the existing API version: + +| Consumer | Base URL | Documentation | +| --- | --- | --- | +| Admin panel | `/api/v1/admin` | `/swagger/admin/index.html` | +| Customer web and mobile apps | `/api/v1` (unchanged) | `/swagger/client/index.html` | + +Customer apps do not need a `/client` prefix or a base URL change. The checkout website retains its +existing base URL configuration. Protected customer requests still use customer authentication and +subscription checks; protected admin requests require staff authentication and existing RBAC permissions. + +## Admin panel changes + +Admin route registrations live in `internal/web_server/routes_admin.go`. All panel operations, +including login, refresh, catalog authoring, question banks, users, subscriptions, payments, settings, +referrals, analytics, RBAC, notification management, CSV exports, and WebSockets, use `/api/v1/admin`. +Endpoints already under `/admin` keep a single prefix. Admin-account management is `/admin/admins`. + +The admin panel's API helper accepts `VITE_API_BASE_URL` ending in either `/api/v1` or `/api/v1/admin`. +It ensures the `/admin` prefix is added exactly once. Panel endpoint definitions no longer supply a +second `/admin` segment. Raw refresh calls, CSV downloads, and notification sockets use the same base. +Staff profiles use `/api/v1/admin/team/me` rather than the customer self-profile endpoint. + +Shared reads have separate registrations: the panel reads `/api/v1/admin/exam-prep/catalog-courses`, +while customers continue reading `/api/v1/exam-prep/catalog-courses`. Admin reads retain their existing +permissions and staff visibility. Customer reads retain publication, subscription, and free-content rules. +Raw authoring endpoints belong to the admin API; customer practice questions are delivered through +`/api/v1/exam-prep/practices/{practiceId}/questions`. + +## Examples + +| Purpose | Route | +| --- | --- | +| Staff login | `POST /api/v1/admin/team/login` | +| Staff refresh | `POST /api/v1/admin/team/refresh` | +| Manage learners | `GET /api/v1/admin/users` | +| View all payments | `GET /api/v1/admin/payments` | +| Configure referrals | `PUT /api/v1/admin/referrals/settings` | +| Author a catalog course | `POST /api/v1/admin/exam-prep/catalog-courses` | +| Customer login | `POST /api/v1/auth/customer-login` (unchanged) | +| Customer registration | `POST /api/v1/user/register` (unchanged) | +| Customer catalog | `GET /api/v1/exam-prep/catalog-courses` (unchanged) | +| Customer checkout | `POST /api/v1/payments/subscribe` (unchanged) | +| Customer subscriptions | `GET /api/v1/subscriptions/me` (unchanged) | +| Customer referrals | `GET /api/v1/referrals/me` (unchanged) | + +See `api-route-migration.json` for the complete method/path mapping. Customer and staff tokens cannot +be used interchangeably. Customer plan discovery excludes inactive plans. Customer profile-picture +updates are restricted to the authenticated account. Notification queries and live delivery distinguish +customer IDs from team-member IDs, including when numeric IDs match. + +## External integrations and documentation + +Gateway URLs retain their existing paths and verification behavior: + +- `POST /api/v1/payments/webhook` +- `GET /api/v1/payments/chapa/callback` +- `GET /api/v1/payments/chapa/success` +- `GET /api/v1/payments/arifpay/success` +- `GET /payment/success` +- `GET /api/v1/auth/google/callback` + +No payment callback configuration or database migration is required for the prefix change. +Separate OpenAPI documents are available at `/swagger/admin/doc.json` and `/swagger/client/doc.json`; +these documentation paths do not change the customer API base. The `/routes` and `/auth/test` debugging +endpoints are not exposed. + +## Verification + +Run `go test ./...` in the backend and `npm run build` in the admin and checkout repositories. +Notification SQL isolation can be checked with `node db/tests/notification-audiences.test.cjs`, using +the scratch PGlite setup and `REFERRAL_TEST_PACKAGE_JSON` described in `referral-system.md`. diff --git a/docs/api-route-migration.json b/docs/api-route-migration.json new file mode 100644 index 00000000..10fec87c --- /dev/null +++ b/docs/api-route-migration.json @@ -0,0 +1,2006 @@ +[ + { + "method": "POST", + "old": "/api/v1/referrals/code", + "new": "/api/v1/referrals/code", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/referrals/code", + "new": "/api/v1/referrals/code", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/referrals/me", + "new": "/api/v1/referrals/me", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/referrals/apply", + "new": "/api/v1/referrals/apply", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/referrals", + "new": "/api/v1/referrals", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/referrals/wallet", + "new": "/api/v1/referrals/wallet", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/admin/referrals/settings", + "new": "/api/v1/admin/referrals/settings", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/referrals/settings", + "new": "/api/v1/admin/referrals/settings", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/catalog-courses", + "new": "/api/v1/admin/exam-prep/catalog-courses", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses", + "new": "/api/v1/admin/exam-prep/catalog-courses", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses", + "new": "/api/v1/exam-prep/catalog-courses", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/catalog-courses/reorder", + "new": "/api/v1/admin/exam-prep/catalog-courses/reorder", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:id", + "new": "/api/v1/admin/exam-prep/catalog-courses/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:id", + "new": "/api/v1/exam-prep/catalog-courses/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/catalog-courses/:id", + "new": "/api/v1/admin/exam-prep/catalog-courses/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/catalog-courses/:id", + "new": "/api/v1/admin/exam-prep/catalog-courses/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/units", + "new": "/api/v1/admin/exam-prep/catalog-courses/:catalogCourseId/units", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/units", + "new": "/api/v1/admin/exam-prep/catalog-courses/:catalogCourseId/units", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/units", + "new": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/units", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/units/reorder", + "new": "/api/v1/admin/exam-prep/catalog-courses/:catalogCourseId/units/reorder", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:id", + "new": "/api/v1/admin/exam-prep/units/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:id", + "new": "/api/v1/exam-prep/units/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/units/:id", + "new": "/api/v1/admin/exam-prep/units/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/units/:id", + "new": "/api/v1/admin/exam-prep/units/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/units/:unitId/modules", + "new": "/api/v1/admin/exam-prep/units/:unitId/modules", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:unitId/modules", + "new": "/api/v1/admin/exam-prep/units/:unitId/modules", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:unitId/modules", + "new": "/api/v1/exam-prep/units/:unitId/modules", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/units/:unitId/modules/reorder", + "new": "/api/v1/admin/exam-prep/units/:unitId/modules/reorder", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/modules/:id", + "new": "/api/v1/admin/exam-prep/modules/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/modules/:id", + "new": "/api/v1/exam-prep/modules/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/modules/:id", + "new": "/api/v1/admin/exam-prep/modules/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/modules/:id", + "new": "/api/v1/admin/exam-prep/modules/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/modules/:moduleId/lessons", + "new": "/api/v1/admin/exam-prep/modules/:moduleId/lessons", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/modules/:moduleId/lessons", + "new": "/api/v1/admin/exam-prep/modules/:moduleId/lessons", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/modules/:moduleId/lessons", + "new": "/api/v1/exam-prep/modules/:moduleId/lessons", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/modules/:moduleId/lessons/reorder", + "new": "/api/v1/admin/exam-prep/modules/:moduleId/lessons/reorder", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/lessons/:id", + "new": "/api/v1/admin/exam-prep/lessons/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/lessons/:id", + "new": "/api/v1/exam-prep/lessons/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/lessons/:id", + "new": "/api/v1/admin/exam-prep/lessons/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/lessons/:id", + "new": "/api/v1/admin/exam-prep/lessons/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/assessments", + "new": "/api/v1/admin/exam-prep/assessments", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/assessments", + "new": "/api/v1/exam-prep/assessments", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/assessments", + "new": "/api/v1/admin/exam-prep/assessments", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/assessments/:questionSetId/parents/:parentKind/:parentId", + "new": "/api/v1/admin/exam-prep/assessments/:questionSetId/parents/:parentKind/:parentId", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/practices", + "new": "/api/v1/admin/exam-prep/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices", + "new": "/api/v1/admin/exam-prep/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices", + "new": "/api/v1/exam-prep/practices", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/practices", + "new": "/api/v1/admin/exam-prep/catalog-courses/:catalogCourseId/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/practices", + "new": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/practices", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/catalog-courses/:catalogCourseId/practices", + "new": "/api/v1/admin/exam-prep/catalog-courses/:catalogCourseId/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:unitId/practices", + "new": "/api/v1/admin/exam-prep/units/:unitId/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/units/:unitId/practices", + "new": "/api/v1/exam-prep/units/:unitId/practices", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/units/:unitId/practices", + "new": "/api/v1/admin/exam-prep/units/:unitId/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/lessons/:lessonId/practices", + "new": "/api/v1/admin/exam-prep/lessons/:lessonId/practices", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/lessons/:lessonId/practices", + "new": "/api/v1/exam-prep/lessons/:lessonId/practices", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices/:id", + "new": "/api/v1/admin/exam-prep/practices/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices/:id", + "new": "/api/v1/exam-prep/practices/:id", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices/:id/full", + "new": "/api/v1/admin/exam-prep/practices/:id/full", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/practices/:id", + "new": "/api/v1/admin/exam-prep/practices/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/practices/:id/full", + "new": "/api/v1/admin/exam-prep/practices/:id/full", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/exam-prep/practices/:id/parents", + "new": "/api/v1/admin/exam-prep/practices/:id/parents", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/practices/:id/parents/:parentKind/:parentId", + "new": "/api/v1/admin/exam-prep/practices/:id/parents/:parentKind/:parentId", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/exam-prep/practices/:id", + "new": "/api/v1/admin/exam-prep/practices/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/progress/practices/:id/complete", + "new": "/api/v1/exam-prep/progress/practices/:id/complete", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/exam-prep/videos/engagement/heartbeat", + "new": "/api/v1/exam-prep/videos/engagement/heartbeat", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/progress-summary", + "new": "/api/v1/exam-prep/progress-summary", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/exam-prep/practices/:practiceId/questions", + "new": "/api/v1/exam-prep/practices/:practiceId/questions", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/personas", + "new": "/api/v1/admin/personas", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/personas", + "new": "/api/v1/personas", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/personas", + "new": "/api/v1/admin/personas", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/personas/:id", + "new": "/api/v1/admin/personas/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/personas/:id", + "new": "/api/v1/personas/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/personas/:id", + "new": "/api/v1/admin/personas/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/personas/:id", + "new": "/api/v1/admin/personas/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/files/url", + "new": "/api/v1/admin/files/url", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/files/url", + "new": "/api/v1/files/url", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/files/refresh-url", + "new": "/api/v1/admin/files/refresh-url", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/files/refresh-url", + "new": "/api/v1/files/refresh-url", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/files/presign-upload", + "new": "/api/v1/admin/files/presign-upload", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/files/presign-upload", + "new": "/api/v1/files/presign-upload", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/files/complete-upload", + "new": "/api/v1/admin/files/complete-upload", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/files/complete-upload", + "new": "/api/v1/files/complete-upload", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/files/upload", + "new": "/api/v1/admin/files/upload", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/files/upload", + "new": "/api/v1/files/upload", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/files/audio", + "new": "/api/v1/admin/files/audio", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/files/audio", + "new": "/api/v1/files/audio", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/questions/audio-answer", + "new": "/api/v1/questions/audio-answer", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/questions", + "new": "/api/v1/admin/questions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions", + "new": "/api/v1/admin/questions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/search", + "new": "/api/v1/admin/questions/search", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/component-catalog", + "new": "/api/v1/admin/questions/component-catalog", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/questions/validate-question-type-definition", + "new": "/api/v1/admin/questions/validate-question-type-definition", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/questions/type-definition-groups", + "new": "/api/v1/admin/questions/type-definition-groups", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/type-definition-groups", + "new": "/api/v1/admin/questions/type-definition-groups", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/type-definition-groups/:id", + "new": "/api/v1/admin/questions/type-definition-groups/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/questions/type-definition-groups/:id", + "new": "/api/v1/admin/questions/type-definition-groups/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/questions/type-definition-groups/:id", + "new": "/api/v1/admin/questions/type-definition-groups/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/questions/type-definitions", + "new": "/api/v1/admin/questions/type-definitions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/type-definitions", + "new": "/api/v1/admin/questions/type-definitions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/type-definitions/:id", + "new": "/api/v1/admin/questions/type-definitions/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/type-definitions/:id/practices", + "new": "/api/v1/admin/questions/type-definitions/:id/practices", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/questions/type-definitions/:id", + "new": "/api/v1/admin/questions/type-definitions/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/questions/type-definitions/:id", + "new": "/api/v1/admin/questions/type-definitions/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/questions/:id", + "new": "/api/v1/admin/questions/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/questions/:id", + "new": "/api/v1/admin/questions/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/questions/:id", + "new": "/api/v1/admin/questions/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/faqs", + "new": "/api/v1/faqs", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/faqs/:id", + "new": "/api/v1/faqs/:id", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/admin/faqs", + "new": "/api/v1/admin/faqs", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/faqs/:id", + "new": "/api/v1/admin/faqs/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/faqs", + "new": "/api/v1/admin/faqs", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/faqs/:id", + "new": "/api/v1/admin/faqs/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/admin/faqs/:id", + "new": "/api/v1/admin/faqs/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/app/version/check", + "new": "/api/v1/app/version/check", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/admin/app-versions", + "new": "/api/v1/admin/app-versions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/app-versions/:id", + "new": "/api/v1/admin/app-versions/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/app-versions", + "new": "/api/v1/admin/app-versions", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/app-versions/:id", + "new": "/api/v1/admin/app-versions/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/admin/app-versions/:id", + "new": "/api/v1/admin/app-versions/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/email-templates", + "new": "/api/v1/admin/email-templates", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/email-templates/slug/:slug", + "new": "/api/v1/admin/email-templates/slug/:slug", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/email-templates/slug/:slug/preview", + "new": "/api/v1/admin/email-templates/slug/:slug/preview", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/email-templates/:id", + "new": "/api/v1/admin/email-templates/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/email-templates/:id/preview", + "new": "/api/v1/admin/email-templates/:id/preview", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/email-templates", + "new": "/api/v1/admin/email-templates", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/email-templates/:id", + "new": "/api/v1/admin/email-templates/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/admin/email-templates/:id", + "new": "/api/v1/admin/email-templates/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/field-options", + "new": "/api/v1/field-options", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/field-options/fields", + "new": "/api/v1/field-options/fields", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/admin/field-options", + "new": "/api/v1/admin/field-options", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/field-options/:id", + "new": "/api/v1/admin/field-options/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/field-options", + "new": "/api/v1/admin/field-options", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/field-options/:id", + "new": "/api/v1/admin/field-options/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/admin/field-options/:id", + "new": "/api/v1/admin/field-options/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/payments", + "new": "/api/v1/admin/payments", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/payments/export", + "new": "/api/v1/admin/payments/export", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/payments/:id", + "new": "/api/v1/admin/payments/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/question-sets", + "new": "/api/v1/admin/question-sets", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets", + "new": "/api/v1/admin/question-sets", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets/by-owner", + "new": "/api/v1/admin/question-sets/by-owner", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets/:id", + "new": "/api/v1/admin/question-sets/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/question-sets/:id", + "new": "/api/v1/admin/question-sets/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/question-sets/:id", + "new": "/api/v1/admin/question-sets/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/question-sets/:setId/questions", + "new": "/api/v1/admin/question-sets/:setId/questions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets/:setId/question-types", + "new": "/api/v1/admin/question-sets/:setId/question-types", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets/:setId/questions", + "new": "/api/v1/admin/question-sets/:setId/questions", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/question-sets/:setId/questions/:questionId", + "new": "/api/v1/admin/question-sets/:setId/questions/:questionId", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/question-sets/:setId/questions/:questionId/order", + "new": "/api/v1/admin/question-sets/:setId/questions/:questionId/order", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/question-sets/:setId/personas", + "new": "/api/v1/admin/question-sets/:setId/personas", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/question-sets/:setId/personas", + "new": "/api/v1/admin/question-sets/:setId/personas", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/question-sets/:setId/personas/:userId", + "new": "/api/v1/admin/question-sets/:setId/personas/:userId", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/subscription-plans", + "new": "/api/v1/admin/subscription-plans", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/subscription-plans", + "new": "/api/v1/admin/subscription-plans", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/subscription-plans", + "new": "/api/v1/subscription-plans", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/subscription-plans/:id", + "new": "/api/v1/admin/subscription-plans/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/subscription-plans/:id", + "new": "/api/v1/subscription-plans/:id", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/subscription-plans/:id", + "new": "/api/v1/admin/subscription-plans/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/subscription-plans/:id", + "new": "/api/v1/admin/subscription-plans/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/subscriptions", + "new": "/api/v1/subscriptions", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/subscriptions/checkout", + "new": "/api/v1/subscriptions/checkout", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/subscriptions/request-checkout-link", + "new": "/api/v1/subscriptions/request-checkout-link", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/subscriptions/me", + "new": "/api/v1/subscriptions/me", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/subscriptions/history", + "new": "/api/v1/subscriptions/history", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/subscriptions/status", + "new": "/api/v1/subscriptions/status", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/subscriptions/:id/cancel", + "new": "/api/v1/subscriptions/:id/cancel", + "audience": "client" + }, + { + "method": "PUT", + "old": "/api/v1/subscriptions/:id/auto-renew", + "new": "/api/v1/subscriptions/:id/auto-renew", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/subscribe", + "new": "/api/v1/payments/subscribe", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments/verify/:session_id", + "new": "/api/v1/payments/verify/:session_id", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments", + "new": "/api/v1/payments", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments/methods", + "new": "/api/v1/payments/methods", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments/:id", + "new": "/api/v1/payments/:id", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/:id/cancel", + "new": "/api/v1/payments/:id/cancel", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/webhook", + "new": "/api/v1/payments/webhook", + "audience": "integration" + }, + { + "method": "GET", + "old": "/api/v1/payments/arifpay/success", + "new": "/api/v1/payments/arifpay/success", + "audience": "integration" + }, + { + "method": "GET", + "old": "/api/v1/payments/chapa/success", + "new": "/api/v1/payments/chapa/success", + "audience": "integration" + }, + { + "method": "GET", + "old": "/api/v1/payments/chapa/callback", + "new": "/api/v1/payments/chapa/callback", + "audience": "integration" + }, + { + "method": "POST", + "old": "/api/v1/payments/chapa/direct", + "new": "/api/v1/payments/chapa/direct", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/chapa/direct/authorize", + "new": "/api/v1/payments/chapa/direct/authorize", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments/chapa/direct/methods", + "new": "/api/v1/payments/chapa/direct/methods", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/direct", + "new": "/api/v1/payments/direct", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/payments/direct/verify-otp", + "new": "/api/v1/payments/direct/verify-otp", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/payments/direct/methods", + "new": "/api/v1/payments/direct/methods", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/auth/google/android", + "new": "/api/v1/auth/google/android", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/auth/google/login", + "new": "/api/v1/auth/google/login", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/auth/google/callback", + "new": "/api/v1/auth/google/callback", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/auth/apple", + "new": "/api/v1/auth/apple", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/auth/customer-login", + "new": "/api/v1/auth/customer-login", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/auth/admin-login", + "new": "/api/v1/admin/auth/admin-login", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/auth/super-login", + "new": "/api/v1/admin/auth/super-login", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/auth/refresh", + "new": "/api/v1/auth/refresh", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/:id/profile-picture", + "new": "/api/v1/user/:id/profile-picture", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/auth/logout", + "new": "/api/v1/auth/logout", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/user/:user_id/is-profile-completed", + "new": "/api/v1/user/:user_id/is-profile-completed", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/users", + "new": "/api/v1/admin/users", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/users/export", + "new": "/api/v1/admin/users/export", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/users/deletion-requests", + "new": "/api/v1/admin/users/deletion-requests", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/subscriptions/export", + "new": "/api/v1/admin/subscriptions/export", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/subscriptions/:id/cancel", + "new": "/api/v1/admin/subscriptions/:id/cancel", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/users/:user_id/recent-activity", + "new": "/api/v1/admin/users/:user_id/recent-activity", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/users/:user_id/learning-activity", + "new": "/api/v1/admin/users/:user_id/learning-activity", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/users/:user_id/subscriptions", + "new": "/api/v1/admin/users/:user_id/subscriptions", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/users/:user_id/subscriptions/extend", + "new": "/api/v1/admin/users/:user_id/subscriptions/extend", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/users/summary", + "new": "/api/v1/admin/users/summary", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/user", + "new": "/api/v1/user", + "audience": "client" + }, + { + "method": "PATCH", + "old": "/api/v1/user/status", + "new": "/api/v1/admin/user/status", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/user/knowledge-level", + "new": "/api/v1/user/knowledge-level", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/user/:user_name/is-pending", + "new": "/api/v1/user/:user_name/is-pending", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/resetPassword", + "new": "/api/v1/user/resetPassword", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/sendResetCode", + "new": "/api/v1/user/sendResetCode", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/verify-otp", + "new": "/api/v1/user/verify-otp", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/resend-otp", + "new": "/api/v1/user/resend-otp", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/register", + "new": "/api/v1/user/register", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/sendRegisterCode", + "new": "/api/v1/user/sendRegisterCode", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/checkPhoneEmailExist", + "new": "/api/v1/user/checkPhoneEmailExist", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/user/admin-profile", + "new": "/api/v1/admin/user/admin-profile", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/user/user-profile", + "new": "/api/v1/user/user-profile", + "audience": "client" + }, + { + "method": "DELETE", + "old": "/api/v1/user/me", + "new": "/api/v1/user/me", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/me/deletion/cancel", + "new": "/api/v1/user/me/deletion/cancel", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/internal/users/purge-due-deletions", + "new": "/api/v1/admin/internal/users/purge-due-deletions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/user/single/:id", + "new": "/api/v1/admin/user/single/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/user/delete/:id", + "new": "/api/v1/admin/user/delete/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/user/search", + "new": "/api/v1/admin/user/search", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin", + "new": "/api/v1/admin/admins", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/admin/:id", + "new": "/api/v1/admin/admins/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin", + "new": "/api/v1/admin/admins", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/admin/:id", + "new": "/api/v1/admin/admins/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/roles/:role/bulk-deactivate", + "new": "/api/v1/admin/admins/roles/:role/bulk-deactivate", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/admin/roles/:role/bulk-reactivate", + "new": "/api/v1/admin/admins/roles/:role/bulk-reactivate", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/logs", + "new": "/api/v1/admin/logs", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/activity-logs", + "new": "/api/v1/admin/activity-logs", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/activity-logs/export", + "new": "/api/v1/admin/activity-logs/export", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/activity-logs/:id", + "new": "/api/v1/admin/activity-logs/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/sendSMS", + "new": "/api/v1/admin/sendSMS", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/ws/connect", + "new": "/api/v1/admin/ws/connect", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/ws/connect", + "new": "/api/v1/ws/connect", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/notifications", + "new": "/api/v1/admin/notifications", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/notifications", + "new": "/api/v1/notifications", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/notifications/all", + "new": "/api/v1/admin/notifications/all", + "audience": "admin" + }, + { + "method": "PATCH", + "old": "/api/v1/notifications/:id/read", + "new": "/api/v1/admin/notifications/:id/read", + "audience": "admin" + }, + { + "method": "PATCH", + "old": "/api/v1/notifications/:id/read", + "new": "/api/v1/notifications/:id/read", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/notifications/mark-all-read", + "new": "/api/v1/admin/notifications/mark-all-read", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/mark-all-read", + "new": "/api/v1/notifications/mark-all-read", + "audience": "client" + }, + { + "method": "PATCH", + "old": "/api/v1/notifications/:id/unread", + "new": "/api/v1/admin/notifications/:id/unread", + "audience": "admin" + }, + { + "method": "PATCH", + "old": "/api/v1/notifications/:id/unread", + "new": "/api/v1/notifications/:id/unread", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/notifications/mark-all-unread", + "new": "/api/v1/admin/notifications/mark-all-unread", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/mark-all-unread", + "new": "/api/v1/notifications/mark-all-unread", + "audience": "client" + }, + { + "method": "DELETE", + "old": "/api/v1/notifications", + "new": "/api/v1/admin/notifications", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/notifications", + "new": "/api/v1/notifications", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/notifications/delete-in-app", + "new": "/api/v1/admin/notifications/delete-in-app", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/delete-in-app", + "new": "/api/v1/notifications/delete-in-app", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/notifications/unread", + "new": "/api/v1/admin/notifications/unread", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/notifications/unread", + "new": "/api/v1/notifications/unread", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/notifications/create", + "new": "/api/v1/admin/notifications/create", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/test-push", + "new": "/api/v1/admin/notifications/test-push", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/bulk-push", + "new": "/api/v1/admin/notifications/bulk-push", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/bulk-sms", + "new": "/api/v1/admin/notifications/bulk-sms", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/bulk-in-app", + "new": "/api/v1/admin/notifications/bulk-in-app", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/send-email", + "new": "/api/v1/admin/notifications/send-email", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/bulk-email", + "new": "/api/v1/admin/notifications/bulk-email", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/notifications/scheduled", + "new": "/api/v1/admin/notifications/scheduled", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/notifications/scheduled/:id", + "new": "/api/v1/admin/notifications/scheduled/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/notifications/scheduled/:id/cancel", + "new": "/api/v1/admin/notifications/scheduled/:id/cancel", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/notifications/:id", + "new": "/api/v1/admin/notifications/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/notifications/:id", + "new": "/api/v1/notifications/:id", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/notifications/:id", + "new": "/api/v1/admin/notifications/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/notifications/:id", + "new": "/api/v1/notifications/:id", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/issues", + "new": "/api/v1/issues", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/issues/me", + "new": "/api/v1/issues/me", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/issues/user/:user_id", + "new": "/api/v1/admin/issues/user/:user_id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/issues", + "new": "/api/v1/admin/issues", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/issues/:id", + "new": "/api/v1/admin/issues/:id", + "audience": "admin" + }, + { + "method": "PATCH", + "old": "/api/v1/issues/:id/status", + "new": "/api/v1/admin/issues/:id/status", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/issues/:id", + "new": "/api/v1/admin/issues/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/devices/register", + "new": "/api/v1/admin/devices/register", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/devices/register", + "new": "/api/v1/devices/register", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/devices/unregister", + "new": "/api/v1/admin/devices/unregister", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/devices/unregister", + "new": "/api/v1/devices/unregister", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/settings", + "new": "/api/v1/admin/settings", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/settings/:key", + "new": "/api/v1/admin/settings/:key", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/settings", + "new": "/api/v1/admin/settings", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/analytics/dashboard", + "new": "/api/v1/admin/analytics/dashboard", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/videos", + "new": "/api/v1/admin/vimeo/videos", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/videos/:video_id", + "new": "/api/v1/admin/vimeo/videos/:video_id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/videos/:video_id/embed", + "new": "/api/v1/admin/vimeo/videos/:video_id/embed", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/videos/:video_id/status", + "new": "/api/v1/admin/vimeo/videos/:video_id/status", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/vimeo/videos/:video_id", + "new": "/api/v1/admin/vimeo/videos/:video_id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/vimeo/uploads/pull", + "new": "/api/v1/admin/vimeo/uploads/pull", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/vimeo/uploads/tus", + "new": "/api/v1/admin/vimeo/uploads/tus", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/oembed", + "new": "/api/v1/admin/vimeo/oembed", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/oembed", + "new": "/api/v1/vimeo/oembed", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/sample", + "new": "/api/v1/admin/vimeo/sample", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/vimeo/sample", + "new": "/api/v1/vimeo/sample", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/team/login", + "new": "/api/v1/admin/team/login", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/refresh", + "new": "/api/v1/admin/team/refresh", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/sendResetCode", + "new": "/api/v1/admin/team/sendResetCode", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/verifyResetCode", + "new": "/api/v1/admin/team/verifyResetCode", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/resetPassword", + "new": "/api/v1/admin/team/resetPassword", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/invitations/verify", + "new": "/api/v1/admin/team/invitations/verify", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/invitations/accept", + "new": "/api/v1/admin/team/invitations/accept", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/me", + "new": "/api/v1/admin/team/me", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/team/me", + "new": "/api/v1/admin/team/me", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/stats", + "new": "/api/v1/admin/team/stats", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/members", + "new": "/api/v1/admin/team/members", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/members/export", + "new": "/api/v1/admin/team/members/export", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/members/invite", + "new": "/api/v1/admin/team/members/invite", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/members", + "new": "/api/v1/admin/team/members", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/members/:id/resend-invite", + "new": "/api/v1/admin/team/members/:id/resend-invite", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/members/:id", + "new": "/api/v1/admin/team/members/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/team/members/:id", + "new": "/api/v1/admin/team/members/:id", + "audience": "admin" + }, + { + "method": "PATCH", + "old": "/api/v1/team/members/:id/status", + "new": "/api/v1/admin/team/members/:id/status", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/team/members/:id", + "new": "/api/v1/admin/team/members/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/members/:id/change-password", + "new": "/api/v1/admin/team/members/:id/change-password", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/team/invitations", + "new": "/api/v1/admin/team/invitations", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/team/invitations/:id/revoke", + "new": "/api/v1/admin/team/invitations/:id/revoke", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/ratings", + "new": "/api/v1/ratings", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/ratings", + "new": "/api/v1/admin/ratings", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/ratings", + "new": "/api/v1/ratings", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/ratings/summary", + "new": "/api/v1/admin/ratings/summary", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/ratings/summary", + "new": "/api/v1/ratings/summary", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/ratings/me", + "new": "/api/v1/ratings/me", + "audience": "client" + }, + { + "method": "GET", + "old": "/api/v1/ratings/me/all", + "new": "/api/v1/ratings/me/all", + "audience": "client" + }, + { + "method": "DELETE", + "old": "/api/v1/ratings/:id", + "new": "/api/v1/admin/ratings/:id", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/rbac/roles", + "new": "/api/v1/admin/rbac/roles", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/rbac/roles/:id", + "new": "/api/v1/admin/rbac/roles/:id", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/rbac/roles", + "new": "/api/v1/admin/rbac/roles", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/rbac/roles/:id", + "new": "/api/v1/admin/rbac/roles/:id", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/rbac/roles/:id", + "new": "/api/v1/admin/rbac/roles/:id", + "audience": "admin" + }, + { + "method": "PUT", + "old": "/api/v1/rbac/roles/:id/permissions", + "new": "/api/v1/admin/rbac/roles/:id/permissions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/rbac/roles/:id/permissions", + "new": "/api/v1/admin/rbac/roles/:id/permissions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/rbac/permissions", + "new": "/api/v1/admin/rbac/permissions", + "audience": "admin" + }, + { + "method": "GET", + "old": "/api/v1/rbac/permissions/groups", + "new": "/api/v1/admin/rbac/permissions/groups", + "audience": "admin" + }, + { + "method": "POST", + "old": "/api/v1/rbac/permissions/sync", + "new": "/api/v1/admin/rbac/permissions/sync", + "audience": "admin" + }, + { + "method": "DELETE", + "old": "/api/v1/ratings/:id", + "new": "/api/v1/ratings/:id", + "audience": "client" + }, + { + "method": "POST", + "old": "/api/v1/user/:id/profile-picture", + "new": "/api/v1/admin/user/:id/profile-picture", + "audience": "admin" + } +] diff --git a/docs/docs.go b/docs/docs.go index d86d75f9..f8048f80 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -24,7 +24,7 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/api/v1/activity-logs": { + "/api/v1/admin/activity-logs": { "get": { "description": "Returns a filtered, paginated list of activity logs", "produces": [ @@ -108,7 +108,7 @@ const docTemplate = `{ } } }, - "/api/v1/activity-logs/export": { + "/api/v1/admin/activity-logs/export": { "get": { "produces": [ "text/csv" @@ -120,7 +120,7 @@ const docTemplate = `{ "responses": {} } }, - "/api/v1/activity-logs/{id}": { + "/api/v1/admin/activity-logs/{id}": { "get": { "description": "Returns a single activity log entry by its ID", "produces": [ @@ -161,7 +161,7 @@ const docTemplate = `{ } } }, - "/api/v1/admin": { + "/api/v1/admin/admins": { "get": { "description": "Get all Admins", "consumes": [ @@ -266,6 +266,308 @@ const docTemplate = `{ } } }, + "/api/v1/admin/admins/roles/{role}/bulk-deactivate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets all platform users with the given users.role to DEACTIVATED (except the caller) and all team_members with the given team_role to inactive. Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk change other platform ADMIN users (team_members with team_role ADMIN under path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id to skip one team_members row (e.g. yourself).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "parameters": [ + { + "type": "string", + "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", + "name": "role", + "in": "path", + "required": true + }, + { + "description": "Optional exclusions", + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/admins/roles/{role}/bulk-reactivate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets all platform users with the given role from DEACTIVATED to ACTIVE (except the caller) and all team_members with the given team_role from inactive to active. Path :role may be a role key or decimal RBAC roles.id (see bulk-deactivate). Path role must correspond to valid platform users.role or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users (team_members ADMIN under path ADMIN is allowed). Matches only users currently DEACTIVATED and team rows currently inactive.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "parameters": [ + { + "type": "string", + "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", + "name": "role", + "in": "path", + "required": true + }, + { + "description": "Optional exclusions", + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/admins/{id}": { + "get": { + "description": "Get a single admin by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Get admin by id", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.AdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "put": { + "description": "Update Admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Update Admin", + "parameters": [ + { + "description": "Update Admin", + "name": "admin", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateAdminReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/analytics/dashboard": { + "get": { + "description": "Platform analytics with optional date filters in Africa/Addis_Ababa (EAT): all-time (default), year, year+month, or custom from/to range. When year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals (EAT) per currency for that calendar year. Optional payment_method filters payment/revenue metrics (exact or METHOD:% variants). Daily series remains in revenue_last_30_days (see date_filter.series_*). Courses section counts LMS + exam_prep inventory.", + "produces": [ + "application/json" + ], + "tags": [ + "analytics" + ], + "summary": "Analytics dashboard", + "parameters": [ + { + "type": "integer", + "description": "EAT calendar year (e.g. 2025)", + "name": "year", + "in": "query" + }, + { + "type": "integer", + "description": "EAT calendar month 1-12 (requires year)", + "name": "month", + "in": "query" + }, + { + "type": "string", + "description": "Custom EAT range start (YYYY-MM-DD or RFC3339)", + "name": "from", + "in": "query" + }, + { + "type": "string", + "description": "Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive)", + "name": "to", + "in": "query" + }, + { + "type": "string", + "description": "Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT)", + "name": "payment_method", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AnalyticsDashboard" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, "/api/v1/admin/app-versions": { "get": { "security": [ @@ -537,6 +839,138 @@ const docTemplate = `{ } } }, + "/api/v1/admin/auth/admin-login": { + "post": { + "description": "Login user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login user", + "parameters": [ + { + "description": "Login admin", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.LoginAdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/auth/super-login": { + "post": { + "description": "Login super-admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login super-admin", + "parameters": [ + { + "description": "Login super-admin", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.LoginAdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/devices/register": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "RegisterDeviceToken", + "responses": {} + } + }, + "/api/v1/admin/devices/unregister": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "UnregisterDeviceToken", + "responses": {} + } + }, "/api/v1/admin/email-templates": { "get": { "description": "Returns email templates for admin management", @@ -953,6 +1387,984 @@ const docTemplate = `{ } } }, + "/api/v1/admin/exam-prep/assessments": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "ListExamPrepAssessments", + "responses": {} + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "LinkExamPrepAssessment", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/assessments/{questionSetId}/parents/{parentKind}/{parentId}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UnlinkExamPrepAssessment", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep catalog courses", + "parameters": [ + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "description": "Top-level exam track (DET, IELTS, …) in schema exam_prep — separate from LMS programs/courses", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep catalog course", + "parameters": [ + { + "description": "Catalog course", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepCatalogCourseInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/reorder": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Reorder all exam-prep catalog courses", + "parameters": [ + { + "description": "ordered_ids: every catalog course id exactly once", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the catalog course.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice under a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep units for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "description": "Unit under a catalog course (e.g. chapter title). Optional sort_order assigns position within that catalog course (siblings at or after that index are shifted); omit to append after the current highest sort_order in the catalog course.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "Unit", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepUnitInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder units within a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "ordered_ids: every unit id in this catalog course, new order", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep catalog course by ID", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepCatalogCourseInput" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/lessons/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep lesson by ID", + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep lesson", + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep lesson", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/lessons/{lessonId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a lesson", + "parameters": [ + { + "type": "integer", + "description": "Exam prep lesson ID", + "name": "lessonId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the lesson.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep module by ID", + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep module", + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep module", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{moduleId}/lessons": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep lessons for a unit module", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep lesson (under a unit module)", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "description": "Lesson", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepLessonInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{moduleId}/lessons/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder lessons within an exam-prep unit module", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices globally", + "parameters": [ + { + "type": "integer", + "description": "Page size. Omit (with offset) to return all practices.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset. Defaults to 0 when limit is provided; ignored semantics when both omitted (all rows).", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "description": "When true, return only practices with no parent links (admin)", + "name": "unlinked_only", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice (optional parents; link later via PUT /exam-prep/practices/:id/parents)", + "parameters": [ + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice by ID", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep practice", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepPracticeInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep practice", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}/full": { + "get": { + "description": "Returns exam-prep practice metadata, linked question set settings, and all questions in the set.", + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice with question set and questions", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates exam-prep practice metadata, linked question set settings, and syncs questions in one request.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Full update exam-prep practice with question set and questions", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Full practice update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.FullUpdatePracticeInput" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/exam-prep/practices/{id}/parents": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Replace exam-prep practice parent links", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Parent links (replaces all; use empty array to detach)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepPracticeParentsInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}/parents/{parentKind}/{parentId}": { + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Unlink one exam-prep practice parent", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent kind (CATALOG_COURSE, UNIT, LESSON)", + "name": "parentKind", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Parent entity ID", + "name": "parentId", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep unit by ID", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepUnitInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/modules": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep modules for a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep module", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "Module", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepModuleInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/modules/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder modules within a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "ordered_ids", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the unit.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice under a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, "/api/v1/admin/faqs": { "get": { "description": "Returns FAQs for admin management with status/category filtering", @@ -1372,6 +2784,1366 @@ const docTemplate = `{ } } }, + "/api/v1/admin/files/audio": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "files" + ], + "summary": "Upload an audio file", + "parameters": [ + { + "type": "file", + "description": "Audio file (mp3, wav, ogg, m4a, aac, webm)", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/complete-upload": { + "post": { + "description": "Call after PUT upload to upload_url. Returns the same file metadata shape as POST /files/upload.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Complete presigned MinIO upload", + "parameters": [ + { + "description": "Complete upload request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.completePresignedUploadReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/presign-upload": { + "post": { + "description": "Returns a short-lived PUT URL and object key. Upload the file with HTTP PUT to upload_url using the same Content-Type, then call POST /files/complete-upload.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Create presigned MinIO upload URL", + "parameters": [ + { + "description": "Presigned upload request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.presignedUploadReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/refresh-url": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Refresh presigned URL for a file", + "parameters": [ + { + "description": "reference (object key, minio://..., or existing presigned URL)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.refreshFileURLReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/upload": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "files" + ], + "summary": "Upload media file", + "parameters": [ + { + "type": "string", + "description": "Media type: image|audio|video|pdf", + "name": "media_type", + "in": "formData", + "required": true + }, + { + "type": "file", + "description": "Media file", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/url": { + "get": { + "tags": [ + "files" + ], + "summary": "Get presigned URL for a file", + "parameters": [ + { + "type": "string", + "description": "MinIO object key (e.g. profile_pictures/uuid.jpg)", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/internal/users/purge-due-deletions": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Worker-safe purge for due self-deletion requests", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Purge due account deletions", + "parameters": [ + { + "type": "integer", + "description": "Max users to purge in one run (default 100, max 1000)", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/issues": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns all reported issues with pagination (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get all issues", + "parameters": [ + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueListRes" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/user/{user_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns paginated issues reported by a specific user (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get issues for a specific user", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueListRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns a single issue report by its ID (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get issue by ID", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes an issue report (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Delete an issue", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/{id}/status": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Updates the status of an issue (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Update issue status", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateIssueStatusReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/logs": { + "get": { + "description": "Fetches application logs from MongoDB with pagination, level filtering, and search", + "produces": [ + "application/json" + ], + "tags": [ + "Logs" + ], + "summary": "Retrieve application logs with filtering and pagination", + "parameters": [ + { + "type": "string", + "description": "Filter logs by level (debug, info, warn, error, dpanic, panic, fatal)", + "name": "level", + "in": "query" + }, + { + "type": "string", + "description": "Search term to match against message or fields", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "Page number for pagination (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "Number of items per page (default: 50, max: 100)", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Paginated list of application logs", + "schema": { + "$ref": "#/definitions/domain.LogResponse" + } + }, + "400": { + "description": "Invalid request parameters", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "GetUserNotification", + "responses": {} + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "DeleteUserNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/all": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetAllNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/bulk-email": { + "post": { + "description": "Sends an email to specified user IDs, users of a platform role, team member IDs, team members of a team_role, or direct email addresses with optional image attachment. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk email", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-in-app": { + "post": { + "description": "Creates in-app notifications for specified platform user IDs, users matching a platform role, team member IDs, or team members matching a team_role. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk in-app notification", + "parameters": [ + { + "description": "Bulk in-app content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "level": { + "type": "string" + }, + "message": { + "type": "string" + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "team_member_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "team_role": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-push": { + "post": { + "description": "Sends a push notification to specified user IDs or all users matching a role. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk push notification", + "parameters": [ + { + "description": "Bulk push content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "image": { + "type": "string" + }, + "message": { + "type": "string" + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "title": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-sms": { + "post": { + "description": "Sends an SMS to specified user IDs, all users of a role, or direct phone numbers. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk SMS", + "parameters": [ + { + "description": "Bulk SMS content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "phone_numbers": { + "type": "array", + "items": { + "type": "string" + } + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/create": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "CreateAndSendNotification", + "responses": {} + } + }, + "/api/v1/admin/notifications/delete-in-app": { + "post": { + "description": "Deletes in-app notifications by ID for the authenticated user. Non-matching IDs are ignored.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Delete multiple in-app notifications", + "parameters": [ + { + "description": "Notification IDs", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/mark-all-read": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsRead", + "responses": {} + } + }, + "/api/v1/admin/notifications/mark-all-unread": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsUnread", + "responses": {} + } + }, + "/api/v1/admin/notifications/scheduled": { + "get": { + "description": "Returns paginated scheduled notifications with optional status, channel, and date filters", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "List scheduled notifications", + "parameters": [ + { + "type": "string", + "description": "Filter by status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Filter by channel", + "name": "channel", + "in": "query" + }, + { + "type": "string", + "description": "Filter after date (RFC3339)", + "name": "after", + "in": "query" + }, + { + "type": "string", + "description": "Filter before date (RFC3339)", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "Page number", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/scheduled/{id}": { + "get": { + "description": "Returns a single scheduled notification by its ID", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Get scheduled notification", + "parameters": [ + { + "type": "integer", + "description": "Scheduled Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/scheduled/{id}/cancel": { + "post": { + "description": "Cancels a scheduled notification if it is still pending or processing", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Cancel scheduled notification", + "parameters": [ + { + "type": "integer", + "description": "Scheduled Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/send-email": { + "post": { + "description": "Sends an email to a single email address with optional image attachment", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send single email", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/test-push": { + "post": { + "description": "Sends a test push notification to all registered devices of the current user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send test push notification", + "parameters": [ + { + "description": "Test notification content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "title": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/unread": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "CountUnreadNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/{id}": { + "get": { + "description": "Returns a single in-app notification. Users may only fetch their own notifications unless they have list-all access.", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Get in-app notification by ID", + "parameters": [ + { + "type": "integer", + "description": "Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Deletes one in-app notification owned by the authenticated user.", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Delete a single in-app notification", + "parameters": [ + { + "type": "integer", + "description": "Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/{id}/read": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsRead", + "responses": {} + } + }, + "/api/v1/admin/notifications/{id}/unread": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsUnread", + "responses": {} + } + }, "/api/v1/admin/payments": { "get": { "description": "Returns paginated payments across Chapa and ArifPay with optional filters", @@ -1551,14 +4323,179 @@ const docTemplate = `{ } } }, - "/api/v1/admin/roles/{role}/bulk-deactivate": { - "post": { - "security": [ + "/api/v1/admin/personas": { + "get": { + "tags": [ + "personas" + ], + "summary": "List LMS personas (catalog for practice assignment)", + "parameters": [ { - "Bearer": [] + "type": "boolean", + "default": true, + "description": "When true (default), return only active personas", + "name": "active_only", + "in": "query" + }, + { + "type": "integer", + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset", + "name": "offset", + "in": "query" } ], - "description": "Sets all platform users with the given users.role to DEACTIVATED (except the caller) and all team_members with the given team_role to inactive. Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk change other platform ADMIN users (team_members with team_role ADMIN under path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id to skip one team_members row (e.g. yourself).", + "responses": {} + }, + "post": { + "consumes": [ + "application/json" + ], + "tags": [ + "personas" + ], + "summary": "Create LMS persona catalog entry", + "parameters": [ + { + "description": "Persona", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateLmsPersonaInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/personas/{id}": { + "get": { + "tags": [ + "personas" + ], + "summary": "Get LMS persona by ID", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "personas" + ], + "summary": "Update LMS persona", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateLmsPersonaInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "personas" + ], + "summary": "Delete LMS persona (practices referencing it will have persona_id cleared)", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/question-sets": { + "get": { + "description": "Returns a paginated list of question sets filtered by type", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question sets by type", + "parameters": [ + { + "type": "string", + "description": "Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE)", + "name": "set_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new question set (practice, assessment, quiz, exam, or survey)", "consumes": [ "application/json" ], @@ -1566,23 +4503,157 @@ const docTemplate = `{ "application/json" ], "tags": [ - "admin" + "question-sets" ], - "summary": "Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "summary": "Create a new question set", + "parameters": [ + { + "description": "Create question set payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionSetReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/by-owner": { + "get": { + "description": "Returns question sets for a specific owner (e.g., sub-course)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question sets by owner", "parameters": [ { "type": "string", - "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", - "name": "role", + "description": "Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE)", + "name": "owner_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Owner ID", + "name": "owner_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{id}": { + "get": { + "description": "Returns a question set with question count", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question set by ID", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a question set's properties", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Update a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", "in": "path", "required": true }, { - "description": "Optional exclusions", + "description": "Update question set payload", "name": "body", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + "$ref": "#/definitions/handlers.updateQuestionSetReq" } } ], @@ -1599,8 +4670,222 @@ const docTemplate = `{ "$ref": "#/definitions/domain.ErrorResponse" } }, - "403": { - "description": "Forbidden", + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Archives a question set (soft delete)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Delete a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/personas": { + "get": { + "description": "Returns all users assigned as personas to a question set (practice)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get user personas for a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Links a user as a persona to a question set (practice)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Add a user as persona to a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "description": "Add user persona payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.addUserPersonaReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/personas/{userId}": { + "delete": { + "description": "Unlinks a user as persona from a question set (practice)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Remove a user persona from a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/question-types": { + "get": { + "description": "Returns distinct question type definitions (key, display_name, counts) for non-archived questions in the set. Legacy stored question_type values (e.g. AUDIO) are resolved to builder definitions when possible.", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "List question types in a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -1620,14 +4905,48 @@ const docTemplate = `{ } } }, - "/api/v1/admin/roles/{role}/bulk-reactivate": { - "post": { - "security": [ + "/api/v1/admin/question-sets/{setId}/questions": { + "get": { + "description": "Returns all questions in a question set with contextual shared stimulus data for linked LMS and exam-prep practices", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Get questions in set", + "parameters": [ { - "Bearer": [] + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true } ], - "description": "Sets all platform users with the given role from DEACTIVATED to ACTIVE (except the caller) and all team_members with the given team_role from inactive to active. Path :role may be a role key or decimal RBAC roles.id (see bulk-deactivate). Path role must correspond to valid platform users.role or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users (team_members ADMIN under path ADMIN is allowed). Matches only users currently DEACTIVATED and team rows currently inactive.", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Links a question to a question set. Omit display_order to append after the current max; the assigned value is returned in the response.", "consumes": [ "application/json" ], @@ -1635,23 +4954,132 @@ const docTemplate = `{ "application/json" ], "tags": [ - "admin" + "question-set-items" ], - "summary": "Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "summary": "Add question to set", "parameters": [ { - "type": "string", - "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", - "name": "role", + "type": "integer", + "description": "Question Set ID", + "name": "setId", "in": "path", "required": true }, { - "description": "Optional exclusions", + "description": "Add question to set payload", "name": "body", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + "$ref": "#/definitions/handlers.addQuestionToSetReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/questions/{questionId}": { + "delete": { + "description": "Unlinks a question from a question set", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Remove question from set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Question ID", + "name": "questionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/questions/{questionId}/order": { + "put": { + "description": "Updates the display order of a question in a set", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Update question order in set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Question ID", + "name": "questionId", + "in": "path", + "required": true + }, + { + "description": "Update order payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionOrderReq" } } ], @@ -1668,8 +5096,501 @@ const docTemplate = `{ "$ref": "#/definitions/domain.ErrorResponse" } }, - "403": { - "description": "Forbidden", + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions": { + "get": { + "description": "Returns a paginated list of questions with optional filters", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List questions", + "parameters": [ + { + "type": "string", + "description": "Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER)", + "name": "question_type", + "in": "query" + }, + { + "type": "string", + "description": "Difficulty level filter (EASY, MEDIUM, HARD)", + "name": "difficulty", + "in": "query" + }, + { + "type": "string", + "description": "Status filter (DRAFT, PUBLISHED, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new question with options (for MCQ/TRUE_FALSE) or short answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; use dynamic_payload stimulus instead. Legacy types require question_text.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create a new question", + "parameters": [ + { + "description": "Create question payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/component-catalog": { + "get": { + "description": "Valid stimulus and response component kind codes for dynamic question-type definitions", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Question-type builder component catalog", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/search": { + "get": { + "description": "Search questions by text", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Search questions", + "parameters": [ + { + "type": "string", + "description": "Search query", + "name": "q", + "in": "query", + "required": true + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definition-groups": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List question type definition groups", + "parameters": [ + { + "type": "string", + "description": "Filter by status (ACTIVE, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size (default 20, max 200)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Page offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create question type definition group", + "parameters": [ + { + "description": "Group payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionTypeDefinitionGroupReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/type-definition-groups/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get question type definition group with definitions", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update question type definition group", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update group payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionGroupReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete question type definition group", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List reusable question-type definitions", + "parameters": [ + { + "type": "string", + "description": "Filter by status (ACTIVE, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "boolean", + "default": true, + "description": "Include system seeded definitions", + "name": "include_system", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size (default 20, max 200)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Page offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Stores a reusable dynamic question-type definition for future question construction. Only runtime-mappable definitions are persisted.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create reusable question-type definition", + "parameters": [ + { + "description": "Question type definition payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get reusable question-type definition by id", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -1679,6 +5600,1328 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + } + } + }, + "put": { + "description": "Updates a reusable dynamic question-type definition. Updated definitions must remain runtime-mappable.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update reusable question-type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update question type definition payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete reusable question-type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions/{id}/practices": { + "get": { + "description": "Returns LMS and exam-prep practices whose linked question set contains at least one non-archived question matching the definition (by question_type_definition_id or legacy question_type).", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List practices globally by question type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/validate-question-type-definition": { + "post": { + "description": "Validates selected stimulus and response component kinds for temporary question-type definitions (component-level validation only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Validate dynamic question-type definition", + "parameters": [ + { + "description": "Stimulus and response component kinds", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.validateQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/{id}": { + "get": { + "description": "Returns a question with its options/short answers", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get question by ID", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a question and optionally replaces its options/short answers. Supports question_type_definition_id for dynamic builder-linked questions.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update a question", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update question payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Archives a question (soft delete)", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete a question", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings": { + "get": { + "description": "Returns paginated ratings for a specific target", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Get ratings for a target", + "parameters": [ + { + "type": "string", + "description": "Target type (app, course, sub_course)", + "name": "target_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Target ID (0 for app)", + "name": "target_id", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Limit (default 20)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (default 0)", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings/summary": { + "get": { + "description": "Returns the total count and average stars for a specific target", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Get rating summary for a target", + "parameters": [ + { + "type": "string", + "description": "Target type (app, course, sub_course)", + "name": "target_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Target ID (0 for app)", + "name": "target_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings/{id}": { + "delete": { + "description": "Deletes a rating by ID for the current user", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Delete a rating", + "parameters": [ + { + "type": "integer", + "description": "Rating ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all permissions in the system grouped by group name", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List all permissions", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Permission" + } + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all distinct permission group names", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List permission groups", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions/sync": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Re-seed permissions from code and reload the RBAC cache", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Sync permissions", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all roles with optional filters", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List all roles", + "parameters": [ + { + "type": "string", + "description": "Search by role name", + "name": "query", + "in": "query" + }, + { + "type": "boolean", + "description": "Filter by system role (true/false)", + "name": "is_system", + "in": "query" + }, + { + "type": "integer", + "description": "Page number (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Page size (default: 20)", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Create a new role with a name and description", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Create a new role", + "parameters": [ + { + "description": "Role creation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateRoleReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.RoleRecord" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get a role and its permissions by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Get a role by ID", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.RoleWithPermissions" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update an existing role's name and description", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Update a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Role update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateRoleReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Delete a non-system role by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Delete a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles/{id}/permissions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all permissions assigned to a role", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Get permissions for a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Permission" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Replace all permissions for a role with the given permission IDs", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Set permissions for a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Permission IDs payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SetRolePermissionsReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/referrals/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetReferralSettings", + "responses": {} + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UpdateReferralSettings", + "responses": {} + } + }, + "/api/v1/admin/sendSMS": { + "post": { + "description": "Sends an SMS message to a single phone number using AfroMessage", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Send single SMS via AfroMessage", + "parameters": [ + { + "description": "Send SMS request", + "name": "sendSMS", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.SendSingleAfroSMSReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetGlobalSettingList", + "responses": {} + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UpdateGlobalSettingList", + "responses": {} + } + }, + "/api/v1/admin/settings/{key}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetGlobalSettingByKey", + "responses": {} + } + }, + "/api/v1/admin/subscription-plans": { + "get": { + "description": "Returns subscription plans. Optional category filter: EDUCATION.", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "List subscription plans", + "parameters": [ + { + "type": "boolean", + "description": "Return only active plans (default true)", + "name": "active_only", + "in": "query" + }, + { + "type": "string", + "description": "Filter by plan category (EDUCATION)", + "name": "category", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new subscription plan (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Create a subscription plan", + "parameters": [ + { + "description": "Create plan payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createPlanReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/subscription-plans/{id}": { + "get": { + "description": "Returns a single subscription plan by ID", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Get a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a subscription plan (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Update a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update plan payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updatePlanReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Deletes a subscription plan (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Delete a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } }, "500": { "description": "Internal Server Error", @@ -1753,6 +6996,1612 @@ const docTemplate = `{ } } }, + "/api/v1/admin/team/invitations": { + "get": { + "description": "Lists team member invitations with optional status filter", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "List team invitations", + "parameters": [ + { + "type": "string", + "description": "pending, accepted, expired, or revoked", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "Limit (default 20)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (default 0)", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/accept": { + "post": { + "description": "Public endpoint to set password and profile details after following the invite link", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Accept team invitation and complete account setup", + "parameters": [ + { + "description": "Accept invitation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.AcceptTeamInvitationReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/verify": { + "get": { + "description": "Public endpoint used by the admin panel accept-invite page", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Verify team invitation token", + "parameters": [ + { + "type": "string", + "description": "Invitation token", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/{id}/revoke": { + "post": { + "description": "Revokes the invitation and removes the pending team member if not yet accepted", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Revoke a pending team invitation", + "parameters": [ + { + "type": "integer", + "description": "Invitation ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/login": { + "post": { + "description": "Authenticate a team member (internal staff) with email and password", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Login team member", + "parameters": [ + { + "description": "Team member login credentials", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamMemberLoginReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.teamMemberLoginRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/me": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get the authenticated team member's own profile", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get my team profile", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update the authenticated team member's own profile fields", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update my team profile", + "parameters": [ + { + "description": "Profile update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateMyTeamProfileReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get a paginated list of team members with optional filtering", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "List all team members", + "parameters": [ + { + "type": "string", + "description": "Filter by team role (super_admin, admin, content_manager, support_agent, instructor, finance, hr, analyst)", + "name": "team_role", + "in": "query" + }, + { + "type": "string", + "description": "Filter by department", + "name": "department", + "in": "query" + }, + { + "type": "string", + "description": "Filter by status (active, inactive, suspended, terminated)", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Search by name, email, or phone number", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "description": "Page number (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Items per page (default: 10, max: 100)", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + }, + "metadata": { + "$ref": "#/definitions/domain.Pagination" + } + } + } + ] + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Create a new internal team member (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Create a new team member", + "parameters": [ + { + "description": "Team member creation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateTeamMemberReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/export": { + "get": { + "produces": [ + "text/csv" + ], + "tags": [ + "team" + ], + "summary": "Export team members as CSV (admin)", + "responses": {} + } + }, + "/api/v1/admin/team/members/invite": { + "post": { + "description": "Creates a pending team member (email + team_role only) and sends an invitation email; profile is completed on accept", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Invite a team member by email", + "parameters": [ + { + "description": "Invite payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.InviteTeamMemberReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Retrieve a team member's details by their ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get team member by ID", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update an existing team member's details (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update team member", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Team member update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateTeamMemberReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Delete a team member (super admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Delete team member", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/change-password": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Change a team member's password (requires current password)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Change team member password", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Password change payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.changePasswordReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/resend-invite": { + "post": { + "description": "Revokes the current pending invite and sends a new invitation email", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Resend team invitation", + "parameters": [ + { + "type": "integer", + "description": "Team member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/status": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update a team member's status (active, inactive, suspended, terminated)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update team member status", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateTeamMemberStatusReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/refresh": { + "post": { + "description": "Exchanges a valid team refresh token for a new access JWT and a rotated refresh token (use only tokens from POST /team/login or this endpoint).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Refresh team member tokens", + "parameters": [ + { + "description": "Current refresh token", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.teamMemberRefreshReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.teamMemberLoginRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/resetPassword": { + "post": { + "description": "Completes team password reset using email + OTP from the reset link. Public.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Reset team member password", + "parameters": [ + { + "description": "Reset payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamResetPasswordReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/sendResetCode": { + "post": { + "description": "Sends a password-reset email with a link to the team member (admin panel). Public.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Send team password reset link", + "parameters": [ + { + "description": "Email", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamSendPasswordResetReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/stats": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get statistics about team members by status", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get team member statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberStats" + } + } + } + ] + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/verifyResetCode": { + "get": { + "description": "Checks whether email+otp from a reset link are still valid without consuming the OTP. Public.", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Verify team password reset link", + "parameters": [ + { + "type": "string", + "description": "Team member email", + "name": "email", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Reset OTP from the email link", + "name": "otp", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/user/admin-profile": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get user profile", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user profile", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.AdminProfileRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/delete/{id}": { + "delete": { + "description": "Delete a user by their ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete user by ID", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/search": { + "post": { + "description": "Search for user using name or phone", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Search for user using name or phone", + "parameters": [ + { + "description": "Search for using his name or phone", + "name": "searchUserByNameOrPhone", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.SearchUserByNameOrPhoneReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UserProfileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/single/{id}": { + "get": { + "description": "Get a single user by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user by id", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UserProfileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/status": { + "patch": { + "description": "Activates, deactivates, or suspends a user account", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Update user status", + "parameters": [ + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/{id}/profile-picture": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Uploads a profile picture for the specified user", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Upload profile picture", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Image file (jpg|png|webp)", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/users": { + "get": { + "description": "Get users with optional filters. Each user includes subscription_status: ACTIVE, PENDING, or Unsubscribed.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get all users", + "parameters": [ + { + "type": "string", + "description": "Role filter", + "name": "role", + "in": "query" + }, + { + "type": "string", + "description": "Search query", + "name": "query", + "in": "query" + }, + { + "type": "integer", + "description": "Page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Created before (RFC3339)", + "name": "created_before", + "in": "query" + }, + { + "type": "string", + "description": "Created after (RFC3339)", + "name": "created_after", + "in": "query" + }, + { + "type": "string", + "description": "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, or INACTIVE for all non-ACTIVE statuses)", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Country filter (case-insensitive match on stored value)", + "name": "country", + "in": "query" + }, + { + "type": "string", + "description": "Region filter (case-insensitive match on stored value)", + "name": "region", + "in": "query" + }, + { + "type": "string", + "description": "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)", + "name": "subscription_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/admin/users/deletion-requests": { "get": { "description": "Returns account deletion requests for admin panel tracking with filtering and pagination", @@ -1850,6 +8699,64 @@ const docTemplate = `{ } } }, + "/api/v1/admin/users/export": { + "get": { + "produces": [ + "text/csv" + ], + "tags": [ + "user" + ], + "summary": "Export users as CSV (admin)", + "responses": {} + } + }, + "/api/v1/admin/users/summary": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns total users, active users, and users who joined this month", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user summary statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.UserSummary" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, "/api/v1/admin/users/{user_id}/learning-activity": { "get": { "security": [ @@ -1857,12 +8764,12 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Returns LMS and exam-prep completion trees, progress summaries, completed ID snapshots, and recent activity timeline", + "description": "Returns the unified catalog-course learning tree, progress summary, and recent activity timeline", "produces": [ "application/json" ], "tags": [ - "lms" + "exam-prep" ], "summary": "Get full learning activity for a user (admin)", "parameters": [ @@ -1926,52 +8833,6 @@ const docTemplate = `{ } } }, - "/api/v1/admin/users/{user_id}/lms-learning-activity": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns programs, courses, modules, and lessons with completion details and completed practices. Only persisted completion signals are included (completed lessons, completed published practices, and rollup completion timestamps—not partial or in-progress attempts).", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get a user's nested LMS learning activity (admin)", - "parameters": [ - { - "type": "integer", - "description": "Target user ID", - "name": "user_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/admin/users/{user_id}/recent-activity": { "get": { "security": [ @@ -2170,9 +9031,9 @@ const docTemplate = `{ } } }, - "/api/v1/admin/{id}": { + "/api/v1/admin/vimeo/oembed": { "get": { - "description": "Get a single admin by id", + "description": "Fetches oEmbed metadata for a Vimeo video URL", "consumes": [ "application/json" ], @@ -2180,14 +9041,313 @@ const docTemplate = `{ "application/json" ], "tags": [ - "admin" + "Vimeo" ], - "summary": "Get admin by id", + "summary": "Get oEmbed data for a Vimeo URL", + "parameters": [ + { + "type": "string", + "description": "Vimeo video URL", + "name": "url", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Desired width", + "name": "width", + "in": "query" + }, + { + "type": "integer", + "description": "Desired height", + "name": "height", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/vimeo.OEmbedResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/sample": { + "get": { + "description": "Fetches a sample video from Vimeo and returns video details along with an embeddable iframe for client-side integration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get a sample Vimeo video with iframe embed", + "parameters": [ + { + "type": "string", + "default": "76979871", + "description": "Vimeo Video ID to use as sample", + "name": "video_id", + "in": "query" + }, + { + "type": "integer", + "default": 640, + "description": "Player width", + "name": "width", + "in": "query" + }, + { + "type": "integer", + "default": 360, + "description": "Player height", + "name": "height", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/uploads/pull": { + "post": { + "description": "Initiates a pull upload where Vimeo fetches the video from a URL", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Create a pull upload to Vimeo", + "parameters": [ + { + "description": "Pull Upload Request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CreatePullUploadRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/handlers.VimeoUploadResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/uploads/tus": { + "post": { + "description": "Initiates a TUS resumable upload and returns the upload link", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Create a TUS resumable upload to Vimeo", + "parameters": [ + { + "description": "TUS Upload Request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CreateTusUploadRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/handlers.VimeoUploadResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/videos": { + "get": { + "description": "Returns a paginated list of videos for the Vimeo API token (GET https://api.vimeo.com/me/videos)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "List videos stored in the Vimeo account", "parameters": [ { "type": "integer", - "description": "User ID", - "name": "id", + "default": 1, + "description": "Page number (starts at 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 25, + "description": "Page size (Vimeo max 100)", + "name": "per_page", + "in": "query" + }, + { + "type": "string", + "description": "Search query", + "name": "query", + "in": "query" + }, + { + "type": "string", + "description": "Sort field (e.g. date, alphabetical, plays, likes, comments, duration, relevance)", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "asc or desc", + "name": "direction", + "in": "query" + }, + { + "type": "string", + "description": "Vimeo filter (e.g. embeddable, playable)", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "description": "Vimeo filter_type when using filter", + "name": "filter_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.VimeoVideoResponse" + } + }, + "metadata": { + "$ref": "#/definitions/handlers.VimeoVideosListMetadata" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "503": { + "description": "Service Unavailable", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/videos/{video_id}": { + "get": { + "description": "Retrieves video details from Vimeo by video ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get video information from Vimeo", + "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", "in": "path", "required": true } @@ -2196,31 +9356,25 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/handlers.AdminRes" + "$ref": "#/definitions/handlers.VimeoVideoResponse" } }, "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } } } }, - "put": { - "description": "Update Admin", + "delete": { + "description": "Deletes a video from the Vimeo account", "consumes": [ "application/json" ], @@ -2228,87 +9382,94 @@ const docTemplate = `{ "application/json" ], "tags": [ - "admin" + "Vimeo" ], - "summary": "Update Admin", + "summary": "Delete a video from Vimeo", "parameters": [ { - "description": "Update Admin", - "name": "admin", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateAdminReq" - } + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } + "204": { + "description": "No Content" }, "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } } } } }, - "/api/v1/analytics/dashboard": { + "/api/v1/admin/vimeo/videos/{video_id}/embed": { "get": { - "description": "Platform analytics with optional date filters in Africa/Addis_Ababa (EAT): all-time (default), year, year+month, or custom from/to range. When year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals (EAT) per currency for that calendar year. Optional payment_method filters payment/revenue metrics (exact or METHOD:% variants). Daily series remains in revenue_last_30_days (see date_filter.series_*). Courses section counts LMS + exam_prep inventory.", + "description": "Generates an embeddable player iframe for the video", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ - "analytics" + "Vimeo" ], - "summary": "Analytics dashboard", + "summary": "Get embed code for a Vimeo video", "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true + }, { "type": "integer", - "description": "EAT calendar year (e.g. 2025)", - "name": "year", + "default": 640, + "description": "Player width", + "name": "width", "in": "query" }, { "type": "integer", - "description": "EAT calendar month 1-12 (requires year)", - "name": "month", + "default": 360, + "description": "Player height", + "name": "height", "in": "query" }, { - "type": "string", - "description": "Custom EAT range start (YYYY-MM-DD or RFC3339)", - "name": "from", + "type": "boolean", + "description": "Autoplay video", + "name": "autoplay", "in": "query" }, { - "type": "string", - "description": "Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive)", - "name": "to", + "type": "boolean", + "description": "Loop video", + "name": "loop", "in": "query" }, { - "type": "string", - "description": "Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT)", - "name": "payment_method", + "type": "boolean", + "description": "Mute video", + "name": "muted", + "in": "query" + }, + { + "type": "boolean", + "description": "Background mode (no controls)", + "name": "background", "in": "query" } ], @@ -2316,7 +9477,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.AnalyticsDashboard" + "$ref": "#/definitions/handlers.VimeoEmbedResponse" } }, "400": { @@ -2334,6 +9495,71 @@ const docTemplate = `{ } } }, + "/api/v1/admin/vimeo/videos/{video_id}/status": { + "get": { + "description": "Returns the current transcoding status of a video", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get transcode status of a Vimeo video", + "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ws/connect": { + "get": { + "tags": [ + "client" + ], + "summary": "ConnectSocket", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": {} + } + }, "/api/v1/app/version/check": { "get": { "description": "Public endpoint for mobile clients to determine if an app update is available (force or optional)", @@ -2409,6 +9635,58 @@ const docTemplate = `{ "responses": {} } }, + "/api/v1/auth/customer-login": { + "post": { + "description": "Login user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login user", + "parameters": [ + { + "description": "Login user", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.loginUserRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/auth/google/android": { "post": { "tags": [ @@ -2551,20 +9829,124 @@ const docTemplate = `{ } } }, - "/api/v1/courses/{courseId}/modules": { + "/api/v1/devices/register": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "RegisterDeviceToken", + "responses": {} + } + }, + "/api/v1/devices/unregister": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "UnregisterDeviceToken", + "responses": {} + } + }, + "/api/v1/exam-prep/assessments": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "ListExamPrepAssessments", + "responses": {} + } + }, + "/api/v1/exam-prep/catalog-courses": { "get": { "produces": [ "application/json" ], "tags": [ - "modules" + "exam-prep" ], - "summary": "List modules for a course", + "summary": "List exam-prep catalog courses", "parameters": [ { "type": "integer", - "description": "Course ID", - "name": "courseId", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/exam-prep/catalog-courses/{catalogCourseId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the catalog course.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/catalog-courses/{catalogCourseId}/units": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep units for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", "in": "path", "required": true }, @@ -2591,40 +9973,205 @@ const docTemplate = `{ } } } - }, - "post": { - "description": "Create a module under a course; parent program is taken from the course.", - "consumes": [ - "application/json" - ], + } + }, + "/api/v1/exam-prep/catalog-courses/{id}": { + "get": { "produces": [ "application/json" ], "tags": [ - "modules" + "exam-prep" ], - "summary": "Create module", + "summary": "Get exam-prep catalog course by ID", "parameters": [ { "type": "integer", - "description": "Course ID", - "name": "courseId", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/exam-prep/lessons/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep lesson by ID", + "responses": {} + } + }, + "/api/v1/exam-prep/lessons/{lessonId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a lesson", + "parameters": [ + { + "type": "integer", + "description": "Exam prep lesson ID", + "name": "lessonId", "in": "path", "required": true }, { - "description": "Module", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateModuleInput" - } + "type": "integer", + "description": "Page size. Omit to return all practices for the lesson.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/modules/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep module by ID", + "responses": {} + } + }, + "/api/v1/exam-prep/modules/{moduleId}/lessons": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep lessons for a unit module", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices globally", + "parameters": [ + { + "type": "integer", + "description": "Page size. Omit (with offset) to return all practices.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset. Defaults to 0 when limit is provided; ignored semantics when both omitted (all rows).", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "description": "When true, return only practices with no parent links (admin)", + "name": "unlinked_only", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice by ID", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices/{practiceId}/questions": { + "get": { + "description": "Returns paginated questions for an exam-prep practice, including shared stimulus blocks and each question's effective dynamic payload", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Get questions by practice", + "parameters": [ + { + "type": "integer", + "description": "Exam-prep practice ID", + "name": "practiceId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Question type filter (e.g. AUDIO)", + "name": "question_type", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" } ], "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "schema": { "$ref": "#/definitions/domain.Response" } @@ -2634,50 +10181,62 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } } }, - "/api/v1/courses/{courseId}/modules/reorder": { - "put": { - "tags": [ - "modules" - ], - "summary": "Reorder modules within a course", - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "courseId", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every module id in this course, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/courses/{id}": { + "/api/v1/exam-prep/progress-summary": { "get": { + "description": "Returns progress for the catalog course → unit → module → lesson learning hierarchy.", "produces": [ "application/json" ], "tags": [ - "courses" + "exam-prep" ], - "summary": "Get course by ID", + "summary": "Get my learning progress summary", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/exam-prep/progress/practices/{id}/complete": { + "post": { + "description": "Marks a practice question set as completed for the authenticated learner in its exam-prep parent scope", + "produces": [ + "application/json" + ], + "tags": [ + "progression" + ], + "summary": "Mark exam-prep practice as completed", "parameters": [ { "type": "integer", - "description": "Course ID", + "description": "Practice Question Set ID", "name": "id", "in": "path", "required": true @@ -2690,15 +10249,102 @@ const docTemplate = `{ "$ref": "#/definitions/domain.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } - }, - "put": { + } + }, + "/api/v1/exam-prep/units/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep unit by ID", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/units/{unitId}/modules": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep modules for a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/units/{unitId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the unit.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/videos/engagement/heartbeat": { + "post": { + "description": "Records playback position for analytics (completion, replay, and drop-off). Send periodic heartbeats while watching; set ended=true when the viewer leaves. A new session starts after 30 minutes of inactivity or when ended=true on the prior session.", "consumes": [ "application/json" ], @@ -2706,24 +10352,17 @@ const docTemplate = `{ "application/json" ], "tags": [ - "courses" + "videos" ], - "summary": "Update course", + "summary": "Report video playback progress", "parameters": [ { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", + "description": "Playback heartbeat", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateCourseInput" + "$ref": "#/definitions/domain.VideoEngagementHeartbeatInput" } } ], @@ -2731,7 +10370,31 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.Response" + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.VideoWatchSessionResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" } }, "404": { @@ -2741,52 +10404,6 @@ const docTemplate = `{ } } } - }, - "delete": { - "tags": [ - "courses" - ], - "summary": "Delete course", - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/courses/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} } }, "/api/v1/faqs": { @@ -3127,109 +10744,7 @@ const docTemplate = `{ } } }, - "/api/v1/internal/users/purge-due-deletions": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Worker-safe purge for due self-deletion requests", - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Purge due account deletions", - "parameters": [ - { - "type": "integer", - "description": "Max users to purge in one run (default 100, max 1000)", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/issues": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns all reported issues with pagination (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Get all issues", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueListRes" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, "post": { "security": [ { @@ -3357,134 +10872,18 @@ const docTemplate = `{ } } }, - "/api/v1/issues/user/{user_id}": { + "/api/v1/notifications": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns paginated issues reported by a specific user (admin only)", - "produces": [ - "application/json" - ], "tags": [ - "issues" + "client" ], - "summary": "Get issues for a specific user", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "user_id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueListRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/issues/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns a single issue report by its ID (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Get issue by ID", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetUserNotification", + "responses": {} }, "delete": { "security": [ @@ -3492,745 +10891,11 @@ const docTemplate = `{ "Bearer": [] } ], - "description": "Deletes an issue report (admin only)", - "produces": [ - "application/json" - ], "tags": [ - "issues" - ], - "summary": "Delete an issue", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/issues/{id}/status": { - "patch": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates the status of an issue (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Update issue status", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateIssueStatusReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lessons/{id}": { - "get": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } + "client" ], + "summary": "DeleteUserNotifications", "responses": {} - }, - "put": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateLessonInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/lessons/{id}/complete": { - "post": { - "description": "Records lesson completion; may cascade to module, course, and program progress for the authenticated user. Learners must meet sequential prerequisites; staff bypass checks.", - "tags": [ - "lessons" - ], - "summary": "Mark a lesson as completed", - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lessons/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/lms/progress": { - "get": { - "description": "Returns practice-based completed lesson, module, course, and program IDs for the authenticated user (ordered by completion time, then id).", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get my LMS completion history", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lms/progress-summary": { - "get": { - "description": "Returns the learner's nested Learn English hierarchy (programs) and exam-prep hierarchy (exam_prep) with the same access progress data exposed on the individual content APIs.", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get my LMS and exam-prep progress summary", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/logs": { - "get": { - "description": "Fetches application logs from MongoDB with pagination, level filtering, and search", - "produces": [ - "application/json" - ], - "tags": [ - "Logs" - ], - "summary": "Retrieve application logs with filtering and pagination", - "parameters": [ - { - "type": "string", - "description": "Filter logs by level (debug, info, warn, error, dpanic, panic, fatal)", - "name": "level", - "in": "query" - }, - { - "type": "string", - "description": "Search term to match against message or fields", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "Page number for pagination (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 50, - "description": "Number of items per page (default: 50, max: 100)", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Paginated list of application logs", - "schema": { - "$ref": "#/definitions/domain.LogResponse" - } - }, - "400": { - "description": "Invalid request parameters", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/modules/{id}": { - "get": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "put": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateModuleInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/modules/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/modules/{moduleId}/lessons": { - "get": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "lessons" - ], - "summary": "Create lesson", - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "description": "Lesson", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateLessonInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/modules/{moduleId}/lessons/reorder": { - "put": { - "tags": [ - "lessons" - ], - "summary": "Reorder lessons within a module", - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every lesson id in this module, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/notifications/bulk-email": { - "post": { - "description": "Sends an email to specified user IDs, users of a platform role, team member IDs, team members of a team_role, or direct email addresses with optional image attachment. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk email", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-in-app": { - "post": { - "description": "Creates in-app notifications for specified platform user IDs, users matching a platform role, team member IDs, or team members matching a team_role. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk in-app notification", - "parameters": [ - { - "description": "Bulk in-app content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "level": { - "type": "string" - }, - "message": { - "type": "string" - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "team_member_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "team_role": { - "type": "string" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-push": { - "post": { - "description": "Sends a push notification to specified user IDs or all users matching a role. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk push notification", - "parameters": [ - { - "description": "Bulk push content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "image": { - "type": "string" - }, - "message": { - "type": "string" - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "title": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-sms": { - "post": { - "description": "Sends an SMS to specified user IDs, all users of a role, or direct phone numbers. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk SMS", - "parameters": [ - { - "description": "Bulk SMS content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "phone_numbers": { - "type": "array", - "items": { - "type": "string" - } - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/notifications/delete-in-app": { @@ -4279,253 +10944,46 @@ const docTemplate = `{ } } }, - "/api/v1/notifications/scheduled": { + "/api/v1/notifications/mark-all-read": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsRead", + "responses": {} + } + }, + "/api/v1/notifications/mark-all-unread": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsUnread", + "responses": {} + } + }, + "/api/v1/notifications/unread": { "get": { - "description": "Returns paginated scheduled notifications with optional status, channel, and date filters", - "produces": [ - "application/json" + "security": [ + { + "Bearer": [] + } ], "tags": [ - "notifications" + "client" ], - "summary": "List scheduled notifications", - "parameters": [ - { - "type": "string", - "description": "Filter by status", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Filter by channel", - "name": "channel", - "in": "query" - }, - { - "type": "string", - "description": "Filter after date (RFC3339)", - "name": "after", - "in": "query" - }, - { - "type": "string", - "description": "Filter before date (RFC3339)", - "name": "before", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "Page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/scheduled/{id}": { - "get": { - "description": "Returns a single scheduled notification by its ID", - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Get scheduled notification", - "parameters": [ - { - "type": "integer", - "description": "Scheduled Notification ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/scheduled/{id}/cancel": { - "post": { - "description": "Cancels a scheduled notification if it is still pending or processing", - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Cancel scheduled notification", - "parameters": [ - { - "type": "integer", - "description": "Scheduled Notification ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/send-email": { - "post": { - "description": "Sends an email to a single email address with optional image attachment", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send single email", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/test-push": { - "post": { - "description": "Sends a test push notification to all registered devices of the current user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send test push notification", - "parameters": [ - { - "description": "Test notification content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "title": { - "type": "string" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "CountUnreadNotifications", + "responses": {} } }, "/api/v1/notifications/{id}": { @@ -4626,6 +11084,34 @@ const docTemplate = `{ } } }, + "/api/v1/notifications/{id}/read": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsRead", + "responses": {} + } + }, + "/api/v1/notifications/{id}/unread": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsUnread", + "responses": {} + } + }, "/api/v1/payments": { "get": { "description": "Returns the authenticated user's payment history", @@ -5246,34 +11732,6 @@ const docTemplate = `{ } ], "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "tags": [ - "personas" - ], - "summary": "Create LMS persona catalog entry", - "parameters": [ - { - "description": "Persona", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateLmsPersonaInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } } }, "/api/v1/personas/{id}": { @@ -5292,1563 +11750,6 @@ const docTemplate = `{ } ], "responses": {} - }, - "put": { - "tags": [ - "personas" - ], - "summary": "Update LMS persona", - "parameters": [ - { - "type": "integer", - "description": "Persona ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateLmsPersonaInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "personas" - ], - "summary": "Delete LMS persona (practices referencing it will have persona_id cleared)", - "parameters": [ - { - "type": "integer", - "description": "Persona ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "Page offset (default 0)", - "name": "offset", - "in": "query" - }, - { - "type": "boolean", - "description": "When true, return only practices with no parent links (admin)", - "name": "unlinked_only", - "in": "query" - } - ], - "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "tags": [ - "practices" - ], - "parameters": [ - { - "description": "Practice (optional parents; link later via PUT /practices/:id/parents)", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreatePracticeInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - }, - "put": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Practice metadata fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePracticeInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}/full": { - "get": { - "description": "Returns practice metadata, linked question set settings, and all questions in the set (same shape as PUT /practices/{id}/full).", - "produces": [ - "application/json" - ], - "tags": [ - "practices" - ], - "summary": "Get LMS practice with question set and questions", - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates practice metadata, linked question set settings, and syncs questions in one request. Questions omitted from the questions array are removed from the set (not deleted from the bank).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "practices" - ], - "summary": "Full update LMS practice with question set and questions", - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Full practice update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.FullUpdatePracticeInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/practices/{id}/parents": { - "put": { - "consumes": [ - "application/json" - ], - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Parent links (replaces all; use empty array to detach)", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePracticeParentsInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}/parents/{parentKind}/{parentId}": { - "delete": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent kind (COURSE, MODULE, LESSON)", - "name": "parentKind", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Parent entity ID", - "name": "parentId", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices/{practiceId}/questions": { - "get": { - "description": "Returns paginated questions for an LMS practice, including shared stimulus blocks and each question's effective dynamic payload", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Get questions by practice", - "parameters": [ - { - "type": "integer", - "description": "LMS practice ID", - "name": "practiceId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Question type filter (e.g. AUDIO)", - "name": "question_type", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs": { - "get": { - "description": "Paginated list of programs", - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "List programs", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Create a top-level LMS program. Optional sort_order inserts at that global ordering; omit it to append after the current highest sort_order. Unique constraint applies to sort_order.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Create program", - "parameters": [ - { - "description": "Program", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateProgramInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/reorder": { - "put": { - "description": "Sets learning order of programs. Body must list every current program id exactly once, in the desired order (index 0 = first in path).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Reorder all programs", - "parameters": [ - { - "description": "New order: ordered_ids is the full set of program ids", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Get program by ID", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Update program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateProgramInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "programs" - ], - "summary": "Delete program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}/courses": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "courses" - ], - "summary": "List courses by program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Create a course under a program. Optional sort_order assigns position within that program (siblings shifted); omit to append after the current highest sort_order in the program.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "courses" - ], - "summary": "Create course", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Course", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateCourseInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}/courses/reorder": { - "put": { - "tags": [ - "courses" - ], - "summary": "Reorder courses within a program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every course id in this program, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/progress/practices/{id}/complete": { - "post": { - "description": "Marks a practice question set as completed for the authenticated learner", - "produces": [ - "application/json" - ], - "tags": [ - "progression" - ], - "summary": "Mark practice as completed", - "parameters": [ - { - "type": "integer", - "description": "Practice Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets": { - "get": { - "description": "Returns a paginated list of question sets filtered by type", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question sets by type", - "parameters": [ - { - "type": "string", - "description": "Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE)", - "name": "set_type", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Creates a new question set (practice, assessment, quiz, exam, or survey)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Create a new question set", - "parameters": [ - { - "description": "Create question set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionSetReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/by-owner": { - "get": { - "description": "Returns question sets for a specific owner (e.g., sub-course)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question sets by owner", - "parameters": [ - { - "type": "string", - "description": "Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE)", - "name": "owner_type", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "Owner ID", - "name": "owner_id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{id}": { - "get": { - "description": "Returns a question set with question count", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question set by ID", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a question set's properties", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Update a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionSetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Archives a question set (soft delete)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Delete a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/personas": { - "get": { - "description": "Returns all users assigned as personas to a question set (practice)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get user personas for a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Links a user as a persona to a question set (practice)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Add a user as persona to a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "description": "Add user persona payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.addUserPersonaReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/personas/{userId}": { - "delete": { - "description": "Unlinks a user as persona from a question set (practice)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Remove a user persona from a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/question-types": { - "get": { - "description": "Returns distinct question type definitions (key, display_name, counts) for non-archived questions in the set. Legacy stored question_type values (e.g. AUDIO) are resolved to builder definitions when possible.", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "List question types in a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions": { - "get": { - "description": "Returns all questions in a question set with contextual shared stimulus data for linked LMS and exam-prep practices", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Get questions in set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Links a question to a question set. Omit display_order to append after the current max; the assigned value is returned in the response.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Add question to set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "description": "Add question to set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.addQuestionToSetReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions/{questionId}": { - "delete": { - "description": "Unlinks a question from a question set", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Remove question from set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Question ID", - "name": "questionId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions/{questionId}/order": { - "put": { - "description": "Updates the display order of a question in a set", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Update question order in set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Question ID", - "name": "questionId", - "in": "path", - "required": true - }, - { - "description": "Update order payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionOrderReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions": { - "get": { - "description": "Returns a paginated list of questions with optional filters", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List questions", - "parameters": [ - { - "type": "string", - "description": "Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER)", - "name": "question_type", - "in": "query" - }, - { - "type": "string", - "description": "Difficulty level filter (EASY, MEDIUM, HARD)", - "name": "difficulty", - "in": "query" - }, - { - "type": "string", - "description": "Status filter (DRAFT, PUBLISHED, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Creates a new question with options (for MCQ/TRUE_FALSE) or short answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; use dynamic_payload stimulus instead. Legacy types require question_text.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create a new question", - "parameters": [ - { - "description": "Create question payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/questions/audio-answer": { @@ -6893,710 +11794,6 @@ const docTemplate = `{ } } }, - "/api/v1/questions/component-catalog": { - "get": { - "description": "Valid stimulus and response component kind codes for dynamic question-type definitions", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Question-type builder component catalog", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/search": { - "get": { - "description": "Search questions by text", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Search questions", - "parameters": [ - { - "type": "string", - "description": "Search query", - "name": "q", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definition-groups": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List question type definition groups", - "parameters": [ - { - "type": "string", - "description": "Filter by status (ACTIVE, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Page offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create question type definition group", - "parameters": [ - { - "description": "Group payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionTypeDefinitionGroupReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/type-definition-groups/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get question type definition group with definitions", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update question type definition group", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update group payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionGroupReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete question type definition group", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/type-definitions": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List reusable question-type definitions", - "parameters": [ - { - "type": "string", - "description": "Filter by status (ACTIVE, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "boolean", - "default": true, - "description": "Include system seeded definitions", - "name": "include_system", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Page offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Stores a reusable dynamic question-type definition for future question construction. Only runtime-mappable definitions are persisted.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create reusable question-type definition", - "parameters": [ - { - "description": "Question type definition payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definitions/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get reusable question-type definition by id", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a reusable dynamic question-type definition. Updated definitions must remain runtime-mappable.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update reusable question-type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question type definition payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete reusable question-type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definitions/{id}/practices": { - "get": { - "description": "Returns LMS and exam-prep practices whose linked question set contains at least one non-archived question matching the definition (by question_type_definition_id or legacy question_type).", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List practices globally by question type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/validate-question-type-definition": { - "post": { - "description": "Validates selected stimulus and response component kinds for temporary question-type definitions (component-level validation only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Validate dynamic question-type definition", - "parameters": [ - { - "description": "Stimulus and response component kinds", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.validateQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/{id}": { - "get": { - "description": "Returns a question with its options/short answers", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get question by ID", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a question and optionally replaces its options/short answers. Supports question_type_definition_id for dynamic builder-linked questions.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update a question", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Archives a question (soft delete)", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete a question", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/ratings": { "get": { "description": "Returns paginated ratings for a specific target", @@ -7870,593 +12067,81 @@ const docTemplate = `{ } } }, - "/api/v1/rbac/permissions": { + "/api/v1/referrals": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all permissions in the system grouped by group name", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "List all permissions", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Permission" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "ListMyReferrals", + "responses": {} } }, - "/api/v1/rbac/permissions/groups": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all distinct permission group names", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "List permission groups", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/rbac/permissions/sync": { + "/api/v1/referrals/apply": { "post": { "security": [ { "Bearer": [] } ], - "description": "Re-seed permissions from code and reload the RBAC cache", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Sync permissions", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "ApplyReferralCode", + "responses": {} } }, - "/api/v1/rbac/roles": { + "/api/v1/referrals/code": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all roles with optional filters", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "List all roles", - "parameters": [ - { - "type": "string", - "description": "Search by role name", - "name": "query", - "in": "query" - }, - { - "type": "boolean", - "description": "Filter by system role (true/false)", - "name": "is_system", - "in": "query" - }, - { - "type": "integer", - "description": "Page number (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Page size (default: 20)", - "name": "page_size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetReferralCode", + "responses": {} }, "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new role with a name and description", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Create a new role", - "parameters": [ - { - "description": "Role creation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateRoleReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.RoleRecord" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "CreateReferralCode", + "responses": {} } }, - "/api/v1/rbac/roles/{id}": { + "/api/v1/referrals/me": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get a role and its permissions by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Get a role by ID", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.RoleWithPermissions" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update an existing role's name and description", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Update a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Role update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateRoleReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a non-system role by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Delete a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetMyReferrals", + "responses": {} } }, - "/api/v1/rbac/roles/{id}/permissions": { + "/api/v1/referrals/wallet": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all permissions assigned to a role", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Get permissions for a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Permission" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Replace all permissions for a role with the given permission IDs", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Set permissions for a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Permission IDs payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.SetRolePermissionsReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/sendSMS": { - "post": { - "description": "Sends an SMS message to a single phone number using AfroMessage", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send single SMS via AfroMessage", - "parameters": [ - { - "description": "Send SMS request", - "name": "sendSMS", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.SendSingleAfroSMSReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } + "summary": "GetReferralWallet", + "responses": {} } }, "/api/v1/subscription-plans": { @@ -8503,50 +12188,6 @@ const docTemplate = `{ } } } - }, - "post": { - "description": "Creates a new subscription plan (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Create a subscription plan", - "parameters": [ - { - "description": "Create plan payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createPlanReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/subscription-plans/{id}": { @@ -8582,90 +12223,6 @@ const docTemplate = `{ } } } - }, - "put": { - "description": "Updates a subscription plan (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Update a subscription plan", - "parameters": [ - { - "type": "integer", - "description": "Plan ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update plan payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updatePlanReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes a subscription plan (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Delete a subscription plan", - "parameters": [ - { - "type": "integer", - "description": "Plan ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/subscriptions": { @@ -8982,1431 +12539,6 @@ const docTemplate = `{ } } }, - "/api/v1/super-login": { - "post": { - "description": "Login super-admin", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login super-admin", - "parameters": [ - { - "description": "Login super-admin", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.LoginAdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/t-approver/{id}": { - "get": { - "description": "Get a single admin by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "admin" - ], - "summary": "Get admin by id", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.AdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - }, - "put": { - "description": "Update Admin", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "admin" - ], - "summary": "Update Admin", - "parameters": [ - { - "description": "Update Admin", - "name": "admin", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateAdminReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/team/invitations": { - "get": { - "description": "Lists team member invitations with optional status filter", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "List team invitations", - "parameters": [ - { - "type": "string", - "description": "pending, accepted, expired, or revoked", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "description": "Limit (default 20)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "Offset (default 0)", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/accept": { - "post": { - "description": "Public endpoint to set password and profile details after following the invite link", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Accept team invitation and complete account setup", - "parameters": [ - { - "description": "Accept invitation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.AcceptTeamInvitationReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/verify": { - "get": { - "description": "Public endpoint used by the admin panel accept-invite page", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Verify team invitation token", - "parameters": [ - { - "type": "string", - "description": "Invitation token", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/{id}/revoke": { - "post": { - "description": "Revokes the invitation and removes the pending team member if not yet accepted", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Revoke a pending team invitation", - "parameters": [ - { - "type": "integer", - "description": "Invitation ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/login": { - "post": { - "description": "Authenticate a team member (internal staff) with email and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Login team member", - "parameters": [ - { - "description": "Team member login credentials", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamMemberLoginReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.teamMemberLoginRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/me": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get the authenticated team member's own profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get my team profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update the authenticated team member's own profile fields", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update my team profile", - "parameters": [ - { - "description": "Profile update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateMyTeamProfileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get a paginated list of team members with optional filtering", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "List all team members", - "parameters": [ - { - "type": "string", - "description": "Filter by team role (super_admin, admin, content_manager, support_agent, instructor, finance, hr, analyst)", - "name": "team_role", - "in": "query" - }, - { - "type": "string", - "description": "Filter by department", - "name": "department", - "in": "query" - }, - { - "type": "string", - "description": "Filter by status (active, inactive, suspended, terminated)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Search by name, email, or phone number", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "description": "Page number (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Items per page (default: 10, max: 100)", - "name": "page_size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - }, - "metadata": { - "$ref": "#/definitions/domain.Pagination" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new internal team member (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Create a new team member", - "parameters": [ - { - "description": "Team member creation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateTeamMemberReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/export": { - "get": { - "produces": [ - "text/csv" - ], - "tags": [ - "team" - ], - "summary": "Export team members as CSV (admin)", - "responses": {} - } - }, - "/api/v1/team/members/invite": { - "post": { - "description": "Creates a pending team member (email + team_role only) and sends an invitation email; profile is completed on accept", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Invite a team member by email", - "parameters": [ - { - "description": "Invite payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.InviteTeamMemberReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieve a team member's details by their ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get team member by ID", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update an existing team member's details (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update team member", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Team member update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateTeamMemberReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a team member (super admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Delete team member", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/change-password": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Change a team member's password (requires current password)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Change team member password", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Password change payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.changePasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/resend-invite": { - "post": { - "description": "Revokes the current pending invite and sends a new invitation email", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Resend team invitation", - "parameters": [ - { - "type": "integer", - "description": "Team member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/status": { - "patch": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update a team member's status (active, inactive, suspended, terminated)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update team member status", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateTeamMemberStatusReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/refresh": { - "post": { - "description": "Exchanges a valid team refresh token for a new access JWT and a rotated refresh token (use only tokens from POST /team/login or this endpoint).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Refresh team member tokens", - "parameters": [ - { - "description": "Current refresh token", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.teamMemberRefreshReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.teamMemberLoginRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/resetPassword": { - "post": { - "description": "Completes team password reset using email + OTP from the reset link. Public.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Reset team member password", - "parameters": [ - { - "description": "Reset payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamResetPasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/sendResetCode": { - "post": { - "description": "Sends a password-reset email with a link to the team member (admin panel). Public.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Send team password reset link", - "parameters": [ - { - "description": "Email", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamSendPasswordResetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/stats": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get statistics about team members by status", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get team member statistics", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberStats" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/verifyResetCode": { - "get": { - "description": "Checks whether email+otp from a reset link are still valid without consuming the OTP. Public.", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Verify team password reset link", - "parameters": [ - { - "type": "string", - "description": "Team member email", - "name": "email", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Reset OTP from the email link", - "name": "otp", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/tenant": { - "get": { - "description": "Check if phone number or email exist", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if phone number or email exist", - "parameters": [ - { - "description": "Check phone number or email exist", - "name": "checkPhoneEmailExist", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/user": { "put": { "description": "Updates user profile information (partial updates supported)", @@ -10466,9 +12598,9 @@ const docTemplate = `{ } } }, - "/api/v1/user/delete/{id}": { - "delete": { - "description": "Delete a user by their ID", + "/api/v1/user/checkPhoneEmailExist": { + "post": { + "description": "Check if phone number or email exist", "consumes": [ "application/json" ], @@ -10478,21 +12610,23 @@ const docTemplate = `{ "tags": [ "user" ], - "summary": "Delete user by ID", + "summary": "Check if phone number or email exist", "parameters": [ { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true + "description": "Check phone number or email exist", + "name": "checkPhoneEmailExist", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" } }, "400": { @@ -10654,6 +12788,98 @@ const docTemplate = `{ } } }, + "/api/v1/user/register": { + "post": { + "description": "Register user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Register user", + "parameters": [ + { + "description": "Register user", + "name": "registerUser", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.RegisterUserReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/user/resend-otp": { + "post": { + "description": "Resend OTP if the previous one is expired", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "otp" + ], + "summary": "Resend OTP", + "parameters": [ + { + "description": "Resend OTP", + "name": "resendOtp", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ResendOtpReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/user/resetPassword": { "post": { "description": "Reset password", @@ -10700,9 +12926,9 @@ const docTemplate = `{ } } }, - "/api/v1/user/search": { + "/api/v1/user/sendRegisterCode": { "post": { - "description": "Search for user using name or phone", + "description": "Send register code", "consumes": [ "application/json" ], @@ -10712,15 +12938,15 @@ const docTemplate = `{ "tags": [ "user" ], - "summary": "Search for user using name or phone", + "summary": "Send register code", "parameters": [ { - "description": "Search for using his name or phone", - "name": "searchUserByNameOrPhone", + "description": "Send register code", + "name": "registerCode", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handlers.SearchUserByNameOrPhoneReq" + "$ref": "#/definitions/handlers.RegisterCodeReq" } } ], @@ -10728,7 +12954,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.UserProfileResponse" + "$ref": "#/definitions/response.APIResponse" } }, "400": { @@ -10792,9 +13018,14 @@ const docTemplate = `{ } } }, - "/api/v1/user/single/{id}": { + "/api/v1/user/user-profile": { "get": { - "description": "Get a single user by id", + "security": [ + { + "Bearer": [] + } + ], + "description": "Get user profile", "consumes": [ "application/json" ], @@ -10804,16 +13035,7 @@ const docTemplate = `{ "tags": [ "user" ], - "summary": "Get user by id", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true - } - ], + "summary": "Get user profile", "responses": { "200": { "description": "OK", @@ -10827,58 +13049,6 @@ const docTemplate = `{ "$ref": "#/definitions/response.APIResponse" } }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/user/status": { - "patch": { - "description": "Activates, deactivates, or suspends a user account", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Update user status", - "parameters": [ - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, "500": { "description": "Internal Server Error", "schema": { @@ -10990,56 +13160,6 @@ const docTemplate = `{ } } }, - "/api/v1/user/{user_id}/is-pending": { - "get": { - "description": "Returns whether the specified user has a status of \"pending\"", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if user status is pending", - "parameters": [ - { - "type": "string", - "description": "User ID", - "name": "user_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/user/{user_id}/is-profile-completed": { "get": { "description": "Returns the profile completion status and percentage for the specified user", @@ -11090,9 +13210,9 @@ const docTemplate = `{ } } }, - "/api/v1/users": { + "/api/v1/user/{user_name}/is-pending": { "get": { - "description": "Get users with optional filters. Each user includes subscription_status: ACTIVE, PENDING, or Unsubscribed.", + "description": "Returns whether the specified user has a status of \"pending\"", "consumes": [ "application/json" ], @@ -11102,200 +13222,25 @@ const docTemplate = `{ "tags": [ "user" ], - "summary": "Get all users", + "summary": "Check if user status is pending", "parameters": [ { "type": "string", - "description": "Role filter", - "name": "role", - "in": "query" - }, - { - "type": "string", - "description": "Search query", - "name": "query", - "in": "query" - }, - { - "type": "integer", - "description": "Page number", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Page size", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "Created before (RFC3339)", - "name": "created_before", - "in": "query" - }, - { - "type": "string", - "description": "Created after (RFC3339)", - "name": "created_after", - "in": "query" - }, - { - "type": "string", - "description": "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, or INACTIVE for all non-ACTIVE statuses)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Country filter (case-insensitive match on stored value)", - "name": "country", - "in": "query" - }, - { - "type": "string", - "description": "Region filter (case-insensitive match on stored value)", - "name": "region", - "in": "query" - }, - { - "type": "string", - "description": "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)", - "name": "subscription_status", - "in": "query" + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.Response" } }, "400": { "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/users/export": { - "get": { - "produces": [ - "text/csv" - ], - "tags": [ - "user" - ], - "summary": "Export users as CSV (admin)", - "responses": {} - } - }, - "/api/v1/users/summary": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns total users, active users, and users who joined this month", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user summary statistics", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserSummary" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/videos/engagement/heartbeat": { - "post": { - "description": "Records playback position for analytics (completion, replay, and drop-off). Send periodic heartbeats while watching; set ended=true when the viewer leaves. A new session starts after 30 minutes of inactivity or when ended=true on the prior session.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "videos" - ], - "summary": "Report video playback progress", - "parameters": [ - { - "description": "Playback heartbeat", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.VideoEngagementHeartbeatInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.VideoWatchSessionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -11305,6 +13250,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } } @@ -11417,913 +13368,22 @@ const docTemplate = `{ } } }, - "/api/v1/vimeo/uploads/pull": { - "post": { - "description": "Initiates a pull upload where Vimeo fetches the video from a URL", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Create a pull upload to Vimeo", - "parameters": [ - { - "description": "Pull Upload Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CreatePullUploadRequest" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/handlers.VimeoUploadResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/uploads/tus": { - "post": { - "description": "Initiates a TUS resumable upload and returns the upload link", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Create a TUS resumable upload to Vimeo", - "parameters": [ - { - "description": "TUS Upload Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CreateTusUploadRequest" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/handlers.VimeoUploadResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos": { + "/api/v1/ws/connect": { "get": { - "description": "Returns a paginated list of videos for the Vimeo API token (GET https://api.vimeo.com/me/videos)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "Vimeo" + "client" ], - "summary": "List videos stored in the Vimeo account", - "parameters": [ - { - "type": "integer", - "default": 1, - "description": "Page number (starts at 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 25, - "description": "Page size (Vimeo max 100)", - "name": "per_page", - "in": "query" - }, - { - "type": "string", - "description": "Search query", - "name": "query", - "in": "query" - }, - { - "type": "string", - "description": "Sort field (e.g. date, alphabetical, plays, likes, comments, duration, relevance)", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "asc or desc", - "name": "direction", - "in": "query" - }, - { - "type": "string", - "description": "Vimeo filter (e.g. embeddable, playable)", - "name": "filter", - "in": "query" - }, - { - "type": "string", - "description": "Vimeo filter_type when using filter", - "name": "filter_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/handlers.VimeoVideoResponse" - } - }, - "metadata": { - "$ref": "#/definitions/handlers.VimeoVideosListMetadata" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "503": { - "description": "Service Unavailable", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}": { - "get": { - "description": "Retrieves video details from Vimeo by video ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get video information from Vimeo", + "summary": "ConnectSocket", "parameters": [ { "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", + "description": "Access token", + "name": "token", + "in": "query", "required": true } ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.VimeoVideoResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes a video from the Vimeo account", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Delete a video from Vimeo", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}/embed": { - "get": { - "description": "Generates an embeddable player iframe for the video", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get embed code for a Vimeo video", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 640, - "description": "Player width", - "name": "width", - "in": "query" - }, - { - "type": "integer", - "default": 360, - "description": "Player height", - "name": "height", - "in": "query" - }, - { - "type": "boolean", - "description": "Autoplay video", - "name": "autoplay", - "in": "query" - }, - { - "type": "boolean", - "description": "Loop video", - "name": "loop", - "in": "query" - }, - { - "type": "boolean", - "description": "Mute video", - "name": "muted", - "in": "query" - }, - { - "type": "boolean", - "description": "Background mode (no controls)", - "name": "background", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.VimeoEmbedResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}/status": { - "get": { - "description": "Returns the current transcoding status of a video", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get transcode status of a Vimeo video", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/admin-login": { - "post": { - "description": "Login user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login user", - "parameters": [ - { - "description": "Login admin", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.LoginAdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/otp/resend": { - "post": { - "description": "Resend OTP if the previous one is expired", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "otp" - ], - "summary": "Resend OTP", - "parameters": [ - { - "description": "Resend OTP", - "name": "resendOtp", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ResendOtpReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user-login": { - "post": { - "description": "Login user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login user", - "parameters": [ - { - "description": "Login user", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.loginUserRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/admin-profile": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get user profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.AdminProfileRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/checkPhoneEmailExist": { - "post": { - "description": "Check if phone number or email exist", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if phone number or email exist", - "parameters": [ - { - "description": "Check phone number or email exist", - "name": "checkPhoneEmailExist", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/register": { - "post": { - "description": "Register user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Register user", - "parameters": [ - { - "description": "Register user", - "name": "registerUser", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.RegisterUserReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/resetPassword": { - "post": { - "description": "Reset tenant password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Reset tenant password", - "parameters": [ - { - "description": "Reset password", - "name": "resetPassword", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.ResetPasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/sendRegisterCode": { - "post": { - "description": "Send register code", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send register code", - "parameters": [ - { - "description": "Send register code", - "name": "registerCode", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.RegisterCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/sendResetCode": { - "post": { - "description": "Send reset code", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send reset code", - "parameters": [ - { - "description": "Send reset code", - "name": "resetCode", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.ResetCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/user-profile": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get user profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.UserProfileResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/payment/success": { - "get": { - "description": "Displays the Rezina success page after Chapa redirects the learner to return_url", - "produces": [ - "text/html" - ], - "tags": [ - "payments" - ], - "summary": "Chapa payment success page", - "parameters": [ - { - "type": "string", - "description": "Chapa transaction reference (tx_ref)", - "name": "trx_ref", - "in": "query" - }, - { - "type": "string", - "description": "Chapa transaction reference", - "name": "tx_ref", - "in": "query" - }, - { - "type": "string", - "description": "Chapa reference ID", - "name": "ref_id", - "in": "query" - }, - { - "type": "string", - "description": "Payment status from Chapa redirect", - "name": "status", - "in": "query" - } - ], - "responses": { - "200": { - "description": "HTML success page", - "schema": { - "type": "string" - } - } - } + "responses": {} } } }, @@ -12500,141 +13560,6 @@ const docTemplate = `{ } } }, - "domain.AdminLMSCourseLearningEntry": { - "type": "object", - "properties": { - "course_level_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "id": { - "type": "integer" - }, - "modules": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSModuleLearningEntry" - } - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSLessonLearningEntry": { - "type": "object", - "properties": { - "completed_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "lesson_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "sort_order": { - "type": "integer" - }, - "title": { - "type": "string" - } - } - }, - "domain.AdminLMSModuleLearningEntry": { - "type": "object", - "properties": { - "id": { - "type": "integer" - }, - "lessons": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSLessonLearningEntry" - } - }, - "module_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSPracticeLearningEntry": { - "type": "object", - "properties": { - "completed_at": { - "type": "string" - }, - "lms_practice_id": { - "type": "integer" - }, - "scope": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "domain.AdminLMSProgramLearningEntry": { - "type": "object", - "properties": { - "courses": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSCourseLearningEntry" - } - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSUserLearningActivityTree": { - "type": "object", - "properties": { - "programs": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSProgramLearningEntry" - } - }, - "user_id": { - "type": "integer" - } - } - }, "domain.AdminUserExamPrepLearningSection": { "type": "object", "properties": { @@ -12646,29 +13571,12 @@ const docTemplate = `{ } } }, - "domain.AdminUserLMSLearningSection": { - "type": "object", - "properties": { - "completed_ids": { - "$ref": "#/definitions/domain.LMSUserProgress" - }, - "completions": { - "$ref": "#/definitions/domain.AdminLMSUserLearningActivityTree" - }, - "progress": { - "$ref": "#/definitions/domain.LMSProgressSummary" - } - } - }, "domain.AdminUserLearningActivityDetails": { "type": "object", "properties": { "exam_prep": { "$ref": "#/definitions/domain.AdminUserExamPrepLearningSection" }, - "lms": { - "$ref": "#/definitions/domain.AdminUserLMSLearningSection" - }, "recent_activity": { "$ref": "#/definitions/domain.UserRecentActivityFeed" }, @@ -12868,11 +13776,8 @@ const docTemplate = `{ "exam_prep": { "$ref": "#/definitions/domain.AnalyticsExamPrepContentCounts" }, - "lms": { - "$ref": "#/definitions/domain.AnalyticsLMSContentCounts" - }, "total_categories": { - "description": "Top-level keys preserved for existing clients: map to LMS programs, courses, modules, and all video lessons (LMS + exam prep).", + "description": "Top-level summary fields preserve the dashboard contract using the unified hierarchy.", "type": "integer" }, "total_courses": { @@ -13014,38 +13919,6 @@ const docTemplate = `{ } } }, - "domain.AnalyticsLMSContentCounts": { - "type": "object", - "properties": { - "courses": { - "type": "integer" - }, - "lessons": { - "type": "integer" - }, - "lessons_with_video": { - "type": "integer" - }, - "modules": { - "type": "integer" - }, - "practices": { - "type": "integer" - }, - "practices_at_course": { - "type": "integer" - }, - "practices_at_lesson": { - "type": "integer" - }, - "practices_at_module": { - "type": "integer" - }, - "programs": { - "type": "integer" - } - } - }, "domain.AnalyticsLabelAmount": { "type": "object", "properties": { @@ -13602,6 +14475,7 @@ const docTemplate = `{ "category": { "type": "string", "enum": [ + "EDUCATION", "IELTS", "DUOLINGO" ] @@ -14531,135 +15405,6 @@ const docTemplate = `{ } } }, - "domain.LMSProgressSummary": { - "type": "object", - "properties": { - "exam_prep": { - "$ref": "#/definitions/domain.ExamPrepProgressSummary" - }, - "programs": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryProgram" - } - } - } - }, - "domain.LMSProgressSummaryCourse": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "id": { - "type": "integer" - }, - "modules": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryModule" - } - }, - "name": { - "type": "string" - }, - "program_id": { - "type": "integer" - } - } - }, - "domain.LMSProgressSummaryLesson": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "id": { - "type": "integer" - }, - "module_id": { - "type": "integer" - }, - "title": { - "type": "string" - } - } - }, - "domain.LMSProgressSummaryModule": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "course_id": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "lessons": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryLesson" - } - }, - "name": { - "type": "string" - }, - "program_id": { - "type": "integer" - } - } - }, - "domain.LMSProgressSummaryProgram": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "courses": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryCourse" - } - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "domain.LMSUserProgress": { - "type": "object", - "properties": { - "course_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "lesson_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "module_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "program_ids": { - "type": "array", - "items": { - "type": "integer" - } - } - } - }, "domain.LogEntry": { "type": "object", "properties": { @@ -14879,6 +15624,9 @@ const docTemplate = `{ "phone_number": { "type": "string" }, + "referral_code": { + "type": "string" + }, "role": { "type": "string" } @@ -15228,6 +15976,7 @@ const docTemplate = `{ "category": { "type": "string", "enum": [ + "EDUCATION", "IELTS", "DUOLINGO" ] diff --git a/docs/swagger.json b/docs/swagger.json index 5cbedbdf..d43daf1a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -16,7 +16,7 @@ "version": "1.0.1" }, "paths": { - "/api/v1/activity-logs": { + "/api/v1/admin/activity-logs": { "get": { "description": "Returns a filtered, paginated list of activity logs", "produces": [ @@ -100,7 +100,7 @@ } } }, - "/api/v1/activity-logs/export": { + "/api/v1/admin/activity-logs/export": { "get": { "produces": [ "text/csv" @@ -112,7 +112,7 @@ "responses": {} } }, - "/api/v1/activity-logs/{id}": { + "/api/v1/admin/activity-logs/{id}": { "get": { "description": "Returns a single activity log entry by its ID", "produces": [ @@ -153,7 +153,7 @@ } } }, - "/api/v1/admin": { + "/api/v1/admin/admins": { "get": { "description": "Get all Admins", "consumes": [ @@ -258,6 +258,308 @@ } } }, + "/api/v1/admin/admins/roles/{role}/bulk-deactivate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets all platform users with the given users.role to DEACTIVATED (except the caller) and all team_members with the given team_role to inactive. Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk change other platform ADMIN users (team_members with team_role ADMIN under path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id to skip one team_members row (e.g. yourself).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "parameters": [ + { + "type": "string", + "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", + "name": "role", + "in": "path", + "required": true + }, + { + "description": "Optional exclusions", + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/admins/roles/{role}/bulk-reactivate": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Sets all platform users with the given role from DEACTIVATED to ACTIVE (except the caller) and all team_members with the given team_role from inactive to active. Path :role may be a role key or decimal RBAC roles.id (see bulk-deactivate). Path role must correspond to valid platform users.role or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users (team_members ADMIN under path ADMIN is allowed). Matches only users currently DEACTIVATED and team rows currently inactive.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "parameters": [ + { + "type": "string", + "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", + "name": "role", + "in": "path", + "required": true + }, + { + "description": "Optional exclusions", + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/admins/{id}": { + "get": { + "description": "Get a single admin by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Get admin by id", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.AdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "put": { + "description": "Update Admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "Update Admin", + "parameters": [ + { + "description": "Update Admin", + "name": "admin", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateAdminReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/analytics/dashboard": { + "get": { + "description": "Platform analytics with optional date filters in Africa/Addis_Ababa (EAT): all-time (default), year, year+month, or custom from/to range. When year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals (EAT) per currency for that calendar year. Optional payment_method filters payment/revenue metrics (exact or METHOD:% variants). Daily series remains in revenue_last_30_days (see date_filter.series_*). Courses section counts LMS + exam_prep inventory.", + "produces": [ + "application/json" + ], + "tags": [ + "analytics" + ], + "summary": "Analytics dashboard", + "parameters": [ + { + "type": "integer", + "description": "EAT calendar year (e.g. 2025)", + "name": "year", + "in": "query" + }, + { + "type": "integer", + "description": "EAT calendar month 1-12 (requires year)", + "name": "month", + "in": "query" + }, + { + "type": "string", + "description": "Custom EAT range start (YYYY-MM-DD or RFC3339)", + "name": "from", + "in": "query" + }, + { + "type": "string", + "description": "Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive)", + "name": "to", + "in": "query" + }, + { + "type": "string", + "description": "Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT)", + "name": "payment_method", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AnalyticsDashboard" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, "/api/v1/admin/app-versions": { "get": { "security": [ @@ -529,6 +831,138 @@ } } }, + "/api/v1/admin/auth/admin-login": { + "post": { + "description": "Login user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login user", + "parameters": [ + { + "description": "Login admin", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.LoginAdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/auth/super-login": { + "post": { + "description": "Login super-admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login super-admin", + "parameters": [ + { + "description": "Login super-admin", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.LoginAdminRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/devices/register": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "RegisterDeviceToken", + "responses": {} + } + }, + "/api/v1/admin/devices/unregister": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "UnregisterDeviceToken", + "responses": {} + } + }, "/api/v1/admin/email-templates": { "get": { "description": "Returns email templates for admin management", @@ -945,6 +1379,984 @@ } } }, + "/api/v1/admin/exam-prep/assessments": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "ListExamPrepAssessments", + "responses": {} + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "LinkExamPrepAssessment", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/assessments/{questionSetId}/parents/{parentKind}/{parentId}": { + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UnlinkExamPrepAssessment", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep catalog courses", + "parameters": [ + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "description": "Top-level exam track (DET, IELTS, …) in schema exam_prep — separate from LMS programs/courses", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep catalog course", + "parameters": [ + { + "description": "Catalog course", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepCatalogCourseInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/reorder": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Reorder all exam-prep catalog courses", + "parameters": [ + { + "description": "ordered_ids: every catalog course id exactly once", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the catalog course.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice under a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep units for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "description": "Unit under a catalog course (e.g. chapter title). Optional sort_order assigns position within that catalog course (siblings at or after that index are shifted); omit to append after the current highest sort_order in the catalog course.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "Unit", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepUnitInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder units within a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "description": "ordered_ids: every unit id in this catalog course, new order", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/catalog-courses/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep catalog course by ID", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepCatalogCourseInput" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/exam-prep/lessons/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep lesson by ID", + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep lesson", + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep lesson", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/lessons/{lessonId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a lesson", + "parameters": [ + { + "type": "integer", + "description": "Exam prep lesson ID", + "name": "lessonId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the lesson.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep module by ID", + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep module", + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep module", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{moduleId}/lessons": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep lessons for a unit module", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep lesson (under a unit module)", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "description": "Lesson", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepLessonInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/modules/{moduleId}/lessons/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder lessons within an exam-prep unit module", + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices globally", + "parameters": [ + { + "type": "integer", + "description": "Page size. Omit (with offset) to return all practices.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset. Defaults to 0 when limit is provided; ignored semantics when both omitted (all rows).", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "description": "When true, return only practices with no parent links (admin)", + "name": "unlinked_only", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice (optional parents; link later via PUT /exam-prep/practices/:id/parents)", + "parameters": [ + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice by ID", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep practice", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepPracticeInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep practice", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}/full": { + "get": { + "description": "Returns exam-prep practice metadata, linked question set settings, and all questions in the set.", + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice with question set and questions", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates exam-prep practice metadata, linked question set settings, and syncs questions in one request.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "exam-prep" + ], + "summary": "Full update exam-prep practice with question set and questions", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Full practice update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.FullUpdatePracticeInput" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/exam-prep/practices/{id}/parents": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Replace exam-prep practice parent links", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Parent links (replaces all; use empty array to detach)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepPracticeParentsInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/practices/{id}/parents/{parentKind}/{parentId}": { + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Unlink one exam-prep practice parent", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent kind (CATALOG_COURSE, UNIT, LESSON)", + "name": "parentKind", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Parent entity ID", + "name": "parentId", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep unit by ID", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Update exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateExamPrepUnitInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "exam-prep" + ], + "summary": "Delete exam-prep unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/modules": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep modules for a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep module", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "Module", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepModuleInput" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/modules/reorder": { + "put": { + "tags": [ + "exam-prep" + ], + "summary": "Reorder modules within a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "ordered_ids", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ReorderIDsRequest" + } + } + ], + "responses": {} + } + }, + "/api/v1/admin/exam-prep/units/{unitId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the unit.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + }, + "post": { + "tags": [ + "exam-prep" + ], + "summary": "Create exam-prep practice under a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "description": "Practice", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateExamPrepPracticeInput" + } + } + ], + "responses": {} + } + }, "/api/v1/admin/faqs": { "get": { "description": "Returns FAQs for admin management with status/category filtering", @@ -1364,6 +2776,1366 @@ } } }, + "/api/v1/admin/files/audio": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "files" + ], + "summary": "Upload an audio file", + "parameters": [ + { + "type": "file", + "description": "Audio file (mp3, wav, ogg, m4a, aac, webm)", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/complete-upload": { + "post": { + "description": "Call after PUT upload to upload_url. Returns the same file metadata shape as POST /files/upload.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Complete presigned MinIO upload", + "parameters": [ + { + "description": "Complete upload request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.completePresignedUploadReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/presign-upload": { + "post": { + "description": "Returns a short-lived PUT URL and object key. Upload the file with HTTP PUT to upload_url using the same Content-Type, then call POST /files/complete-upload.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Create presigned MinIO upload URL", + "parameters": [ + { + "description": "Presigned upload request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.presignedUploadReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/refresh-url": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "files" + ], + "summary": "Refresh presigned URL for a file", + "parameters": [ + { + "description": "reference (object key, minio://..., or existing presigned URL)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.refreshFileURLReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/upload": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "files" + ], + "summary": "Upload media file", + "parameters": [ + { + "type": "string", + "description": "Media type: image|audio|video|pdf", + "name": "media_type", + "in": "formData", + "required": true + }, + { + "type": "file", + "description": "Media file", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/files/url": { + "get": { + "tags": [ + "files" + ], + "summary": "Get presigned URL for a file", + "parameters": [ + { + "type": "string", + "description": "MinIO object key (e.g. profile_pictures/uuid.jpg)", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/internal/users/purge-due-deletions": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Worker-safe purge for due self-deletion requests", + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Purge due account deletions", + "parameters": [ + { + "type": "integer", + "description": "Max users to purge in one run (default 100, max 1000)", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/issues": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns all reported issues with pagination (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get all issues", + "parameters": [ + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueListRes" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/user/{user_id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns paginated issues reported by a specific user (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get issues for a specific user", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueListRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns a single issue report by its ID (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Get issue by ID", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.issueRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes an issue report (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Delete an issue", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/issues/{id}/status": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Updates the status of an issue (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "issues" + ], + "summary": "Update issue status", + "parameters": [ + { + "type": "integer", + "description": "Issue ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateIssueStatusReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/logs": { + "get": { + "description": "Fetches application logs from MongoDB with pagination, level filtering, and search", + "produces": [ + "application/json" + ], + "tags": [ + "Logs" + ], + "summary": "Retrieve application logs with filtering and pagination", + "parameters": [ + { + "type": "string", + "description": "Filter logs by level (debug, info, warn, error, dpanic, panic, fatal)", + "name": "level", + "in": "query" + }, + { + "type": "string", + "description": "Search term to match against message or fields", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "Page number for pagination (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 50, + "description": "Number of items per page (default: 50, max: 100)", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Paginated list of application logs", + "schema": { + "$ref": "#/definitions/domain.LogResponse" + } + }, + "400": { + "description": "Invalid request parameters", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "GetUserNotification", + "responses": {} + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "DeleteUserNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/all": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetAllNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/bulk-email": { + "post": { + "description": "Sends an email to specified user IDs, users of a platform role, team member IDs, team members of a team_role, or direct email addresses with optional image attachment. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk email", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-in-app": { + "post": { + "description": "Creates in-app notifications for specified platform user IDs, users matching a platform role, team member IDs, or team members matching a team_role. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk in-app notification", + "parameters": [ + { + "description": "Bulk in-app content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "level": { + "type": "string" + }, + "message": { + "type": "string" + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "team_member_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "team_role": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-push": { + "post": { + "description": "Sends a push notification to specified user IDs or all users matching a role. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk push notification", + "parameters": [ + { + "description": "Bulk push content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "image": { + "type": "string" + }, + "message": { + "type": "string" + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "title": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/bulk-sms": { + "post": { + "description": "Sends an SMS to specified user IDs, all users of a role, or direct phone numbers. Optionally schedule for later with scheduled_at (RFC3339).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send bulk SMS", + "parameters": [ + { + "description": "Bulk SMS content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "phone_numbers": { + "type": "array", + "items": { + "type": "string" + } + }, + "role": { + "type": "string" + }, + "scheduled_at": { + "type": "string" + }, + "user_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/create": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "CreateAndSendNotification", + "responses": {} + } + }, + "/api/v1/admin/notifications/delete-in-app": { + "post": { + "description": "Deletes in-app notifications by ID for the authenticated user. Non-matching IDs are ignored.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Delete multiple in-app notifications", + "parameters": [ + { + "description": "Notification IDs", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/mark-all-read": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsRead", + "responses": {} + } + }, + "/api/v1/admin/notifications/mark-all-unread": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsUnread", + "responses": {} + } + }, + "/api/v1/admin/notifications/scheduled": { + "get": { + "description": "Returns paginated scheduled notifications with optional status, channel, and date filters", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "List scheduled notifications", + "parameters": [ + { + "type": "string", + "description": "Filter by status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Filter by channel", + "name": "channel", + "in": "query" + }, + { + "type": "string", + "description": "Filter after date (RFC3339)", + "name": "after", + "in": "query" + }, + { + "type": "string", + "description": "Filter before date (RFC3339)", + "name": "before", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 1, + "description": "Page number", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/scheduled/{id}": { + "get": { + "description": "Returns a single scheduled notification by its ID", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Get scheduled notification", + "parameters": [ + { + "type": "integer", + "description": "Scheduled Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/scheduled/{id}/cancel": { + "post": { + "description": "Cancels a scheduled notification if it is still pending or processing", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Cancel scheduled notification", + "parameters": [ + { + "type": "integer", + "description": "Scheduled Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/send-email": { + "post": { + "description": "Sends an email to a single email address with optional image attachment", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send single email", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/test-push": { + "post": { + "description": "Sends a test push notification to all registered devices of the current user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Send test push notification", + "parameters": [ + { + "description": "Test notification content", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "title": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/unread": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "CountUnreadNotifications", + "responses": {} + } + }, + "/api/v1/admin/notifications/{id}": { + "get": { + "description": "Returns a single in-app notification. Users may only fetch their own notifications unless they have list-all access.", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Get in-app notification by ID", + "parameters": [ + { + "type": "integer", + "description": "Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Deletes one in-app notification owned by the authenticated user.", + "produces": [ + "application/json" + ], + "tags": [ + "notifications" + ], + "summary": "Delete a single in-app notification", + "parameters": [ + { + "type": "integer", + "description": "Notification ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/notifications/{id}/read": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsRead", + "responses": {} + } + }, + "/api/v1/admin/notifications/{id}/unread": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsUnread", + "responses": {} + } + }, "/api/v1/admin/payments": { "get": { "description": "Returns paginated payments across Chapa and ArifPay with optional filters", @@ -1543,14 +4315,179 @@ } } }, - "/api/v1/admin/roles/{role}/bulk-deactivate": { - "post": { - "security": [ + "/api/v1/admin/personas": { + "get": { + "tags": [ + "personas" + ], + "summary": "List LMS personas (catalog for practice assignment)", + "parameters": [ { - "Bearer": [] + "type": "boolean", + "default": true, + "description": "When true (default), return only active personas", + "name": "active_only", + "in": "query" + }, + { + "type": "integer", + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset", + "name": "offset", + "in": "query" } ], - "description": "Sets all platform users with the given users.role to DEACTIVATED (except the caller) and all team_members with the given team_role to inactive. Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk change other platform ADMIN users (team_members with team_role ADMIN under path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id to skip one team_members row (e.g. yourself).", + "responses": {} + }, + "post": { + "consumes": [ + "application/json" + ], + "tags": [ + "personas" + ], + "summary": "Create LMS persona catalog entry", + "parameters": [ + { + "description": "Persona", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateLmsPersonaInput" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/personas/{id}": { + "get": { + "tags": [ + "personas" + ], + "summary": "Get LMS persona by ID", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + }, + "put": { + "tags": [ + "personas" + ], + "summary": "Update LMS persona", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Fields to update", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateLmsPersonaInput" + } + } + ], + "responses": {} + }, + "delete": { + "tags": [ + "personas" + ], + "summary": "Delete LMS persona (practices referencing it will have persona_id cleared)", + "parameters": [ + { + "type": "integer", + "description": "Persona ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/admin/question-sets": { + "get": { + "description": "Returns a paginated list of question sets filtered by type", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question sets by type", + "parameters": [ + { + "type": "string", + "description": "Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE)", + "name": "set_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new question set (practice, assessment, quiz, exam, or survey)", "consumes": [ "application/json" ], @@ -1558,23 +4495,157 @@ "application/json" ], "tags": [ - "admin" + "question-sets" ], - "summary": "Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "summary": "Create a new question set", + "parameters": [ + { + "description": "Create question set payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionSetReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/by-owner": { + "get": { + "description": "Returns question sets for a specific owner (e.g., sub-course)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question sets by owner", "parameters": [ { "type": "string", - "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", - "name": "role", + "description": "Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE)", + "name": "owner_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Owner ID", + "name": "owner_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{id}": { + "get": { + "description": "Returns a question set with question count", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get question set by ID", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a question set's properties", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Update a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", "in": "path", "required": true }, { - "description": "Optional exclusions", + "description": "Update question set payload", "name": "body", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + "$ref": "#/definitions/handlers.updateQuestionSetReq" } } ], @@ -1591,8 +4662,222 @@ "$ref": "#/definitions/domain.ErrorResponse" } }, - "403": { - "description": "Forbidden", + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Archives a question set (soft delete)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Delete a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/personas": { + "get": { + "description": "Returns all users assigned as personas to a question set (practice)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Get user personas for a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Links a user as a persona to a question set (practice)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Add a user as persona to a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "description": "Add user persona payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.addUserPersonaReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/personas/{userId}": { + "delete": { + "description": "Unlinks a user as persona from a question set (practice)", + "produces": [ + "application/json" + ], + "tags": [ + "question-sets" + ], + "summary": "Remove a user persona from a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/question-types": { + "get": { + "description": "Returns distinct question type definitions (key, display_name, counts) for non-archived questions in the set. Legacy stored question_type values (e.g. AUDIO) are resolved to builder definitions when possible.", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "List question types in a question set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -1612,14 +4897,48 @@ } } }, - "/api/v1/admin/roles/{role}/bulk-reactivate": { - "post": { - "security": [ + "/api/v1/admin/question-sets/{setId}/questions": { + "get": { + "description": "Returns all questions in a question set with contextual shared stimulus data for linked LMS and exam-prep practices", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Get questions in set", + "parameters": [ { - "Bearer": [] + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true } ], - "description": "Sets all platform users with the given role from DEACTIVATED to ACTIVE (except the caller) and all team_members with the given team_role from inactive to active. Path :role may be a role key or decimal RBAC roles.id (see bulk-deactivate). Path role must correspond to valid platform users.role or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users (team_members ADMIN under path ADMIN is allowed). Matches only users currently DEACTIVATED and team rows currently inactive.", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Links a question to a question set. Omit display_order to append after the current max; the assigned value is returned in the response.", "consumes": [ "application/json" ], @@ -1627,23 +4946,132 @@ "application/json" ], "tags": [ - "admin" + "question-set-items" ], - "summary": "Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)", + "summary": "Add question to set", "parameters": [ { - "type": "string", - "description": "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)", - "name": "role", + "type": "integer", + "description": "Question Set ID", + "name": "setId", "in": "path", "required": true }, { - "description": "Optional exclusions", + "description": "Add question to set payload", "name": "body", "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/domain.BulkAccountsByRoleRequest" + "$ref": "#/definitions/handlers.addQuestionToSetReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/questions/{questionId}": { + "delete": { + "description": "Unlinks a question from a question set", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Remove question from set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Question ID", + "name": "questionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/question-sets/{setId}/questions/{questionId}/order": { + "put": { + "description": "Updates the display order of a question in a set", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Update question order in set", + "parameters": [ + { + "type": "integer", + "description": "Question Set ID", + "name": "setId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Question ID", + "name": "questionId", + "in": "path", + "required": true + }, + { + "description": "Update order payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionOrderReq" } } ], @@ -1660,8 +5088,501 @@ "$ref": "#/definitions/domain.ErrorResponse" } }, - "403": { - "description": "Forbidden", + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions": { + "get": { + "description": "Returns a paginated list of questions with optional filters", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List questions", + "parameters": [ + { + "type": "string", + "description": "Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER)", + "name": "question_type", + "in": "query" + }, + { + "type": "string", + "description": "Difficulty level filter (EASY, MEDIUM, HARD)", + "name": "difficulty", + "in": "query" + }, + { + "type": "string", + "description": "Status filter (DRAFT, PUBLISHED, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new question with options (for MCQ/TRUE_FALSE) or short answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; use dynamic_payload stimulus instead. Legacy types require question_text.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create a new question", + "parameters": [ + { + "description": "Create question payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/component-catalog": { + "get": { + "description": "Valid stimulus and response component kind codes for dynamic question-type definitions", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Question-type builder component catalog", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/search": { + "get": { + "description": "Search questions by text", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Search questions", + "parameters": [ + { + "type": "string", + "description": "Search query", + "name": "q", + "in": "query", + "required": true + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definition-groups": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List question type definition groups", + "parameters": [ + { + "type": "string", + "description": "Filter by status (ACTIVE, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size (default 20, max 200)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Page offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create question type definition group", + "parameters": [ + { + "description": "Group payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionTypeDefinitionGroupReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/type-definition-groups/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get question type definition group with definitions", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update question type definition group", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update group payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionGroupReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete question type definition group", + "parameters": [ + { + "type": "integer", + "description": "Group id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List reusable question-type definitions", + "parameters": [ + { + "type": "string", + "description": "Filter by status (ACTIVE, INACTIVE)", + "name": "status", + "in": "query" + }, + { + "type": "boolean", + "default": true, + "description": "Include system seeded definitions", + "name": "include_system", + "in": "query" + }, + { + "type": "integer", + "default": 20, + "description": "Page size (default 20, max 200)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Page offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Stores a reusable dynamic question-type definition for future question construction. Only runtime-mappable definitions are persisted.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Create reusable question-type definition", + "parameters": [ + { + "description": "Question type definition payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions/{id}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get reusable question-type definition by id", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -1671,6 +5592,1328 @@ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + } + } + }, + "put": { + "description": "Updates a reusable dynamic question-type definition. Updated definitions must remain runtime-mappable.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update reusable question-type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update question type definition payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete reusable question-type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/type-definitions/{id}/practices": { + "get": { + "description": "Returns LMS and exam-prep practices whose linked question set contains at least one non-archived question matching the definition (by question_type_definition_id or legacy question_type).", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "List practices globally by question type definition", + "parameters": [ + { + "type": "integer", + "description": "Question type definition id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/validate-question-type-definition": { + "post": { + "description": "Validates selected stimulus and response component kinds for temporary question-type definitions (component-level validation only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Validate dynamic question-type definition", + "parameters": [ + { + "description": "Stimulus and response component kinds", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.validateQuestionTypeDefinitionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/questions/{id}": { + "get": { + "description": "Returns a question with its options/short answers", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Get question by ID", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a question and optionally replaces its options/short answers. Supports question_type_definition_id for dynamic builder-linked questions.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Update a question", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update question payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updateQuestionReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Archives a question (soft delete)", + "produces": [ + "application/json" + ], + "tags": [ + "questions" + ], + "summary": "Delete a question", + "parameters": [ + { + "type": "integer", + "description": "Question ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings": { + "get": { + "description": "Returns paginated ratings for a specific target", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Get ratings for a target", + "parameters": [ + { + "type": "string", + "description": "Target type (app, course, sub_course)", + "name": "target_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Target ID (0 for app)", + "name": "target_id", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Limit (default 20)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (default 0)", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings/summary": { + "get": { + "description": "Returns the total count and average stars for a specific target", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Get rating summary for a target", + "parameters": [ + { + "type": "string", + "description": "Target type (app, course, sub_course)", + "name": "target_type", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Target ID (0 for app)", + "name": "target_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ratings/{id}": { + "delete": { + "description": "Deletes a rating by ID for the current user", + "produces": [ + "application/json" + ], + "tags": [ + "ratings" + ], + "summary": "Delete a rating", + "parameters": [ + { + "type": "integer", + "description": "Rating ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all permissions in the system grouped by group name", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List all permissions", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Permission" + } + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions/groups": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all distinct permission group names", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List permission groups", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/permissions/sync": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Re-seed permissions from code and reload the RBAC cache", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Sync permissions", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all roles with optional filters", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "List all roles", + "parameters": [ + { + "type": "string", + "description": "Search by role name", + "name": "query", + "in": "query" + }, + { + "type": "boolean", + "description": "Filter by system role (true/false)", + "name": "is_system", + "in": "query" + }, + { + "type": "integer", + "description": "Page number (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Page size (default: 20)", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Create a new role with a name and description", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Create a new role", + "parameters": [ + { + "description": "Role creation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateRoleReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.RoleRecord" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get a role and its permissions by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Get a role by ID", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.RoleWithPermissions" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update an existing role's name and description", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Update a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Role update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateRoleReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Delete a non-system role by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Delete a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/rbac/roles/{id}/permissions": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get all permissions assigned to a role", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Get permissions for a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Permission" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Replace all permissions for a role with the given permission IDs", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "rbac" + ], + "summary": "Set permissions for a role", + "parameters": [ + { + "type": "integer", + "description": "Role ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Permission IDs payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SetRolePermissionsReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/referrals/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetReferralSettings", + "responses": {} + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UpdateReferralSettings", + "responses": {} + } + }, + "/api/v1/admin/sendSMS": { + "post": { + "description": "Sends an SMS message to a single phone number using AfroMessage", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Send single SMS via AfroMessage", + "parameters": [ + { + "description": "Send SMS request", + "name": "sendSMS", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.SendSingleAfroSMSReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/settings": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetGlobalSettingList", + "responses": {} + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "UpdateGlobalSettingList", + "responses": {} + } + }, + "/api/v1/admin/settings/{key}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "admin" + ], + "summary": "GetGlobalSettingByKey", + "responses": {} + } + }, + "/api/v1/admin/subscription-plans": { + "get": { + "description": "Returns subscription plans. Optional category filter: EDUCATION.", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "List subscription plans", + "parameters": [ + { + "type": "boolean", + "description": "Return only active plans (default true)", + "name": "active_only", + "in": "query" + }, + { + "type": "string", + "description": "Filter by plan category (EDUCATION)", + "name": "category", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "description": "Creates a new subscription plan (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Create a subscription plan", + "parameters": [ + { + "description": "Create plan payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.createPlanReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/subscription-plans/{id}": { + "get": { + "description": "Returns a single subscription plan by ID", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Get a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "description": "Updates a subscription plan (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Update a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update plan payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.updatePlanReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "description": "Deletes a subscription plan (admin only)", + "produces": [ + "application/json" + ], + "tags": [ + "subscriptions" + ], + "summary": "Delete a subscription plan", + "parameters": [ + { + "type": "integer", + "description": "Plan ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } }, "500": { "description": "Internal Server Error", @@ -1745,6 +6988,1612 @@ } } }, + "/api/v1/admin/team/invitations": { + "get": { + "description": "Lists team member invitations with optional status filter", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "List team invitations", + "parameters": [ + { + "type": "string", + "description": "pending, accepted, expired, or revoked", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "description": "Limit (default 20)", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (default 0)", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/accept": { + "post": { + "description": "Public endpoint to set password and profile details after following the invite link", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Accept team invitation and complete account setup", + "parameters": [ + { + "description": "Accept invitation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.AcceptTeamInvitationReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/verify": { + "get": { + "description": "Public endpoint used by the admin panel accept-invite page", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Verify team invitation token", + "parameters": [ + { + "type": "string", + "description": "Invitation token", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/invitations/{id}/revoke": { + "post": { + "description": "Revokes the invitation and removes the pending team member if not yet accepted", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Revoke a pending team invitation", + "parameters": [ + { + "type": "integer", + "description": "Invitation ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/team/login": { + "post": { + "description": "Authenticate a team member (internal staff) with email and password", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Login team member", + "parameters": [ + { + "description": "Team member login credentials", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamMemberLoginReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.teamMemberLoginRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/me": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get the authenticated team member's own profile", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get my team profile", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update the authenticated team member's own profile fields", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update my team profile", + "parameters": [ + { + "description": "Profile update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateMyTeamProfileReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get a paginated list of team members with optional filtering", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "List all team members", + "parameters": [ + { + "type": "string", + "description": "Filter by team role (super_admin, admin, content_manager, support_agent, instructor, finance, hr, analyst)", + "name": "team_role", + "in": "query" + }, + { + "type": "string", + "description": "Filter by department", + "name": "department", + "in": "query" + }, + { + "type": "string", + "description": "Filter by status (active, inactive, suspended, terminated)", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Search by name, email, or phone number", + "name": "search", + "in": "query" + }, + { + "type": "integer", + "description": "Page number (default: 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Items per page (default: 10, max: 100)", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + }, + "metadata": { + "$ref": "#/definitions/domain.Pagination" + } + } + } + ] + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Create a new internal team member (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Create a new team member", + "parameters": [ + { + "description": "Team member creation payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateTeamMemberReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/export": { + "get": { + "produces": [ + "text/csv" + ], + "tags": [ + "team" + ], + "summary": "Export team members as CSV (admin)", + "responses": {} + } + }, + "/api/v1/admin/team/members/invite": { + "post": { + "description": "Creates a pending team member (email + team_role only) and sends an invitation email; profile is completed on accept", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Invite a team member by email", + "parameters": [ + { + "description": "Invite payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.InviteTeamMemberReq" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Retrieve a team member's details by their ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get team member by ID", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update an existing team member's details (admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update team member", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Team member update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateTeamMemberReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Delete a team member (super admin only)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Delete team member", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/change-password": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Change a team member's password (requires current password)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Change team member password", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Password change payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.changePasswordReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/resend-invite": { + "post": { + "description": "Revokes the current pending invite and sends a new invitation email", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Resend team invitation", + "parameters": [ + { + "type": "integer", + "description": "Team member ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/members/{id}/status": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Update a team member's status (active, inactive, suspended, terminated)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Update team member status", + "parameters": [ + { + "type": "integer", + "description": "Team Member ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateTeamMemberStatusReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/refresh": { + "post": { + "description": "Exchanges a valid team refresh token for a new access JWT and a rotated refresh token (use only tokens from POST /team/login or this endpoint).", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Refresh team member tokens", + "parameters": [ + { + "description": "Current refresh token", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.teamMemberRefreshReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.teamMemberLoginRes" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/resetPassword": { + "post": { + "description": "Completes team password reset using email + OTP from the reset link. Public.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Reset team member password", + "parameters": [ + { + "description": "Reset payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamResetPasswordReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/sendResetCode": { + "post": { + "description": "Sends a password-reset email with a link to the team member (admin panel). Public.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Send team password reset link", + "parameters": [ + { + "description": "Email", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.TeamSendPasswordResetReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/stats": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get statistics about team members by status", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Get team member statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.TeamMemberStats" + } + } + } + ] + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/team/verifyResetCode": { + "get": { + "description": "Checks whether email+otp from a reset link are still valid without consuming the OTP. Public.", + "produces": [ + "application/json" + ], + "tags": [ + "team" + ], + "summary": "Verify team password reset link", + "parameters": [ + { + "type": "string", + "description": "Team member email", + "name": "email", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Reset OTP from the email link", + "name": "otp", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/admin/user/admin-profile": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Get user profile", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user profile", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.AdminProfileRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/delete/{id}": { + "delete": { + "description": "Delete a user by their ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Delete user by ID", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/search": { + "post": { + "description": "Search for user using name or phone", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Search for user using name or phone", + "parameters": [ + { + "description": "Search for using his name or phone", + "name": "searchUserByNameOrPhone", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.SearchUserByNameOrPhoneReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UserProfileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/single/{id}": { + "get": { + "description": "Get a single user by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user by id", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UserProfileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/status": { + "patch": { + "description": "Activates, deactivates, or suspends a user account", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Update user status", + "parameters": [ + { + "description": "Status update payload", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/user/{id}/profile-picture": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Uploads a profile picture for the specified user", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Upload profile picture", + "parameters": [ + { + "type": "integer", + "description": "User ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Image file (jpg|png|webp)", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/admin/users": { + "get": { + "description": "Get users with optional filters. Each user includes subscription_status: ACTIVE, PENDING, or Unsubscribed.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get all users", + "parameters": [ + { + "type": "string", + "description": "Role filter", + "name": "role", + "in": "query" + }, + { + "type": "string", + "description": "Search query", + "name": "query", + "in": "query" + }, + { + "type": "integer", + "description": "Page number", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "Page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "Created before (RFC3339)", + "name": "created_before", + "in": "query" + }, + { + "type": "string", + "description": "Created after (RFC3339)", + "name": "created_after", + "in": "query" + }, + { + "type": "string", + "description": "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, or INACTIVE for all non-ACTIVE statuses)", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "Country filter (case-insensitive match on stored value)", + "name": "country", + "in": "query" + }, + { + "type": "string", + "description": "Region filter (case-insensitive match on stored value)", + "name": "region", + "in": "query" + }, + { + "type": "string", + "description": "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)", + "name": "subscription_status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/admin/users/deletion-requests": { "get": { "description": "Returns account deletion requests for admin panel tracking with filtering and pagination", @@ -1842,6 +8691,64 @@ } } }, + "/api/v1/admin/users/export": { + "get": { + "produces": [ + "text/csv" + ], + "tags": [ + "user" + ], + "summary": "Export users as CSV (admin)", + "responses": {} + } + }, + "/api/v1/admin/users/summary": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns total users, active users, and users who joined this month", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get user summary statistics", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.UserSummary" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, "/api/v1/admin/users/{user_id}/learning-activity": { "get": { "security": [ @@ -1849,12 +8756,12 @@ "Bearer": [] } ], - "description": "Returns LMS and exam-prep completion trees, progress summaries, completed ID snapshots, and recent activity timeline", + "description": "Returns the unified catalog-course learning tree, progress summary, and recent activity timeline", "produces": [ "application/json" ], "tags": [ - "lms" + "exam-prep" ], "summary": "Get full learning activity for a user (admin)", "parameters": [ @@ -1918,52 +8825,6 @@ } } }, - "/api/v1/admin/users/{user_id}/lms-learning-activity": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns programs, courses, modules, and lessons with completion details and completed practices. Only persisted completion signals are included (completed lessons, completed published practices, and rollup completion timestamps—not partial or in-progress attempts).", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get a user's nested LMS learning activity (admin)", - "parameters": [ - { - "type": "integer", - "description": "Target user ID", - "name": "user_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/admin/users/{user_id}/recent-activity": { "get": { "security": [ @@ -2162,9 +9023,9 @@ } } }, - "/api/v1/admin/{id}": { + "/api/v1/admin/vimeo/oembed": { "get": { - "description": "Get a single admin by id", + "description": "Fetches oEmbed metadata for a Vimeo video URL", "consumes": [ "application/json" ], @@ -2172,14 +9033,313 @@ "application/json" ], "tags": [ - "admin" + "Vimeo" ], - "summary": "Get admin by id", + "summary": "Get oEmbed data for a Vimeo URL", + "parameters": [ + { + "type": "string", + "description": "Vimeo video URL", + "name": "url", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "Desired width", + "name": "width", + "in": "query" + }, + { + "type": "integer", + "description": "Desired height", + "name": "height", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/vimeo.OEmbedResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/sample": { + "get": { + "description": "Fetches a sample video from Vimeo and returns video details along with an embeddable iframe for client-side integration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get a sample Vimeo video with iframe embed", + "parameters": [ + { + "type": "string", + "default": "76979871", + "description": "Vimeo Video ID to use as sample", + "name": "video_id", + "in": "query" + }, + { + "type": "integer", + "default": 640, + "description": "Player width", + "name": "width", + "in": "query" + }, + { + "type": "integer", + "default": 360, + "description": "Player height", + "name": "height", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/uploads/pull": { + "post": { + "description": "Initiates a pull upload where Vimeo fetches the video from a URL", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Create a pull upload to Vimeo", + "parameters": [ + { + "description": "Pull Upload Request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CreatePullUploadRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/handlers.VimeoUploadResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/uploads/tus": { + "post": { + "description": "Initiates a TUS resumable upload and returns the upload link", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Create a TUS resumable upload to Vimeo", + "parameters": [ + { + "description": "TUS Upload Request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CreateTusUploadRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/handlers.VimeoUploadResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/videos": { + "get": { + "description": "Returns a paginated list of videos for the Vimeo API token (GET https://api.vimeo.com/me/videos)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "List videos stored in the Vimeo account", "parameters": [ { "type": "integer", - "description": "User ID", - "name": "id", + "default": 1, + "description": "Page number (starts at 1)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 25, + "description": "Page size (Vimeo max 100)", + "name": "per_page", + "in": "query" + }, + { + "type": "string", + "description": "Search query", + "name": "query", + "in": "query" + }, + { + "type": "string", + "description": "Sort field (e.g. date, alphabetical, plays, likes, comments, duration, relevance)", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "asc or desc", + "name": "direction", + "in": "query" + }, + { + "type": "string", + "description": "Vimeo filter (e.g. embeddable, playable)", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "description": "Vimeo filter_type when using filter", + "name": "filter_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.VimeoVideoResponse" + } + }, + "metadata": { + "$ref": "#/definitions/handlers.VimeoVideosListMetadata" + } + } + } + ] + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "503": { + "description": "Service Unavailable", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/vimeo/videos/{video_id}": { + "get": { + "description": "Retrieves video details from Vimeo by video ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get video information from Vimeo", + "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", "in": "path", "required": true } @@ -2188,31 +9348,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/handlers.AdminRes" + "$ref": "#/definitions/handlers.VimeoVideoResponse" } }, "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } } } }, - "put": { - "description": "Update Admin", + "delete": { + "description": "Deletes a video from the Vimeo account", "consumes": [ "application/json" ], @@ -2220,87 +9374,94 @@ "application/json" ], "tags": [ - "admin" + "Vimeo" ], - "summary": "Update Admin", + "summary": "Delete a video from Vimeo", "parameters": [ { - "description": "Update Admin", - "name": "admin", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateAdminReq" - } + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true } ], "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } + "204": { + "description": "No Content" }, "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.ErrorResponse" } } } } }, - "/api/v1/analytics/dashboard": { + "/api/v1/admin/vimeo/videos/{video_id}/embed": { "get": { - "description": "Platform analytics with optional date filters in Africa/Addis_Ababa (EAT): all-time (default), year, year+month, or custom from/to range. When year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals (EAT) per currency for that calendar year. Optional payment_method filters payment/revenue metrics (exact or METHOD:% variants). Daily series remains in revenue_last_30_days (see date_filter.series_*). Courses section counts LMS + exam_prep inventory.", + "description": "Generates an embeddable player iframe for the video", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], "tags": [ - "analytics" + "Vimeo" ], - "summary": "Analytics dashboard", + "summary": "Get embed code for a Vimeo video", "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true + }, { "type": "integer", - "description": "EAT calendar year (e.g. 2025)", - "name": "year", + "default": 640, + "description": "Player width", + "name": "width", "in": "query" }, { "type": "integer", - "description": "EAT calendar month 1-12 (requires year)", - "name": "month", + "default": 360, + "description": "Player height", + "name": "height", "in": "query" }, { - "type": "string", - "description": "Custom EAT range start (YYYY-MM-DD or RFC3339)", - "name": "from", + "type": "boolean", + "description": "Autoplay video", + "name": "autoplay", "in": "query" }, { - "type": "string", - "description": "Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive)", - "name": "to", + "type": "boolean", + "description": "Loop video", + "name": "loop", "in": "query" }, { - "type": "string", - "description": "Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT)", - "name": "payment_method", + "type": "boolean", + "description": "Mute video", + "name": "muted", + "in": "query" + }, + { + "type": "boolean", + "description": "Background mode (no controls)", + "name": "background", "in": "query" } ], @@ -2308,7 +9469,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.AnalyticsDashboard" + "$ref": "#/definitions/handlers.VimeoEmbedResponse" } }, "400": { @@ -2326,6 +9487,71 @@ } } }, + "/api/v1/admin/vimeo/videos/{video_id}/status": { + "get": { + "description": "Returns the current transcoding status of a video", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Vimeo" + ], + "summary": "Get transcode status of a Vimeo video", + "parameters": [ + { + "type": "string", + "description": "Vimeo Video ID", + "name": "video_id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/admin/ws/connect": { + "get": { + "tags": [ + "client" + ], + "summary": "ConnectSocket", + "parameters": [ + { + "type": "string", + "description": "Access token", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": {} + } + }, "/api/v1/app/version/check": { "get": { "description": "Public endpoint for mobile clients to determine if an app update is available (force or optional)", @@ -2401,6 +9627,58 @@ "responses": {} } }, + "/api/v1/auth/customer-login": { + "post": { + "description": "Login user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Login user", + "parameters": [ + { + "description": "Login user", + "name": "login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handlers.loginUserRes" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/auth/google/android": { "post": { "tags": [ @@ -2543,20 +9821,124 @@ } } }, - "/api/v1/courses/{courseId}/modules": { + "/api/v1/devices/register": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "RegisterDeviceToken", + "responses": {} + } + }, + "/api/v1/devices/unregister": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "UnregisterDeviceToken", + "responses": {} + } + }, + "/api/v1/exam-prep/assessments": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "ListExamPrepAssessments", + "responses": {} + } + }, + "/api/v1/exam-prep/catalog-courses": { "get": { "produces": [ "application/json" ], "tags": [ - "modules" + "exam-prep" ], - "summary": "List modules for a course", + "summary": "List exam-prep catalog courses", "parameters": [ { "type": "integer", - "description": "Course ID", - "name": "courseId", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/exam-prep/catalog-courses/{catalogCourseId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Exam prep catalog course ID", + "name": "catalogCourseId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the catalog course.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/catalog-courses/{catalogCourseId}/units": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep units for a catalog course", + "parameters": [ + { + "type": "integer", + "description": "Catalog course ID", + "name": "catalogCourseId", "in": "path", "required": true }, @@ -2583,40 +9965,205 @@ } } } - }, - "post": { - "description": "Create a module under a course; parent program is taken from the course.", - "consumes": [ - "application/json" - ], + } + }, + "/api/v1/exam-prep/catalog-courses/{id}": { + "get": { "produces": [ "application/json" ], "tags": [ - "modules" + "exam-prep" ], - "summary": "Create module", + "summary": "Get exam-prep catalog course by ID", "parameters": [ { "type": "integer", - "description": "Course ID", - "name": "courseId", + "description": "Catalog course ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + } + } + } + }, + "/api/v1/exam-prep/lessons/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep lesson by ID", + "responses": {} + } + }, + "/api/v1/exam-prep/lessons/{lessonId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a lesson", + "parameters": [ + { + "type": "integer", + "description": "Exam prep lesson ID", + "name": "lessonId", "in": "path", "required": true }, { - "description": "Module", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateModuleInput" - } + "type": "integer", + "description": "Page size. Omit to return all practices for the lesson.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/modules/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep module by ID", + "responses": {} + } + }, + "/api/v1/exam-prep/modules/{moduleId}/lessons": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep lessons for a unit module", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit module ID", + "name": "moduleId", + "in": "path", + "required": true + }, + { + "type": "integer", + "default": 20, + "description": "Page size", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices globally", + "parameters": [ + { + "type": "integer", + "description": "Page size. Omit (with offset) to return all practices.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset. Defaults to 0 when limit is provided; ignored semantics when both omitted (all rows).", + "name": "offset", + "in": "query" + }, + { + "type": "boolean", + "description": "When true, return only practices with no parent links (admin)", + "name": "unlinked_only", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep practice by ID", + "parameters": [ + { + "type": "integer", + "description": "Exam prep practice ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/practices/{practiceId}/questions": { + "get": { + "description": "Returns paginated questions for an exam-prep practice, including shared stimulus blocks and each question's effective dynamic payload", + "produces": [ + "application/json" + ], + "tags": [ + "question-set-items" + ], + "summary": "Get questions by practice", + "parameters": [ + { + "type": "integer", + "description": "Exam-prep practice ID", + "name": "practiceId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Question type filter (e.g. AUDIO)", + "name": "question_type", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "Limit", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "default": 0, + "description": "Offset", + "name": "offset", + "in": "query" } ], "responses": { - "201": { - "description": "Created", + "200": { + "description": "OK", "schema": { "$ref": "#/definitions/domain.Response" } @@ -2626,50 +10173,62 @@ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } } }, - "/api/v1/courses/{courseId}/modules/reorder": { - "put": { - "tags": [ - "modules" - ], - "summary": "Reorder modules within a course", - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "courseId", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every module id in this course, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/courses/{id}": { + "/api/v1/exam-prep/progress-summary": { "get": { + "description": "Returns progress for the catalog course → unit → module → lesson learning hierarchy.", "produces": [ "application/json" ], "tags": [ - "courses" + "exam-prep" ], - "summary": "Get course by ID", + "summary": "Get my learning progress summary", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + } + } + } + }, + "/api/v1/exam-prep/progress/practices/{id}/complete": { + "post": { + "description": "Marks a practice question set as completed for the authenticated learner in its exam-prep parent scope", + "produces": [ + "application/json" + ], + "tags": [ + "progression" + ], + "summary": "Mark exam-prep practice as completed", "parameters": [ { "type": "integer", - "description": "Course ID", + "description": "Practice Question Set ID", "name": "id", "in": "path", "required": true @@ -2682,15 +10241,102 @@ "$ref": "#/definitions/domain.Response" } }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } - }, - "put": { + } + }, + "/api/v1/exam-prep/units/{id}": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "Get exam-prep unit by ID", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/units/{unitId}/modules": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep modules for a unit", + "parameters": [ + { + "type": "integer", + "description": "Unit ID", + "name": "unitId", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/units/{unitId}/practices": { + "get": { + "tags": [ + "exam-prep" + ], + "summary": "List exam-prep practices for a unit", + "parameters": [ + { + "type": "integer", + "description": "Exam prep unit ID", + "name": "unitId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Page size. Omit to return all practices for the unit.", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Offset (used when limit is provided)", + "name": "offset", + "in": "query" + } + ], + "responses": {} + } + }, + "/api/v1/exam-prep/videos/engagement/heartbeat": { + "post": { + "description": "Records playback position for analytics (completion, replay, and drop-off). Send periodic heartbeats while watching; set ended=true when the viewer leaves. A new session starts after 30 minutes of inactivity or when ended=true on the prior session.", "consumes": [ "application/json" ], @@ -2698,24 +10344,17 @@ "application/json" ], "tags": [ - "courses" + "videos" ], - "summary": "Update course", + "summary": "Report video playback progress", "parameters": [ { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", + "description": "Playback heartbeat", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateCourseInput" + "$ref": "#/definitions/domain.VideoEngagementHeartbeatInput" } } ], @@ -2723,7 +10362,31 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.Response" + "allOf": [ + { + "$ref": "#/definitions/domain.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.VideoWatchSessionResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" } }, "404": { @@ -2733,52 +10396,6 @@ } } } - }, - "delete": { - "tags": [ - "courses" - ], - "summary": "Delete course", - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/courses/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Course ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} } }, "/api/v1/faqs": { @@ -3119,109 +10736,7 @@ } } }, - "/api/v1/internal/users/purge-due-deletions": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Worker-safe purge for due self-deletion requests", - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Purge due account deletions", - "parameters": [ - { - "type": "integer", - "description": "Max users to purge in one run (default 100, max 1000)", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/issues": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns all reported issues with pagination (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Get all issues", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueListRes" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, "post": { "security": [ { @@ -3349,134 +10864,18 @@ } } }, - "/api/v1/issues/user/{user_id}": { + "/api/v1/notifications": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns paginated issues reported by a specific user (admin only)", - "produces": [ - "application/json" - ], "tags": [ - "issues" + "client" ], - "summary": "Get issues for a specific user", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "user_id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueListRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/issues/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns a single issue report by its ID (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Get issue by ID", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.issueRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetUserNotification", + "responses": {} }, "delete": { "security": [ @@ -3484,745 +10883,11 @@ "Bearer": [] } ], - "description": "Deletes an issue report (admin only)", - "produces": [ - "application/json" - ], "tags": [ - "issues" - ], - "summary": "Delete an issue", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/issues/{id}/status": { - "patch": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Updates the status of an issue (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "issues" - ], - "summary": "Update issue status", - "parameters": [ - { - "type": "integer", - "description": "Issue ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateIssueStatusReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lessons/{id}": { - "get": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } + "client" ], + "summary": "DeleteUserNotifications", "responses": {} - }, - "put": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateLessonInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/lessons/{id}/complete": { - "post": { - "description": "Records lesson completion; may cascade to module, course, and program progress for the authenticated user. Learners must meet sequential prerequisites; staff bypass checks.", - "tags": [ - "lessons" - ], - "summary": "Mark a lesson as completed", - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lessons/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Lesson ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/lms/progress": { - "get": { - "description": "Returns practice-based completed lesson, module, course, and program IDs for the authenticated user (ordered by completion time, then id).", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get my LMS completion history", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/lms/progress-summary": { - "get": { - "description": "Returns the learner's nested Learn English hierarchy (programs) and exam-prep hierarchy (exam_prep) with the same access progress data exposed on the individual content APIs.", - "produces": [ - "application/json" - ], - "tags": [ - "lms" - ], - "summary": "Get my LMS and exam-prep progress summary", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/logs": { - "get": { - "description": "Fetches application logs from MongoDB with pagination, level filtering, and search", - "produces": [ - "application/json" - ], - "tags": [ - "Logs" - ], - "summary": "Retrieve application logs with filtering and pagination", - "parameters": [ - { - "type": "string", - "description": "Filter logs by level (debug, info, warn, error, dpanic, panic, fatal)", - "name": "level", - "in": "query" - }, - { - "type": "string", - "description": "Search term to match against message or fields", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "Page number for pagination (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 50, - "description": "Number of items per page (default: 50, max: 100)", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Paginated list of application logs", - "schema": { - "$ref": "#/definitions/domain.LogResponse" - } - }, - "400": { - "description": "Invalid request parameters", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/modules/{id}": { - "get": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "put": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateModuleInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "modules" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/modules/{id}/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/modules/{moduleId}/lessons": { - "get": { - "tags": [ - "lessons" - ], - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "lessons" - ], - "summary": "Create lesson", - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "description": "Lesson", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateLessonInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/modules/{moduleId}/lessons/reorder": { - "put": { - "tags": [ - "lessons" - ], - "summary": "Reorder lessons within a module", - "parameters": [ - { - "type": "integer", - "description": "Module ID", - "name": "moduleId", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every lesson id in this module, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/notifications/bulk-email": { - "post": { - "description": "Sends an email to specified user IDs, users of a platform role, team member IDs, team members of a team_role, or direct email addresses with optional image attachment. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk email", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-in-app": { - "post": { - "description": "Creates in-app notifications for specified platform user IDs, users matching a platform role, team member IDs, or team members matching a team_role. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk in-app notification", - "parameters": [ - { - "description": "Bulk in-app content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "level": { - "type": "string" - }, - "message": { - "type": "string" - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "team_member_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "team_role": { - "type": "string" - }, - "title": { - "type": "string" - }, - "type": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-push": { - "post": { - "description": "Sends a push notification to specified user IDs or all users matching a role. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk push notification", - "parameters": [ - { - "description": "Bulk push content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "image": { - "type": "string" - }, - "message": { - "type": "string" - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "title": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/bulk-sms": { - "post": { - "description": "Sends an SMS to specified user IDs, all users of a role, or direct phone numbers. Optionally schedule for later with scheduled_at (RFC3339).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send bulk SMS", - "parameters": [ - { - "description": "Bulk SMS content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "phone_numbers": { - "type": "array", - "items": { - "type": "string" - } - }, - "role": { - "type": "string" - }, - "scheduled_at": { - "type": "string" - }, - "user_ids": { - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/notifications/delete-in-app": { @@ -4271,253 +10936,46 @@ } } }, - "/api/v1/notifications/scheduled": { + "/api/v1/notifications/mark-all-read": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsRead", + "responses": {} + } + }, + "/api/v1/notifications/mark-all-unread": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkAllNotificationsAsUnread", + "responses": {} + } + }, + "/api/v1/notifications/unread": { "get": { - "description": "Returns paginated scheduled notifications with optional status, channel, and date filters", - "produces": [ - "application/json" + "security": [ + { + "Bearer": [] + } ], "tags": [ - "notifications" + "client" ], - "summary": "List scheduled notifications", - "parameters": [ - { - "type": "string", - "description": "Filter by status", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Filter by channel", - "name": "channel", - "in": "query" - }, - { - "type": "string", - "description": "Filter after date (RFC3339)", - "name": "after", - "in": "query" - }, - { - "type": "string", - "description": "Filter before date (RFC3339)", - "name": "before", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 1, - "description": "Page number", - "name": "page", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/scheduled/{id}": { - "get": { - "description": "Returns a single scheduled notification by its ID", - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Get scheduled notification", - "parameters": [ - { - "type": "integer", - "description": "Scheduled Notification ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/scheduled/{id}/cancel": { - "post": { - "description": "Cancels a scheduled notification if it is still pending or processing", - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Cancel scheduled notification", - "parameters": [ - { - "type": "integer", - "description": "Scheduled Notification ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/send-email": { - "post": { - "description": "Sends an email to a single email address with optional image attachment", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send single email", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/notifications/test-push": { - "post": { - "description": "Sends a test push notification to all registered devices of the current user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "notifications" - ], - "summary": "Send test push notification", - "parameters": [ - { - "description": "Test notification content", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "title": { - "type": "string" - } - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "CountUnreadNotifications", + "responses": {} } }, "/api/v1/notifications/{id}": { @@ -4618,6 +11076,34 @@ } } }, + "/api/v1/notifications/{id}/read": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsRead", + "responses": {} + } + }, + "/api/v1/notifications/{id}/unread": { + "patch": { + "security": [ + { + "Bearer": [] + } + ], + "tags": [ + "client" + ], + "summary": "MarkNotificationAsUnread", + "responses": {} + } + }, "/api/v1/payments": { "get": { "description": "Returns the authenticated user's payment history", @@ -5238,34 +11724,6 @@ } ], "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "tags": [ - "personas" - ], - "summary": "Create LMS persona catalog entry", - "parameters": [ - { - "description": "Persona", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateLmsPersonaInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } } }, "/api/v1/personas/{id}": { @@ -5284,1563 +11742,6 @@ } ], "responses": {} - }, - "put": { - "tags": [ - "personas" - ], - "summary": "Update LMS persona", - "parameters": [ - { - "type": "integer", - "description": "Persona ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateLmsPersonaInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "personas" - ], - "summary": "Delete LMS persona (practices referencing it will have persona_id cleared)", - "parameters": [ - { - "type": "integer", - "description": "Persona ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "Page offset (default 0)", - "name": "offset", - "in": "query" - }, - { - "type": "boolean", - "description": "When true, return only practices with no parent links (admin)", - "name": "unlinked_only", - "in": "query" - } - ], - "responses": {} - }, - "post": { - "consumes": [ - "application/json" - ], - "tags": [ - "practices" - ], - "parameters": [ - { - "description": "Practice (optional parents; link later via PUT /practices/:id/parents)", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreatePracticeInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}": { - "get": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - }, - "put": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Practice metadata fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePracticeInput" - } - } - ], - "responses": {} - }, - "delete": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}/full": { - "get": { - "description": "Returns practice metadata, linked question set settings, and all questions in the set (same shape as PUT /practices/{id}/full).", - "produces": [ - "application/json" - ], - "tags": [ - "practices" - ], - "summary": "Get LMS practice with question set and questions", - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates practice metadata, linked question set settings, and syncs questions in one request. Questions omitted from the questions array are removed from the set (not deleted from the bank).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "practices" - ], - "summary": "Full update LMS practice with question set and questions", - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Full practice update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.FullUpdatePracticeInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/practices/{id}/parents": { - "put": { - "consumes": [ - "application/json" - ], - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Parent links (replaces all; use empty array to detach)", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePracticeParentsInput" - } - } - ], - "responses": {} - } - }, - "/api/v1/practices/{id}/parents/{parentKind}/{parentId}": { - "delete": { - "tags": [ - "practices" - ], - "parameters": [ - { - "type": "integer", - "description": "Practice ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent kind (COURSE, MODULE, LESSON)", - "name": "parentKind", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Parent entity ID", - "name": "parentId", - "in": "path", - "required": true - } - ], - "responses": {} - } - }, - "/api/v1/practices/{practiceId}/questions": { - "get": { - "description": "Returns paginated questions for an LMS practice, including shared stimulus blocks and each question's effective dynamic payload", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Get questions by practice", - "parameters": [ - { - "type": "integer", - "description": "LMS practice ID", - "name": "practiceId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Question type filter (e.g. AUDIO)", - "name": "question_type", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs": { - "get": { - "description": "Paginated list of programs", - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "List programs", - "parameters": [ - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Create a top-level LMS program. Optional sort_order inserts at that global ordering; omit it to append after the current highest sort_order. Unique constraint applies to sort_order.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Create program", - "parameters": [ - { - "description": "Program", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateProgramInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/reorder": { - "put": { - "description": "Sets learning order of programs. Body must list every current program id exactly once, in the desired order (index 0 = first in path).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Reorder all programs", - "parameters": [ - { - "description": "New order: ordered_ids is the full set of program ids", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Get program by ID", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "programs" - ], - "summary": "Update program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Fields to update", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateProgramInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "programs" - ], - "summary": "Delete program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}/courses": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "courses" - ], - "summary": "List courses by program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Page size", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Create a course under a program. Optional sort_order assigns position within that program (siblings shifted); omit to append after the current highest sort_order in the program.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "courses" - ], - "summary": "Create course", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Course", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateCourseInput" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/programs/{id}/courses/reorder": { - "put": { - "tags": [ - "courses" - ], - "summary": "Reorder courses within a program", - "parameters": [ - { - "type": "integer", - "description": "Program ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "ordered_ids: every course id in this program, in the new order", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReorderIDsRequest" - } - } - ], - "responses": {} - } - }, - "/api/v1/progress/practices/{id}/complete": { - "post": { - "description": "Marks a practice question set as completed for the authenticated learner", - "produces": [ - "application/json" - ], - "tags": [ - "progression" - ], - "summary": "Mark practice as completed", - "parameters": [ - { - "type": "integer", - "description": "Practice Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets": { - "get": { - "description": "Returns a paginated list of question sets filtered by type", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question sets by type", - "parameters": [ - { - "type": "string", - "description": "Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE)", - "name": "set_type", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Creates a new question set (practice, assessment, quiz, exam, or survey)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Create a new question set", - "parameters": [ - { - "description": "Create question set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionSetReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/by-owner": { - "get": { - "description": "Returns question sets for a specific owner (e.g., sub-course)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question sets by owner", - "parameters": [ - { - "type": "string", - "description": "Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE)", - "name": "owner_type", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "Owner ID", - "name": "owner_id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{id}": { - "get": { - "description": "Returns a question set with question count", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get question set by ID", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a question set's properties", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Update a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionSetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Archives a question set (soft delete)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Delete a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/personas": { - "get": { - "description": "Returns all users assigned as personas to a question set (practice)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Get user personas for a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Links a user as a persona to a question set (practice)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Add a user as persona to a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "description": "Add user persona payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.addUserPersonaReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/personas/{userId}": { - "delete": { - "description": "Unlinks a user as persona from a question set (practice)", - "produces": [ - "application/json" - ], - "tags": [ - "question-sets" - ], - "summary": "Remove a user persona from a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/question-types": { - "get": { - "description": "Returns distinct question type definitions (key, display_name, counts) for non-archived questions in the set. Legacy stored question_type values (e.g. AUDIO) are resolved to builder definitions when possible.", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "List question types in a question set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions": { - "get": { - "description": "Returns all questions in a question set with contextual shared stimulus data for linked LMS and exam-prep practices", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Get questions in set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Links a question to a question set. Omit display_order to append after the current max; the assigned value is returned in the response.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Add question to set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "description": "Add question to set payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.addQuestionToSetReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions/{questionId}": { - "delete": { - "description": "Unlinks a question from a question set", - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Remove question from set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Question ID", - "name": "questionId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/question-sets/{setId}/questions/{questionId}/order": { - "put": { - "description": "Updates the display order of a question in a set", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "question-set-items" - ], - "summary": "Update question order in set", - "parameters": [ - { - "type": "integer", - "description": "Question Set ID", - "name": "setId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Question ID", - "name": "questionId", - "in": "path", - "required": true - }, - { - "description": "Update order payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionOrderReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions": { - "get": { - "description": "Returns a paginated list of questions with optional filters", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List questions", - "parameters": [ - { - "type": "string", - "description": "Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER)", - "name": "question_type", - "in": "query" - }, - { - "type": "string", - "description": "Difficulty level filter (EASY, MEDIUM, HARD)", - "name": "difficulty", - "in": "query" - }, - { - "type": "string", - "description": "Status filter (DRAFT, PUBLISHED, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Creates a new question with options (for MCQ/TRUE_FALSE) or short answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; use dynamic_payload stimulus instead. Legacy types require question_text.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create a new question", - "parameters": [ - { - "description": "Create question payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/questions/audio-answer": { @@ -6885,710 +11786,6 @@ } } }, - "/api/v1/questions/component-catalog": { - "get": { - "description": "Valid stimulus and response component kind codes for dynamic question-type definitions", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Question-type builder component catalog", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/search": { - "get": { - "description": "Search questions by text", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Search questions", - "parameters": [ - { - "type": "string", - "description": "Search query", - "name": "q", - "in": "query", - "required": true - }, - { - "type": "integer", - "default": 10, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definition-groups": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List question type definition groups", - "parameters": [ - { - "type": "string", - "description": "Filter by status (ACTIVE, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Page offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create question type definition group", - "parameters": [ - { - "description": "Group payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionTypeDefinitionGroupReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/type-definition-groups/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get question type definition group with definitions", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update question type definition group", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update group payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionGroupReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete question type definition group", - "parameters": [ - { - "type": "integer", - "description": "Group id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/questions/type-definitions": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List reusable question-type definitions", - "parameters": [ - { - "type": "string", - "description": "Filter by status (ACTIVE, INACTIVE)", - "name": "status", - "in": "query" - }, - { - "type": "boolean", - "default": true, - "description": "Include system seeded definitions", - "name": "include_system", - "in": "query" - }, - { - "type": "integer", - "default": 20, - "description": "Page size (default 20, max 200)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Page offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "description": "Stores a reusable dynamic question-type definition for future question construction. Only runtime-mappable definitions are persisted.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Create reusable question-type definition", - "parameters": [ - { - "description": "Question type definition payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definitions/{id}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get reusable question-type definition by id", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a reusable dynamic question-type definition. Updated definitions must remain runtime-mappable.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update reusable question-type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question type definition payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete reusable question-type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/type-definitions/{id}/practices": { - "get": { - "description": "Returns LMS and exam-prep practices whose linked question set contains at least one non-archived question matching the definition (by question_type_definition_id or legacy question_type).", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "List practices globally by question type definition", - "parameters": [ - { - "type": "integer", - "description": "Question type definition id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 20, - "description": "Limit", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "default": 0, - "description": "Offset", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/validate-question-type-definition": { - "post": { - "description": "Validates selected stimulus and response component kinds for temporary question-type definitions (component-level validation only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Validate dynamic question-type definition", - "parameters": [ - { - "description": "Stimulus and response component kinds", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.validateQuestionTypeDefinitionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/questions/{id}": { - "get": { - "description": "Returns a question with its options/short answers", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Get question by ID", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "description": "Updates a question and optionally replaces its options/short answers. Supports question_type_definition_id for dynamic builder-linked questions.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Update a question", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update question payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateQuestionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Archives a question (soft delete)", - "produces": [ - "application/json" - ], - "tags": [ - "questions" - ], - "summary": "Delete a question", - "parameters": [ - { - "type": "integer", - "description": "Question ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/ratings": { "get": { "description": "Returns paginated ratings for a specific target", @@ -7862,593 +12059,81 @@ } } }, - "/api/v1/rbac/permissions": { + "/api/v1/referrals": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all permissions in the system grouped by group name", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "List all permissions", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Permission" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "ListMyReferrals", + "responses": {} } }, - "/api/v1/rbac/permissions/groups": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get all distinct permission group names", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "List permission groups", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/rbac/permissions/sync": { + "/api/v1/referrals/apply": { "post": { "security": [ { "Bearer": [] } ], - "description": "Re-seed permissions from code and reload the RBAC cache", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Sync permissions", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "ApplyReferralCode", + "responses": {} } }, - "/api/v1/rbac/roles": { + "/api/v1/referrals/code": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all roles with optional filters", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "List all roles", - "parameters": [ - { - "type": "string", - "description": "Search by role name", - "name": "query", - "in": "query" - }, - { - "type": "boolean", - "description": "Filter by system role (true/false)", - "name": "is_system", - "in": "query" - }, - { - "type": "integer", - "description": "Page number (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Page size (default: 20)", - "name": "page_size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetReferralCode", + "responses": {} }, "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new role with a name and description", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Create a new role", - "parameters": [ - { - "description": "Role creation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateRoleReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.RoleRecord" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "CreateReferralCode", + "responses": {} } }, - "/api/v1/rbac/roles/{id}": { + "/api/v1/referrals/me": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get a role and its permissions by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Get a role by ID", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.RoleWithPermissions" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update an existing role's name and description", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Update a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Role update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateRoleReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a non-system role by ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Delete a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } + "summary": "GetMyReferrals", + "responses": {} } }, - "/api/v1/rbac/roles/{id}/permissions": { + "/api/v1/referrals/wallet": { "get": { "security": [ { "Bearer": [] } ], - "description": "Get all permissions assigned to a role", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "rbac" + "client" ], - "summary": "Get permissions for a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Permission" - } - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Replace all permissions for a role with the given permission IDs", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "rbac" - ], - "summary": "Set permissions for a role", - "parameters": [ - { - "type": "integer", - "description": "Role ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Permission IDs payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.SetRolePermissionsReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/sendSMS": { - "post": { - "description": "Sends an SMS message to a single phone number using AfroMessage", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send single SMS via AfroMessage", - "parameters": [ - { - "description": "Send SMS request", - "name": "sendSMS", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.SendSingleAfroSMSReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } + "summary": "GetReferralWallet", + "responses": {} } }, "/api/v1/subscription-plans": { @@ -8495,50 +12180,6 @@ } } } - }, - "post": { - "description": "Creates a new subscription plan (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Create a subscription plan", - "parameters": [ - { - "description": "Create plan payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.createPlanReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/subscription-plans/{id}": { @@ -8574,90 +12215,6 @@ } } } - }, - "put": { - "description": "Updates a subscription plan (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Update a subscription plan", - "parameters": [ - { - "type": "integer", - "description": "Plan ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Update plan payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updatePlanReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes a subscription plan (admin only)", - "produces": [ - "application/json" - ], - "tags": [ - "subscriptions" - ], - "summary": "Delete a subscription plan", - "parameters": [ - { - "type": "integer", - "description": "Plan ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } } }, "/api/v1/subscriptions": { @@ -8974,1431 +12531,6 @@ } } }, - "/api/v1/super-login": { - "post": { - "description": "Login super-admin", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login super-admin", - "parameters": [ - { - "description": "Login super-admin", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.LoginAdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/t-approver/{id}": { - "get": { - "description": "Get a single admin by id", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "admin" - ], - "summary": "Get admin by id", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.AdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - }, - "put": { - "description": "Update Admin", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "admin" - ], - "summary": "Update Admin", - "parameters": [ - { - "description": "Update Admin", - "name": "admin", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.updateAdminReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/team/invitations": { - "get": { - "description": "Lists team member invitations with optional status filter", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "List team invitations", - "parameters": [ - { - "type": "string", - "description": "pending, accepted, expired, or revoked", - "name": "status", - "in": "query" - }, - { - "type": "integer", - "description": "Limit (default 20)", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "description": "Offset (default 0)", - "name": "offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/accept": { - "post": { - "description": "Public endpoint to set password and profile details after following the invite link", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Accept team invitation and complete account setup", - "parameters": [ - { - "description": "Accept invitation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.AcceptTeamInvitationReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/verify": { - "get": { - "description": "Public endpoint used by the admin panel accept-invite page", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Verify team invitation token", - "parameters": [ - { - "type": "string", - "description": "Invitation token", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/invitations/{id}/revoke": { - "post": { - "description": "Revokes the invitation and removes the pending team member if not yet accepted", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Revoke a pending team invitation", - "parameters": [ - { - "type": "integer", - "description": "Invitation ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/team/login": { - "post": { - "description": "Authenticate a team member (internal staff) with email and password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Login team member", - "parameters": [ - { - "description": "Team member login credentials", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamMemberLoginReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.teamMemberLoginRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/me": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get the authenticated team member's own profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get my team profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update the authenticated team member's own profile fields", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update my team profile", - "parameters": [ - { - "description": "Profile update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateMyTeamProfileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get a paginated list of team members with optional filtering", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "List all team members", - "parameters": [ - { - "type": "string", - "description": "Filter by team role (super_admin, admin, content_manager, support_agent, instructor, finance, hr, analyst)", - "name": "team_role", - "in": "query" - }, - { - "type": "string", - "description": "Filter by department", - "name": "department", - "in": "query" - }, - { - "type": "string", - "description": "Filter by status (active, inactive, suspended, terminated)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Search by name, email, or phone number", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "description": "Page number (default: 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Items per page (default: 10, max: 100)", - "name": "page_size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - }, - "metadata": { - "$ref": "#/definitions/domain.Pagination" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Create a new internal team member (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Create a new team member", - "parameters": [ - { - "description": "Team member creation payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateTeamMemberReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/export": { - "get": { - "produces": [ - "text/csv" - ], - "tags": [ - "team" - ], - "summary": "Export team members as CSV (admin)", - "responses": {} - } - }, - "/api/v1/team/members/invite": { - "post": { - "description": "Creates a pending team member (email + team_role only) and sends an invitation email; profile is completed on accept", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Invite a team member by email", - "parameters": [ - { - "description": "Invite payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.InviteTeamMemberReq" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Retrieve a team member's details by their ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get team member by ID", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update an existing team member's details (admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update team member", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Team member update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateTeamMemberReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Delete a team member (super admin only)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Delete team member", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/change-password": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Change a team member's password (requires current password)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Change team member password", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Password change payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.changePasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/resend-invite": { - "post": { - "description": "Revokes the current pending invite and sends a new invitation email", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Resend team invitation", - "parameters": [ - { - "type": "integer", - "description": "Team member ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/members/{id}/status": { - "patch": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Update a team member's status (active, inactive, suspended, terminated)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Update team member status", - "parameters": [ - { - "type": "integer", - "description": "Team Member ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateTeamMemberStatusReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/refresh": { - "post": { - "description": "Exchanges a valid team refresh token for a new access JWT and a rotated refresh token (use only tokens from POST /team/login or this endpoint).", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Refresh team member tokens", - "parameters": [ - { - "description": "Current refresh token", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.teamMemberRefreshReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/handlers.teamMemberLoginRes" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/resetPassword": { - "post": { - "description": "Completes team password reset using email + OTP from the reset link. Public.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Reset team member password", - "parameters": [ - { - "description": "Reset payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamResetPasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/sendResetCode": { - "post": { - "description": "Sends a password-reset email with a link to the team member (admin panel). Public.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Send team password reset link", - "parameters": [ - { - "description": "Email", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.TeamSendPasswordResetReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/stats": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get statistics about team members by status", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Get team member statistics", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TeamMemberStats" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/team/verifyResetCode": { - "get": { - "description": "Checks whether email+otp from a reset link are still valid without consuming the OTP. Public.", - "produces": [ - "application/json" - ], - "tags": [ - "team" - ], - "summary": "Verify team password reset link", - "parameters": [ - { - "type": "string", - "description": "Team member email", - "name": "email", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Reset OTP from the email link", - "name": "otp", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - } - } - } - }, - "/api/v1/tenant": { - "get": { - "description": "Check if phone number or email exist", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if phone number or email exist", - "parameters": [ - { - "description": "Check phone number or email exist", - "name": "checkPhoneEmailExist", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/user": { "put": { "description": "Updates user profile information (partial updates supported)", @@ -10458,9 +12590,9 @@ } } }, - "/api/v1/user/delete/{id}": { - "delete": { - "description": "Delete a user by their ID", + "/api/v1/user/checkPhoneEmailExist": { + "post": { + "description": "Check if phone number or email exist", "consumes": [ "application/json" ], @@ -10470,21 +12602,23 @@ "tags": [ "user" ], - "summary": "Delete user by ID", + "summary": "Check if phone number or email exist", "parameters": [ { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true + "description": "Check phone number or email exist", + "name": "checkPhoneEmailExist", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" + } } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" } }, "400": { @@ -10646,6 +12780,98 @@ } } }, + "/api/v1/user/register": { + "post": { + "description": "Register user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Register user", + "parameters": [ + { + "description": "Register user", + "name": "registerUser", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.RegisterUserReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/user/resend-otp": { + "post": { + "description": "Resend OTP if the previous one is expired", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "otp" + ], + "summary": "Resend OTP", + "parameters": [ + { + "description": "Resend OTP", + "name": "resendOtp", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ResendOtpReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/user/resetPassword": { "post": { "description": "Reset password", @@ -10692,9 +12918,9 @@ } } }, - "/api/v1/user/search": { + "/api/v1/user/sendRegisterCode": { "post": { - "description": "Search for user using name or phone", + "description": "Send register code", "consumes": [ "application/json" ], @@ -10704,15 +12930,15 @@ "tags": [ "user" ], - "summary": "Search for user using name or phone", + "summary": "Send register code", "parameters": [ { - "description": "Search for using his name or phone", - "name": "searchUserByNameOrPhone", + "description": "Send register code", + "name": "registerCode", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handlers.SearchUserByNameOrPhoneReq" + "$ref": "#/definitions/handlers.RegisterCodeReq" } } ], @@ -10720,7 +12946,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.UserProfileResponse" + "$ref": "#/definitions/response.APIResponse" } }, "400": { @@ -10784,9 +13010,14 @@ } } }, - "/api/v1/user/single/{id}": { + "/api/v1/user/user-profile": { "get": { - "description": "Get a single user by id", + "security": [ + { + "Bearer": [] + } + ], + "description": "Get user profile", "consumes": [ "application/json" ], @@ -10796,16 +13027,7 @@ "tags": [ "user" ], - "summary": "Get user by id", - "parameters": [ - { - "type": "integer", - "description": "User ID", - "name": "id", - "in": "path", - "required": true - } - ], + "summary": "Get user profile", "responses": { "200": { "description": "OK", @@ -10819,58 +13041,6 @@ "$ref": "#/definitions/response.APIResponse" } }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/user/status": { - "patch": { - "description": "Activates, deactivates, or suspends a user account", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Update user status", - "parameters": [ - { - "description": "Status update payload", - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, "500": { "description": "Internal Server Error", "schema": { @@ -10982,56 +13152,6 @@ } } }, - "/api/v1/user/{user_id}/is-pending": { - "get": { - "description": "Returns whether the specified user has a status of \"pending\"", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if user status is pending", - "parameters": [ - { - "type": "string", - "description": "User ID", - "name": "user_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, "/api/v1/user/{user_id}/is-profile-completed": { "get": { "description": "Returns the profile completion status and percentage for the specified user", @@ -11082,9 +13202,9 @@ } } }, - "/api/v1/users": { + "/api/v1/user/{user_name}/is-pending": { "get": { - "description": "Get users with optional filters. Each user includes subscription_status: ACTIVE, PENDING, or Unsubscribed.", + "description": "Returns whether the specified user has a status of \"pending\"", "consumes": [ "application/json" ], @@ -11094,200 +13214,25 @@ "tags": [ "user" ], - "summary": "Get all users", + "summary": "Check if user status is pending", "parameters": [ { "type": "string", - "description": "Role filter", - "name": "role", - "in": "query" - }, - { - "type": "string", - "description": "Search query", - "name": "query", - "in": "query" - }, - { - "type": "integer", - "description": "Page number", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "Page size", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "Created before (RFC3339)", - "name": "created_before", - "in": "query" - }, - { - "type": "string", - "description": "Created after (RFC3339)", - "name": "created_after", - "in": "query" - }, - { - "type": "string", - "description": "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, or INACTIVE for all non-ACTIVE statuses)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Country filter (case-insensitive match on stored value)", - "name": "country", - "in": "query" - }, - { - "type": "string", - "description": "Region filter (case-insensitive match on stored value)", - "name": "region", - "in": "query" - }, - { - "type": "string", - "description": "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)", - "name": "subscription_status", - "in": "query" + "description": "User ID", + "name": "user_id", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/response.APIResponse" + "$ref": "#/definitions/domain.Response" } }, "400": { "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/users/export": { - "get": { - "produces": [ - "text/csv" - ], - "tags": [ - "user" - ], - "summary": "Export users as CSV (admin)", - "responses": {} - } - }, - "/api/v1/users/summary": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Returns total users, active users, and users who joined this month", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user summary statistics", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserSummary" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/videos/engagement/heartbeat": { - "post": { - "description": "Records playback position for analytics (completion, replay, and drop-off). Send periodic heartbeats while watching; set ended=true when the viewer leaves. A new session starts after 30 minutes of inactivity or when ended=true on the prior session.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "videos" - ], - "summary": "Report video playback progress", - "parameters": [ - { - "description": "Playback heartbeat", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.VideoEngagementHeartbeatInput" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.VideoWatchSessionResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "403": { - "description": "Forbidden", "schema": { "$ref": "#/definitions/domain.ErrorResponse" } @@ -11297,6 +13242,12 @@ "schema": { "$ref": "#/definitions/domain.ErrorResponse" } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.ErrorResponse" + } } } } @@ -11409,913 +13360,22 @@ } } }, - "/api/v1/vimeo/uploads/pull": { - "post": { - "description": "Initiates a pull upload where Vimeo fetches the video from a URL", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Create a pull upload to Vimeo", - "parameters": [ - { - "description": "Pull Upload Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CreatePullUploadRequest" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/handlers.VimeoUploadResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/uploads/tus": { - "post": { - "description": "Initiates a TUS resumable upload and returns the upload link", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Create a TUS resumable upload to Vimeo", - "parameters": [ - { - "description": "TUS Upload Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CreateTusUploadRequest" - } - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/handlers.VimeoUploadResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos": { + "/api/v1/ws/connect": { "get": { - "description": "Returns a paginated list of videos for the Vimeo API token (GET https://api.vimeo.com/me/videos)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "tags": [ - "Vimeo" + "client" ], - "summary": "List videos stored in the Vimeo account", - "parameters": [ - { - "type": "integer", - "default": 1, - "description": "Page number (starts at 1)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 25, - "description": "Page size (Vimeo max 100)", - "name": "per_page", - "in": "query" - }, - { - "type": "string", - "description": "Search query", - "name": "query", - "in": "query" - }, - { - "type": "string", - "description": "Sort field (e.g. date, alphabetical, plays, likes, comments, duration, relevance)", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "asc or desc", - "name": "direction", - "in": "query" - }, - { - "type": "string", - "description": "Vimeo filter (e.g. embeddable, playable)", - "name": "filter", - "in": "query" - }, - { - "type": "string", - "description": "Vimeo filter_type when using filter", - "name": "filter_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/domain.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/handlers.VimeoVideoResponse" - } - }, - "metadata": { - "$ref": "#/definitions/handlers.VimeoVideosListMetadata" - } - } - } - ] - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "503": { - "description": "Service Unavailable", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}": { - "get": { - "description": "Retrieves video details from Vimeo by video ID", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get video information from Vimeo", + "summary": "ConnectSocket", "parameters": [ { "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", + "description": "Access token", + "name": "token", + "in": "query", "required": true } ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.VimeoVideoResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes a video from the Vimeo account", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Delete a video from Vimeo", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}/embed": { - "get": { - "description": "Generates an embeddable player iframe for the video", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get embed code for a Vimeo video", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 640, - "description": "Player width", - "name": "width", - "in": "query" - }, - { - "type": "integer", - "default": 360, - "description": "Player height", - "name": "height", - "in": "query" - }, - { - "type": "boolean", - "description": "Autoplay video", - "name": "autoplay", - "in": "query" - }, - { - "type": "boolean", - "description": "Loop video", - "name": "loop", - "in": "query" - }, - { - "type": "boolean", - "description": "Mute video", - "name": "muted", - "in": "query" - }, - { - "type": "boolean", - "description": "Background mode (no controls)", - "name": "background", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.VimeoEmbedResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/vimeo/videos/{video_id}/status": { - "get": { - "description": "Returns the current transcoding status of a video", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Vimeo" - ], - "summary": "Get transcode status of a Vimeo video", - "parameters": [ - { - "type": "string", - "description": "Vimeo Video ID", - "name": "video_id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.ErrorResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/admin-login": { - "post": { - "description": "Login user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login user", - "parameters": [ - { - "description": "Login admin", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.LoginAdminRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/otp/resend": { - "post": { - "description": "Resend OTP if the previous one is expired", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "otp" - ], - "summary": "Resend OTP", - "parameters": [ - { - "description": "Resend OTP", - "name": "resendOtp", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ResendOtpReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user-login": { - "post": { - "description": "Login user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Login user", - "parameters": [ - { - "description": "Login user", - "name": "login", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.loginUserRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/admin-profile": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get user profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.AdminProfileRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/checkPhoneEmailExist": { - "post": { - "description": "Check if phone number or email exist", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Check if phone number or email exist", - "parameters": [ - { - "description": "Check phone number or email exist", - "name": "checkPhoneEmailExist", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/handlers.CheckPhoneEmailExistRes" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/register": { - "post": { - "description": "Register user", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Register user", - "parameters": [ - { - "description": "Register user", - "name": "registerUser", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.RegisterUserReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/resetPassword": { - "post": { - "description": "Reset tenant password", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Reset tenant password", - "parameters": [ - { - "description": "Reset password", - "name": "resetPassword", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.ResetPasswordReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/sendRegisterCode": { - "post": { - "description": "Send register code", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send register code", - "parameters": [ - { - "description": "Send register code", - "name": "registerCode", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.RegisterCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/sendResetCode": { - "post": { - "description": "Send reset code", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Send reset code", - "parameters": [ - { - "description": "Send reset code", - "name": "resetCode", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/handlers.ResetCodeReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/api/v1/{tenant_slug}/user/user-profile": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "Get user profile", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "user" - ], - "summary": "Get user profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.UserProfileResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, - "/payment/success": { - "get": { - "description": "Displays the Rezina success page after Chapa redirects the learner to return_url", - "produces": [ - "text/html" - ], - "tags": [ - "payments" - ], - "summary": "Chapa payment success page", - "parameters": [ - { - "type": "string", - "description": "Chapa transaction reference (tx_ref)", - "name": "trx_ref", - "in": "query" - }, - { - "type": "string", - "description": "Chapa transaction reference", - "name": "tx_ref", - "in": "query" - }, - { - "type": "string", - "description": "Chapa reference ID", - "name": "ref_id", - "in": "query" - }, - { - "type": "string", - "description": "Payment status from Chapa redirect", - "name": "status", - "in": "query" - } - ], - "responses": { - "200": { - "description": "HTML success page", - "schema": { - "type": "string" - } - } - } + "responses": {} } } }, @@ -12492,141 +13552,6 @@ } } }, - "domain.AdminLMSCourseLearningEntry": { - "type": "object", - "properties": { - "course_level_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "id": { - "type": "integer" - }, - "modules": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSModuleLearningEntry" - } - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSLessonLearningEntry": { - "type": "object", - "properties": { - "completed_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "lesson_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "sort_order": { - "type": "integer" - }, - "title": { - "type": "string" - } - } - }, - "domain.AdminLMSModuleLearningEntry": { - "type": "object", - "properties": { - "id": { - "type": "integer" - }, - "lessons": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSLessonLearningEntry" - } - }, - "module_practices": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSPracticeLearningEntry" - } - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSPracticeLearningEntry": { - "type": "object", - "properties": { - "completed_at": { - "type": "string" - }, - "lms_practice_id": { - "type": "integer" - }, - "scope": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "domain.AdminLMSProgramLearningEntry": { - "type": "object", - "properties": { - "courses": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSCourseLearningEntry" - } - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "rollup_completed_at": { - "type": "string" - }, - "sort_order": { - "type": "integer" - } - } - }, - "domain.AdminLMSUserLearningActivityTree": { - "type": "object", - "properties": { - "programs": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLMSProgramLearningEntry" - } - }, - "user_id": { - "type": "integer" - } - } - }, "domain.AdminUserExamPrepLearningSection": { "type": "object", "properties": { @@ -12638,29 +13563,12 @@ } } }, - "domain.AdminUserLMSLearningSection": { - "type": "object", - "properties": { - "completed_ids": { - "$ref": "#/definitions/domain.LMSUserProgress" - }, - "completions": { - "$ref": "#/definitions/domain.AdminLMSUserLearningActivityTree" - }, - "progress": { - "$ref": "#/definitions/domain.LMSProgressSummary" - } - } - }, "domain.AdminUserLearningActivityDetails": { "type": "object", "properties": { "exam_prep": { "$ref": "#/definitions/domain.AdminUserExamPrepLearningSection" }, - "lms": { - "$ref": "#/definitions/domain.AdminUserLMSLearningSection" - }, "recent_activity": { "$ref": "#/definitions/domain.UserRecentActivityFeed" }, @@ -12860,11 +13768,8 @@ "exam_prep": { "$ref": "#/definitions/domain.AnalyticsExamPrepContentCounts" }, - "lms": { - "$ref": "#/definitions/domain.AnalyticsLMSContentCounts" - }, "total_categories": { - "description": "Top-level keys preserved for existing clients: map to LMS programs, courses, modules, and all video lessons (LMS + exam prep).", + "description": "Top-level summary fields preserve the dashboard contract using the unified hierarchy.", "type": "integer" }, "total_courses": { @@ -13006,38 +13911,6 @@ } } }, - "domain.AnalyticsLMSContentCounts": { - "type": "object", - "properties": { - "courses": { - "type": "integer" - }, - "lessons": { - "type": "integer" - }, - "lessons_with_video": { - "type": "integer" - }, - "modules": { - "type": "integer" - }, - "practices": { - "type": "integer" - }, - "practices_at_course": { - "type": "integer" - }, - "practices_at_lesson": { - "type": "integer" - }, - "practices_at_module": { - "type": "integer" - }, - "programs": { - "type": "integer" - } - } - }, "domain.AnalyticsLabelAmount": { "type": "object", "properties": { @@ -13594,6 +14467,7 @@ "category": { "type": "string", "enum": [ + "EDUCATION", "IELTS", "DUOLINGO" ] @@ -14523,135 +15397,6 @@ } } }, - "domain.LMSProgressSummary": { - "type": "object", - "properties": { - "exam_prep": { - "$ref": "#/definitions/domain.ExamPrepProgressSummary" - }, - "programs": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryProgram" - } - } - } - }, - "domain.LMSProgressSummaryCourse": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "id": { - "type": "integer" - }, - "modules": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryModule" - } - }, - "name": { - "type": "string" - }, - "program_id": { - "type": "integer" - } - } - }, - "domain.LMSProgressSummaryLesson": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "id": { - "type": "integer" - }, - "module_id": { - "type": "integer" - }, - "title": { - "type": "string" - } - } - }, - "domain.LMSProgressSummaryModule": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "course_id": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "lessons": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryLesson" - } - }, - "name": { - "type": "string" - }, - "program_id": { - "type": "integer" - } - } - }, - "domain.LMSProgressSummaryProgram": { - "type": "object", - "properties": { - "access": { - "$ref": "#/definitions/domain.LMSEntityAccess" - }, - "courses": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.LMSProgressSummaryCourse" - } - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "domain.LMSUserProgress": { - "type": "object", - "properties": { - "course_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "lesson_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "module_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "program_ids": { - "type": "array", - "items": { - "type": "integer" - } - } - } - }, "domain.LogEntry": { "type": "object", "properties": { @@ -14871,6 +15616,9 @@ "phone_number": { "type": "string" }, + "referral_code": { + "type": "string" + }, "role": { "type": "string" } @@ -15220,6 +15968,7 @@ "category": { "type": "string", "enum": [ + "EDUCATION", "IELTS", "DUOLINGO" ] diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 1213e60c..d9104715 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -113,94 +113,6 @@ definitions: user_id: type: integer type: object - domain.AdminLMSCourseLearningEntry: - properties: - course_level_practices: - items: - $ref: '#/definitions/domain.AdminLMSPracticeLearningEntry' - type: array - id: - type: integer - modules: - items: - $ref: '#/definitions/domain.AdminLMSModuleLearningEntry' - type: array - name: - type: string - rollup_completed_at: - type: string - sort_order: - type: integer - type: object - domain.AdminLMSLessonLearningEntry: - properties: - completed_at: - type: string - id: - type: integer - lesson_practices: - items: - $ref: '#/definitions/domain.AdminLMSPracticeLearningEntry' - type: array - sort_order: - type: integer - title: - type: string - type: object - domain.AdminLMSModuleLearningEntry: - properties: - id: - type: integer - lessons: - items: - $ref: '#/definitions/domain.AdminLMSLessonLearningEntry' - type: array - module_practices: - items: - $ref: '#/definitions/domain.AdminLMSPracticeLearningEntry' - type: array - name: - type: string - rollup_completed_at: - type: string - sort_order: - type: integer - type: object - domain.AdminLMSPracticeLearningEntry: - properties: - completed_at: - type: string - lms_practice_id: - type: integer - scope: - type: string - title: - type: string - type: object - domain.AdminLMSProgramLearningEntry: - properties: - courses: - items: - $ref: '#/definitions/domain.AdminLMSCourseLearningEntry' - type: array - id: - type: integer - name: - type: string - rollup_completed_at: - type: string - sort_order: - type: integer - type: object - domain.AdminLMSUserLearningActivityTree: - properties: - programs: - items: - $ref: '#/definitions/domain.AdminLMSProgramLearningEntry' - type: array - user_id: - type: integer - type: object domain.AdminUserExamPrepLearningSection: properties: completions: @@ -208,21 +120,10 @@ definitions: progress: $ref: '#/definitions/domain.ExamPrepProgressSummary' type: object - domain.AdminUserLMSLearningSection: - properties: - completed_ids: - $ref: '#/definitions/domain.LMSUserProgress' - completions: - $ref: '#/definitions/domain.AdminLMSUserLearningActivityTree' - progress: - $ref: '#/definitions/domain.LMSProgressSummary' - type: object domain.AdminUserLearningActivityDetails: properties: exam_prep: $ref: '#/definitions/domain.AdminUserExamPrepLearningSection' - lms: - $ref: '#/definitions/domain.AdminUserLMSLearningSection' recent_activity: $ref: '#/definitions/domain.UserRecentActivityFeed' user_id: @@ -358,11 +259,9 @@ definitions: properties: exam_prep: $ref: '#/definitions/domain.AnalyticsExamPrepContentCounts' - lms: - $ref: '#/definitions/domain.AnalyticsLMSContentCounts' total_categories: - description: 'Top-level keys preserved for existing clients: map to LMS programs, - courses, modules, and all video lessons (LMS + exam prep).' + description: Top-level summary fields preserve the dashboard contract using + the unified hierarchy. type: integer total_courses: type: integer @@ -455,27 +354,6 @@ definitions: total_issues: type: integer type: object - domain.AnalyticsLMSContentCounts: - properties: - courses: - type: integer - lessons: - type: integer - lessons_with_video: - type: integer - modules: - type: integer - practices: - type: integer - practices_at_course: - type: integer - practices_at_lesson: - type: integer - practices_at_module: - type: integer - programs: - type: integer - type: object domain.AnalyticsLabelAmount: properties: amount: @@ -846,6 +724,7 @@ definitions: type: string category: enum: + - EDUCATION - IELTS - DUOLINGO type: string @@ -1502,90 +1381,6 @@ definitions: total_count: type: integer type: object - domain.LMSProgressSummary: - properties: - exam_prep: - $ref: '#/definitions/domain.ExamPrepProgressSummary' - programs: - items: - $ref: '#/definitions/domain.LMSProgressSummaryProgram' - type: array - type: object - domain.LMSProgressSummaryCourse: - properties: - access: - $ref: '#/definitions/domain.LMSEntityAccess' - id: - type: integer - modules: - items: - $ref: '#/definitions/domain.LMSProgressSummaryModule' - type: array - name: - type: string - program_id: - type: integer - type: object - domain.LMSProgressSummaryLesson: - properties: - access: - $ref: '#/definitions/domain.LMSEntityAccess' - id: - type: integer - module_id: - type: integer - title: - type: string - type: object - domain.LMSProgressSummaryModule: - properties: - access: - $ref: '#/definitions/domain.LMSEntityAccess' - course_id: - type: integer - id: - type: integer - lessons: - items: - $ref: '#/definitions/domain.LMSProgressSummaryLesson' - type: array - name: - type: string - program_id: - type: integer - type: object - domain.LMSProgressSummaryProgram: - properties: - access: - $ref: '#/definitions/domain.LMSEntityAccess' - courses: - items: - $ref: '#/definitions/domain.LMSProgressSummaryCourse' - type: array - id: - type: integer - name: - type: string - type: object - domain.LMSUserProgress: - properties: - course_ids: - items: - type: integer - type: array - lesson_ids: - items: - type: integer - type: array - module_ids: - items: - type: integer - type: array - program_ids: - items: - type: integer - type: array - type: object domain.LogEntry: properties: caller: @@ -1731,6 +1526,8 @@ definitions: type: string phone_number: type: string + referral_code: + type: string role: type: string type: object @@ -1975,6 +1772,7 @@ definitions: type: string category: enum: + - EDUCATION - IELTS - DUOLINGO type: string @@ -3613,305 +3411,7 @@ info: title: Rezina API version: 1.0.1 paths: - /api/v1/{tenant_slug}/admin-login: - post: - consumes: - - application/json - description: Login user - parameters: - - description: Login admin - in: body - name: login - required: true - schema: - $ref: '#/definitions/domain.LoginRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.LoginAdminRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Login user - tags: - - auth - /api/v1/{tenant_slug}/otp/resend: - post: - consumes: - - application/json - description: Resend OTP if the previous one is expired - parameters: - - description: Resend OTP - in: body - name: resendOtp - required: true - schema: - $ref: '#/definitions/domain.ResendOtpReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Resend OTP - tags: - - otp - /api/v1/{tenant_slug}/user-login: - post: - consumes: - - application/json - description: Login user - parameters: - - description: Login user - in: body - name: login - required: true - schema: - $ref: '#/definitions/domain.LoginRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.loginUserRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Login user - tags: - - auth - /api/v1/{tenant_slug}/user/admin-profile: - get: - consumes: - - application/json - description: Get user profile - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.AdminProfileRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - security: - - Bearer: [] - summary: Get user profile - tags: - - user - /api/v1/{tenant_slug}/user/checkPhoneEmailExist: - post: - consumes: - - application/json - description: Check if phone number or email exist - parameters: - - description: Check phone number or email exist - in: body - name: checkPhoneEmailExist - required: true - schema: - $ref: '#/definitions/handlers.CheckPhoneEmailExistReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.CheckPhoneEmailExistRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Check if phone number or email exist - tags: - - user - /api/v1/{tenant_slug}/user/register: - post: - consumes: - - application/json - description: Register user - parameters: - - description: Register user - in: body - name: registerUser - required: true - schema: - $ref: '#/definitions/domain.RegisterUserReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Register user - tags: - - user - /api/v1/{tenant_slug}/user/resetPassword: - post: - consumes: - - application/json - description: Reset tenant password - parameters: - - description: Reset password - in: body - name: resetPassword - required: true - schema: - $ref: '#/definitions/handlers.ResetPasswordReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Reset tenant password - tags: - - user - /api/v1/{tenant_slug}/user/sendRegisterCode: - post: - consumes: - - application/json - description: Send register code - parameters: - - description: Send register code - in: body - name: registerCode - required: true - schema: - $ref: '#/definitions/handlers.RegisterCodeReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Send register code - tags: - - user - /api/v1/{tenant_slug}/user/sendResetCode: - post: - consumes: - - application/json - description: Send reset code - parameters: - - description: Send reset code - in: body - name: resetCode - required: true - schema: - $ref: '#/definitions/handlers.ResetCodeReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Send reset code - tags: - - user - /api/v1/{tenant_slug}/user/user-profile: - get: - consumes: - - application/json - description: Get user profile - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.UserProfileResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - security: - - Bearer: [] - summary: Get user profile - tags: - - user - /api/v1/activity-logs: + /api/v1/admin/activity-logs: get: description: Returns a filtered, paginated list of activity logs parameters: @@ -3967,7 +3467,7 @@ paths: summary: Get activity logs tags: - activity-logs - /api/v1/activity-logs/{id}: + /api/v1/admin/activity-logs/{id}: get: description: Returns a single activity log entry by its ID parameters: @@ -3994,7 +3494,7 @@ paths: summary: Get activity log by ID tags: - activity-logs - /api/v1/activity-logs/export: + /api/v1/admin/activity-logs/export: get: produces: - text/csv @@ -4002,7 +3502,7 @@ paths: summary: Export activity logs as CSV (admin) tags: - activity-logs - /api/v1/admin: + /api/v1/admin/admins: get: consumes: - application/json @@ -4071,7 +3571,7 @@ paths: summary: Create Admin tags: - admin - /api/v1/admin/{id}: + /api/v1/admin/admins/{id}: get: consumes: - application/json @@ -4137,6 +3637,158 @@ paths: summary: Update Admin tags: - admin + /api/v1/admin/admins/roles/{role}/bulk-deactivate: + post: + consumes: + - application/json + description: Sets all platform users with the given users.role to DEACTIVATED + (except the caller) and all team_members with the given team_role to inactive. + Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id + from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN + cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk + change other platform ADMIN users (team_members with team_role ADMIN under + path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id + to skip one team_members row (e.g. yourself). + parameters: + - description: Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string) + in: path + name: role + required: true + type: string + - description: Optional exclusions + in: body + name: body + schema: + $ref: '#/definitions/domain.BulkAccountsByRoleRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users + only) + tags: + - admin + /api/v1/admin/admins/roles/{role}/bulk-reactivate: + post: + consumes: + - application/json + description: Sets all platform users with the given role from DEACTIVATED to + ACTIVE (except the caller) and all team_members with the given team_role from + inactive to active. Path :role may be a role key or decimal RBAC roles.id + (see bulk-deactivate). Path role must correspond to valid platform users.role + or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot + be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users + (team_members ADMIN under path ADMIN is allowed). Matches only users currently + DEACTIVATED and team rows currently inactive. + parameters: + - description: Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string) + in: path + name: role + required: true + type: string + - description: Optional exclusions + in: body + name: body + schema: + $ref: '#/definitions/domain.BulkAccountsByRoleRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users + only) + tags: + - admin + /api/v1/admin/analytics/dashboard: + get: + description: 'Platform analytics with optional date filters in Africa/Addis_Ababa + (EAT): all-time (default), year, year+month, or custom from/to range. When + year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals + (EAT) per currency for that calendar year. Optional payment_method filters + payment/revenue metrics (exact or METHOD:% variants). Daily series remains + in revenue_last_30_days (see date_filter.series_*). Courses section counts + LMS + exam_prep inventory.' + parameters: + - description: EAT calendar year (e.g. 2025) + in: query + name: year + type: integer + - description: EAT calendar month 1-12 (requires year) + in: query + name: month + type: integer + - description: Custom EAT range start (YYYY-MM-DD or RFC3339) + in: query + name: from + type: string + - description: Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive) + in: query + name: to + type: string + - description: Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT) + in: query + name: payment_method + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.AnalyticsDashboard' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Analytics dashboard + tags: + - analytics /api/v1/admin/app-versions: get: parameters: @@ -4308,6 +3960,90 @@ paths: summary: Update mobile app version (admin) tags: - app-versions + /api/v1/admin/auth/admin-login: + post: + consumes: + - application/json + description: Login user + parameters: + - description: Login admin + in: body + name: login + required: true + schema: + $ref: '#/definitions/domain.LoginRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.LoginAdminRes' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Login user + tags: + - auth + /api/v1/admin/auth/super-login: + post: + consumes: + - application/json + description: Login super-admin + parameters: + - description: Login super-admin + in: body + name: login + required: true + schema: + $ref: '#/definitions/domain.LoginRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.LoginAdminRes' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Login super-admin + tags: + - auth + /api/v1/admin/devices/register: + post: + responses: {} + security: + - Bearer: [] + summary: RegisterDeviceToken + tags: + - client + /api/v1/admin/devices/unregister: + post: + responses: {} + security: + - Bearer: [] + summary: UnregisterDeviceToken + tags: + - client /api/v1/admin/email-templates: get: description: Returns email templates for admin management @@ -4583,6 +4319,663 @@ paths: summary: Preview email template by slug tags: - email-templates + /api/v1/admin/exam-prep/assessments: + get: + responses: {} + security: + - Bearer: [] + summary: ListExamPrepAssessments + tags: + - client + post: + responses: {} + security: + - Bearer: [] + summary: LinkExamPrepAssessment + tags: + - admin + /api/v1/admin/exam-prep/assessments/{questionSetId}/parents/{parentKind}/{parentId}: + delete: + responses: {} + security: + - Bearer: [] + summary: UnlinkExamPrepAssessment + tags: + - admin + /api/v1/admin/exam-prep/catalog-courses: + get: + parameters: + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: List exam-prep catalog courses + tags: + - exam-prep + post: + consumes: + - application/json + description: Top-level exam track (DET, IELTS, …) in schema exam_prep — separate + from LMS programs/courses + parameters: + - description: Catalog course + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepCatalogCourseInput' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create exam-prep catalog course + tags: + - exam-prep + /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices: + get: + parameters: + - description: Exam prep catalog course ID + in: path + name: catalogCourseId + required: true + type: integer + - description: Page size. Omit to return all practices for the catalog course. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a catalog course + tags: + - exam-prep + post: + parameters: + - description: Exam prep catalog course ID + in: path + name: catalogCourseId + required: true + type: integer + - description: Practice + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepPracticeInput' + responses: {} + summary: Create exam-prep practice under a catalog course + tags: + - exam-prep + /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units: + get: + parameters: + - description: Catalog course ID + in: path + name: catalogCourseId + required: true + type: integer + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: List exam-prep units for a catalog course + tags: + - exam-prep + post: + consumes: + - application/json + description: Unit under a catalog course (e.g. chapter title). Optional sort_order + assigns position within that catalog course (siblings at or after that index + are shifted); omit to append after the current highest sort_order in the catalog + course. + parameters: + - description: Catalog course ID + in: path + name: catalogCourseId + required: true + type: integer + - description: Unit + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepUnitInput' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + summary: Create exam-prep unit + tags: + - exam-prep + /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units/reorder: + put: + parameters: + - description: Catalog course ID + in: path + name: catalogCourseId + required: true + type: integer + - description: 'ordered_ids: every unit id in this catalog course, new order' + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.ReorderIDsRequest' + responses: {} + summary: Reorder units within a catalog course + tags: + - exam-prep + /api/v1/admin/exam-prep/catalog-courses/{id}: + delete: + parameters: + - description: Catalog course ID + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Delete exam-prep catalog course + tags: + - exam-prep + get: + parameters: + - description: Catalog course ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Get exam-prep catalog course by ID + tags: + - exam-prep + put: + consumes: + - application/json + parameters: + - description: Catalog course ID + in: path + name: id + required: true + type: integer + - description: Fields to update + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateExamPrepCatalogCourseInput' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Update exam-prep catalog course + tags: + - exam-prep + /api/v1/admin/exam-prep/catalog-courses/reorder: + put: + consumes: + - application/json + parameters: + - description: 'ordered_ids: every catalog course id exactly once' + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.ReorderIDsRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Reorder all exam-prep catalog courses + tags: + - exam-prep + /api/v1/admin/exam-prep/lessons/{id}: + delete: + responses: {} + summary: Delete exam-prep lesson + tags: + - exam-prep + get: + responses: {} + summary: Get exam-prep lesson by ID + tags: + - exam-prep + put: + responses: {} + summary: Update exam-prep lesson + tags: + - exam-prep + /api/v1/admin/exam-prep/lessons/{lessonId}/practices: + get: + parameters: + - description: Exam prep lesson ID + in: path + name: lessonId + required: true + type: integer + - description: Page size. Omit to return all practices for the lesson. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a lesson + tags: + - exam-prep + /api/v1/admin/exam-prep/modules/{id}: + delete: + responses: {} + summary: Delete exam-prep module + tags: + - exam-prep + get: + responses: {} + summary: Get exam-prep module by ID + tags: + - exam-prep + put: + responses: {} + summary: Update exam-prep module + tags: + - exam-prep + /api/v1/admin/exam-prep/modules/{moduleId}/lessons: + get: + parameters: + - description: Exam prep unit module ID + in: path + name: moduleId + required: true + type: integer + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep lessons for a unit module + tags: + - exam-prep + post: + parameters: + - description: Exam prep unit module ID + in: path + name: moduleId + required: true + type: integer + - description: Lesson + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepLessonInput' + responses: {} + summary: Create exam-prep lesson (under a unit module) + tags: + - exam-prep + /api/v1/admin/exam-prep/modules/{moduleId}/lessons/reorder: + put: + responses: {} + summary: Reorder lessons within an exam-prep unit module + tags: + - exam-prep + /api/v1/admin/exam-prep/practices: + get: + parameters: + - description: Page size. Omit (with offset) to return all practices. + in: query + name: limit + type: integer + - description: Offset. Defaults to 0 when limit is provided; ignored semantics + when both omitted (all rows). + in: query + name: offset + type: integer + - description: When true, return only practices with no parent links (admin) + in: query + name: unlinked_only + type: boolean + responses: {} + summary: List exam-prep practices globally + tags: + - exam-prep + post: + parameters: + - description: Practice + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepPracticeInput' + responses: {} + summary: Create exam-prep practice (optional parents; link later via PUT /exam-prep/practices/:id/parents) + tags: + - exam-prep + /api/v1/admin/exam-prep/practices/{id}: + delete: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Delete exam-prep practice + tags: + - exam-prep + get: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Get exam-prep practice by ID + tags: + - exam-prep + put: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + - description: Fields to update + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateExamPrepPracticeInput' + responses: {} + summary: Update exam-prep practice + tags: + - exam-prep + /api/v1/admin/exam-prep/practices/{id}/full: + get: + description: Returns exam-prep practice metadata, linked question set settings, + and all questions in the set. + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get exam-prep practice with question set and questions + tags: + - exam-prep + put: + consumes: + - application/json + description: Updates exam-prep practice metadata, linked question set settings, + and syncs questions in one request. + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + - description: Full practice update payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.FullUpdatePracticeInput' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Full update exam-prep practice with question set and questions + tags: + - exam-prep + /api/v1/admin/exam-prep/practices/{id}/parents: + put: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + - description: Parent links (replaces all; use empty array to detach) + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateExamPrepPracticeParentsInput' + responses: {} + summary: Replace exam-prep practice parent links + tags: + - exam-prep + /api/v1/admin/exam-prep/practices/{id}/parents/{parentKind}/{parentId}: + delete: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + - description: Parent kind (CATALOG_COURSE, UNIT, LESSON) + in: path + name: parentKind + required: true + type: string + - description: Parent entity ID + in: path + name: parentId + required: true + type: integer + responses: {} + summary: Unlink one exam-prep practice parent + tags: + - exam-prep + /api/v1/admin/exam-prep/units/{id}: + delete: + parameters: + - description: Unit ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Delete exam-prep unit + tags: + - exam-prep + get: + parameters: + - description: Unit ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Get exam-prep unit by ID + tags: + - exam-prep + put: + parameters: + - description: Unit ID + in: path + name: id + required: true + type: integer + - description: Fields to update + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateExamPrepUnitInput' + responses: {} + summary: Update exam-prep unit + tags: + - exam-prep + /api/v1/admin/exam-prep/units/{unitId}/modules: + get: + parameters: + - description: Unit ID + in: path + name: unitId + required: true + type: integer + responses: {} + summary: List exam-prep modules for a unit + tags: + - exam-prep + post: + parameters: + - description: Unit ID + in: path + name: unitId + required: true + type: integer + - description: Module + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepModuleInput' + responses: {} + summary: Create exam-prep module + tags: + - exam-prep + /api/v1/admin/exam-prep/units/{unitId}/modules/reorder: + put: + parameters: + - description: Unit ID + in: path + name: unitId + required: true + type: integer + - description: ordered_ids + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.ReorderIDsRequest' + responses: {} + summary: Reorder modules within a unit + tags: + - exam-prep + /api/v1/admin/exam-prep/units/{unitId}/practices: + get: + parameters: + - description: Exam prep unit ID + in: path + name: unitId + required: true + type: integer + - description: Page size. Omit to return all practices for the unit. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a unit + tags: + - exam-prep + post: + parameters: + - description: Exam prep unit ID + in: path + name: unitId + required: true + type: integer + - description: Practice + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateExamPrepPracticeInput' + responses: {} + summary: Create exam-prep practice under a unit + tags: + - exam-prep /api/v1/admin/faqs: get: description: Returns FAQs for admin management with status/category filtering @@ -4858,6 +5251,889 @@ paths: summary: Update field option (admin) tags: - field-options + /api/v1/admin/files/audio: + post: + consumes: + - multipart/form-data + parameters: + - description: Audio file (mp3, wav, ogg, m4a, aac, webm) + in: formData + name: file + required: true + type: file + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Upload an audio file + tags: + - files + /api/v1/admin/files/complete-upload: + post: + consumes: + - application/json + description: Call after PUT upload to upload_url. Returns the same file metadata + shape as POST /files/upload. + parameters: + - description: Complete upload request + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.completePresignedUploadReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Complete presigned MinIO upload + tags: + - files + /api/v1/admin/files/presign-upload: + post: + consumes: + - application/json + description: Returns a short-lived PUT URL and object key. Upload the file with + HTTP PUT to upload_url using the same Content-Type, then call POST /files/complete-upload. + parameters: + - description: Presigned upload request + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.presignedUploadReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + summary: Create presigned MinIO upload URL + tags: + - files + /api/v1/admin/files/refresh-url: + post: + consumes: + - application/json + parameters: + - description: reference (object key, minio://..., or existing presigned URL) + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.refreshFileURLReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Refresh presigned URL for a file + tags: + - files + /api/v1/admin/files/upload: + post: + consumes: + - multipart/form-data + parameters: + - description: 'Media type: image|audio|video|pdf' + in: formData + name: media_type + required: true + type: string + - description: Media file + in: formData + name: file + required: true + type: file + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Upload media file + tags: + - files + /api/v1/admin/files/url: + get: + parameters: + - description: MinIO object key (e.g. profile_pictures/uuid.jpg) + in: query + name: key + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Get presigned URL for a file + tags: + - files + /api/v1/admin/internal/users/purge-due-deletions: + post: + description: Worker-safe purge for due self-deletion requests + parameters: + - description: Max users to purge in one run (default 100, max 1000) + in: query + name: limit + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - Bearer: [] + summary: Purge due account deletions + tags: + - user + /api/v1/admin/issues: + get: + description: Returns all reported issues with pagination (admin only) + parameters: + - default: 20 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/handlers.issueListRes' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get all issues + tags: + - issues + /api/v1/admin/issues/{id}: + delete: + description: Deletes an issue report (admin only) + parameters: + - description: Issue ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Delete an issue + tags: + - issues + get: + description: Returns a single issue report by its ID (admin only) + parameters: + - description: Issue ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/handlers.issueRes' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get issue by ID + tags: + - issues + /api/v1/admin/issues/{id}/status: + patch: + consumes: + - application/json + description: Updates the status of an issue (admin only) + parameters: + - description: Issue ID + in: path + name: id + required: true + type: integer + - description: Status update payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateIssueStatusReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Update issue status + tags: + - issues + /api/v1/admin/issues/user/{user_id}: + get: + description: Returns paginated issues reported by a specific user (admin only) + parameters: + - description: User ID + in: path + name: user_id + required: true + type: integer + - default: 20 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/handlers.issueListRes' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get issues for a specific user + tags: + - issues + /api/v1/admin/logs: + get: + description: Fetches application logs from MongoDB with pagination, level filtering, + and search + parameters: + - description: Filter logs by level (debug, info, warn, error, dpanic, panic, + fatal) + in: query + name: level + type: string + - description: Search term to match against message or fields + in: query + name: search + type: string + - default: 1 + description: 'Page number for pagination (default: 1)' + in: query + name: page + type: integer + - default: 50 + description: 'Number of items per page (default: 50, max: 100)' + in: query + name: limit + type: integer + produces: + - application/json + responses: + "200": + description: Paginated list of application logs + schema: + $ref: '#/definitions/domain.LogResponse' + "400": + description: Invalid request parameters + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Retrieve application logs with filtering and pagination + tags: + - Logs + /api/v1/admin/notifications: + delete: + responses: {} + security: + - Bearer: [] + summary: DeleteUserNotifications + tags: + - client + get: + responses: {} + security: + - Bearer: [] + summary: GetUserNotification + tags: + - client + /api/v1/admin/notifications/{id}: + delete: + description: Deletes one in-app notification owned by the authenticated user. + parameters: + - description: Notification ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a single in-app notification + tags: + - notifications + get: + description: Returns a single in-app notification. Users may only fetch their + own notifications unless they have list-all access. + parameters: + - description: Notification ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get in-app notification by ID + tags: + - notifications + /api/v1/admin/notifications/{id}/read: + patch: + responses: {} + security: + - Bearer: [] + summary: MarkNotificationAsRead + tags: + - client + /api/v1/admin/notifications/{id}/unread: + patch: + responses: {} + security: + - Bearer: [] + summary: MarkNotificationAsUnread + tags: + - client + /api/v1/admin/notifications/all: + get: + responses: {} + security: + - Bearer: [] + summary: GetAllNotifications + tags: + - admin + /api/v1/admin/notifications/bulk-email: + post: + consumes: + - multipart/form-data + description: Sends an email to specified user IDs, users of a platform role, + team member IDs, team members of a team_role, or direct email addresses with + optional image attachment. Optionally schedule for later with scheduled_at + (RFC3339). + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send bulk email + tags: + - notifications + /api/v1/admin/notifications/bulk-in-app: + post: + consumes: + - application/json + description: Creates in-app notifications for specified platform user IDs, users + matching a platform role, team member IDs, or team members matching a team_role. + Optionally schedule for later with scheduled_at (RFC3339). + parameters: + - description: Bulk in-app content + in: body + name: body + required: true + schema: + properties: + level: + type: string + message: + type: string + role: + type: string + scheduled_at: + type: string + team_member_ids: + items: + format: int64 + type: integer + type: array + team_role: + type: string + title: + type: string + type: + type: string + user_ids: + items: + format: int64 + type: integer + type: array + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send bulk in-app notification + tags: + - notifications + /api/v1/admin/notifications/bulk-push: + post: + consumes: + - application/json + description: Sends a push notification to specified user IDs or all users matching + a role. Optionally schedule for later with scheduled_at (RFC3339). + parameters: + - description: Bulk push content + in: body + name: body + required: true + schema: + properties: + image: + type: string + message: + type: string + role: + type: string + scheduled_at: + type: string + title: + type: string + user_ids: + items: + format: int64 + type: integer + type: array + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send bulk push notification + tags: + - notifications + /api/v1/admin/notifications/bulk-sms: + post: + consumes: + - application/json + description: Sends an SMS to specified user IDs, all users of a role, or direct + phone numbers. Optionally schedule for later with scheduled_at (RFC3339). + parameters: + - description: Bulk SMS content + in: body + name: body + required: true + schema: + properties: + message: + type: string + phone_numbers: + items: + type: string + type: array + role: + type: string + scheduled_at: + type: string + user_ids: + items: + format: int64 + type: integer + type: array + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send bulk SMS + tags: + - notifications + /api/v1/admin/notifications/create: + post: + responses: {} + security: + - Bearer: [] + summary: CreateAndSendNotification + tags: + - admin + /api/v1/admin/notifications/delete-in-app: + post: + consumes: + - application/json + description: Deletes in-app notifications by ID for the authenticated user. + Non-matching IDs are ignored. + parameters: + - description: Notification IDs + in: body + name: body + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete multiple in-app notifications + tags: + - notifications + /api/v1/admin/notifications/mark-all-read: + post: + responses: {} + security: + - Bearer: [] + summary: MarkAllNotificationsAsRead + tags: + - client + /api/v1/admin/notifications/mark-all-unread: + post: + responses: {} + security: + - Bearer: [] + summary: MarkAllNotificationsAsUnread + tags: + - client + /api/v1/admin/notifications/scheduled: + get: + description: Returns paginated scheduled notifications with optional status, + channel, and date filters + parameters: + - description: Filter by status + in: query + name: status + type: string + - description: Filter by channel + in: query + name: channel + type: string + - description: Filter after date (RFC3339) + in: query + name: after + type: string + - description: Filter before date (RFC3339) + in: query + name: before + type: string + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 1 + description: Page number + in: query + name: page + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List scheduled notifications + tags: + - notifications + /api/v1/admin/notifications/scheduled/{id}: + get: + description: Returns a single scheduled notification by its ID + parameters: + - description: Scheduled Notification ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get scheduled notification + tags: + - notifications + /api/v1/admin/notifications/scheduled/{id}/cancel: + post: + description: Cancels a scheduled notification if it is still pending or processing + parameters: + - description: Scheduled Notification ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Cancel scheduled notification + tags: + - notifications + /api/v1/admin/notifications/send-email: + post: + consumes: + - multipart/form-data + description: Sends an email to a single email address with optional image attachment + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send single email + tags: + - notifications + /api/v1/admin/notifications/test-push: + post: + consumes: + - application/json + description: Sends a test push notification to all registered devices of the + current user + parameters: + - description: Test notification content + in: body + name: body + required: true + schema: + properties: + message: + type: string + title: + type: string + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send test push notification + tags: + - notifications + /api/v1/admin/notifications/unread: + get: + responses: {} + security: + - Bearer: [] + summary: CountUnreadNotifications + tags: + - client /api/v1/admin/payments: get: description: Returns paginated payments across Chapa and ArifPay with optional @@ -4979,29 +6255,103 @@ paths: summary: Export payments as CSV (admin) tags: - payments - /api/v1/admin/roles/{role}/bulk-deactivate: + /api/v1/admin/personas: + get: + parameters: + - default: true + description: When true (default), return only active personas + in: query + name: active_only + type: boolean + - description: Page size + in: query + name: limit + type: integer + - description: Offset + in: query + name: offset + type: integer + responses: {} + summary: List LMS personas (catalog for practice assignment) + tags: + - personas post: consumes: - application/json - description: Sets all platform users with the given users.role to DEACTIVATED - (except the caller) and all team_members with the given team_role to inactive. - Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id - from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN - cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk - change other platform ADMIN users (team_members with team_role ADMIN under - path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id - to skip one team_members row (e.g. yourself). parameters: - - description: Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string) - in: path - name: role - required: true - type: string - - description: Optional exclusions + - description: Persona in: body name: body + required: true schema: - $ref: '#/definitions/domain.BulkAccountsByRoleRequest' + $ref: '#/definitions/domain.CreateLmsPersonaInput' + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + summary: Create LMS persona catalog entry + tags: + - personas + /api/v1/admin/personas/{id}: + delete: + parameters: + - description: Persona ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Delete LMS persona (practices referencing it will have persona_id cleared) + tags: + - personas + get: + parameters: + - description: Persona ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Get LMS persona by ID + tags: + - personas + put: + parameters: + - description: Persona ID + in: path + name: id + required: true + type: integer + - description: Fields to update + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateLmsPersonaInput' + responses: {} + summary: Update LMS persona + tags: + - personas + /api/v1/admin/question-sets: + get: + description: Returns a paginated list of question sets filtered by type + parameters: + - description: Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE) + in: query + name: set_type + required: true + type: string + - default: 10 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer produces: - application/json responses: @@ -5013,8 +6363,1275 @@ paths: description: Bad Request schema: $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get question sets by type + tags: + - question-sets + post: + consumes: + - application/json + description: Creates a new question set (practice, assessment, quiz, exam, or + survey) + parameters: + - description: Create question set payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.createQuestionSetReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create a new question set + tags: + - question-sets + /api/v1/admin/question-sets/{id}: + delete: + description: Archives a question set (soft delete) + parameters: + - description: Question Set ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a question set + tags: + - question-sets + get: + description: Returns a question set with question count + parameters: + - description: Question Set ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get question set by ID + tags: + - question-sets + put: + consumes: + - application/json + description: Updates a question set's properties + parameters: + - description: Question Set ID + in: path + name: id + required: true + type: integer + - description: Update question set payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateQuestionSetReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Update a question set + tags: + - question-sets + /api/v1/admin/question-sets/{setId}/personas: + get: + description: Returns all users assigned as personas to a question set (practice) + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get user personas for a question set + tags: + - question-sets + post: + consumes: + - application/json + description: Links a user as a persona to a question set (practice) + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + - description: Add user persona payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.addUserPersonaReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Add a user as persona to a question set + tags: + - question-sets + /api/v1/admin/question-sets/{setId}/personas/{userId}: + delete: + description: Unlinks a user as persona from a question set (practice) + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + - description: User ID + in: path + name: userId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Remove a user persona from a question set + tags: + - question-sets + /api/v1/admin/question-sets/{setId}/question-types: + get: + description: Returns distinct question type definitions (key, display_name, + counts) for non-archived questions in the set. Legacy stored question_type + values (e.g. AUDIO) are resolved to builder definitions when possible. + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List question types in a question set + tags: + - question-set-items + /api/v1/admin/question-sets/{setId}/questions: + get: + description: Returns all questions in a question set with contextual shared + stimulus data for linked LMS and exam-prep practices + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get questions in set + tags: + - question-set-items + post: + consumes: + - application/json + description: Links a question to a question set. Omit display_order to append + after the current max; the assigned value is returned in the response. + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + - description: Add question to set payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.addQuestionToSetReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Add question to set + tags: + - question-set-items + /api/v1/admin/question-sets/{setId}/questions/{questionId}: + delete: + description: Unlinks a question from a question set + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + - description: Question ID + in: path + name: questionId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Remove question from set + tags: + - question-set-items + /api/v1/admin/question-sets/{setId}/questions/{questionId}/order: + put: + consumes: + - application/json + description: Updates the display order of a question in a set + parameters: + - description: Question Set ID + in: path + name: setId + required: true + type: integer + - description: Question ID + in: path + name: questionId + required: true + type: integer + - description: Update order payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateQuestionOrderReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Update question order in set + tags: + - question-set-items + /api/v1/admin/question-sets/by-owner: + get: + description: Returns question sets for a specific owner (e.g., sub-course) + parameters: + - description: Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE) + in: query + name: owner_type + required: true + type: string + - description: Owner ID + in: query + name: owner_id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get question sets by owner + tags: + - question-sets + /api/v1/admin/questions: + get: + description: Returns a paginated list of questions with optional filters + parameters: + - description: Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER) + in: query + name: question_type + type: string + - description: Difficulty level filter (EASY, MEDIUM, HARD) + in: query + name: difficulty + type: string + - description: Status filter (DRAFT, PUBLISHED, INACTIVE) + in: query + name: status + type: string + - default: 10 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List questions + tags: + - questions + post: + consumes: + - application/json + description: Creates a new question with options (for MCQ/TRUE_FALSE) or short + answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; + use dynamic_payload stimulus instead. Legacy types require question_text. + parameters: + - description: Create question payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.createQuestionReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create a new question + tags: + - questions + /api/v1/admin/questions/{id}: + delete: + description: Archives a question (soft delete) + parameters: + - description: Question ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a question + tags: + - questions + get: + description: Returns a question with its options/short answers + parameters: + - description: Question ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get question by ID + tags: + - questions + put: + consumes: + - application/json + description: Updates a question and optionally replaces its options/short answers. + Supports question_type_definition_id for dynamic builder-linked questions. + parameters: + - description: Question ID + in: path + name: id + required: true + type: integer + - description: Update question payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateQuestionReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Update a question + tags: + - questions + /api/v1/admin/questions/component-catalog: + get: + description: Valid stimulus and response component kind codes for dynamic question-type + definitions + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Question-type builder component catalog + tags: + - questions + /api/v1/admin/questions/search: + get: + description: Search questions by text + parameters: + - description: Search query + in: query + name: q + required: true + type: string + - default: 10 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Search questions + tags: + - questions + /api/v1/admin/questions/type-definition-groups: + get: + parameters: + - description: Filter by status (ACTIVE, INACTIVE) + in: query + name: status + type: string + - default: 20 + description: Page size (default 20, max 200) + in: query + name: limit + type: integer + - default: 0 + description: Page offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: List question type definition groups + tags: + - questions + post: + consumes: + - application/json + parameters: + - description: Group payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.createQuestionTypeDefinitionGroupReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + summary: Create question type definition group + tags: + - questions + /api/v1/admin/questions/type-definition-groups/{id}: + delete: + parameters: + - description: Group id + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Delete question type definition group + tags: + - questions + get: + parameters: + - description: Group id + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get question type definition group with definitions + tags: + - questions + put: + consumes: + - application/json + parameters: + - description: Group id + in: path + name: id + required: true + type: integer + - description: Update group payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateQuestionTypeDefinitionGroupReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Update question type definition group + tags: + - questions + /api/v1/admin/questions/type-definitions: + get: + parameters: + - description: Filter by status (ACTIVE, INACTIVE) + in: query + name: status + type: string + - default: true + description: Include system seeded definitions + in: query + name: include_system + type: boolean + - default: 20 + description: Page size (default 20, max 200) + in: query + name: limit + type: integer + - default: 0 + description: Page offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List reusable question-type definitions + tags: + - questions + post: + consumes: + - application/json + description: Stores a reusable dynamic question-type definition for future question + construction. Only runtime-mappable definitions are persisted. + parameters: + - description: Question type definition payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.createQuestionTypeDefinitionReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create reusable question-type definition + tags: + - questions + /api/v1/admin/questions/type-definitions/{id}: + delete: + parameters: + - description: Question type definition id + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete reusable question-type definition + tags: + - questions + get: + parameters: + - description: Question type definition id + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get reusable question-type definition by id + tags: + - questions + put: + consumes: + - application/json + description: Updates a reusable dynamic question-type definition. Updated definitions + must remain runtime-mappable. + parameters: + - description: Question type definition id + in: path + name: id + required: true + type: integer + - description: Update question type definition payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updateQuestionTypeDefinitionReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Update reusable question-type definition + tags: + - questions + /api/v1/admin/questions/type-definitions/{id}/practices: + get: + description: Returns LMS and exam-prep practices whose linked question set contains + at least one non-archived question matching the definition (by question_type_definition_id + or legacy question_type). + parameters: + - description: Question type definition id + in: path + name: id + required: true + type: integer + - default: 20 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List practices globally by question type definition + tags: + - questions + /api/v1/admin/questions/validate-question-type-definition: + post: + consumes: + - application/json + description: Validates selected stimulus and response component kinds for temporary + question-type definitions (component-level validation only) + parameters: + - description: Stimulus and response component kinds + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.validateQuestionTypeDefinitionReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Validate dynamic question-type definition + tags: + - questions + /api/v1/admin/ratings: + get: + description: Returns paginated ratings for a specific target + parameters: + - description: Target type (app, course, sub_course) + in: query + name: target_type + required: true + type: string + - description: Target ID (0 for app) + in: query + name: target_id + required: true + type: integer + - description: Limit (default 20) + in: query + name: limit + type: integer + - description: Offset (default 0) + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get ratings for a target + tags: + - ratings + /api/v1/admin/ratings/{id}: + delete: + description: Deletes a rating by ID for the current user + parameters: + - description: Rating ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a rating + tags: + - ratings + /api/v1/admin/ratings/summary: + get: + description: Returns the total count and average stars for a specific target + parameters: + - description: Target type (app, course, sub_course) + in: query + name: target_type + required: true + type: string + - description: Target ID (0 for app) + in: query + name: target_id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get rating summary for a target + tags: + - ratings + /api/v1/admin/rbac/permissions: + get: + consumes: + - application/json + description: Get all permissions in the system grouped by group name + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + items: + $ref: '#/definitions/domain.Permission' + type: array + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: List all permissions + tags: + - rbac + /api/v1/admin/rbac/permissions/groups: + get: + consumes: + - application/json + description: Get all distinct permission group names + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + items: + type: string + type: array + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: List permission groups + tags: + - rbac + /api/v1/admin/rbac/permissions/sync: + post: + consumes: + - application/json + description: Re-seed permissions from code and reload the RBAC cache + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Sync permissions + tags: + - rbac + /api/v1/admin/rbac/roles: + get: + consumes: + - application/json + description: Get all roles with optional filters + parameters: + - description: Search by role name + in: query + name: query + type: string + - description: Filter by system role (true/false) + in: query + name: is_system + type: boolean + - description: 'Page number (default: 1)' + in: query + name: page + type: integer + - description: 'Page size (default: 20)' + in: query + name: page_size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: List all roles + tags: + - rbac + post: + consumes: + - application/json + description: Create a new role with a name and description + parameters: + - description: Role creation payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateRoleReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.RoleRecord' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Create a new role + tags: + - rbac + /api/v1/admin/rbac/roles/{id}: + delete: + consumes: + - application/json + description: Delete a non-system role by ID + parameters: + - description: Role ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Delete a role + tags: + - rbac + get: + consumes: + - application/json + description: Get a role and its permissions by ID + parameters: + - description: Role ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.RoleWithPermissions' + type: object + "400": + description: Bad Request schema: $ref: '#/definitions/domain.ErrorResponse' "404": @@ -5027,33 +7644,25 @@ paths: $ref: '#/definitions/domain.ErrorResponse' security: - Bearer: [] - summary: Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users - only) + summary: Get a role by ID tags: - - admin - /api/v1/admin/roles/{role}/bulk-reactivate: - post: + - rbac + put: consumes: - application/json - description: Sets all platform users with the given role from DEACTIVATED to - ACTIVE (except the caller) and all team_members with the given team_role from - inactive to active. Path :role may be a role key or decimal RBAC roles.id - (see bulk-deactivate). Path role must correspond to valid platform users.role - or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot - be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users - (team_members ADMIN under path ADMIN is allowed). Matches only users currently - DEACTIVATED and team rows currently inactive. + description: Update an existing role's name and description parameters: - - description: Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string) + - description: Role ID in: path - name: role + name: id required: true - type: string - - description: Optional exclusions + type: integer + - description: Role update payload in: body name: body + required: true schema: - $ref: '#/definitions/domain.BulkAccountsByRoleRequest' + $ref: '#/definitions/domain.UpdateRoleReq' produces: - application/json responses: @@ -5065,12 +7674,42 @@ paths: description: Bad Request schema: $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden + "500": + description: Internal Server Error schema: $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found + security: + - Bearer: [] + summary: Update a role + tags: + - rbac + /api/v1/admin/rbac/roles/{id}/permissions: + get: + consumes: + - application/json + description: Get all permissions assigned to a role + parameters: + - description: Role ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + items: + $ref: '#/definitions/domain.Permission' + type: array + type: object + "400": + description: Bad Request schema: $ref: '#/definitions/domain.ErrorResponse' "500": @@ -5079,10 +7718,251 @@ paths: $ref: '#/definitions/domain.ErrorResponse' security: - Bearer: [] - summary: Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users - only) + summary: Get permissions for a role + tags: + - rbac + put: + consumes: + - application/json + description: Replace all permissions for a role with the given permission IDs + parameters: + - description: Role ID + in: path + name: id + required: true + type: integer + - description: Permission IDs payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.SetRolePermissionsReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Set permissions for a role + tags: + - rbac + /api/v1/admin/referrals/settings: + get: + responses: {} + security: + - Bearer: [] + summary: GetReferralSettings tags: - admin + put: + responses: {} + security: + - Bearer: [] + summary: UpdateReferralSettings + tags: + - admin + /api/v1/admin/sendSMS: + post: + consumes: + - application/json + description: Sends an SMS message to a single phone number using AfroMessage + parameters: + - description: Send SMS request + in: body + name: sendSMS + required: true + schema: + $ref: '#/definitions/handlers.SendSingleAfroSMSReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Send single SMS via AfroMessage + tags: + - user + /api/v1/admin/settings: + get: + responses: {} + security: + - Bearer: [] + summary: GetGlobalSettingList + tags: + - admin + put: + responses: {} + security: + - Bearer: [] + summary: UpdateGlobalSettingList + tags: + - admin + /api/v1/admin/settings/{key}: + get: + responses: {} + security: + - Bearer: [] + summary: GetGlobalSettingByKey + tags: + - admin + /api/v1/admin/subscription-plans: + get: + description: 'Returns subscription plans. Optional category filter: EDUCATION.' + parameters: + - description: Return only active plans (default true) + in: query + name: active_only + type: boolean + - description: Filter by plan category (EDUCATION) + in: query + name: category + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List subscription plans + tags: + - subscriptions + post: + consumes: + - application/json + description: Creates a new subscription plan (admin only) + parameters: + - description: Create plan payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.createPlanReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create a subscription plan + tags: + - subscriptions + /api/v1/admin/subscription-plans/{id}: + delete: + description: Deletes a subscription plan (admin only) + parameters: + - description: Plan ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a subscription plan + tags: + - subscriptions + get: + description: Returns a single subscription plan by ID + parameters: + - description: Plan ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get a subscription plan + tags: + - subscriptions + put: + consumes: + - application/json + description: Updates a subscription plan (admin only) + parameters: + - description: Plan ID + in: path + name: id + required: true + type: integer + - description: Update plan payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.updatePlanReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Update a subscription plan + tags: + - subscriptions /api/v1/admin/subscriptions/{id}/cancel: post: description: Cancels any user_subscriptions row by ID. Does not require ownership @@ -5125,10 +8005,1040 @@ paths: summary: Export user subscriptions as CSV (admin) tags: - subscriptions + /api/v1/admin/team/invitations: + get: + description: Lists team member invitations with optional status filter + parameters: + - description: pending, accepted, expired, or revoked + in: query + name: status + type: string + - description: Limit (default 20) + in: query + name: limit + type: integer + - description: Offset (default 0) + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: List team invitations + tags: + - team + /api/v1/admin/team/invitations/{id}/revoke: + post: + description: Revokes the invitation and removes the pending team member if not + yet accepted + parameters: + - description: Invitation ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Revoke a pending team invitation + tags: + - team + /api/v1/admin/team/invitations/accept: + post: + consumes: + - application/json + description: Public endpoint to set password and profile details after following + the invite link + parameters: + - description: Accept invitation payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.AcceptTeamInvitationReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Accept team invitation and complete account setup + tags: + - team + /api/v1/admin/team/invitations/verify: + get: + description: Public endpoint used by the admin panel accept-invite page + parameters: + - description: Invitation token + in: query + name: token + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Verify team invitation token + tags: + - team + /api/v1/admin/team/login: + post: + consumes: + - application/json + description: Authenticate a team member (internal staff) with email and password + parameters: + - description: Team member login credentials + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.TeamMemberLoginReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/handlers.teamMemberLoginRes' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Login team member + tags: + - team + /api/v1/admin/team/me: + get: + consumes: + - application/json + description: Get the authenticated team member's own profile + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.TeamMemberResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get my team profile + tags: + - team + put: + consumes: + - application/json + description: Update the authenticated team member's own profile fields + parameters: + - description: Profile update payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateMyTeamProfileReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.TeamMemberResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Update my team profile + tags: + - team + /api/v1/admin/team/members: + get: + consumes: + - application/json + description: Get a paginated list of team members with optional filtering + parameters: + - description: Filter by team role (super_admin, admin, content_manager, support_agent, + instructor, finance, hr, analyst) + in: query + name: team_role + type: string + - description: Filter by department + in: query + name: department + type: string + - description: Filter by status (active, inactive, suspended, terminated) + in: query + name: status + type: string + - description: Search by name, email, or phone number + in: query + name: search + type: string + - description: 'Page number (default: 1)' + in: query + name: page + type: integer + - description: 'Items per page (default: 10, max: 100)' + in: query + name: page_size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + items: + $ref: '#/definitions/domain.TeamMemberResponse' + type: array + metadata: + $ref: '#/definitions/domain.Pagination' + type: object + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: List all team members + tags: + - team + post: + consumes: + - application/json + description: Create a new internal team member (admin only) + parameters: + - description: Team member creation payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.CreateTeamMemberReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.TeamMemberResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Create a new team member + tags: + - team + /api/v1/admin/team/members/{id}: + delete: + consumes: + - application/json + description: Delete a team member (super admin only) + parameters: + - description: Team Member ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Delete team member + tags: + - team + get: + consumes: + - application/json + description: Retrieve a team member's details by their ID + parameters: + - description: Team Member ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.TeamMemberResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get team member by ID + tags: + - team + put: + consumes: + - application/json + description: Update an existing team member's details (admin only) + parameters: + - description: Team Member ID + in: path + name: id + required: true + type: integer + - description: Team member update payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateTeamMemberReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Update team member + tags: + - team + /api/v1/admin/team/members/{id}/change-password: + post: + consumes: + - application/json + description: Change a team member's password (requires current password) + parameters: + - description: Team Member ID + in: path + name: id + required: true + type: integer + - description: Password change payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.changePasswordReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Change team member password + tags: + - team + /api/v1/admin/team/members/{id}/resend-invite: + post: + description: Revokes the current pending invite and sends a new invitation email + parameters: + - description: Team member ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Resend team invitation + tags: + - team + /api/v1/admin/team/members/{id}/status: + patch: + consumes: + - application/json + description: Update a team member's status (active, inactive, suspended, terminated) + parameters: + - description: Team Member ID + in: path + name: id + required: true + type: integer + - description: Status update payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.UpdateTeamMemberStatusReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Update team member status + tags: + - team + /api/v1/admin/team/members/export: + get: + produces: + - text/csv + responses: {} + summary: Export team members as CSV (admin) + tags: + - team + /api/v1/admin/team/members/invite: + post: + consumes: + - application/json + description: Creates a pending team member (email + team_role only) and sends + an invitation email; profile is completed on accept + parameters: + - description: Invite payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.InviteTeamMemberReq' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Invite a team member by email + tags: + - team + /api/v1/admin/team/refresh: + post: + consumes: + - application/json + description: Exchanges a valid team refresh token for a new access JWT and a + rotated refresh token (use only tokens from POST /team/login or this endpoint). + parameters: + - description: Current refresh token + in: body + name: body + required: true + schema: + $ref: '#/definitions/handlers.teamMemberRefreshReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/handlers.teamMemberLoginRes' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Refresh team member tokens + tags: + - team + /api/v1/admin/team/resetPassword: + post: + consumes: + - application/json + description: Completes team password reset using email + OTP from the reset + link. Public. + parameters: + - description: Reset payload + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.TeamResetPasswordReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Reset team member password + tags: + - team + /api/v1/admin/team/sendResetCode: + post: + consumes: + - application/json + description: Sends a password-reset email with a link to the team member (admin + panel). Public. + parameters: + - description: Email + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.TeamSendPasswordResetReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Send team password reset link + tags: + - team + /api/v1/admin/team/stats: + get: + consumes: + - application/json + description: Get statistics about team members by status + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.TeamMemberStats' + type: object + "401": + description: Unauthorized + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get team member statistics + tags: + - team + /api/v1/admin/team/verifyResetCode: + get: + description: Checks whether email+otp from a reset link are still valid without + consuming the OTP. Public. + parameters: + - description: Team member email + in: query + name: email + required: true + type: string + - description: Reset OTP from the email link + in: query + name: otp + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Verify team password reset link + tags: + - team + /api/v1/admin/user/{id}/profile-picture: + post: + consumes: + - multipart/form-data + description: Uploads a profile picture for the specified user + parameters: + - description: User ID + in: path + name: id + required: true + type: integer + - description: Image file (jpg|png|webp) + in: formData + name: file + required: true + type: file + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - Bearer: [] + summary: Upload profile picture + tags: + - user + /api/v1/admin/user/admin-profile: + get: + consumes: + - application/json + description: Get user profile + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.AdminProfileRes' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - Bearer: [] + summary: Get user profile + tags: + - user + /api/v1/admin/user/delete/{id}: + delete: + consumes: + - application/json + description: Delete a user by their ID + parameters: + - description: User ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Delete user by ID + tags: + - user + /api/v1/admin/user/search: + post: + consumes: + - application/json + description: Search for user using name or phone + parameters: + - description: Search for using his name or phone + in: body + name: searchUserByNameOrPhone + required: true + schema: + $ref: '#/definitions/handlers.SearchUserByNameOrPhoneReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.UserProfileResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Search for user using name or phone + tags: + - user + /api/v1/admin/user/single/{id}: + get: + consumes: + - application/json + description: Get a single user by id + parameters: + - description: User ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.UserProfileResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Get user by id + tags: + - user + /api/v1/admin/user/status: + patch: + consumes: + - application/json + description: Activates, deactivates, or suspends a user account + parameters: + - description: Status update payload + in: body + name: body + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Update user status + tags: + - user + /api/v1/admin/users: + get: + consumes: + - application/json + description: 'Get users with optional filters. Each user includes subscription_status: + ACTIVE, PENDING, or Unsubscribed.' + parameters: + - description: Role filter + in: query + name: role + type: string + - description: Search query + in: query + name: query + type: string + - description: Page number + in: query + name: page + type: integer + - description: Page size + in: query + name: page_size + type: integer + - description: Created before (RFC3339) + in: query + name: created_before + type: string + - description: Created after (RFC3339) + in: query + name: created_after + type: string + - description: User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, + or INACTIVE for all non-ACTIVE statuses) + in: query + name: status + type: string + - description: Country filter (case-insensitive match on stored value) + in: query + name: country + type: string + - description: Region filter (case-insensitive match on stored value) + in: query + name: region + type: string + - description: 'Derived subscription filter: ACTIVE, PENDING, or Unsubscribed + (matches response subscription_status semantics)' + in: query + name: subscription_status + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Get all users + tags: + - user /api/v1/admin/users/{user_id}/learning-activity: get: - description: Returns LMS and exam-prep completion trees, progress summaries, - completed ID snapshots, and recent activity timeline + description: Returns the unified catalog-course learning tree, progress summary, + and recent activity timeline parameters: - description: Target user ID in: path @@ -5171,39 +9081,7 @@ paths: - Bearer: [] summary: Get full learning activity for a user (admin) tags: - - lms - /api/v1/admin/users/{user_id}/lms-learning-activity: - get: - description: Returns programs, courses, modules, and lessons with completion - details and completed practices. Only persisted completion signals are included - (completed lessons, completed published practices, and rollup completion timestamps—not - partial or in-progress attempts). - parameters: - - description: Target user ID - in: path - name: user_id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get a user's nested LMS learning activity (admin) - tags: - - lms + - exam-prep /api/v1/admin/users/{user_id}/recent-activity: get: description: 'Reverse-chronological feed for profile UI: account joined plus @@ -5401,43 +9279,66 @@ paths: summary: List account deletion requests tags: - user - /api/v1/analytics/dashboard: + /api/v1/admin/users/export: get: - description: 'Platform analytics with optional date filters in Africa/Addis_Ababa - (EAT): all-time (default), year, year+month, or custom from/to range. When - year is set, payments.revenue_monthly returns Jan–Dec SUCCESS revenue totals - (EAT) per currency for that calendar year. Optional payment_method filters - payment/revenue metrics (exact or METHOD:% variants). Daily series remains - in revenue_last_30_days (see date_filter.series_*). Courses section counts - LMS + exam_prep inventory.' - parameters: - - description: EAT calendar year (e.g. 2025) - in: query - name: year - type: integer - - description: EAT calendar month 1-12 (requires year) - in: query - name: month - type: integer - - description: Custom EAT range start (YYYY-MM-DD or RFC3339) - in: query - name: from - type: string - - description: Custom EAT range end (YYYY-MM-DD or RFC3339, inclusive) - in: query - name: to - type: string - - description: Filter payment/revenue metrics (e.g. CHAPA, ARIFPAY, ADMIN_GRANT) - in: query - name: payment_method - type: string + produces: + - text/csv + responses: {} + summary: Export users as CSV (admin) + tags: + - user + /api/v1/admin/users/summary: + get: + consumes: + - application/json + description: Returns total users, active users, and users who joined this month produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.AnalyticsDashboard' + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.UserSummary' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + security: + - Bearer: [] + summary: Get user summary statistics + tags: + - user + /api/v1/admin/vimeo/oembed: + get: + consumes: + - application/json + description: Fetches oEmbed metadata for a Vimeo video URL + parameters: + - description: Vimeo video URL + in: query + name: url + required: true + type: string + - description: Desired width + in: query + name: width + type: integer + - description: Desired height + in: query + name: height + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/vimeo.OEmbedResponse' "400": description: Bad Request schema: @@ -5446,9 +9347,323 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/domain.ErrorResponse' - summary: Analytics dashboard + summary: Get oEmbed data for a Vimeo URL tags: - - analytics + - Vimeo + /api/v1/admin/vimeo/sample: + get: + consumes: + - application/json + description: Fetches a sample video from Vimeo and returns video details along + with an embeddable iframe for client-side integration + parameters: + - default: "76979871" + description: Vimeo Video ID to use as sample + in: query + name: video_id + type: string + - default: 640 + description: Player width + in: query + name: width + type: integer + - default: 360 + description: Player height + in: query + name: height + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get a sample Vimeo video with iframe embed + tags: + - Vimeo + /api/v1/admin/vimeo/uploads/pull: + post: + consumes: + - application/json + description: Initiates a pull upload where Vimeo fetches the video from a URL + parameters: + - description: Pull Upload Request + in: body + name: request + required: true + schema: + $ref: '#/definitions/handlers.CreatePullUploadRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/handlers.VimeoUploadResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create a pull upload to Vimeo + tags: + - Vimeo + /api/v1/admin/vimeo/uploads/tus: + post: + consumes: + - application/json + description: Initiates a TUS resumable upload and returns the upload link + parameters: + - description: TUS Upload Request + in: body + name: request + required: true + schema: + $ref: '#/definitions/handlers.CreateTusUploadRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/handlers.VimeoUploadResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Create a TUS resumable upload to Vimeo + tags: + - Vimeo + /api/v1/admin/vimeo/videos: + get: + consumes: + - application/json + description: Returns a paginated list of videos for the Vimeo API token (GET + https://api.vimeo.com/me/videos) + parameters: + - default: 1 + description: Page number (starts at 1) + in: query + name: page + type: integer + - default: 25 + description: Page size (Vimeo max 100) + in: query + name: per_page + type: integer + - description: Search query + in: query + name: query + type: string + - description: Sort field (e.g. date, alphabetical, plays, likes, comments, + duration, relevance) + in: query + name: sort + type: string + - description: asc or desc + in: query + name: direction + type: string + - description: Vimeo filter (e.g. embeddable, playable) + in: query + name: filter + type: string + - description: Vimeo filter_type when using filter + in: query + name: filter_type + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + items: + $ref: '#/definitions/handlers.VimeoVideoResponse' + type: array + metadata: + $ref: '#/definitions/handlers.VimeoVideosListMetadata' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + "503": + description: Service Unavailable + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: List videos stored in the Vimeo account + tags: + - Vimeo + /api/v1/admin/vimeo/videos/{video_id}: + delete: + consumes: + - application/json + description: Deletes a video from the Vimeo account + parameters: + - description: Vimeo Video ID + in: path + name: video_id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Delete a video from Vimeo + tags: + - Vimeo + get: + consumes: + - application/json + description: Retrieves video details from Vimeo by video ID + parameters: + - description: Vimeo Video ID + in: path + name: video_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.VimeoVideoResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get video information from Vimeo + tags: + - Vimeo + /api/v1/admin/vimeo/videos/{video_id}/embed: + get: + consumes: + - application/json + description: Generates an embeddable player iframe for the video + parameters: + - description: Vimeo Video ID + in: path + name: video_id + required: true + type: string + - default: 640 + description: Player width + in: query + name: width + type: integer + - default: 360 + description: Player height + in: query + name: height + type: integer + - description: Autoplay video + in: query + name: autoplay + type: boolean + - description: Loop video + in: query + name: loop + type: boolean + - description: Mute video + in: query + name: muted + type: boolean + - description: Background mode (no controls) + in: query + name: background + type: boolean + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.VimeoEmbedResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get embed code for a Vimeo video + tags: + - Vimeo + /api/v1/admin/vimeo/videos/{video_id}/status: + get: + consumes: + - application/json + description: Returns the current transcoding status of a video + parameters: + - description: Vimeo Video ID + in: path + name: video_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get transcode status of a Vimeo video + tags: + - Vimeo + /api/v1/admin/ws/connect: + get: + parameters: + - description: Access token + in: query + name: token + required: true + type: string + responses: {} + summary: ConnectSocket + tags: + - client /api/v1/app/version/check: get: description: Public endpoint for mobile clients to determine if an app update @@ -5501,6 +9716,40 @@ paths: summary: Login via Sign in with Apple identity token tags: - auth + /api/v1/auth/customer-login: + post: + consumes: + - application/json + description: Login user + parameters: + - description: Login user + in: body + name: login + required: true + schema: + $ref: '#/definitions/domain.LoginRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.loginUserRes' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Login user + tags: + - auth /api/v1/auth/google/android: post: parameters: @@ -5594,14 +9843,33 @@ paths: summary: Refresh token tags: - auth - /api/v1/courses/{courseId}/modules: + /api/v1/devices/register: + post: + responses: {} + security: + - Bearer: [] + summary: RegisterDeviceToken + tags: + - client + /api/v1/devices/unregister: + post: + responses: {} + security: + - Bearer: [] + summary: UnregisterDeviceToken + tags: + - client + /api/v1/exam-prep/assessments: + get: + responses: {} + security: + - Bearer: [] + summary: ListExamPrepAssessments + tags: + - client + /api/v1/exam-prep/catalog-courses: get: parameters: - - description: Course ID - in: path - name: courseId - required: true - type: integer - default: 20 description: Page size in: query @@ -5619,81 +9887,229 @@ paths: description: OK schema: $ref: '#/definitions/domain.Response' - summary: List modules for a course + summary: List exam-prep catalog courses tags: - - modules - post: - consumes: - - application/json - description: Create a module under a course; parent program is taken from the - course. + - exam-prep + /api/v1/exam-prep/catalog-courses/{catalogCourseId}/practices: + get: parameters: - - description: Course ID + - description: Exam prep catalog course ID in: path - name: courseId + name: catalogCourseId required: true type: integer - - description: Module - in: body - name: body + - description: Page size. Omit to return all practices for the catalog course. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a catalog course + tags: + - exam-prep + /api/v1/exam-prep/catalog-courses/{catalogCourseId}/units: + get: + parameters: + - description: Catalog course ID + in: path + name: catalogCourseId required: true - schema: - $ref: '#/definitions/domain.CreateModuleInput' + type: integer + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: List exam-prep units for a catalog course + tags: + - exam-prep + /api/v1/exam-prep/catalog-courses/{id}: + get: + parameters: + - description: Catalog course ID + in: path + name: id + required: true + type: integer produces: - application/json responses: - "201": - description: Created + "200": + description: OK + schema: + $ref: '#/definitions/domain.Response' + summary: Get exam-prep catalog course by ID + tags: + - exam-prep + /api/v1/exam-prep/lessons/{id}: + get: + responses: {} + summary: Get exam-prep lesson by ID + tags: + - exam-prep + /api/v1/exam-prep/lessons/{lessonId}/practices: + get: + parameters: + - description: Exam prep lesson ID + in: path + name: lessonId + required: true + type: integer + - description: Page size. Omit to return all practices for the lesson. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a lesson + tags: + - exam-prep + /api/v1/exam-prep/modules/{id}: + get: + responses: {} + summary: Get exam-prep module by ID + tags: + - exam-prep + /api/v1/exam-prep/modules/{moduleId}/lessons: + get: + parameters: + - description: Exam prep unit module ID + in: path + name: moduleId + required: true + type: integer + - default: 20 + description: Page size + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep lessons for a unit module + tags: + - exam-prep + /api/v1/exam-prep/practices: + get: + parameters: + - description: Page size. Omit (with offset) to return all practices. + in: query + name: limit + type: integer + - description: Offset. Defaults to 0 when limit is provided; ignored semantics + when both omitted (all rows). + in: query + name: offset + type: integer + - description: When true, return only practices with no parent links (admin) + in: query + name: unlinked_only + type: boolean + responses: {} + summary: List exam-prep practices globally + tags: + - exam-prep + /api/v1/exam-prep/practices/{id}: + get: + parameters: + - description: Exam prep practice ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Get exam-prep practice by ID + tags: + - exam-prep + /api/v1/exam-prep/practices/{practiceId}/questions: + get: + description: Returns paginated questions for an exam-prep practice, including + shared stimulus blocks and each question's effective dynamic payload + parameters: + - description: Exam-prep practice ID + in: path + name: practiceId + required: true + type: integer + - description: Question type filter (e.g. AUDIO) + in: query + name: question_type + type: string + - default: 10 + description: Limit + in: query + name: limit + type: integer + - default: 0 + description: Offset + in: query + name: offset + type: integer + produces: + - application/json + responses: + "200": + description: OK schema: $ref: '#/definitions/domain.Response' "400": description: Bad Request schema: $ref: '#/definitions/domain.ErrorResponse' - summary: Create module + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Get questions by practice tags: - - modules - /api/v1/courses/{courseId}/modules/reorder: - put: - parameters: - - description: Course ID - in: path - name: courseId - required: true - type: integer - - description: 'ordered_ids: every module id in this course, in the new order' - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.ReorderIDsRequest' - responses: {} - summary: Reorder modules within a course - tags: - - modules - /api/v1/courses/{id}: - delete: - parameters: - - description: Course ID - in: path - name: id - required: true - type: integer + - question-set-items + /api/v1/exam-prep/progress-summary: + get: + description: Returns progress for the catalog course → unit → module → lesson + learning hierarchy. + produces: + - application/json responses: "200": description: OK schema: $ref: '#/definitions/domain.Response' - "404": - description: Not Found + "500": + description: Internal Server Error schema: $ref: '#/definitions/domain.ErrorResponse' - summary: Delete course + summary: Get my learning progress summary tags: - - courses - get: + - exam-prep + /api/v1/exam-prep/progress/practices/{id}/complete: + post: + description: Marks a practice question set as completed for the authenticated + learner in its exam-prep parent scope parameters: - - description: Course ID + - description: Practice Question Set ID in: path name: id required: true @@ -5705,53 +10121,111 @@ paths: description: OK schema: $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' "404": description: Not Found schema: $ref: '#/definitions/domain.ErrorResponse' - summary: Get course by ID + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Mark exam-prep practice as completed tags: - - courses - put: + - progression + /api/v1/exam-prep/units/{id}: + get: + parameters: + - description: Unit ID + in: path + name: id + required: true + type: integer + responses: {} + summary: Get exam-prep unit by ID + tags: + - exam-prep + /api/v1/exam-prep/units/{unitId}/modules: + get: + parameters: + - description: Unit ID + in: path + name: unitId + required: true + type: integer + responses: {} + summary: List exam-prep modules for a unit + tags: + - exam-prep + /api/v1/exam-prep/units/{unitId}/practices: + get: + parameters: + - description: Exam prep unit ID + in: path + name: unitId + required: true + type: integer + - description: Page size. Omit to return all practices for the unit. + in: query + name: limit + type: integer + - description: Offset (used when limit is provided) + in: query + name: offset + type: integer + responses: {} + summary: List exam-prep practices for a unit + tags: + - exam-prep + /api/v1/exam-prep/videos/engagement/heartbeat: + post: consumes: - application/json + description: Records playback position for analytics (completion, replay, and + drop-off). Send periodic heartbeats while watching; set ended=true when the + viewer leaves. A new session starts after 30 minutes of inactivity or when + ended=true on the prior session. parameters: - - description: Course ID - in: path - name: id - required: true - type: integer - - description: Fields to update + - description: Playback heartbeat in: body name: body required: true schema: - $ref: '#/definitions/domain.UpdateCourseInput' + $ref: '#/definitions/domain.VideoEngagementHeartbeatInput' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.Response' + allOf: + - $ref: '#/definitions/domain.Response' + - properties: + data: + $ref: '#/definitions/domain.VideoWatchSessionResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "403": + description: Forbidden + schema: + $ref: '#/definitions/domain.ErrorResponse' "404": description: Not Found schema: $ref: '#/definitions/domain.ErrorResponse' - summary: Update course + summary: Report video playback progress tags: - - courses - /api/v1/courses/{id}/practices: - get: - parameters: - - description: Course ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - practices + - videos /api/v1/faqs: get: description: Returns active FAQs for public/help center usage @@ -5975,69 +10449,7 @@ paths: summary: Get presigned URL for a file tags: - files - /api/v1/internal/users/purge-due-deletions: - post: - description: Worker-safe purge for due self-deletion requests - parameters: - - description: Max users to purge in one run (default 100, max 1000) - in: query - name: limit - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - security: - - Bearer: [] - summary: Purge due account deletions - tags: - - user /api/v1/issues: - get: - description: Returns all reported issues with pagination (admin only) - parameters: - - default: 20 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/handlers.issueListRes' - type: object - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get all issues - tags: - - issues post: consumes: - application/json @@ -6078,105 +10490,6 @@ paths: summary: Report an issue tags: - issues - /api/v1/issues/{id}: - delete: - description: Deletes an issue report (admin only) - parameters: - - description: Issue ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Delete an issue - tags: - - issues - get: - description: Returns a single issue report by its ID (admin only) - parameters: - - description: Issue ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/handlers.issueRes' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get issue by ID - tags: - - issues - /api/v1/issues/{id}/status: - patch: - consumes: - - application/json - description: Updates the status of an issue (admin only) - parameters: - - description: Issue ID - in: path - name: id - required: true - type: integer - - description: Status update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateIssueStatusReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Update issue status - tags: - - issues /api/v1/issues/me: get: description: Returns paginated issues reported by the authenticated user @@ -6212,312 +10525,21 @@ paths: summary: Get my reported issues tags: - issues - /api/v1/issues/user/{user_id}: - get: - description: Returns paginated issues reported by a specific user (admin only) - parameters: - - description: User ID - in: path - name: user_id - required: true - type: integer - - default: 20 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/handlers.issueListRes' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + /api/v1/notifications: + delete: + responses: {} security: - Bearer: [] - summary: Get issues for a specific user + summary: DeleteUserNotifications tags: - - issues - /api/v1/lessons/{id}: - delete: - parameters: - - description: Lesson ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - lessons + - client get: - parameters: - - description: Lesson ID - in: path - name: id - required: true - type: integer responses: {} + security: + - Bearer: [] + summary: GetUserNotification tags: - - lessons - put: - parameters: - - description: Lesson ID - in: path - name: id - required: true - type: integer - - description: Fields to update - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateLessonInput' - responses: {} - tags: - - lessons - /api/v1/lessons/{id}/complete: - post: - description: Records lesson completion; may cascade to module, course, and program - progress for the authenticated user. Learners must meet sequential prerequisites; - staff bypass checks. - parameters: - - description: Lesson ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Mark a lesson as completed - tags: - - lessons - /api/v1/lessons/{id}/practices: - get: - parameters: - - description: Lesson ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - practices - /api/v1/lms/progress: - get: - description: Returns practice-based completed lesson, module, course, and program - IDs for the authenticated user (ordered by completion time, then id). - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get my LMS completion history - tags: - - lms - /api/v1/lms/progress-summary: - get: - description: Returns the learner's nested Learn English hierarchy (programs) - and exam-prep hierarchy (exam_prep) with the same access progress data exposed - on the individual content APIs. - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get my LMS and exam-prep progress summary - tags: - - lms - /api/v1/logs: - get: - description: Fetches application logs from MongoDB with pagination, level filtering, - and search - parameters: - - description: Filter logs by level (debug, info, warn, error, dpanic, panic, - fatal) - in: query - name: level - type: string - - description: Search term to match against message or fields - in: query - name: search - type: string - - default: 1 - description: 'Page number for pagination (default: 1)' - in: query - name: page - type: integer - - default: 50 - description: 'Number of items per page (default: 50, max: 100)' - in: query - name: limit - type: integer - produces: - - application/json - responses: - "200": - description: Paginated list of application logs - schema: - $ref: '#/definitions/domain.LogResponse' - "400": - description: Invalid request parameters - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal server error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Retrieve application logs with filtering and pagination - tags: - - Logs - /api/v1/modules/{id}: - delete: - parameters: - - description: Module ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - modules - get: - parameters: - - description: Module ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - tags: - - modules - put: - parameters: - - description: Module ID - in: path - name: id - required: true - type: integer - - description: Fields to update - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateModuleInput' - responses: {} - tags: - - modules - /api/v1/modules/{id}/practices: - get: - parameters: - - description: Module ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - practices - /api/v1/modules/{moduleId}/lessons: - get: - parameters: - - description: Module ID - in: path - name: moduleId - required: true - type: integer - - default: 20 - description: Page size - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - responses: {} - tags: - - lessons - post: - consumes: - - application/json - parameters: - - description: Module ID - in: path - name: moduleId - required: true - type: integer - - description: Lesson - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateLessonInput' - produces: - - application/json - responses: {} - summary: Create lesson - tags: - - lessons - /api/v1/modules/{moduleId}/lessons/reorder: - put: - parameters: - - description: Module ID - in: path - name: moduleId - required: true - type: integer - - description: 'ordered_ids: every lesson id in this module, in the new order' - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.ReorderIDsRequest' - responses: {} - summary: Reorder lessons within a module - tags: - - lessons + - client /api/v1/notifications/{id}: delete: description: Deletes one in-app notification owned by the authenticated user. @@ -6584,183 +10606,22 @@ paths: summary: Get in-app notification by ID tags: - notifications - /api/v1/notifications/bulk-email: - post: - consumes: - - multipart/form-data - description: Sends an email to specified user IDs, users of a platform role, - team member IDs, team members of a team_role, or direct email addresses with - optional image attachment. Optionally schedule for later with scheduled_at - (RFC3339). - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send bulk email + /api/v1/notifications/{id}/read: + patch: + responses: {} + security: + - Bearer: [] + summary: MarkNotificationAsRead tags: - - notifications - /api/v1/notifications/bulk-in-app: - post: - consumes: - - application/json - description: Creates in-app notifications for specified platform user IDs, users - matching a platform role, team member IDs, or team members matching a team_role. - Optionally schedule for later with scheduled_at (RFC3339). - parameters: - - description: Bulk in-app content - in: body - name: body - required: true - schema: - properties: - level: - type: string - message: - type: string - role: - type: string - scheduled_at: - type: string - team_member_ids: - items: - format: int64 - type: integer - type: array - team_role: - type: string - title: - type: string - type: - type: string - user_ids: - items: - format: int64 - type: integer - type: array - type: object - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send bulk in-app notification + - client + /api/v1/notifications/{id}/unread: + patch: + responses: {} + security: + - Bearer: [] + summary: MarkNotificationAsUnread tags: - - notifications - /api/v1/notifications/bulk-push: - post: - consumes: - - application/json - description: Sends a push notification to specified user IDs or all users matching - a role. Optionally schedule for later with scheduled_at (RFC3339). - parameters: - - description: Bulk push content - in: body - name: body - required: true - schema: - properties: - image: - type: string - message: - type: string - role: - type: string - scheduled_at: - type: string - title: - type: string - user_ids: - items: - format: int64 - type: integer - type: array - type: object - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send bulk push notification - tags: - - notifications - /api/v1/notifications/bulk-sms: - post: - consumes: - - application/json - description: Sends an SMS to specified user IDs, all users of a role, or direct - phone numbers. Optionally schedule for later with scheduled_at (RFC3339). - parameters: - - description: Bulk SMS content - in: body - name: body - required: true - schema: - properties: - message: - type: string - phone_numbers: - items: - type: string - type: array - role: - type: string - scheduled_at: - type: string - user_ids: - items: - format: int64 - type: integer - type: array - type: object - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send bulk SMS - tags: - - notifications + - client /api/v1/notifications/delete-in-app: post: consumes: @@ -6792,172 +10653,30 @@ paths: summary: Delete multiple in-app notifications tags: - notifications - /api/v1/notifications/scheduled: + /api/v1/notifications/mark-all-read: + post: + responses: {} + security: + - Bearer: [] + summary: MarkAllNotificationsAsRead + tags: + - client + /api/v1/notifications/mark-all-unread: + post: + responses: {} + security: + - Bearer: [] + summary: MarkAllNotificationsAsUnread + tags: + - client + /api/v1/notifications/unread: get: - description: Returns paginated scheduled notifications with optional status, - channel, and date filters - parameters: - - description: Filter by status - in: query - name: status - type: string - - description: Filter by channel - in: query - name: channel - type: string - - description: Filter after date (RFC3339) - in: query - name: after - type: string - - description: Filter before date (RFC3339) - in: query - name: before - type: string - - default: 20 - description: Page size - in: query - name: limit - type: integer - - default: 1 - description: Page number - in: query - name: page - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List scheduled notifications + responses: {} + security: + - Bearer: [] + summary: CountUnreadNotifications tags: - - notifications - /api/v1/notifications/scheduled/{id}: - get: - description: Returns a single scheduled notification by its ID - parameters: - - description: Scheduled Notification ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get scheduled notification - tags: - - notifications - /api/v1/notifications/scheduled/{id}/cancel: - post: - description: Cancels a scheduled notification if it is still pending or processing - parameters: - - description: Scheduled Notification ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Cancel scheduled notification - tags: - - notifications - /api/v1/notifications/send-email: - post: - consumes: - - multipart/form-data - description: Sends an email to a single email address with optional image attachment - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send single email - tags: - - notifications - /api/v1/notifications/test-push: - post: - consumes: - - application/json - description: Sends a test push notification to all registered devices of the - current user - parameters: - - description: Test notification content - in: body - name: body - required: true - schema: - properties: - message: - type: string - title: - type: string - type: object - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send test push notification - tags: - - notifications + - client /api/v1/payments: get: description: Returns the authenticated user's payment history @@ -7371,36 +11090,7 @@ paths: summary: List LMS personas (catalog for practice assignment) tags: - personas - post: - consumes: - - application/json - parameters: - - description: Persona - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateLmsPersonaInput' - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - summary: Create LMS persona catalog entry - tags: - - personas /api/v1/personas/{id}: - delete: - parameters: - - description: Persona ID - in: path - name: id - required: true - type: integer - responses: {} - summary: Delete LMS persona (practices referencing it will have persona_id cleared) - tags: - - personas get: parameters: - description: Persona ID @@ -7412,1133 +11102,6 @@ paths: summary: Get LMS persona by ID tags: - personas - put: - parameters: - - description: Persona ID - in: path - name: id - required: true - type: integer - - description: Fields to update - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateLmsPersonaInput' - responses: {} - summary: Update LMS persona - tags: - - personas - /api/v1/practices: - get: - parameters: - - description: Page size (default 20, max 200) - in: query - name: limit - type: integer - - description: Page offset (default 0) - in: query - name: offset - type: integer - - description: When true, return only practices with no parent links (admin) - in: query - name: unlinked_only - type: boolean - responses: {} - tags: - - practices - post: - consumes: - - application/json - parameters: - - description: Practice (optional parents; link later via PUT /practices/:id/parents) - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreatePracticeInput' - responses: {} - tags: - - practices - /api/v1/practices/{id}: - delete: - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - practices - get: - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - responses: {} - tags: - - practices - put: - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - - description: Practice metadata fields to update - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdatePracticeInput' - responses: {} - tags: - - practices - /api/v1/practices/{id}/full: - get: - description: Returns practice metadata, linked question set settings, and all - questions in the set (same shape as PUT /practices/{id}/full). - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get LMS practice with question set and questions - tags: - - practices - put: - consumes: - - application/json - description: Updates practice metadata, linked question set settings, and syncs - questions in one request. Questions omitted from the questions array are removed - from the set (not deleted from the bank). - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - - description: Full practice update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.FullUpdatePracticeInput' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Full update LMS practice with question set and questions - tags: - - practices - /api/v1/practices/{id}/parents: - put: - consumes: - - application/json - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - - description: Parent links (replaces all; use empty array to detach) - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdatePracticeParentsInput' - responses: {} - tags: - - practices - /api/v1/practices/{id}/parents/{parentKind}/{parentId}: - delete: - parameters: - - description: Practice ID - in: path - name: id - required: true - type: integer - - description: Parent kind (COURSE, MODULE, LESSON) - in: path - name: parentKind - required: true - type: string - - description: Parent entity ID - in: path - name: parentId - required: true - type: integer - responses: {} - tags: - - practices - /api/v1/practices/{practiceId}/questions: - get: - description: Returns paginated questions for an LMS practice, including shared - stimulus blocks and each question's effective dynamic payload - parameters: - - description: LMS practice ID - in: path - name: practiceId - required: true - type: integer - - description: Question type filter (e.g. AUDIO) - in: query - name: question_type - type: string - - default: 10 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get questions by practice - tags: - - question-set-items - /api/v1/programs: - get: - description: Paginated list of programs - parameters: - - default: 20 - description: Page size - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List programs - tags: - - programs - post: - consumes: - - application/json - description: Create a top-level LMS program. Optional sort_order inserts at - that global ordering; omit it to append after the current highest sort_order. - Unique constraint applies to sort_order. - parameters: - - description: Program - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateProgramInput' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create program - tags: - - programs - /api/v1/programs/{id}: - delete: - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete program - tags: - - programs - get: - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get program by ID - tags: - - programs - put: - consumes: - - application/json - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - - description: Fields to update - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateProgramInput' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update program - tags: - - programs - /api/v1/programs/{id}/courses: - get: - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - - default: 20 - description: Page size - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List courses by program - tags: - - courses - post: - consumes: - - application/json - description: Create a course under a program. Optional sort_order assigns position - within that program (siblings shifted); omit to append after the current highest - sort_order in the program. - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - - description: Course - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateCourseInput' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create course - tags: - - courses - /api/v1/programs/{id}/courses/reorder: - put: - parameters: - - description: Program ID - in: path - name: id - required: true - type: integer - - description: 'ordered_ids: every course id in this program, in the new order' - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.ReorderIDsRequest' - responses: {} - summary: Reorder courses within a program - tags: - - courses - /api/v1/programs/reorder: - put: - consumes: - - application/json - description: Sets learning order of programs. Body must list every current program - id exactly once, in the desired order (index 0 = first in path). - parameters: - - description: 'New order: ordered_ids is the full set of program ids' - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.ReorderIDsRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Reorder all programs - tags: - - programs - /api/v1/progress/practices/{id}/complete: - post: - description: Marks a practice question set as completed for the authenticated - learner - parameters: - - description: Practice Question Set ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Mark practice as completed - tags: - - progression - /api/v1/question-sets: - get: - description: Returns a paginated list of question sets filtered by type - parameters: - - description: Set type (PRACTICE, QUIZ, EXAM, SURVEY, CAPSTONE) - in: query - name: set_type - required: true - type: string - - default: 10 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get question sets by type - tags: - - question-sets - post: - consumes: - - application/json - description: Creates a new question set (practice, assessment, quiz, exam, or - survey) - parameters: - - description: Create question set payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.createQuestionSetReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create a new question set - tags: - - question-sets - /api/v1/question-sets/{id}: - delete: - description: Archives a question set (soft delete) - parameters: - - description: Question Set ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete a question set - tags: - - question-sets - get: - description: Returns a question set with question count - parameters: - - description: Question Set ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get question set by ID - tags: - - question-sets - put: - consumes: - - application/json - description: Updates a question set's properties - parameters: - - description: Question Set ID - in: path - name: id - required: true - type: integer - - description: Update question set payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateQuestionSetReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update a question set - tags: - - question-sets - /api/v1/question-sets/{setId}/personas: - get: - description: Returns all users assigned as personas to a question set (practice) - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get user personas for a question set - tags: - - question-sets - post: - consumes: - - application/json - description: Links a user as a persona to a question set (practice) - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - - description: Add user persona payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.addUserPersonaReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Add a user as persona to a question set - tags: - - question-sets - /api/v1/question-sets/{setId}/personas/{userId}: - delete: - description: Unlinks a user as persona from a question set (practice) - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - - description: User ID - in: path - name: userId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Remove a user persona from a question set - tags: - - question-sets - /api/v1/question-sets/{setId}/question-types: - get: - description: Returns distinct question type definitions (key, display_name, - counts) for non-archived questions in the set. Legacy stored question_type - values (e.g. AUDIO) are resolved to builder definitions when possible. - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List question types in a question set - tags: - - question-set-items - /api/v1/question-sets/{setId}/questions: - get: - description: Returns all questions in a question set with contextual shared - stimulus data for linked LMS and exam-prep practices - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get questions in set - tags: - - question-set-items - post: - consumes: - - application/json - description: Links a question to a question set. Omit display_order to append - after the current max; the assigned value is returned in the response. - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - - description: Add question to set payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.addQuestionToSetReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Add question to set - tags: - - question-set-items - /api/v1/question-sets/{setId}/questions/{questionId}: - delete: - description: Unlinks a question from a question set - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - - description: Question ID - in: path - name: questionId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Remove question from set - tags: - - question-set-items - /api/v1/question-sets/{setId}/questions/{questionId}/order: - put: - consumes: - - application/json - description: Updates the display order of a question in a set - parameters: - - description: Question Set ID - in: path - name: setId - required: true - type: integer - - description: Question ID - in: path - name: questionId - required: true - type: integer - - description: Update order payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateQuestionOrderReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update question order in set - tags: - - question-set-items - /api/v1/question-sets/by-owner: - get: - description: Returns question sets for a specific owner (e.g., sub-course) - parameters: - - description: Owner type (SUB_COURSE, COURSE, CATEGORY, STANDALONE) - in: query - name: owner_type - required: true - type: string - - description: Owner ID - in: query - name: owner_id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get question sets by owner - tags: - - question-sets - /api/v1/questions: - get: - description: Returns a paginated list of questions with optional filters - parameters: - - description: Question type filter (MCQ, TRUE_FALSE, SHORT_ANSWER) - in: query - name: question_type - type: string - - description: Difficulty level filter (EASY, MEDIUM, HARD) - in: query - name: difficulty - type: string - - description: Status filter (DRAFT, PUBLISHED, INACTIVE) - in: query - name: status - type: string - - default: 10 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List questions - tags: - - questions - post: - consumes: - - application/json - description: Creates a new question with options (for MCQ/TRUE_FALSE) or short - answers (for SHORT_ANSWER). DYNAMIC questions must not send question_text; - use dynamic_payload stimulus instead. Legacy types require question_text. - parameters: - - description: Create question payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.createQuestionReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create a new question - tags: - - questions - /api/v1/questions/{id}: - delete: - description: Archives a question (soft delete) - parameters: - - description: Question ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete a question - tags: - - questions - get: - description: Returns a question with its options/short answers - parameters: - - description: Question ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get question by ID - tags: - - questions - put: - consumes: - - application/json - description: Updates a question and optionally replaces its options/short answers. - Supports question_type_definition_id for dynamic builder-linked questions. - parameters: - - description: Question ID - in: path - name: id - required: true - type: integer - - description: Update question payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateQuestionReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update a question - tags: - - questions /api/v1/questions/audio-answer: post: consumes: @@ -8567,390 +11130,6 @@ paths: summary: Submit audio answer for a question tags: - questions - /api/v1/questions/component-catalog: - get: - description: Valid stimulus and response component kind codes for dynamic question-type - definitions - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Question-type builder component catalog - tags: - - questions - /api/v1/questions/search: - get: - description: Search questions by text - parameters: - - description: Search query - in: query - name: q - required: true - type: string - - default: 10 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Search questions - tags: - - questions - /api/v1/questions/type-definition-groups: - get: - parameters: - - description: Filter by status (ACTIVE, INACTIVE) - in: query - name: status - type: string - - default: 20 - description: Page size (default 20, max 200) - in: query - name: limit - type: integer - - default: 0 - description: Page offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: List question type definition groups - tags: - - questions - post: - consumes: - - application/json - parameters: - - description: Group payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.createQuestionTypeDefinitionGroupReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - summary: Create question type definition group - tags: - - questions - /api/v1/questions/type-definition-groups/{id}: - delete: - parameters: - - description: Group id - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Delete question type definition group - tags: - - questions - get: - parameters: - - description: Group id - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get question type definition group with definitions - tags: - - questions - put: - consumes: - - application/json - parameters: - - description: Group id - in: path - name: id - required: true - type: integer - - description: Update group payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateQuestionTypeDefinitionGroupReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Update question type definition group - tags: - - questions - /api/v1/questions/type-definitions: - get: - parameters: - - description: Filter by status (ACTIVE, INACTIVE) - in: query - name: status - type: string - - default: true - description: Include system seeded definitions - in: query - name: include_system - type: boolean - - default: 20 - description: Page size (default 20, max 200) - in: query - name: limit - type: integer - - default: 0 - description: Page offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List reusable question-type definitions - tags: - - questions - post: - consumes: - - application/json - description: Stores a reusable dynamic question-type definition for future question - construction. Only runtime-mappable definitions are persisted. - parameters: - - description: Question type definition payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.createQuestionTypeDefinitionReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create reusable question-type definition - tags: - - questions - /api/v1/questions/type-definitions/{id}: - delete: - parameters: - - description: Question type definition id - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete reusable question-type definition - tags: - - questions - get: - parameters: - - description: Question type definition id - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get reusable question-type definition by id - tags: - - questions - put: - consumes: - - application/json - description: Updates a reusable dynamic question-type definition. Updated definitions - must remain runtime-mappable. - parameters: - - description: Question type definition id - in: path - name: id - required: true - type: integer - - description: Update question type definition payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updateQuestionTypeDefinitionReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update reusable question-type definition - tags: - - questions - /api/v1/questions/type-definitions/{id}/practices: - get: - description: Returns LMS and exam-prep practices whose linked question set contains - at least one non-archived question matching the definition (by question_type_definition_id - or legacy question_type). - parameters: - - description: Question type definition id - in: path - name: id - required: true - type: integer - - default: 20 - description: Limit - in: query - name: limit - type: integer - - default: 0 - description: Offset - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List practices globally by question type definition - tags: - - questions - /api/v1/questions/validate-question-type-definition: - post: - consumes: - - application/json - description: Validates selected stimulus and response component kinds for temporary - question-type definitions (component-level validation only) - parameters: - - description: Stimulus and response component kinds - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.validateQuestionTypeDefinitionReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Validate dynamic question-type definition - tags: - - questions /api/v1/ratings: get: description: Returns paginated ratings for a specific target @@ -9132,367 +11311,51 @@ paths: summary: Get rating summary for a target tags: - ratings - /api/v1/rbac/permissions: + /api/v1/referrals: get: - consumes: - - application/json - description: Get all permissions in the system grouped by group name - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - items: - $ref: '#/definitions/domain.Permission' - type: array - type: object - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + responses: {} security: - Bearer: [] - summary: List all permissions + summary: ListMyReferrals tags: - - rbac - /api/v1/rbac/permissions/groups: - get: - consumes: - - application/json - description: Get all distinct permission group names - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - items: - type: string - type: array - type: object - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: List permission groups - tags: - - rbac - /api/v1/rbac/permissions/sync: + - client + /api/v1/referrals/apply: post: - consumes: - - application/json - description: Re-seed permissions from code and reload the RBAC cache - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + responses: {} security: - Bearer: [] - summary: Sync permissions + summary: ApplyReferralCode tags: - - rbac - /api/v1/rbac/roles: + - client + /api/v1/referrals/code: get: - consumes: - - application/json - description: Get all roles with optional filters - parameters: - - description: Search by role name - in: query - name: query - type: string - - description: Filter by system role (true/false) - in: query - name: is_system - type: boolean - - description: 'Page number (default: 1)' - in: query - name: page - type: integer - - description: 'Page size (default: 20)' - in: query - name: page_size - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + responses: {} security: - Bearer: [] - summary: List all roles + summary: GetReferralCode tags: - - rbac + - client post: - consumes: - - application/json - description: Create a new role with a name and description - parameters: - - description: Role creation payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateRoleReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.RoleRecord' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Create a new role + responses: {} + summary: CreateReferralCode tags: - - rbac - /api/v1/rbac/roles/{id}: - delete: - consumes: - - application/json - description: Delete a non-system role by ID - parameters: - - description: Role ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Delete a role - tags: - - rbac + - client + /api/v1/referrals/me: get: - consumes: - - application/json - description: Get a role and its permissions by ID - parameters: - - description: Role ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.RoleWithPermissions' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + responses: {} security: - Bearer: [] - summary: Get a role by ID + summary: GetMyReferrals tags: - - rbac - put: - consumes: - - application/json - description: Update an existing role's name and description - parameters: - - description: Role ID - in: path - name: id - required: true - type: integer - - description: Role update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateRoleReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Update a role - tags: - - rbac - /api/v1/rbac/roles/{id}/permissions: + - client + /api/v1/referrals/wallet: get: - consumes: - - application/json - description: Get all permissions assigned to a role - parameters: - - description: Role ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - items: - $ref: '#/definitions/domain.Permission' - type: array - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' + responses: {} security: - Bearer: [] - summary: Get permissions for a role + summary: GetReferralWallet tags: - - rbac - put: - consumes: - - application/json - description: Replace all permissions for a role with the given permission IDs - parameters: - - description: Role ID - in: path - name: id - required: true - type: integer - - description: Permission IDs payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.SetRolePermissionsReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Set permissions for a role - tags: - - rbac - /api/v1/sendSMS: - post: - consumes: - - application/json - description: Sends an SMS message to a single phone number using AfroMessage - parameters: - - description: Send SMS request - in: body - name: sendSMS - required: true - schema: - $ref: '#/definitions/handlers.SendSingleAfroSMSReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Send single SMS via AfroMessage - tags: - - user + - client /api/v1/subscription-plans: get: description: 'Returns subscription plans. Optional category filter: EDUCATION.' @@ -9523,58 +11386,7 @@ paths: summary: List subscription plans tags: - subscriptions - post: - consumes: - - application/json - description: Creates a new subscription plan (admin only) - parameters: - - description: Create plan payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.createPlanReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create a subscription plan - tags: - - subscriptions /api/v1/subscription-plans/{id}: - delete: - description: Deletes a subscription plan (admin only) - parameters: - - description: Plan ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete a subscription plan - tags: - - subscriptions get: description: Returns a single subscription plan by ID parameters: @@ -9597,40 +11409,6 @@ paths: summary: Get a subscription plan tags: - subscriptions - put: - consumes: - - application/json - description: Updates a subscription plan (admin only) - parameters: - - description: Plan ID - in: path - name: id - required: true - type: integer - - description: Update plan payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.updatePlanReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Update a subscription plan - tags: - - subscriptions /api/v1/subscriptions: post: consumes: @@ -9842,916 +11620,6 @@ paths: summary: Check subscription status tags: - subscriptions - /api/v1/super-login: - post: - consumes: - - application/json - description: Login super-admin - parameters: - - description: Login super-admin - in: body - name: login - required: true - schema: - $ref: '#/definitions/domain.LoginRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.LoginAdminRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Login super-admin - tags: - - auth - /api/v1/t-approver/{id}: - get: - consumes: - - application/json - description: Get a single admin by id - parameters: - - description: User ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.AdminRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Get admin by id - tags: - - admin - put: - consumes: - - application/json - description: Update Admin - parameters: - - description: Update Admin - in: body - name: admin - required: true - schema: - $ref: '#/definitions/handlers.updateAdminReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Update Admin - tags: - - admin - /api/v1/team/invitations: - get: - description: Lists team member invitations with optional status filter - parameters: - - description: pending, accepted, expired, or revoked - in: query - name: status - type: string - - description: Limit (default 20) - in: query - name: limit - type: integer - - description: Offset (default 0) - in: query - name: offset - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: List team invitations - tags: - - team - /api/v1/team/invitations/{id}/revoke: - post: - description: Revokes the invitation and removes the pending team member if not - yet accepted - parameters: - - description: Invitation ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Revoke a pending team invitation - tags: - - team - /api/v1/team/invitations/accept: - post: - consumes: - - application/json - description: Public endpoint to set password and profile details after following - the invite link - parameters: - - description: Accept invitation payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.AcceptTeamInvitationReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Accept team invitation and complete account setup - tags: - - team - /api/v1/team/invitations/verify: - get: - description: Public endpoint used by the admin panel accept-invite page - parameters: - - description: Invitation token - in: query - name: token - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Verify team invitation token - tags: - - team - /api/v1/team/login: - post: - consumes: - - application/json - description: Authenticate a team member (internal staff) with email and password - parameters: - - description: Team member login credentials - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.TeamMemberLoginReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/handlers.teamMemberLoginRes' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Login team member - tags: - - team - /api/v1/team/me: - get: - consumes: - - application/json - description: Get the authenticated team member's own profile - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.TeamMemberResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get my team profile - tags: - - team - put: - consumes: - - application/json - description: Update the authenticated team member's own profile fields - parameters: - - description: Profile update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateMyTeamProfileReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.TeamMemberResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Update my team profile - tags: - - team - /api/v1/team/members: - get: - consumes: - - application/json - description: Get a paginated list of team members with optional filtering - parameters: - - description: Filter by team role (super_admin, admin, content_manager, support_agent, - instructor, finance, hr, analyst) - in: query - name: team_role - type: string - - description: Filter by department - in: query - name: department - type: string - - description: Filter by status (active, inactive, suspended, terminated) - in: query - name: status - type: string - - description: Search by name, email, or phone number - in: query - name: search - type: string - - description: 'Page number (default: 1)' - in: query - name: page - type: integer - - description: 'Items per page (default: 10, max: 100)' - in: query - name: page_size - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - items: - $ref: '#/definitions/domain.TeamMemberResponse' - type: array - metadata: - $ref: '#/definitions/domain.Pagination' - type: object - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: List all team members - tags: - - team - post: - consumes: - - application/json - description: Create a new internal team member (admin only) - parameters: - - description: Team member creation payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.CreateTeamMemberReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.TeamMemberResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Create a new team member - tags: - - team - /api/v1/team/members/{id}: - delete: - consumes: - - application/json - description: Delete a team member (super admin only) - parameters: - - description: Team Member ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Delete team member - tags: - - team - get: - consumes: - - application/json - description: Retrieve a team member's details by their ID - parameters: - - description: Team Member ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.TeamMemberResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get team member by ID - tags: - - team - put: - consumes: - - application/json - description: Update an existing team member's details (admin only) - parameters: - - description: Team Member ID - in: path - name: id - required: true - type: integer - - description: Team member update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateTeamMemberReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Update team member - tags: - - team - /api/v1/team/members/{id}/change-password: - post: - consumes: - - application/json - description: Change a team member's password (requires current password) - parameters: - - description: Team Member ID - in: path - name: id - required: true - type: integer - - description: Password change payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.changePasswordReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Change team member password - tags: - - team - /api/v1/team/members/{id}/resend-invite: - post: - description: Revokes the current pending invite and sends a new invitation email - parameters: - - description: Team member ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Resend team invitation - tags: - - team - /api/v1/team/members/{id}/status: - patch: - consumes: - - application/json - description: Update a team member's status (active, inactive, suspended, terminated) - parameters: - - description: Team Member ID - in: path - name: id - required: true - type: integer - - description: Status update payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateTeamMemberStatusReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Update team member status - tags: - - team - /api/v1/team/members/export: - get: - produces: - - text/csv - responses: {} - summary: Export team members as CSV (admin) - tags: - - team - /api/v1/team/members/invite: - post: - consumes: - - application/json - description: Creates a pending team member (email + team_role only) and sends - an invitation email; profile is completed on accept - parameters: - - description: Invite payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.InviteTeamMemberReq' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Invite a team member by email - tags: - - team - /api/v1/team/refresh: - post: - consumes: - - application/json - description: Exchanges a valid team refresh token for a new access JWT and a - rotated refresh token (use only tokens from POST /team/login or this endpoint). - parameters: - - description: Current refresh token - in: body - name: body - required: true - schema: - $ref: '#/definitions/handlers.teamMemberRefreshReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/handlers.teamMemberLoginRes' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Refresh team member tokens - tags: - - team - /api/v1/team/resetPassword: - post: - consumes: - - application/json - description: Completes team password reset using email + OTP from the reset - link. Public. - parameters: - - description: Reset payload - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.TeamResetPasswordReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Reset team member password - tags: - - team - /api/v1/team/sendResetCode: - post: - consumes: - - application/json - description: Sends a password-reset email with a link to the team member (admin - panel). Public. - parameters: - - description: Email - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.TeamSendPasswordResetReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Send team password reset link - tags: - - team - /api/v1/team/stats: - get: - consumes: - - application/json - description: Get statistics about team members by status - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.TeamMemberStats' - type: object - "401": - description: Unauthorized - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get team member statistics - tags: - - team - /api/v1/team/verifyResetCode: - get: - description: Checks whether email+otp from a reset link are still valid without - consuming the OTP. Public. - parameters: - - description: Team member email - in: query - name: email - required: true - type: string - - description: Reset OTP from the email link - in: query - name: otp - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - summary: Verify team password reset link - tags: - - team - /api/v1/tenant: - get: - consumes: - - application/json - description: Check if phone number or email exist - parameters: - - description: Check phone number or email exist - in: body - name: checkPhoneEmailExist - required: true - schema: - $ref: '#/definitions/handlers.CheckPhoneEmailExistReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.CheckPhoneEmailExistRes' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Check if phone number or email exist - tags: - - user /api/v1/user: put: consumes: @@ -10827,39 +11695,6 @@ paths: summary: Upload profile picture tags: - user - /api/v1/user/{user_id}/is-pending: - get: - consumes: - - application/json - description: Returns whether the specified user has a status of "pending" - parameters: - - description: User ID - in: path - name: user_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Check if user status is pending - tags: - - user /api/v1/user/{user_id}/is-profile-completed: get: consumes: @@ -10894,24 +11729,58 @@ paths: summary: Check if user profile is completed tags: - user - /api/v1/user/delete/{id}: - delete: + /api/v1/user/{user_name}/is-pending: + get: consumes: - application/json - description: Delete a user by their ID + description: Returns whether the specified user has a status of "pending" parameters: - description: User ID in: path - name: id + name: user_id required: true - type: integer + type: string produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/response.APIResponse' + $ref: '#/definitions/domain.Response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.ErrorResponse' + "404": + description: Not Found + schema: + $ref: '#/definitions/domain.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.ErrorResponse' + summary: Check if user status is pending + tags: + - user + /api/v1/user/checkPhoneEmailExist: + post: + consumes: + - application/json + description: Check if phone number or email exist + parameters: + - description: Check phone number or email exist + in: body + name: checkPhoneEmailExist + required: true + schema: + $ref: '#/definitions/handlers.CheckPhoneEmailExistReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handlers.CheckPhoneEmailExistRes' "400": description: Bad Request schema: @@ -10920,7 +11789,7 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/response.APIResponse' - summary: Delete user by ID + summary: Check if phone number or email exist tags: - user /api/v1/user/knowledge-level: @@ -11015,6 +11884,66 @@ paths: summary: Cancel my account deletion request tags: - user + /api/v1/user/register: + post: + consumes: + - application/json + description: Register user + parameters: + - description: Register user + in: body + name: registerUser + required: true + schema: + $ref: '#/definitions/domain.RegisterUserReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Register user + tags: + - user + /api/v1/user/resend-otp: + post: + consumes: + - application/json + description: Resend OTP if the previous one is expired + parameters: + - description: Resend OTP + in: body + name: resendOtp + required: true + schema: + $ref: '#/definitions/domain.ResendOtpReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/response.APIResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + summary: Resend OTP + tags: + - otp /api/v1/user/resetPassword: post: consumes: @@ -11045,25 +11974,25 @@ paths: summary: Reset password tags: - user - /api/v1/user/search: + /api/v1/user/sendRegisterCode: post: consumes: - application/json - description: Search for user using name or phone + description: Send register code parameters: - - description: Search for using his name or phone + - description: Send register code in: body - name: searchUserByNameOrPhone + name: registerCode required: true schema: - $ref: '#/definitions/handlers.SearchUserByNameOrPhoneReq' + $ref: '#/definitions/handlers.RegisterCodeReq' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.UserProfileResponse' + $ref: '#/definitions/response.APIResponse' "400": description: Bad Request schema: @@ -11072,7 +12001,7 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/response.APIResponse' - summary: Search for user using name or phone + summary: Send register code tags: - user /api/v1/user/sendResetCode: @@ -11106,17 +12035,11 @@ paths: summary: Send reset code tags: - user - /api/v1/user/single/{id}: + /api/v1/user/user-profile: get: consumes: - application/json - description: Get a single user by id - parameters: - - description: User ID - in: path - name: id - required: true - type: integer + description: Get user profile produces: - application/json responses: @@ -11128,45 +12051,13 @@ paths: description: Bad Request schema: $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.APIResponse' "500": description: Internal Server Error schema: $ref: '#/definitions/response.APIResponse' - summary: Get user by id - tags: - - user - /api/v1/user/status: - patch: - consumes: - - application/json - description: Activates, deactivates, or suspends a user account - parameters: - - description: Status update payload - in: body - name: body - required: true - schema: - type: object - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Update user status + security: + - Bearer: [] + summary: Get user profile tags: - user /api/v1/user/verify-otp: @@ -11199,149 +12090,6 @@ paths: summary: Verify OTP tags: - user - /api/v1/users: - get: - consumes: - - application/json - description: 'Get users with optional filters. Each user includes subscription_status: - ACTIVE, PENDING, or Unsubscribed.' - parameters: - - description: Role filter - in: query - name: role - type: string - - description: Search query - in: query - name: query - type: string - - description: Page number - in: query - name: page - type: integer - - description: Page size - in: query - name: page_size - type: integer - - description: Created before (RFC3339) - in: query - name: created_before - type: string - - description: Created after (RFC3339) - in: query - name: created_after - type: string - - description: User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, - or INACTIVE for all non-ACTIVE statuses) - in: query - name: status - type: string - - description: Country filter (case-insensitive match on stored value) - in: query - name: country - type: string - - description: Region filter (case-insensitive match on stored value) - in: query - name: region - type: string - - description: 'Derived subscription filter: ACTIVE, PENDING, or Unsubscribed - (matches response subscription_status semantics)' - in: query - name: subscription_status - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.APIResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.APIResponse' - summary: Get all users - tags: - - user - /api/v1/users/export: - get: - produces: - - text/csv - responses: {} - summary: Export users as CSV (admin) - tags: - - user - /api/v1/users/summary: - get: - consumes: - - application/json - description: Returns total users, active users, and users who joined this month - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.UserSummary' - type: object - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - security: - - Bearer: [] - summary: Get user summary statistics - tags: - - user - /api/v1/videos/engagement/heartbeat: - post: - consumes: - - application/json - description: Records playback position for analytics (completion, replay, and - drop-off). Send periodic heartbeats while watching; set ended=true when the - viewer leaves. A new session starts after 30 minutes of inactivity or when - ended=true on the prior session. - parameters: - - description: Playback heartbeat - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.VideoEngagementHeartbeatInput' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - $ref: '#/definitions/domain.VideoWatchSessionResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "403": - description: Forbidden - schema: - $ref: '#/definitions/domain.ErrorResponse' - "404": - description: Not Found - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Report video playback progress - tags: - - videos /api/v1/vimeo/oembed: get: consumes: @@ -11415,303 +12163,18 @@ paths: summary: Get a sample Vimeo video with iframe embed tags: - Vimeo - /api/v1/vimeo/uploads/pull: - post: - consumes: - - application/json - description: Initiates a pull upload where Vimeo fetches the video from a URL - parameters: - - description: Pull Upload Request - in: body - name: request - required: true - schema: - $ref: '#/definitions/handlers.CreatePullUploadRequest' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/handlers.VimeoUploadResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create a pull upload to Vimeo - tags: - - Vimeo - /api/v1/vimeo/uploads/tus: - post: - consumes: - - application/json - description: Initiates a TUS resumable upload and returns the upload link - parameters: - - description: TUS Upload Request - in: body - name: request - required: true - schema: - $ref: '#/definitions/handlers.CreateTusUploadRequest' - produces: - - application/json - responses: - "201": - description: Created - schema: - $ref: '#/definitions/handlers.VimeoUploadResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Create a TUS resumable upload to Vimeo - tags: - - Vimeo - /api/v1/vimeo/videos: + /api/v1/ws/connect: get: - consumes: - - application/json - description: Returns a paginated list of videos for the Vimeo API token (GET - https://api.vimeo.com/me/videos) parameters: - - default: 1 - description: Page number (starts at 1) + - description: Access token in: query - name: page - type: integer - - default: 25 - description: Page size (Vimeo max 100) - in: query - name: per_page - type: integer - - description: Search query - in: query - name: query - type: string - - description: Sort field (e.g. date, alphabetical, plays, likes, comments, - duration, relevance) - in: query - name: sort - type: string - - description: asc or desc - in: query - name: direction - type: string - - description: Vimeo filter (e.g. embeddable, playable) - in: query - name: filter - type: string - - description: Vimeo filter_type when using filter - in: query - name: filter_type - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/domain.Response' - - properties: - data: - items: - $ref: '#/definitions/handlers.VimeoVideoResponse' - type: array - metadata: - $ref: '#/definitions/handlers.VimeoVideosListMetadata' - type: object - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - "503": - description: Service Unavailable - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: List videos stored in the Vimeo account - tags: - - Vimeo - /api/v1/vimeo/videos/{video_id}: - delete: - consumes: - - application/json - description: Deletes a video from the Vimeo account - parameters: - - description: Vimeo Video ID - in: path - name: video_id + name: token required: true type: string - produces: - - application/json - responses: - "204": - description: No Content - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Delete a video from Vimeo + responses: {} + summary: ConnectSocket tags: - - Vimeo - get: - consumes: - - application/json - description: Retrieves video details from Vimeo by video ID - parameters: - - description: Vimeo Video ID - in: path - name: video_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.VimeoVideoResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get video information from Vimeo - tags: - - Vimeo - /api/v1/vimeo/videos/{video_id}/embed: - get: - consumes: - - application/json - description: Generates an embeddable player iframe for the video - parameters: - - description: Vimeo Video ID - in: path - name: video_id - required: true - type: string - - default: 640 - description: Player width - in: query - name: width - type: integer - - default: 360 - description: Player height - in: query - name: height - type: integer - - description: Autoplay video - in: query - name: autoplay - type: boolean - - description: Loop video - in: query - name: loop - type: boolean - - description: Mute video - in: query - name: muted - type: boolean - - description: Background mode (no controls) - in: query - name: background - type: boolean - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/handlers.VimeoEmbedResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get embed code for a Vimeo video - tags: - - Vimeo - /api/v1/vimeo/videos/{video_id}/status: - get: - consumes: - - application/json - description: Returns the current transcoding status of a video - parameters: - - description: Vimeo Video ID - in: path - name: video_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - additionalProperties: - type: string - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.ErrorResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.ErrorResponse' - summary: Get transcode status of a Vimeo video - tags: - - Vimeo - /payment/success: - get: - description: Displays the Rezina success page after Chapa redirects the learner - to return_url - parameters: - - description: Chapa transaction reference (tx_ref) - in: query - name: trx_ref - type: string - - description: Chapa transaction reference - in: query - name: tx_ref - type: string - - description: Chapa reference ID - in: query - name: ref_id - type: string - - description: Payment status from Chapa redirect - in: query - name: status - type: string - produces: - - text/html - responses: - "200": - description: HTML success page - schema: - type: string - summary: Chapa payment success page - tags: - - payments + - client securityDefinitions: Bearer: in: header diff --git a/gen/db/notification.sql.go b/gen/db/notification.sql.go index 54c7bc23..6094348e 100644 --- a/gen/db/notification.sql.go +++ b/gen/db/notification.sql.go @@ -15,11 +15,17 @@ const CountUnreadNotifications = `-- name: CountUnreadNotifications :one SELECT COUNT(*) FROM notifications WHERE user_id = $1 + AND receiver_type = $2 AND is_read = FALSE ` -func (q *Queries) CountUnreadNotifications(ctx context.Context, userID int64) (int64, error) { - row := q.db.QueryRow(ctx, CountUnreadNotifications, userID) +type CountUnreadNotificationsParams struct { + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` +} + +func (q *Queries) CountUnreadNotifications(ctx context.Context, arg CountUnreadNotificationsParams) (int64, error) { + row := q.db.QueryRow(ctx, CountUnreadNotifications, arg.UserID, arg.ReceiverType) var count int64 err := row.Scan(&count) return count, err @@ -92,17 +98,19 @@ func (q *Queries) CreateNotification(ctx context.Context, arg CreateNotification const DeleteUserInAppNotification = `-- name: DeleteUserInAppNotification :execrows DELETE FROM notifications WHERE id = $1 + AND receiver_type = $3 AND user_id = $2 AND channel = 'in_app' ` type DeleteUserInAppNotificationParams struct { - ID int64 `json:"id"` - UserID int64 `json:"user_id"` + ID int64 `json:"id"` + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` } func (q *Queries) DeleteUserInAppNotification(ctx context.Context, arg DeleteUserInAppNotificationParams) (int64, error) { - result, err := q.db.Exec(ctx, DeleteUserInAppNotification, arg.ID, arg.UserID) + result, err := q.db.Exec(ctx, DeleteUserInAppNotification, arg.ID, arg.UserID, arg.ReceiverType) if err != nil { return 0, err } @@ -112,17 +120,19 @@ func (q *Queries) DeleteUserInAppNotification(ctx context.Context, arg DeleteUse const DeleteUserInAppNotificationsByIDs = `-- name: DeleteUserInAppNotificationsByIDs :execrows DELETE FROM notifications WHERE user_id = $1 + AND receiver_type = $3 AND channel = 'in_app' AND id = ANY($2::BIGINT[]) ` type DeleteUserInAppNotificationsByIDsParams struct { - UserID int64 `json:"user_id"` - Column2 []int64 `json:"column_2"` + UserID int64 `json:"user_id"` + Column2 []int64 `json:"column_2"` + ReceiverType string `json:"receiver_type"` } func (q *Queries) DeleteUserInAppNotificationsByIDs(ctx context.Context, arg DeleteUserInAppNotificationsByIDsParams) (int64, error) { - result, err := q.db.Exec(ctx, DeleteUserInAppNotificationsByIDs, arg.UserID, arg.Column2) + result, err := q.db.Exec(ctx, DeleteUserInAppNotificationsByIDs, arg.UserID, arg.Column2, arg.ReceiverType) if err != nil { return 0, err } @@ -132,10 +142,16 @@ func (q *Queries) DeleteUserInAppNotificationsByIDs(ctx context.Context, arg Del const DeleteUserNotifications = `-- name: DeleteUserNotifications :exec DELETE FROM notifications WHERE user_id = $1 + AND receiver_type = $2 ` -func (q *Queries) DeleteUserNotifications(ctx context.Context, userID int64) error { - _, err := q.db.Exec(ctx, DeleteUserNotifications, userID) +type DeleteUserNotificationsParams struct { + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` +} + +func (q *Queries) DeleteUserNotifications(ctx context.Context, arg DeleteUserNotificationsParams) error { + _, err := q.db.Exec(ctx, DeleteUserNotifications, arg.UserID, arg.ReceiverType) return err } @@ -329,10 +345,16 @@ const GetUserNotificationCount = `-- name: GetUserNotificationCount :one SELECT COUNT(*) FROM notifications WHERE user_id = $1 + AND receiver_type = $2 ` -func (q *Queries) GetUserNotificationCount(ctx context.Context, userID int64) (int64, error) { - row := q.db.QueryRow(ctx, GetUserNotificationCount, userID) +type GetUserNotificationCountParams struct { + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` +} + +func (q *Queries) GetUserNotificationCount(ctx context.Context, arg GetUserNotificationCountParams) (int64, error) { + row := q.db.QueryRow(ctx, GetUserNotificationCount, arg.UserID, arg.ReceiverType) var count int64 err := row.Scan(&count) return count, err @@ -342,18 +364,25 @@ const GetUserNotifications = `-- name: GetUserNotifications :many SELECT id, user_id, type, level, channel, title, message, payload, is_read, created_at, read_at, receiver_type FROM notifications WHERE user_id = $1 + AND receiver_type = $4 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetUserNotificationsParams struct { - UserID int64 `json:"user_id"` - Limit int32 `json:"limit"` - Offset int32 `json:"offset"` + UserID int64 `json:"user_id"` + Limit int32 `json:"limit"` + Offset int32 `json:"offset"` + ReceiverType string `json:"receiver_type"` } func (q *Queries) GetUserNotifications(ctx context.Context, arg GetUserNotificationsParams) ([]Notification, error) { - rows, err := q.db.Query(ctx, GetUserNotifications, arg.UserID, arg.Limit, arg.Offset) + rows, err := q.db.Query(ctx, GetUserNotifications, + arg.UserID, + arg.Limit, + arg.Offset, + arg.ReceiverType, + ) if err != nil { return nil, err } @@ -390,11 +419,17 @@ UPDATE notifications SET is_read = TRUE, read_at = NOW() WHERE user_id = $1 + AND receiver_type = $2 AND is_read = FALSE ` -func (q *Queries) MarkAllUserNotificationsAsRead(ctx context.Context, userID int64) error { - _, err := q.db.Exec(ctx, MarkAllUserNotificationsAsRead, userID) +type MarkAllUserNotificationsAsReadParams struct { + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` +} + +func (q *Queries) MarkAllUserNotificationsAsRead(ctx context.Context, arg MarkAllUserNotificationsAsReadParams) error { + _, err := q.db.Exec(ctx, MarkAllUserNotificationsAsRead, arg.UserID, arg.ReceiverType) return err } @@ -403,11 +438,17 @@ UPDATE notifications SET is_read = FALSE, read_at = NULL WHERE user_id = $1 + AND receiver_type = $2 AND is_read = TRUE ` -func (q *Queries) MarkAllUserNotificationsAsUnread(ctx context.Context, userID int64) error { - _, err := q.db.Exec(ctx, MarkAllUserNotificationsAsUnread, userID) +type MarkAllUserNotificationsAsUnreadParams struct { + UserID int64 `json:"user_id"` + ReceiverType string `json:"receiver_type"` +} + +func (q *Queries) MarkAllUserNotificationsAsUnread(ctx context.Context, arg MarkAllUserNotificationsAsUnreadParams) error { + _, err := q.db.Exec(ctx, MarkAllUserNotificationsAsUnread, arg.UserID, arg.ReceiverType) return err } @@ -416,11 +457,18 @@ UPDATE notifications SET is_read = TRUE, read_at = NOW() WHERE id = $1 + AND receiver_type = $2 AND user_id = $3 RETURNING id, user_id, type, level, channel, title, message, payload, is_read, created_at, read_at, receiver_type ` -func (q *Queries) MarkNotificationAsRead(ctx context.Context, id int64) (Notification, error) { - row := q.db.QueryRow(ctx, MarkNotificationAsRead, id) +type MarkNotificationAsReadParams struct { + ID int64 `json:"id"` + ReceiverType string `json:"receiver_type"` + RequesterID int64 `json:"requester_id"` +} + +func (q *Queries) MarkNotificationAsRead(ctx context.Context, arg MarkNotificationAsReadParams) (Notification, error) { + row := q.db.QueryRow(ctx, MarkNotificationAsRead, arg.ID, arg.ReceiverType, arg.RequesterID) var i Notification err := row.Scan( &i.ID, @@ -444,11 +492,18 @@ UPDATE notifications SET is_read = FALSE, read_at = NULL WHERE id = $1 + AND receiver_type = $2 AND user_id = $3 RETURNING id, user_id, type, level, channel, title, message, payload, is_read, created_at, read_at, receiver_type ` -func (q *Queries) MarkNotificationAsUnread(ctx context.Context, id int64) (Notification, error) { - row := q.db.QueryRow(ctx, MarkNotificationAsUnread, id) +type MarkNotificationAsUnreadParams struct { + ID int64 `json:"id"` + ReceiverType string `json:"receiver_type"` + RequesterID int64 `json:"requester_id"` +} + +func (q *Queries) MarkNotificationAsUnread(ctx context.Context, arg MarkNotificationAsUnreadParams) (Notification, error) { + row := q.db.QueryRow(ctx, MarkNotificationAsUnread, arg.ID, arg.ReceiverType, arg.RequesterID) var i Notification err := row.Scan( &i.ID, diff --git a/internal/domain/notification_scope.go b/internal/domain/notification_scope.go new file mode 100644 index 00000000..eadb3c69 --- /dev/null +++ b/internal/domain/notification_scope.go @@ -0,0 +1,19 @@ +package domain + +import "context" + +type NotificationScope struct { + UserID int64 + ReceiverType ReceiverType +} +type notificationScopeKey struct{} + +func WithNotificationScope(ctx context.Context, userID int64, receiver ReceiverType) context.Context { + return context.WithValue(ctx, notificationScopeKey{}, NotificationScope{UserID: userID, ReceiverType: receiver}) +} +func NotificationScopeFromContext(ctx context.Context) NotificationScope { + if scope, ok := ctx.Value(notificationScopeKey{}).(NotificationScope); ok { + return scope + } + return NotificationScope{ReceiverType: ReceiverTypeUser} +} diff --git a/internal/repository/notification.go b/internal/repository/notification.go index 69844cd8..7ad1f561 100644 --- a/internal/repository/notification.go +++ b/internal/repository/notification.go @@ -76,9 +76,10 @@ func (r *Store) GetUserNotifications( ) ([]domain.Notification, int64, error) { params := dbgen.GetUserNotificationsParams{ - UserID: userID, - Limit: int32(limit), - Offset: int32(offset), + ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType), + UserID: userID, + Limit: int32(limit), + Offset: int32(offset), } rows, err := r.queries.GetUserNotifications(ctx, params) @@ -86,7 +87,7 @@ func (r *Store) GetUserNotifications( return nil, 0, err } - total, err := r.queries.GetUserNotificationCount(ctx, userID) + total, err := r.queries.GetUserNotificationCount(ctx, dbgen.GetUserNotificationCountParams{UserID: userID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) if err != nil { return nil, 0, err } @@ -179,7 +180,7 @@ func (r *Store) CountUnreadNotifications( ctx context.Context, userID int64, ) (int64, error) { - return r.queries.CountUnreadNotifications(ctx, userID) + return r.queries.CountUnreadNotifications(ctx, dbgen.CountUnreadNotificationsParams{UserID: userID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) } /* ========================= @@ -191,7 +192,7 @@ func (r *Store) MarkNotificationAsRead( id int64, ) (*domain.Notification, error) { - dbNotif, err := r.queries.MarkNotificationAsRead(ctx, id) + dbNotif, err := r.queries.MarkNotificationAsRead(ctx, dbgen.MarkNotificationAsReadParams{ID: id, RequesterID: domain.NotificationScopeFromContext(ctx).UserID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) if err != nil { return nil, err } @@ -203,7 +204,7 @@ func (r *Store) MarkAllUserNotificationsAsRead( ctx context.Context, userID int64, ) error { - return r.queries.MarkAllUserNotificationsAsRead(ctx, userID) + return r.queries.MarkAllUserNotificationsAsRead(ctx, dbgen.MarkAllUserNotificationsAsReadParams{UserID: userID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) } func (r *Store) MarkNotificationAsUnread( @@ -211,7 +212,7 @@ func (r *Store) MarkNotificationAsUnread( id int64, ) (*domain.Notification, error) { - dbNotif, err := r.queries.MarkNotificationAsUnread(ctx, id) + dbNotif, err := r.queries.MarkNotificationAsUnread(ctx, dbgen.MarkNotificationAsUnreadParams{ID: id, RequesterID: domain.NotificationScopeFromContext(ctx).UserID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) if err != nil { return nil, err } @@ -223,7 +224,7 @@ func (r *Store) MarkAllUserNotificationsAsUnread( ctx context.Context, userID int64, ) error { - return r.queries.MarkAllUserNotificationsAsUnread(ctx, userID) + return r.queries.MarkAllUserNotificationsAsUnread(ctx, dbgen.MarkAllUserNotificationsAsUnreadParams{UserID: userID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) } /* ========================= @@ -234,7 +235,7 @@ func (r *Store) DeleteUserNotifications( ctx context.Context, userID int64, ) error { - return r.queries.DeleteUserNotifications(ctx, userID) + return r.queries.DeleteUserNotifications(ctx, dbgen.DeleteUserNotificationsParams{UserID: userID, ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType)}) } func (r *Store) DeleteUserInAppNotification( @@ -242,8 +243,9 @@ func (r *Store) DeleteUserInAppNotification( id, userID int64, ) (int64, error) { return r.queries.DeleteUserInAppNotification(ctx, dbgen.DeleteUserInAppNotificationParams{ - ID: id, - UserID: userID, + ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType), + ID: id, + UserID: userID, }) } @@ -253,8 +255,9 @@ func (r *Store) DeleteUserInAppNotificationsByIDs( ids []int64, ) (int64, error) { return r.queries.DeleteUserInAppNotificationsByIDs(ctx, dbgen.DeleteUserInAppNotificationsByIDsParams{ - UserID: userID, - Column2: ids, + ReceiverType: string(domain.NotificationScopeFromContext(ctx).ReceiverType), + UserID: userID, + Column2: ids, }) } diff --git a/internal/services/notification/service.go b/internal/services/notification/service.go index dad9328e..e2f04721 100644 --- a/internal/services/notification/service.go +++ b/internal/services/notification/service.go @@ -65,18 +65,18 @@ func New( hub := ws.NewNotificationHub() svc := &Service{ - store: store, - Hub: hub, - mongoLogger: mongoLogger, - logger: logger, - connections: sync.Map{}, - notificationCh: make(chan *domain.Notification, 1000), - stopCh: make(chan struct{}), - messengerSvc: messengerSvc, - userSvc: userSvc, - teamStore: teamStore, + store: store, + Hub: hub, + mongoLogger: mongoLogger, + logger: logger, + connections: sync.Map{}, + notificationCh: make(chan *domain.Notification, 1000), + stopCh: make(chan struct{}), + messengerSvc: messengerSvc, + userSvc: userSvc, + teamStore: teamStore, emailTemplateSvc: emailTemplateSvc, - config: cfg, + config: cfg, } mongoLogger.Info("FCM credentials config at startup", @@ -277,9 +277,10 @@ func (s *Service) SendNotification(ctx context.Context, notification *domain.Not if notification.DeliveryChannel == domain.DeliveryChannelInApp { s.Hub.Broadcast <- map[string]interface{}{ - "type": "CREATED_NOTIFICATION", - "recipient_id": notification.RecipientID, - "payload": notification, + "type": "CREATED_NOTIFICATION", + "recipient_id": notification.RecipientID, + "receiver_type": notification.ReceiverType, + "payload": notification, } } @@ -346,7 +347,8 @@ func (s *Service) GetNotificationByID(ctx context.Context, id, requesterID int64 return nil, err } - if !allowAll && notification.RecipientID != requesterID { + scope := domain.NotificationScopeFromContext(ctx) + if !allowAll && (notification.RecipientID != requesterID || (notification.ReceiverType != "" && notification.ReceiverType != scope.ReceiverType)) { return nil, ErrNotificationForbidden } diff --git a/internal/services/notification/service_get_test.go b/internal/services/notification/service_get_test.go index 258f7ffa..93cf8ceb 100644 --- a/internal/services/notification/service_get_test.go +++ b/internal/services/notification/service_get_test.go @@ -91,3 +91,15 @@ func TestGetNotificationByID_notFound(t *testing.T) { t.Fatalf("expected ErrNotificationNotFound, got %v", err) } } + +func TestGetNotificationByID_DistinguishesReceiverTypes(t *testing.T) { + svc := &Service{store: &getNotificationStoreStub{notification: &domain.Notification{ID: "10", RecipientID: 42, ReceiverType: domain.ReceiverTypeTeamMember}}} + customerCtx := domain.WithNotificationScope(context.Background(), 42, domain.ReceiverTypeUser) + if _, err := svc.GetNotificationByID(customerCtx, 10, 42, false); !errors.Is(err, ErrNotificationForbidden) { + t.Fatalf("customer read a team member notification: %v", err) + } + staffCtx := domain.WithNotificationScope(context.Background(), 42, domain.ReceiverTypeTeamMember) + if _, err := svc.GetNotificationByID(staffCtx, 10, 42, false); err != nil { + t.Fatalf("staff could not read own notification: %v", err) + } +} diff --git a/internal/web_server/api_audience.go b/internal/web_server/api_audience.go new file mode 100644 index 00000000..d02c2282 --- /dev/null +++ b/internal/web_server/api_audience.go @@ -0,0 +1,46 @@ +package httpserver + +import ( + "Rezina-Backend/internal/domain" + "github.com/gofiber/fiber/v2" +) + +const apiAudienceKey = "api_audience" + +// apiAudience marks public and authenticated requests so shared handlers can apply audience defaults. +func apiAudience(audience string) fiber.Handler { + return func(c *fiber.Ctx) error { c.Locals(apiAudienceKey, audience); return c.Next() } +} + +func validateAPIAudience(role domain.Role, audience string) error { + if !role.IsValid() { + return fiber.NewError(fiber.StatusForbidden, "Unknown account role") + } + switch audience { + case "admin": + if role.IsCustomerLearnerRole() { + return fiber.NewError(fiber.StatusForbidden, "A staff account is required for the admin API") + } + case "client": + if !role.IsCustomerLearnerRole() { + return fiber.NewError(fiber.StatusForbidden, "A customer account is required for the client API") + } + } + return nil +} +func (a *App) adminAuthMiddleware(c *fiber.Ctx) error { + c.Locals(apiAudienceKey, "admin") + return a.authMiddleware(c) +} +func (a *App) clientAuthMiddleware(c *fiber.Ctx) error { + c.Locals(apiAudienceKey, "client") + return a.authMiddleware(c) +} +func (a *App) adminWebsocketAuthMiddleware(c *fiber.Ctx) error { + c.Locals(apiAudienceKey, "admin") + return a.WebsocketAuthMiddleware(c) +} +func (a *App) clientWebsocketAuthMiddleware(c *fiber.Ctx) error { + c.Locals(apiAudienceKey, "client") + return a.WebsocketAuthMiddleware(c) +} diff --git a/internal/web_server/api_audience_test.go b/internal/web_server/api_audience_test.go new file mode 100644 index 00000000..ee2779b2 --- /dev/null +++ b/internal/web_server/api_audience_test.go @@ -0,0 +1,126 @@ +package httpserver + +import ( + "Rezina-Backend/internal/domain" + "Rezina-Backend/internal/ports" + userservice "Rezina-Backend/internal/services/user" + "Rezina-Backend/internal/web_server/handlers" + jwtutil "Rezina-Backend/internal/web_server/jwt" + "context" + "github.com/gofiber/fiber/v2" + "go.uber.org/zap" + "log/slog" + "net/http/httptest" + "testing" +) + +type audienceUserStore struct { + ports.UserStore + status domain.UserStatus +} + +func (s audienceUserStore) GetUserByID(context.Context, int64) (domain.User, error) { + return domain.User{ID: 42, Status: s.status}, nil +} +func audienceTestApp(status domain.UserStatus) *App { + return &App{JwtConfig: jwtutil.JwtConfig{JwtAccessKey: "audience-test-key"}, mongoLoggerSvc: zap.NewNop(), logger: slog.Default(), userSvc: userservice.NewService(nil, audienceUserStore{status: status}, nil, nil, nil, nil, nil)} +} +func audienceToken(t *testing.T, a *App, role domain.Role) string { + t.Helper() + token, err := jwtutil.CreateJwt(42, role, a.JwtConfig.JwtAccessKey, 3600) + if err != nil { + t.Fatal(err) + } + return token +} +func TestAPIAudienceAuthentication(t *testing.T) { + for _, tc := range []struct { + name, audience string + role domain.Role + status domain.UserStatus + want int + }{ + {"student client", "client", domain.RoleStudent, domain.UserStatusActive, 204}, + {"open learner client", "client", domain.RoleOpenLearner, domain.UserStatusActive, 204}, + {"admin panel", "admin", domain.RoleAdmin, domain.UserStatusActive, 204}, + {"content manager panel", "admin", domain.RoleContentManager, domain.UserStatusActive, 204}, + {"instructor panel", "admin", domain.RoleInstructor, domain.UserStatusActive, 204}, + {"student cannot administer", "admin", domain.RoleStudent, domain.UserStatusActive, 403}, + {"open learner cannot administer", "admin", domain.RoleOpenLearner, domain.UserStatusActive, 403}, + {"admin cannot act as customer", "client", domain.RoleAdmin, domain.UserStatusActive, 403}, + {"instructor cannot act as customer", "client", domain.RoleInstructor, domain.UserStatusActive, 403}, + {"suspended customer", "client", domain.RoleStudent, domain.UserStatusSuspended, 403}, + {"unknown role", "admin", domain.Role("UNKNOWN"), domain.UserStatusActive, 403}, + } { + t.Run(tc.name, func(t *testing.T) { + a := audienceTestApp(tc.status) + server := fiber.New() + auth := a.adminAuthMiddleware + if tc.audience == "client" { + auth = a.clientAuthMiddleware + } + server.Get("/me", auth, func(c *fiber.Ctx) error { return c.SendStatus(204) }) + request := httptest.NewRequest("GET", "/me", nil) + request.Header.Set("Authorization", "Bearer "+audienceToken(t, a, tc.role)) + response, err := server.Test(request) + if err != nil { + t.Fatal(err) + } + defer response.Body.Close() + if response.StatusCode != tc.want { + t.Fatalf("status=%d want=%d", response.StatusCode, tc.want) + } + }) + } +} +func TestRegisteredAPISurfaces(t *testing.T) { + a := audienceTestApp(domain.UserStatusActive) + server := fiber.New() + h := &handlers.Handler{} + api := server.Group("/api/v1") + a.initAdminRoutes(api.Group("/admin", apiAudience("admin")), h) + a.initClientRoutes(api, h) + a.initIntegrationRoutes(api, h) + routes := map[string]bool{} + for _, stack := range server.Stack() { + for _, route := range stack { + routes[route.Method+" "+route.Path] = true + } + } + for _, route := range []string{"POST /api/v1/admin/exam-prep/catalog-courses", "GET /api/v1/exam-prep/catalog-courses", "POST /api/v1/admin/team/login", "POST /api/v1/user/register", "GET /api/v1/admin/users", "GET /api/v1/referrals/me", "POST /api/v1/payments/webhook", "GET /api/v1/payments/chapa/callback", "GET /api/v1/auth/google/callback"} { + if !routes[route] { + t.Errorf("missing route %s", route) + } + } + for _, route := range []string{"POST /api/v1/exam-prep/catalog-courses", "GET /api/v1/questions", "GET /api/v1/users", "GET /api/v1/rbac/roles", "POST /api/v1/team/login", "GET /api/v1/questions", "POST /api/v1/admin/user/register", "GET /api/v1/client/subscriptions/me", "POST /api/v1/admin/subscriptions/checkout"} { + if routes[route] { + t.Errorf("unexpected route %s", route) + } + } + for _, tc := range []struct { + path string + role domain.Role + }{ + {"/api/v1/admin/users", domain.RoleStudent}, + {"/api/v1/admin/exam-prep/catalog-courses", domain.RoleOpenLearner}, + {"/api/v1/subscriptions/me", domain.RoleAdmin}, + {"/api/v1/admin/ws/connect?token=", domain.RoleStudent}, + {"/api/v1/ws/connect?token=", domain.RoleAdmin}, + } { + token := audienceToken(t, a, tc.role) + path := tc.path + if path[len(path)-1:] == "=" { + path += token + } + request := httptest.NewRequest("GET", path, nil) + request.Header.Set("Authorization", "Bearer "+token) + response, err := server.Test(request) + if err != nil { + t.Fatal(err) + } + response.Body.Close() + if response.StatusCode != 403 { + t.Errorf("%s returned %d", tc.path, response.StatusCode) + } + } +} diff --git a/internal/web_server/api_docs.go b/internal/web_server/api_docs.go new file mode 100644 index 00000000..16a16d8f --- /dev/null +++ b/internal/web_server/api_docs.go @@ -0,0 +1,71 @@ +package httpserver + +import ( + "Rezina-Backend/docs" + "encoding/json" + "github.com/gofiber/fiber/v2" + "strings" +) + +func specificationPathMatchesAudience(path, audience string) bool { + isAdmin := strings.HasPrefix(path, "/api/v1/admin/") + if audience == "admin" { + return isAdmin + } + if audience != "client" || !strings.HasPrefix(path, "/api/v1/") || isAdmin { + return false + } + switch path { + case "/api/v1/payments/webhook", "/api/v1/payments/chapa/callback", "/api/v1/payments/chapa/success", "/api/v1/payments/arifpay/success", "/api/v1/auth/google/callback": + return false + } + return true +} + +// audienceSpecification exposes only an audience's routes and referenced schemas. +func audienceSpecification(audience string) fiber.Handler { + return func(c *fiber.Ctx) error { + var spec map[string]any + if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &spec); err != nil { + return fiber.NewError(500, "Unable to load API documentation") + } + paths, _ := spec["paths"].(map[string]any) + selected := map[string]any{} + for path, operation := range paths { + if specificationPathMatchesAudience(path, audience) { + selected[path] = operation + } + } + spec["paths"] = selected + if info, ok := spec["info"].(map[string]any); ok { + info["title"] = "Rezina " + audience + " API" + } + definitions, _ := spec["definitions"].(map[string]any) + used := map[string]any{} + var collect func(any) + collect = func(value any) { + switch node := value.(type) { + case map[string]any: + if ref, ok := node["$ref"].(string); ok && strings.HasPrefix(ref, "#/definitions/") { + name := strings.TrimPrefix(ref, "#/definitions/") + if _, seen := used[name]; !seen { + if definition, found := definitions[name]; found { + used[name] = definition + collect(definition) + } + } + } + for _, child := range node { + collect(child) + } + case []any: + for _, child := range node { + collect(child) + } + } + } + collect(selected) + spec["definitions"] = used + return c.JSON(spec) + } +} diff --git a/internal/web_server/api_docs_test.go b/internal/web_server/api_docs_test.go new file mode 100644 index 00000000..9bfc3332 --- /dev/null +++ b/internal/web_server/api_docs_test.go @@ -0,0 +1,37 @@ +package httpserver + +import ( + "encoding/json" + "github.com/gofiber/fiber/v2" + "net/http/httptest" + "strings" + "testing" +) + +func TestAudienceSpecifications(t *testing.T) { + for _, audience := range []string{"admin", "client"} { + t.Run(audience, func(t *testing.T) { + server := fiber.New() + server.Get("/doc", audienceSpecification(audience)) + response, err := server.Test(httptest.NewRequest("GET", "/doc", nil)) + if err != nil { + t.Fatal(err) + } + defer response.Body.Close() + var spec struct { + Paths map[string]any `json:"paths"` + } + if err := json.NewDecoder(response.Body).Decode(&spec); err != nil { + t.Fatal(err) + } + if len(spec.Paths) == 0 { + t.Fatal("empty API specification") + } + for path := range spec.Paths { + if (audience == "admin" && !strings.HasPrefix(path, "/api/v1/admin/")) || (audience == "client" && (!strings.HasPrefix(path, "/api/v1/") || strings.HasPrefix(path, "/api/v1/admin/"))) { + t.Errorf("foreign path %s", path) + } + } + }) + } +} diff --git a/internal/web_server/handlers/activity_logs.go b/internal/web_server/handlers/activity_logs.go index a5a83e0b..397d9e74 100644 --- a/internal/web_server/handlers/activity_logs.go +++ b/internal/web_server/handlers/activity_logs.go @@ -51,7 +51,7 @@ type activityLogListRes struct { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/activity-logs [get] +// @Router /api/v1/admin/activity-logs [get] func (h *Handler) GetActivityLogs(c *fiber.Ctx) error { var filter domain.ActivityLogFilter @@ -164,7 +164,7 @@ func (h *Handler) GetActivityLogs(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/activity-logs/{id} [get] +// @Router /api/v1/admin/activity-logs/{id} [get] func (h *Handler) GetActivityLogByID(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) diff --git a/internal/web_server/handlers/admin.go b/internal/web_server/handlers/admin.go index 623ce2c2..f0682c01 100644 --- a/internal/web_server/handlers/admin.go +++ b/internal/web_server/handlers/admin.go @@ -36,7 +36,7 @@ type CreateAdminReq struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/admin [post] +// @Router /api/v1/admin/admins [post] func (h *Handler) CreateAdmin(c *fiber.Ctx) error { // var OrganizationID domain.ValidInt64 var req CreateAdminReq @@ -172,7 +172,7 @@ type AdminRes struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/admin [get] +// @Router /api/v1/admin/admins [get] func (h *Handler) GetAllAdmins(c *fiber.Ctx) error { searchQuery := c.Query("query") searchString := domain.ValidString{ @@ -288,7 +288,7 @@ func (h *Handler) GetAllAdmins(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/admin/{id} [get] +// @Router /api/v1/admin/admins/{id} [get] func (h *Handler) GetAdminByID(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -342,7 +342,7 @@ type updateAdminReq struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/admin/{id} [put] +// @Router /api/v1/admin/admins/{id} [put] func (h *Handler) UpdateAdmin(c *fiber.Ctx) error { var req updateAdminReq if err := c.BodyParser(&req); err != nil { @@ -435,7 +435,7 @@ func (h *Handler) bulkAccountsRoleFromPath(c *fiber.Ctx) (roleKey string, ok boo // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/admin/roles/{role}/bulk-deactivate [post] +// @Router /api/v1/admin/admins/roles/{role}/bulk-deactivate [post] func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error { callerRole, ok := c.Locals("role").(domain.Role) if !ok { @@ -559,7 +559,7 @@ func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error { // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/admin/roles/{role}/bulk-reactivate [post] +// @Router /api/v1/admin/admins/roles/{role}/bulk-reactivate [post] func (h *Handler) BulkReactivateAccountsByRole(c *fiber.Ctx) error { callerRole, ok := c.Locals("role").(domain.Role) if !ok { diff --git a/internal/web_server/handlers/admin_export.go b/internal/web_server/handlers/admin_export.go index 5c60adc5..7023eaec 100644 --- a/internal/web_server/handlers/admin_export.go +++ b/internal/web_server/handlers/admin_export.go @@ -166,7 +166,7 @@ func (h *Handler) ExportAdminPaymentsCSV(c *fiber.Ctx) error { // @Summary Export users as CSV (admin) // @Tags user // @Produce text/csv -// @Router /api/v1/users/export [get] +// @Router /api/v1/admin/users/export [get] func (h *Handler) ExportUsersCSV(c *fiber.Ctx) error { filter, err := parseUserListFilter(c) if err != nil { @@ -244,7 +244,7 @@ func (h *Handler) ExportUsersCSV(c *fiber.Ctx) error { // @Summary Export activity logs as CSV (admin) // @Tags activity-logs // @Produce text/csv -// @Router /api/v1/activity-logs/export [get] +// @Router /api/v1/admin/activity-logs/export [get] func (h *Handler) ExportActivityLogsCSV(c *fiber.Ctx) error { filter, err := parseActivityLogFilterFields(c) if err != nil { @@ -357,7 +357,7 @@ func (h *Handler) ExportUserSubscriptionsCSV(c *fiber.Ctx) error { // @Summary Export team members as CSV (admin) // @Tags team // @Produce text/csv -// @Router /api/v1/team/members/export [get] +// @Router /api/v1/admin/team/members/export [get] func (h *Handler) ExportTeamMembersCSV(c *fiber.Ctx) error { filter := parseTeamMemberListFilter(c) ctx := exportRequestContext(c) diff --git a/internal/web_server/handlers/analytics_handler.go b/internal/web_server/handlers/analytics_handler.go index 47629979..8807a268 100644 --- a/internal/web_server/handlers/analytics_handler.go +++ b/internal/web_server/handlers/analytics_handler.go @@ -33,7 +33,7 @@ func toTime(v interface{}) time.Time { // @Success 200 {object} domain.AnalyticsDashboard // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/analytics/dashboard [get] +// @Router /api/v1/admin/analytics/dashboard [get] func (h *Handler) GetAnalyticsDashboard(c *fiber.Ctx) error { filter, err := domain.ParseAnalyticsDateFilter(c) if err != nil { diff --git a/internal/web_server/handlers/arifpay.go b/internal/web_server/handlers/arifpay.go index 1864a1d1..bc99f577 100644 --- a/internal/web_server/handlers/arifpay.go +++ b/internal/web_server/handlers/arifpay.go @@ -383,7 +383,6 @@ func (h *Handler) HandleArifpaySuccessPage(c *fiber.Ctx) error { // @Param body body domain.WebhookRequest true "Webhook payload" // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse -// @Router /api/v1/payments/webhook [post] func (h *Handler) HandleArifpayWebhook(c *fiber.Ctx) error { var req domain.WebhookRequest if err := c.BodyParser(&req); err != nil { @@ -419,7 +418,6 @@ func (h *Handler) HandleArifpayWebhook(c *fiber.Ctx) error { // @Tags payments // @Produce json // @Success 200 {object} domain.Response -// @Router /api/v1/payments/methods [get] func (h *Handler) GetArifpayPaymentMethods(c *fiber.Ctx) error { methods := h.arifpaySvc.GetPaymentMethodsMapping() diff --git a/internal/web_server/handlers/auth_handler.go b/internal/web_server/handlers/auth_handler.go index 1b85ff7e..25396e7b 100644 --- a/internal/web_server/handlers/auth_handler.go +++ b/internal/web_server/handlers/auth_handler.go @@ -256,7 +256,7 @@ func (h *Handler) GoogleCallback(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user-login [post] +// @Router /api/v1/auth/customer-login [post] func (h *Handler) LoginUser(c *fiber.Ctx) error { var req domain.LoginRequest if err := c.BodyParser(&req); err != nil { @@ -322,6 +322,9 @@ func (h *Handler) LoginUser(c *fiber.Ctx) error { } } + if !successRes.Role.IsCustomerLearnerRole() { + return fiber.NewError(fiber.StatusForbidden, "Use the admin API to sign in with a staff account") + } // if successRes.Role != domain.RoleStudent { // h.mongoLoggerSvc.Info("Login attempt: user login of other role", // zap.Int("status_code", fiber.StatusForbidden), @@ -402,7 +405,7 @@ type LoginAdminRes struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/admin-login [post] +// @Router /api/v1/admin/auth/admin-login [post] func (h *Handler) LoginAdmin(c *fiber.Ctx) error { var req domain.LoginRequest if err := c.BodyParser(&req); err != nil { @@ -504,7 +507,7 @@ func (h *Handler) LoginAdmin(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/super-login [post] +// @Router /api/v1/admin/auth/super-login [post] func (h *Handler) LoginSuper(c *fiber.Ctx) error { var req domain.LoginRequest if err := c.BodyParser(&req); err != nil { @@ -685,6 +688,9 @@ func (h *Handler) RefreshToken(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, "Failed to retrieve user information:"+err.Error()) } + if c.Locals("api_audience") == "client" && !user.Role.IsCustomerLearnerRole() { + return fiber.NewError(fiber.StatusForbidden, "A customer account is required") + } if err := domain.ValidateUserCanAuthenticate(user.Status); err != nil { switch { case errors.Is(err, domain.ErrUserAccountLocked): diff --git a/internal/web_server/handlers/chapa.go b/internal/web_server/handlers/chapa.go index c09ee403..aec5d267 100644 --- a/internal/web_server/handlers/chapa.go +++ b/internal/web_server/handlers/chapa.go @@ -127,7 +127,6 @@ func (h *Handler) HandleChapaCallback(c *fiber.Ctx) error { // @Param status query string false "Payment status from Chapa redirect" // @Success 200 {string} string "HTML success page" // @Router /api/v1/payments/chapa/success [get] -// @Router /payment/success [get] func (h *Handler) HandleChapaSuccessPage(c *fiber.Ctx) error { txRef := firstNonEmpty( c.Query("trx_ref"), diff --git a/internal/web_server/handlers/course_handler.go b/internal/web_server/handlers/course_handler.go index 4a770650..ce4f65f8 100644 --- a/internal/web_server/handlers/course_handler.go +++ b/internal/web_server/handlers/course_handler.go @@ -23,7 +23,6 @@ import ( // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/programs/{id}/courses [post] func (h *Handler) CreateCourse(c *fiber.Ctx) error { programID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -82,7 +81,6 @@ func (h *Handler) CreateCourse(c *fiber.Ctx) error { // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/programs/{id}/courses [get] func (h *Handler) ListCoursesByProgram(c *fiber.Ctx) error { programID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -184,7 +182,6 @@ func (h *Handler) ListCoursesByProgram(c *fiber.Ctx) error { // @Param id path int true "Course ID" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/courses/{id} [get] func (h *Handler) GetCourse(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -254,7 +251,6 @@ func (h *Handler) GetCourse(c *fiber.Ctx) error { // @Param body body domain.UpdateCourseInput true "Fields to update" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/courses/{id} [put] func (h *Handler) UpdateCourse(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -304,7 +300,6 @@ func (h *Handler) UpdateCourse(c *fiber.Ctx) error { // @Param id path int true "Course ID" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/courses/{id} [delete] func (h *Handler) DeleteCourse(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_assessment_handler.go b/internal/web_server/handlers/exam_prep_assessment_handler.go index 2022eef2..ce0b8bd8 100644 --- a/internal/web_server/handlers/exam_prep_assessment_handler.go +++ b/internal/web_server/handlers/exam_prep_assessment_handler.go @@ -20,6 +20,12 @@ func assessmentParentFromQuery(c *fiber.Ctx) (domain.ExamPrepAssessmentParent, e return domain.ExamPrepAssessmentParent{Kind: kind, ID: parentID}, nil } +// ListExamPrepAssessments godoc +// @Summary ListExamPrepAssessments +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/exam-prep/assessments [get] +// @Router /api/v1/exam-prep/assessments [get] func (h *Handler) ListExamPrepAssessments(c *fiber.Ctx) error { parent, err := assessmentParentFromQuery(c) if err != nil || parent.Kind == "" { @@ -32,6 +38,11 @@ func (h *Handler) ListExamPrepAssessments(c *fiber.Ctx) error { return c.JSON(domain.Response{Message: "Assessments retrieved successfully", Data: fiber.Map{"assessments": sets}, Success: true, StatusCode: fiber.StatusOK}) } +// LinkExamPrepAssessment godoc +// @Summary LinkExamPrepAssessment +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/exam-prep/assessments [post] func (h *Handler) LinkExamPrepAssessment(c *fiber.Ctx) error { var input domain.LinkExamPrepAssessmentInput if err := c.BodyParser(&input); err != nil { @@ -48,6 +59,11 @@ func (h *Handler) LinkExamPrepAssessment(c *fiber.Ctx) error { return c.Status(fiber.StatusCreated).JSON(domain.Response{Message: "Assessment linked successfully", Data: fiber.Map{"assessment": set, "parent_kind": input.ParentKind, "parent_id": input.ParentID}, Success: true, StatusCode: fiber.StatusCreated}) } +// UnlinkExamPrepAssessment godoc +// @Summary UnlinkExamPrepAssessment +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/exam-prep/assessments/{questionSetId}/parents/{parentKind}/{parentId} [delete] func (h *Handler) UnlinkExamPrepAssessment(c *fiber.Ctx) error { questionSetID, err := parseAssessmentID(c.Params("questionSetId")) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_catalog_course_handler.go b/internal/web_server/handlers/exam_prep_catalog_course_handler.go index 9f167da1..21e12102 100644 --- a/internal/web_server/handlers/exam_prep_catalog_course_handler.go +++ b/internal/web_server/handlers/exam_prep_catalog_course_handler.go @@ -19,6 +19,7 @@ import ( // @Param body body domain.CreateExamPrepCatalogCourseInput true "Catalog course" // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse +// @Router /api/v1/admin/exam-prep/catalog-courses [post] func (h *Handler) CreateExamPrepCatalogCourse(c *fiber.Ctx) error { var req domain.CreateExamPrepCatalogCourseInput if err := c.BodyParser(&req); err != nil { @@ -56,6 +57,8 @@ func (h *Handler) CreateExamPrepCatalogCourse(c *fiber.Ctx) error { // @Param limit query int false "Page size" default(20) // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses [get] +// @Router /api/v1/exam-prep/catalog-courses [get] func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error { limit, _ := strconv.Atoi(c.Query("limit", "20")) offset, _ := strconv.Atoi(c.Query("offset", "0")) @@ -95,6 +98,7 @@ func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error { // @Produce json // @Param body body domain.ReorderIDsRequest true "ordered_ids: every catalog course id exactly once" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/reorder [put] func (h *Handler) ReorderExamPrepCatalogCourses(c *fiber.Ctx) error { var req domain.ReorderIDsRequest if err := c.BodyParser(&req); err != nil { @@ -134,6 +138,8 @@ func (h *Handler) ReorderExamPrepCatalogCourses(c *fiber.Ctx) error { // @Produce json // @Param id path int true "Catalog course ID" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [get] +// @Router /api/v1/exam-prep/catalog-courses/{id} [get] func (h *Handler) GetExamPrepCatalogCourseByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -184,6 +190,7 @@ func (h *Handler) GetExamPrepCatalogCourseByID(c *fiber.Ctx) error { // @Param id path int true "Catalog course ID" // @Param body body domain.UpdateExamPrepCatalogCourseInput true "Fields to update" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [put] func (h *Handler) UpdateExamPrepCatalogCourse(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -226,6 +233,7 @@ func (h *Handler) UpdateExamPrepCatalogCourse(c *fiber.Ctx) error { // @Tags exam-prep // @Param id path int true "Catalog course ID" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [delete] func (h *Handler) DeleteExamPrepCatalogCourse(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_lesson_handler.go b/internal/web_server/handlers/exam_prep_lesson_handler.go index a7c37eb0..5ff99765 100644 --- a/internal/web_server/handlers/exam_prep_lesson_handler.go +++ b/internal/web_server/handlers/exam_prep_lesson_handler.go @@ -15,6 +15,7 @@ import ( // @Tags exam-prep // @Param moduleId path int true "Exam prep unit module ID" // @Param body body domain.CreateExamPrepLessonInput true "Lesson" +// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons [post] func (h *Handler) CreateExamPrepLesson(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { @@ -64,6 +65,8 @@ func (h *Handler) CreateExamPrepLesson(c *fiber.Ctx) error { // @Param moduleId path int true "Exam prep unit module ID" // @Param limit query int false "Page size" default(20) // @Param offset query int false "Offset" default(0) +// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons [get] +// @Router /api/v1/exam-prep/modules/{moduleId}/lessons [get] func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { @@ -125,6 +128,7 @@ func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error { // ReorderExamPrepLessonsInUnitModule godoc // @Summary Reorder lessons within an exam-prep unit module // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons/reorder [put] func (h *Handler) ReorderExamPrepLessonsInUnitModule(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { @@ -175,6 +179,8 @@ func (h *Handler) ReorderExamPrepLessonsInUnitModule(c *fiber.Ctx) error { // GetExamPrepLessonByID godoc // @Summary Get exam-prep lesson by ID // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/lessons/{id} [get] +// @Router /api/v1/exam-prep/lessons/{id} [get] func (h *Handler) GetExamPrepLessonByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -224,6 +230,7 @@ func (h *Handler) GetExamPrepLessonByID(c *fiber.Ctx) error { // UpdateExamPrepLesson godoc // @Summary Update exam-prep lesson // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/lessons/{id} [put] func (h *Handler) UpdateExamPrepLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -264,6 +271,7 @@ func (h *Handler) UpdateExamPrepLesson(c *fiber.Ctx) error { // DeleteExamPrepLesson godoc // @Summary Delete exam-prep lesson // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/lessons/{id} [delete] func (h *Handler) DeleteExamPrepLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_module_handler.go b/internal/web_server/handlers/exam_prep_module_handler.go index 9f4dfa80..2f750f23 100644 --- a/internal/web_server/handlers/exam_prep_module_handler.go +++ b/internal/web_server/handlers/exam_prep_module_handler.go @@ -15,6 +15,7 @@ import ( // @Tags exam-prep // @Param unitId path int true "Unit ID" // @Param body body domain.CreateExamPrepModuleInput true "Module" +// @Router /api/v1/admin/exam-prep/units/{unitId}/modules [post] func (h *Handler) CreateExamPrepModule(c *fiber.Ctx) error { unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64) if err != nil { @@ -62,6 +63,8 @@ func (h *Handler) CreateExamPrepModule(c *fiber.Ctx) error { // @Summary List exam-prep modules for a unit // @Tags exam-prep // @Param unitId path int true "Unit ID" +// @Router /api/v1/admin/exam-prep/units/{unitId}/modules [get] +// @Router /api/v1/exam-prep/units/{unitId}/modules [get] func (h *Handler) ListExamPrepModulesByUnit(c *fiber.Ctx) error { unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64) if err != nil { @@ -125,6 +128,7 @@ func (h *Handler) ListExamPrepModulesByUnit(c *fiber.Ctx) error { // @Tags exam-prep // @Param unitId path int true "Unit ID" // @Param body body domain.ReorderIDsRequest true "ordered_ids" +// @Router /api/v1/admin/exam-prep/units/{unitId}/modules/reorder [put] func (h *Handler) ReorderExamPrepModulesInUnit(c *fiber.Ctx) error { unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64) if err != nil { @@ -175,6 +179,8 @@ func (h *Handler) ReorderExamPrepModulesInUnit(c *fiber.Ctx) error { // GetExamPrepModuleByID godoc // @Summary Get exam-prep module by ID // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/modules/{id} [get] +// @Router /api/v1/exam-prep/modules/{id} [get] func (h *Handler) GetExamPrepModuleByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -224,6 +230,7 @@ func (h *Handler) GetExamPrepModuleByID(c *fiber.Ctx) error { // UpdateExamPrepModule godoc // @Summary Update exam-prep module // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/modules/{id} [put] func (h *Handler) UpdateExamPrepModule(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -264,6 +271,7 @@ func (h *Handler) UpdateExamPrepModule(c *fiber.Ctx) error { // DeleteExamPrepModule godoc // @Summary Delete exam-prep module // @Tags exam-prep +// @Router /api/v1/admin/exam-prep/modules/{id} [delete] func (h *Handler) DeleteExamPrepModule(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_practice_handler.go b/internal/web_server/handlers/exam_prep_practice_handler.go index 33a066ab..5984ff51 100644 --- a/internal/web_server/handlers/exam_prep_practice_handler.go +++ b/internal/web_server/handlers/exam_prep_practice_handler.go @@ -14,6 +14,7 @@ import ( // @Summary Create exam-prep practice (optional parents; link later via PUT /exam-prep/practices/:id/parents) // @Tags exam-prep // @Param body body domain.CreateExamPrepPracticeInput true "Practice" +// @Router /api/v1/admin/exam-prep/practices [post] func (h *Handler) CreateExamPrepPracticeFromInput(c *fiber.Ctx) error { var req domain.CreateExamPrepPracticeInput if err := c.BodyParser(&req); err != nil { @@ -53,6 +54,8 @@ func (h *Handler) CreateExamPrepPracticeFromInput(c *fiber.Ctx) error { // @Param limit query int false "Page size. Omit (with offset) to return all practices." // @Param offset query int false "Offset. Defaults to 0 when limit is provided; ignored semantics when both omitted (all rows)." // @Param unlinked_only query bool false "When true, return only practices with no parent links (admin)" +// @Router /api/v1/admin/exam-prep/practices [get] +// @Router /api/v1/exam-prep/practices [get] func (h *Handler) ListAllExamPrepPractices(c *fiber.Ctx) error { limit, offset, err := parseOptionalExamPrepPracticePagination(c) if err != nil { @@ -127,6 +130,8 @@ func (h *Handler) CreateExamPrepPractice(c *fiber.Ctx) error { // @Param lessonId path int true "Exam prep lesson ID" // @Param limit query int false "Page size. Omit to return all practices for the lesson." // @Param offset query int false "Offset (used when limit is provided)" +// @Router /api/v1/admin/exam-prep/lessons/{lessonId}/practices [get] +// @Router /api/v1/exam-prep/lessons/{lessonId}/practices [get] func (h *Handler) ListExamPrepPracticesByLesson(c *fiber.Ctx) error { lessonID, err := strconv.ParseInt(c.Params("lessonId"), 10, 64) if err != nil { @@ -160,6 +165,8 @@ func (h *Handler) ListExamPrepPracticesByLesson(c *fiber.Ctx) error { // @Summary Get exam-prep practice by ID // @Tags exam-prep // @Param id path int true "Exam prep practice ID" +// @Router /api/v1/admin/exam-prep/practices/{id} [get] +// @Router /api/v1/exam-prep/practices/{id} [get] func (h *Handler) GetExamPrepPracticeByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -200,6 +207,7 @@ func (h *Handler) GetExamPrepPracticeByID(c *fiber.Ctx) error { // @Tags exam-prep // @Param id path int true "Exam prep practice ID" // @Param body body domain.UpdateExamPrepPracticeInput true "Fields to update" +// @Router /api/v1/admin/exam-prep/practices/{id} [put] func (h *Handler) UpdateExamPrepPractice(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -251,6 +259,7 @@ func (h *Handler) UpdateExamPrepPractice(c *fiber.Ctx) error { // @Tags exam-prep // @Param id path int true "Exam prep practice ID" // @Param body body domain.UpdateExamPrepPracticeParentsInput true "Parent links (replaces all; use empty array to detach)" +// @Router /api/v1/admin/exam-prep/practices/{id}/parents [put] func (h *Handler) UpdateExamPrepPracticeParents(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -306,6 +315,7 @@ func (h *Handler) UpdateExamPrepPracticeParents(c *fiber.Ctx) error { // @Param id path int true "Exam prep practice ID" // @Param parentKind path string true "Parent kind (CATALOG_COURSE, UNIT, LESSON)" // @Param parentId path int true "Parent entity ID" +// @Router /api/v1/admin/exam-prep/practices/{id}/parents/{parentKind}/{parentId} [delete] func (h *Handler) UnlinkExamPrepPracticeParent(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -359,6 +369,7 @@ func (h *Handler) UnlinkExamPrepPracticeParent(c *fiber.Ctx) error { // @Summary Delete exam-prep practice // @Tags exam-prep // @Param id path int true "Exam prep practice ID" +// @Router /api/v1/admin/exam-prep/practices/{id} [delete] func (h *Handler) DeleteExamPrepPractice(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -448,6 +459,7 @@ func (h *Handler) listExamPrepPracticesResponse(c *fiber.Ctx, items []domain.Exa // @Tags exam-prep // @Param catalogCourseId path int true "Exam prep catalog course ID" // @Param body body domain.CreateExamPrepPracticeInput true "Practice" +// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices [post] func (h *Handler) CreateExamPrepPracticeForCatalogCourse(c *fiber.Ctx) error { catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64) if err != nil { @@ -479,6 +491,8 @@ func (h *Handler) CreateExamPrepPracticeForCatalogCourse(c *fiber.Ctx) error { // @Param catalogCourseId path int true "Exam prep catalog course ID" // @Param limit query int false "Page size. Omit to return all practices for the catalog course." // @Param offset query int false "Offset (used when limit is provided)" +// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices [get] +// @Router /api/v1/exam-prep/catalog-courses/{catalogCourseId}/practices [get] func (h *Handler) ListExamPrepPracticesByCatalogCourse(c *fiber.Ctx) error { catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64) if err != nil { @@ -507,6 +521,7 @@ func (h *Handler) ListExamPrepPracticesByCatalogCourse(c *fiber.Ctx) error { // @Tags exam-prep // @Param unitId path int true "Exam prep unit ID" // @Param body body domain.CreateExamPrepPracticeInput true "Practice" +// @Router /api/v1/admin/exam-prep/units/{unitId}/practices [post] func (h *Handler) CreateExamPrepPracticeForUnit(c *fiber.Ctx) error { unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64) if err != nil { @@ -538,6 +553,8 @@ func (h *Handler) CreateExamPrepPracticeForUnit(c *fiber.Ctx) error { // @Param unitId path int true "Exam prep unit ID" // @Param limit query int false "Page size. Omit to return all practices for the unit." // @Param offset query int false "Offset (used when limit is provided)" +// @Router /api/v1/admin/exam-prep/units/{unitId}/practices [get] +// @Router /api/v1/exam-prep/units/{unitId}/practices [get] func (h *Handler) ListExamPrepPracticesByUnit(c *fiber.Ctx) error { unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/exam_prep_unit_handler.go b/internal/web_server/handlers/exam_prep_unit_handler.go index ae2fb35b..bc2545de 100644 --- a/internal/web_server/handlers/exam_prep_unit_handler.go +++ b/internal/web_server/handlers/exam_prep_unit_handler.go @@ -19,6 +19,7 @@ import ( // @Param catalogCourseId path int true "Catalog course ID" // @Param body body domain.CreateExamPrepUnitInput true "Unit" // @Success 201 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units [post] func (h *Handler) CreateExamPrepUnit(c *fiber.Ctx) error { catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64) if err != nil { @@ -69,6 +70,8 @@ func (h *Handler) CreateExamPrepUnit(c *fiber.Ctx) error { // @Param limit query int false "Page size" default(20) // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response +// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units [get] +// @Router /api/v1/exam-prep/catalog-courses/{catalogCourseId}/units [get] func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error { catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64) if err != nil { @@ -132,6 +135,7 @@ func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error { // @Tags exam-prep // @Param catalogCourseId path int true "Catalog course ID" // @Param body body domain.ReorderIDsRequest true "ordered_ids: every unit id in this catalog course, new order" +// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units/reorder [put] func (h *Handler) ReorderExamPrepUnitsInCatalogCourse(c *fiber.Ctx) error { catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64) if err != nil { @@ -183,6 +187,8 @@ func (h *Handler) ReorderExamPrepUnitsInCatalogCourse(c *fiber.Ctx) error { // @Summary Get exam-prep unit by ID // @Tags exam-prep // @Param id path int true "Unit ID" +// @Router /api/v1/admin/exam-prep/units/{id} [get] +// @Router /api/v1/exam-prep/units/{id} [get] func (h *Handler) GetExamPrepUnitByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -234,6 +240,7 @@ func (h *Handler) GetExamPrepUnitByID(c *fiber.Ctx) error { // @Tags exam-prep // @Param id path int true "Unit ID" // @Param body body domain.UpdateExamPrepUnitInput true "Fields to update" +// @Router /api/v1/admin/exam-prep/units/{id} [put] func (h *Handler) UpdateExamPrepUnit(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -275,6 +282,7 @@ func (h *Handler) UpdateExamPrepUnit(c *fiber.Ctx) error { // @Summary Delete exam-prep unit // @Tags exam-prep // @Param id path int true "Unit ID" +// @Router /api/v1/admin/exam-prep/units/{id} [delete] func (h *Handler) DeleteExamPrepUnit(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/file_handler.go b/internal/web_server/handlers/file_handler.go index aba14d16..978084e3 100644 --- a/internal/web_server/handlers/file_handler.go +++ b/internal/web_server/handlers/file_handler.go @@ -75,6 +75,7 @@ func (h *Handler) resolveFileURL(c *fiber.Ctx, storedPath string) string { // @Tags files // @Param key query string true "MinIO object key (e.g. profile_pictures/uuid.jpg)" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/files/url [get] // @Router /api/v1/files/url [get] func (h *Handler) GetFileURL(c *fiber.Ctx) error { key := strings.TrimSpace(c.Query("key")) @@ -121,6 +122,7 @@ func (h *Handler) extractObjectKeyFromReference(reference string) (string, error // @Produce json // @Param body body refreshFileURLReq true "reference (object key, minio://..., or existing presigned URL)" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/files/refresh-url [post] // @Router /api/v1/files/refresh-url [post] func (h *Handler) RefreshFileURL(c *fiber.Ctx) error { if h.minioSvc == nil { @@ -173,6 +175,7 @@ func (h *Handler) RefreshFileURL(c *fiber.Ctx) error { // @Produce json // @Param body body presignedUploadReq true "Presigned upload request" // @Success 201 {object} domain.Response +// @Router /api/v1/admin/files/presign-upload [post] // @Router /api/v1/files/presign-upload [post] func (h *Handler) CreatePresignedUpload(c *fiber.Ctx) error { if h.minioSvc == nil { @@ -263,6 +266,7 @@ func (h *Handler) CreatePresignedUpload(c *fiber.Ctx) error { // @Produce json // @Param body body completePresignedUploadReq true "Complete upload request" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/files/complete-upload [post] // @Router /api/v1/files/complete-upload [post] func (h *Handler) CompletePresignedUpload(c *fiber.Ctx) error { if h.minioSvc == nil { @@ -383,6 +387,7 @@ func objectKeyMatchesMediaType(objectKey, mediaType string) bool { // @Param media_type formData string true "Media type: image|audio|video|pdf" // @Param file formData file true "Media file" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/files/upload [post] // @Router /api/v1/files/upload [post] func (h *Handler) UploadMedia(c *fiber.Ctx) error { mediaType := strings.ToLower(strings.TrimSpace(c.FormValue("media_type"))) @@ -626,6 +631,7 @@ func normalizeAndValidateMediaContentType(mediaType, contentType, fileName strin // @Accept multipart/form-data // @Param file formData file true "Audio file (mp3, wav, ogg, m4a, aac, webm)" // @Success 200 {object} domain.Response +// @Router /api/v1/admin/files/audio [post] // @Router /api/v1/files/audio [post] func (h *Handler) UploadAudio(c *fiber.Ctx) error { if h.minioSvc == nil { diff --git a/internal/web_server/handlers/issue_reporting.go b/internal/web_server/handlers/issue_reporting.go index e56caabb..23573f7d 100644 --- a/internal/web_server/handlers/issue_reporting.go +++ b/internal/web_server/handlers/issue_reporting.go @@ -138,7 +138,7 @@ func (h *Handler) CreateIssue(c *fiber.Ctx) error { // @Success 200 {object} domain.Response{data=issueRes} // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/issues/{id} [get] +// @Router /api/v1/admin/issues/{id} [get] func (h *Handler) GetIssueByID(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -176,7 +176,7 @@ func (h *Handler) GetIssueByID(c *fiber.Ctx) error { // @Success 200 {object} domain.Response{data=issueListRes} // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/issues/user/{user_id} [get] +// @Router /api/v1/admin/issues/user/{user_id} [get] func (h *Handler) GetUserIssues(c *fiber.Ctx) error { userIDStr := c.Params("user_id") userID, err := strconv.ParseInt(userIDStr, 10, 64) @@ -273,7 +273,7 @@ func (h *Handler) GetMyIssues(c *fiber.Ctx) error { // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response{data=issueListRes} // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/issues [get] +// @Router /api/v1/admin/issues [get] func (h *Handler) GetAllIssues(c *fiber.Ctx) error { limit, _ := strconv.Atoi(c.Query("limit", "20")) offset, _ := strconv.Atoi(c.Query("offset", "0")) @@ -318,7 +318,7 @@ func (h *Handler) GetAllIssues(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/issues/{id}/status [patch] +// @Router /api/v1/admin/issues/{id}/status [patch] func (h *Handler) UpdateIssueStatus(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -386,7 +386,7 @@ func (h *Handler) UpdateIssueStatus(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/issues/{id} [delete] +// @Router /api/v1/admin/issues/{id} [delete] func (h *Handler) DeleteIssue(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) diff --git a/internal/web_server/handlers/lesson_handler.go b/internal/web_server/handlers/lesson_handler.go index 89090c36..66674565 100644 --- a/internal/web_server/handlers/lesson_handler.go +++ b/internal/web_server/handlers/lesson_handler.go @@ -20,7 +20,6 @@ import ( // @Produce json // @Param moduleId path int true "Module ID" // @Param body body domain.CreateLessonInput true "Lesson" -// @Router /api/v1/modules/{moduleId}/lessons [post] func (h *Handler) CreateLesson(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { @@ -75,7 +74,6 @@ func (h *Handler) CreateLesson(c *fiber.Ctx) error { // @Param moduleId path int true "Module ID" // @Param limit query int false "Page size" default(20) // @Param offset query int false "Offset" default(0) -// @Router /api/v1/modules/{moduleId}/lessons [get] func (h *Handler) ListLessonsByModule(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { @@ -132,7 +130,6 @@ func (h *Handler) ListLessonsByModule(c *fiber.Ctx) error { // GetLesson godoc // @Tags lessons // @Param id path int true "Lesson ID" -// @Router /api/v1/lessons/{id} [get] func (h *Handler) GetLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -185,7 +182,6 @@ func (h *Handler) GetLesson(c *fiber.Ctx) error { // @Tags lessons // @Param id path int true "Lesson ID" // @Param body body domain.UpdateLessonInput true "Fields to update" -// @Router /api/v1/lessons/{id} [put] func (h *Handler) UpdateLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -232,7 +228,6 @@ func (h *Handler) UpdateLesson(c *fiber.Ctx) error { // DeleteLesson godoc // @Tags lessons // @Param id path int true "Lesson ID" -// @Router /api/v1/lessons/{id} [delete] func (h *Handler) DeleteLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -273,7 +268,6 @@ func (h *Handler) DeleteLesson(c *fiber.Ctx) error { // @Param id path int true "Lesson ID" // @Success 200 {object} domain.Response // @Failure 403 {object} domain.ErrorResponse -// @Router /api/v1/lessons/{id}/complete [post] func (h *Handler) CompleteLesson(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/lms_persona_handler.go b/internal/web_server/handlers/lms_persona_handler.go index b928b787..4d32dd5e 100644 --- a/internal/web_server/handlers/lms_persona_handler.go +++ b/internal/web_server/handlers/lms_persona_handler.go @@ -24,7 +24,7 @@ type listPersonasData struct { // @Accept json // @Param body body domain.CreateLmsPersonaInput true "Persona" // @Success 201 {object} domain.Response -// @Router /api/v1/personas [post] +// @Router /api/v1/admin/personas [post] func (h *Handler) CreatePersona(c *fiber.Ctx) error { var req domain.CreateLmsPersonaInput if err := c.BodyParser(&req); err != nil { @@ -61,6 +61,7 @@ func (h *Handler) CreatePersona(c *fiber.Ctx) error { // @Param active_only query bool false "When true (default), return only active personas" default(true) // @Param limit query int false "Page size" // @Param offset query int false "Offset" +// @Router /api/v1/admin/personas [get] // @Router /api/v1/personas [get] func (h *Handler) ListPersonas(c *fiber.Ctx) error { activeOnlyStr := strings.ToLower(strings.TrimSpace(c.Query("active_only", "true"))) @@ -95,6 +96,7 @@ func (h *Handler) ListPersonas(c *fiber.Ctx) error { // @Summary Get LMS persona by ID // @Tags personas // @Param id path int true "Persona ID" +// @Router /api/v1/admin/personas/{id} [get] // @Router /api/v1/personas/{id} [get] func (h *Handler) GetPersona(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) @@ -120,7 +122,7 @@ func (h *Handler) GetPersona(c *fiber.Ctx) error { // @Tags personas // @Param id path int true "Persona ID" // @Param body body domain.UpdateLmsPersonaInput true "Fields to update" -// @Router /api/v1/personas/{id} [put] +// @Router /api/v1/admin/personas/{id} [put] func (h *Handler) UpdatePersona(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -152,7 +154,7 @@ func (h *Handler) UpdatePersona(c *fiber.Ctx) error { // @Summary Delete LMS persona (practices referencing it will have persona_id cleared) // @Tags personas // @Param id path int true "Persona ID" -// @Router /api/v1/personas/{id} [delete] +// @Router /api/v1/admin/personas/{id} [delete] func (h *Handler) DeletePersona(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { diff --git a/internal/web_server/handlers/lms_progress_handler.go b/internal/web_server/handlers/lms_progress_handler.go index ce4ac4ec..843ded28 100644 --- a/internal/web_server/handlers/lms_progress_handler.go +++ b/internal/web_server/handlers/lms_progress_handler.go @@ -20,7 +20,6 @@ const lmsProgressSummaryPageSize int32 = 200 // @Produce json // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/lms/progress [get] func (h *Handler) GetMyLMSProgress(c *fiber.Ctx) error { uid := c.Locals("user_id").(int64) prog, err := h.lmsProgressSvc.GetMyProgress(c.Context(), uid) @@ -75,7 +74,6 @@ func (h *Handler) GetMyLMSProgressSummary(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/admin/users/{user_id}/lms-learning-activity [get] func (h *Handler) AdminGetUserLMSLearningActivity(c *fiber.Ctx) error { targetIDStr := c.Params("user_id") targetID, err := strconv.ParseInt(targetIDStr, 10, 64) diff --git a/internal/web_server/handlers/lms_reorder_handler.go b/internal/web_server/handlers/lms_reorder_handler.go index d32cef07..39bf1a53 100644 --- a/internal/web_server/handlers/lms_reorder_handler.go +++ b/internal/web_server/handlers/lms_reorder_handler.go @@ -21,7 +21,6 @@ import ( // @Param body body domain.ReorderIDsRequest true "New order: ordered_ids is the full set of program ids" // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse -// @Router /api/v1/programs/reorder [put] func (h *Handler) ReorderPrograms(c *fiber.Ctx) error { var req domain.ReorderIDsRequest if err := c.BodyParser(&req); err != nil { @@ -66,7 +65,6 @@ func (h *Handler) ReorderPrograms(c *fiber.Ctx) error { // @Param id path int true "Program ID" // @Param body body domain.ReorderIDsRequest true "ordered_ids: every course id in this program, in the new order" // @Tags courses -// @Router /api/v1/programs/{id}/courses/reorder [put] func (h *Handler) ReorderCoursesInProgram(c *fiber.Ctx) error { programID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -125,7 +123,6 @@ func (h *Handler) ReorderCoursesInProgram(c *fiber.Ctx) error { // @Param courseId path int true "Course ID" // @Param body body domain.ReorderIDsRequest true "ordered_ids: every module id in this course, in the new order" // @Tags modules -// @Router /api/v1/courses/{courseId}/modules/reorder [put] func (h *Handler) ReorderModulesInCourse(c *fiber.Ctx) error { courseID, err := strconv.ParseInt(c.Params("courseId"), 10, 64) if err != nil { @@ -183,7 +180,6 @@ func (h *Handler) ReorderModulesInCourse(c *fiber.Ctx) error { // @Param moduleId path int true "Module ID" // @Param body body domain.ReorderIDsRequest true "ordered_ids: every lesson id in this module, in the new order" // @Tags lessons -// @Router /api/v1/modules/{moduleId}/lessons/reorder [put] func (h *Handler) ReorderLessonsInModule(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/module_handler.go b/internal/web_server/handlers/module_handler.go index 542200d4..3c6e08d1 100644 --- a/internal/web_server/handlers/module_handler.go +++ b/internal/web_server/handlers/module_handler.go @@ -22,7 +22,6 @@ import ( // @Param body body domain.CreateModuleInput true "Module" // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse -// @Router /api/v1/courses/{courseId}/modules [post] func (h *Handler) CreateModule(c *fiber.Ctx) error { courseID, err := strconv.ParseInt(c.Params("courseId"), 10, 64) if err != nil { @@ -80,7 +79,6 @@ func (h *Handler) CreateModule(c *fiber.Ctx) error { // @Param limit query int false "Page size" default(20) // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response -// @Router /api/v1/courses/{courseId}/modules [get] func (h *Handler) ListModulesByCourse(c *fiber.Ctx) error { courseID, err := strconv.ParseInt(c.Params("courseId"), 10, 64) if err != nil { @@ -148,7 +146,6 @@ func (h *Handler) ListModulesByCourse(c *fiber.Ctx) error { // @Tags modules // @Param id path int true "Module ID" // @Success 200 {object} domain.Response -// @Router /api/v1/modules/{id} [get] func (h *Handler) GetModule(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -201,7 +198,6 @@ func (h *Handler) GetModule(c *fiber.Ctx) error { // @Tags modules // @Param id path int true "Module ID" // @Param body body domain.UpdateModuleInput true "Fields to update" -// @Router /api/v1/modules/{id} [put] func (h *Handler) UpdateModule(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -248,7 +244,6 @@ func (h *Handler) UpdateModule(c *fiber.Ctx) error { // DeleteModule godoc // @Tags modules // @Param id path int true "Module ID" -// @Router /api/v1/modules/{id} [delete] func (h *Handler) DeleteModule(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/mongoLogger.go b/internal/web_server/handlers/mongoLogger.go index 04456329..a4c47c3a 100644 --- a/internal/web_server/handlers/mongoLogger.go +++ b/internal/web_server/handlers/mongoLogger.go @@ -23,7 +23,7 @@ import ( // @Success 200 {object} domain.LogResponse "Paginated list of application logs" // @Failure 400 {object} domain.ErrorResponse "Invalid request parameters" // @Failure 500 {object} domain.ErrorResponse "Internal server error" -// @Router /api/v1/logs [get] +// @Router /api/v1/admin/logs [get] func GetLogsHandler(appCtx context.Context) fiber.Handler { return func(c *fiber.Ctx) error { // Get query parameters diff --git a/internal/web_server/handlers/notification_handler.go b/internal/web_server/handlers/notification_handler.go index e3a89bb5..3aa46c5d 100644 --- a/internal/web_server/handlers/notification_handler.go +++ b/internal/web_server/handlers/notification_handler.go @@ -24,6 +24,21 @@ import ( "go.uber.org/zap" ) +func notificationRequestContext(c *fiber.Ctx) context.Context { + receiver := domain.ReceiverTypeUser + if c.Locals("api_audience") == "admin" { + receiver = domain.ReceiverTypeTeamMember + } + userID, _ := c.Locals("user_id").(int64) + return domain.WithNotificationScope(c.Context(), userID, receiver) +} + +// ConnectSocket godoc +// @Summary ConnectSocket +// @Tags client +// @Param token query string true "Access token" +// @Router /api/v1/admin/ws/connect [get] +// @Router /api/v1/ws/connect [get] func (h *Handler) ConnectSocket(c *fiber.Ctx) error { userID, ok := c.Locals("userID").(int64) if !ok || userID == 0 { @@ -35,6 +50,11 @@ func (h *Handler) ConnectSocket(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusUnauthorized, "Invalid user identification") } + receiverType := domain.ReceiverTypeUser + if c.Locals("api_audience") == "admin" { + receiverType = domain.ReceiverTypeTeamMember + } + // Convert fasthttp request to net/http request for gorilla upgrader stdReq := &http.Request{ Method: http.MethodGet, @@ -69,8 +89,9 @@ func (h *Handler) ConnectSocket(c *fiber.Ctx) error { } client := &ws.Client{ - Conn: wsConn, - RecipientID: userID, + ReceiverType: receiverType, + Conn: wsConn, + RecipientID: userID, } h.notificationSvc.Hub.Register <- client @@ -133,6 +154,7 @@ func (w *hijackResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/notifications/{id} [get] // @Router /api/v1/notifications/{id} [get] func (h *Handler) GetNotificationByID(c *fiber.Ctx) error { idStr := c.Params("id") @@ -155,7 +177,10 @@ func (h *Handler) GetNotificationByID(c *fiber.Ctx) error { role, _ := c.Locals("role").(domain.Role) allowAll := h.rbacSvc.HasPermission(string(role), "notifications.list_all") - notification, err := h.notificationSvc.GetNotificationByID(c.Context(), id, userID, allowAll) + if c.Locals("api_audience") == "client" { + allowAll = false + } + notification, err := h.notificationSvc.GetNotificationByID(notificationRequestContext(c), id, userID, allowAll) if err != nil { switch { case errors.Is(err, notificationservice.ErrNotificationNotFound): @@ -190,6 +215,12 @@ func (h *Handler) GetNotificationByID(c *fiber.Ctx) error { }) } +// MarkNotificationAsRead godoc +// @Summary MarkNotificationAsRead +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications/{id}/read [patch] +// @Router /api/v1/notifications/{id}/read [patch] func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -200,7 +231,7 @@ func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error { }) } - notification, err := h.notificationSvc.MarkNotificationAsRead(context.Background(), id) + notification, err := h.notificationSvc.MarkNotificationAsRead(notificationRequestContext(c), id) if err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.MarkNotificationAsRead] Failed to mark notification as read", zap.Int64("notificationID", id), @@ -224,6 +255,12 @@ func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error { }) } +// MarkAllNotificationsAsRead godoc +// @Summary MarkAllNotificationsAsRead +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications/mark-all-read [post] +// @Router /api/v1/notifications/mark-all-read [post] func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) if !ok || userID == 0 { @@ -233,7 +270,7 @@ func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error { }) } - if err := h.notificationSvc.MarkAllUserNotificationsAsRead(context.Background(), userID); err != nil { + if err := h.notificationSvc.MarkAllUserNotificationsAsRead(notificationRequestContext(c), userID); err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.MarkAllNotificationsAsRead] Failed to mark all notifications as read", zap.Int64("userID", userID), zap.Int("status_code", fiber.StatusInternalServerError), @@ -255,6 +292,12 @@ func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error { }) } +// MarkNotificationAsUnread godoc +// @Summary MarkNotificationAsUnread +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications/{id}/unread [patch] +// @Router /api/v1/notifications/{id}/unread [patch] func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -265,7 +308,7 @@ func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error { }) } - notification, err := h.notificationSvc.MarkNotificationAsUnread(context.Background(), id) + notification, err := h.notificationSvc.MarkNotificationAsUnread(notificationRequestContext(c), id) if err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.MarkNotificationAsUnread] Failed to mark notification as unread", zap.Int64("notificationID", id), @@ -289,6 +332,12 @@ func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error { }) } +// MarkAllNotificationsAsUnread godoc +// @Summary MarkAllNotificationsAsUnread +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications/mark-all-unread [post] +// @Router /api/v1/notifications/mark-all-unread [post] func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) if !ok || userID == 0 { @@ -298,7 +347,7 @@ func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error { }) } - if err := h.notificationSvc.MarkAllUserNotificationsAsUnread(context.Background(), userID); err != nil { + if err := h.notificationSvc.MarkAllUserNotificationsAsUnread(notificationRequestContext(c), userID); err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.MarkAllNotificationsAsUnread] Failed to mark all notifications as unread", zap.Int64("userID", userID), zap.Int("status_code", fiber.StatusInternalServerError), @@ -320,6 +369,12 @@ func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error { }) } +// DeleteUserNotifications godoc +// @Summary DeleteUserNotifications +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications [delete] +// @Router /api/v1/notifications [delete] func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) if !ok || userID == 0 { @@ -329,7 +384,7 @@ func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error { }) } - if err := h.notificationSvc.DeleteUserNotifications(context.Background(), userID); err != nil { + if err := h.notificationSvc.DeleteUserNotifications(notificationRequestContext(c), userID); err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.DeleteUserNotifications] Failed to delete notifications", zap.Int64("userID", userID), zap.Int("status_code", fiber.StatusInternalServerError), @@ -361,6 +416,7 @@ func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/notifications/{id} [delete] // @Router /api/v1/notifications/{id} [delete] func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error { idStr := c.Params("id") @@ -380,7 +436,7 @@ func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error { }) } - if err := h.notificationSvc.DeleteUserInAppNotification(c.Context(), id, userID); err != nil { + if err := h.notificationSvc.DeleteUserInAppNotification(notificationRequestContext(c), id, userID); err != nil { switch { case errors.Is(err, notificationservice.ErrNotificationNotFound): return c.Status(fiber.StatusNotFound).JSON(domain.ErrorResponse{ @@ -420,6 +476,7 @@ func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/notifications/delete-in-app [post] // @Router /api/v1/notifications/delete-in-app [post] func (h *Handler) DeleteInAppNotifications(c *fiber.Ctx) error { type request struct { @@ -448,7 +505,7 @@ func (h *Handler) DeleteInAppNotifications(c *fiber.Ctx) error { }) } - deletedCount, err := h.notificationSvc.DeleteUserInAppNotifications(c.Context(), userID, req.IDs) + deletedCount, err := h.notificationSvc.DeleteUserInAppNotifications(notificationRequestContext(c), userID, req.IDs) if err != nil { h.mongoLoggerSvc.Error("[NotificationHandler.DeleteInAppNotifications] Failed to delete in-app notifications", zap.Int64("userID", userID), @@ -478,6 +535,11 @@ func (h *Handler) DeleteInAppNotifications(c *fiber.Ctx) error { }) } +// CreateAndSendNotification godoc +// @Summary CreateAndSendNotification +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/notifications/create [post] func (h *Handler) CreateAndSendNotification(c *fiber.Ctx) error { type Request struct { RecipientID int64 `json:"recipient_id" validate:"required_if=DeliveryScheme single"` @@ -639,6 +701,12 @@ func (h *Handler) CreateAndSendNotification(c *fiber.Ctx) error { } } +// GetUserNotification godoc +// @Summary GetUserNotification +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications [get] +// @Router /api/v1/notifications [get] func (h *Handler) GetUserNotification(c *fiber.Ctx) error { limitStr := c.Query("limit", "10") offsetStr := c.Query("offset", "0") @@ -676,7 +744,7 @@ func (h *Handler) GetUserNotification(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, "Invalid user identification") } - notifications, total, err := h.notificationSvc.GetUserNotifications(context.Background(), userID, limit, offset) + notifications, total, err := h.notificationSvc.GetUserNotifications(notificationRequestContext(c), userID, limit, offset) if err != nil { h.mongoLoggerSvc.Error("[NotificationSvc.GetUserNotification] Failed to fetch notifications", zap.Int64("userID", userID), @@ -700,6 +768,12 @@ func (h *Handler) GetUserNotification(c *fiber.Ctx) error { // return h.notificationSvc.ListRecipientIDs(ctx, receiver) // } +// CountUnreadNotifications godoc +// @Summary CountUnreadNotifications +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/notifications/unread [get] +// @Router /api/v1/notifications/unread [get] func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) @@ -712,7 +786,7 @@ func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, "Invalid user identification") } - total, err := h.notificationSvc.CountUnreadNotifications(c.Context(), userID) + total, err := h.notificationSvc.CountUnreadNotifications(notificationRequestContext(c), userID) if err != nil { h.mongoLoggerSvc.Error("[NotificationSvc.CountUnreadNotifications] Failed to fetch unread notification count", @@ -729,6 +803,11 @@ func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error { }) } +// GetAllNotifications godoc +// @Summary GetAllNotifications +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/notifications/all [get] func (h *Handler) GetAllNotifications(c *fiber.Ctx) error { limitStr := c.Query("limit", "10") pageStr := c.Query("page", "1") @@ -811,7 +890,7 @@ type SendSingleAfroSMSReq struct { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/sendSMS [post] +// @Router /api/v1/admin/sendSMS [post] func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error { var req SendSingleAfroSMSReq @@ -872,6 +951,12 @@ func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error { }) } +// RegisterDeviceToken godoc +// @Summary RegisterDeviceToken +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/devices/register [post] +// @Router /api/v1/devices/register [post] func (h *Handler) RegisterDeviceToken(c *fiber.Ctx) error { type Request struct { DeviceToken string `json:"device_token" validate:"required"` @@ -952,7 +1037,7 @@ func (h *Handler) RegisterDeviceToken(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 401 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/test-push [post] +// @Router /api/v1/admin/notifications/test-push [post] func (h *Handler) SendTestPushNotification(c *fiber.Ctx) error { title := c.FormValue("title", "Test Push Notification") message := c.FormValue("message", "This is a test push notification from Rezina") @@ -1055,7 +1140,7 @@ func (h *Handler) SendTestPushNotification(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/bulk-push [post] +// @Router /api/v1/admin/notifications/bulk-push [post] func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error { title := c.FormValue("title") message := c.FormValue("message") @@ -1128,10 +1213,10 @@ func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error { scheduledID := created.ID scheduleMeta, _ := json.Marshal(map[string]interface{}{ - "channel": "push", - "target_users": len(userIDs), - "target_role": role, - "scheduled_at": scheduledAtRaw, + "channel": "push", + "target_users": len(userIDs), + "target_role": role, + "scheduled_at": scheduledAtRaw, }) h.recordActivity(c, domain.ActionNotificationBulkSent, domain.ResourceNotification, &scheduledID, fmt.Sprintf("Scheduled push notification ID: %d", scheduledID), scheduleMeta) @@ -1262,7 +1347,7 @@ func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/bulk-sms [post] +// @Router /api/v1/admin/notifications/bulk-sms [post] func (h *Handler) SendBulkSMS(c *fiber.Ctx) error { type Request struct { Message string `json:"message" validate:"required"` @@ -1446,18 +1531,18 @@ func (h *Handler) SendBulkSMS(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/bulk-in-app [post] +// @Router /api/v1/admin/notifications/bulk-in-app [post] func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error { type Request struct { - Title string `json:"title" validate:"required"` - Message string `json:"message" validate:"required"` - UserIDs []int64 `json:"user_ids"` - Role string `json:"role"` - TeamMemberIDs []int64 `json:"team_member_ids"` - TeamRole string `json:"team_role"` - ScheduledAt string `json:"scheduled_at"` - Type string `json:"type"` - Level string `json:"level"` + Title string `json:"title" validate:"required"` + Message string `json:"message" validate:"required"` + UserIDs []int64 `json:"user_ids"` + Role string `json:"role"` + TeamMemberIDs []int64 `json:"team_member_ids"` + TeamRole string `json:"team_role"` + ScheduledAt string `json:"scheduled_at"` + Type string `json:"type"` + Level string `json:"level"` } var req Request @@ -1533,12 +1618,12 @@ func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error { scheduledID := created.ID scheduleMeta, _ := json.Marshal(map[string]interface{}{ - "channel": "in_app", - "target_users": len(req.UserIDs), - "target_role": req.Role, + "channel": "in_app", + "target_users": len(req.UserIDs), + "target_role": req.Role, "target_team_members": len(req.TeamMemberIDs), - "target_team_role": req.TeamRole, - "scheduled_at": req.ScheduledAt, + "target_team_role": req.TeamRole, + "scheduled_at": req.ScheduledAt, }) h.recordActivity(c, domain.ActionNotificationBulkSent, domain.ResourceNotification, &scheduledID, fmt.Sprintf("Scheduled in-app notification ID: %d", scheduledID), scheduleMeta) @@ -1586,12 +1671,12 @@ func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error { ) bulkInAppMeta, _ := json.Marshal(map[string]interface{}{ - "channel": "in_app", - "total_recipients": totalRecipients, - "user_recipients": len(userIDs), + "channel": "in_app", + "total_recipients": totalRecipients, + "user_recipients": len(userIDs), "team_member_recipients": len(teamMemberIDs), - "sent": sent, - "failed": failed, + "sent": sent, + "failed": failed, }) h.recordActivity(c, domain.ActionNotificationBulkSent, domain.ResourceNotification, nil, fmt.Sprintf("Bulk in-app notification sent to %d recipients", totalRecipients), bulkInAppMeta) @@ -1618,7 +1703,7 @@ func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/scheduled/{id} [get] +// @Router /api/v1/admin/notifications/scheduled/{id} [get] func (h *Handler) GetScheduledNotification(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -1658,7 +1743,7 @@ func (h *Handler) GetScheduledNotification(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/scheduled [get] +// @Router /api/v1/admin/notifications/scheduled [get] func (h *Handler) ListScheduledNotifications(c *fiber.Ctx) error { limit, err := strconv.Atoi(c.Query("limit", "20")) if err != nil || limit <= 0 { @@ -1727,7 +1812,7 @@ func (h *Handler) ListScheduledNotifications(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/scheduled/{id}/cancel [post] +// @Router /api/v1/admin/notifications/scheduled/{id}/cancel [post] func (h *Handler) CancelScheduledNotification(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -1790,7 +1875,7 @@ func (h *Handler) parseEmailAttachment(c *fiber.Ctx) []*resend.Attachment { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/send-email [post] +// @Router /api/v1/admin/notifications/send-email [post] func (h *Handler) SendSingleEmail(c *fiber.Ctx) error { recipient := strings.TrimSpace(c.FormValue("recipient")) if recipient == "" { @@ -1845,7 +1930,7 @@ func (h *Handler) SendSingleEmail(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/notifications/bulk-email [post] +// @Router /api/v1/admin/notifications/bulk-email [post] func (h *Handler) SendBulkEmail(c *fiber.Ctx) error { role := c.FormValue("role") userIDsRaw := c.FormValue("user_ids") @@ -2033,6 +2118,12 @@ func (h *Handler) SendBulkEmail(c *fiber.Ctx) error { }) } +// UnregisterDeviceToken godoc +// @Summary UnregisterDeviceToken +// @Tags client +// @Security Bearer +// @Router /api/v1/admin/devices/unregister [post] +// @Router /api/v1/devices/unregister [post] func (h *Handler) UnregisterDeviceToken(c *fiber.Ctx) error { type Request struct { DeviceToken string `json:"device_token" validate:"required"` diff --git a/internal/web_server/handlers/practice_full_update_handler.go b/internal/web_server/handlers/practice_full_update_handler.go index 62c66749..ca770435 100644 --- a/internal/web_server/handlers/practice_full_update_handler.go +++ b/internal/web_server/handlers/practice_full_update_handler.go @@ -170,7 +170,6 @@ func mapPracticeFullError(err error, action string) (int, string) { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/practices/{id}/full [get] func (h *Handler) GetLmsPracticeFull(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -240,6 +239,7 @@ func (h *Handler) GetLmsPracticeFull(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse +// @Router /api/v1/admin/exam-prep/practices/{id}/full [get] func (h *Handler) GetExamPrepPracticeFull(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -307,7 +307,6 @@ func (h *Handler) GetExamPrepPracticeFull(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/practices/{id}/full [put] func (h *Handler) UpdateLmsPracticeFull(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -381,6 +380,7 @@ func (h *Handler) UpdateLmsPracticeFull(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse +// @Router /api/v1/admin/exam-prep/practices/{id}/full [put] func (h *Handler) UpdateExamPrepPracticeFull(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/practice_handler.go b/internal/web_server/handlers/practice_handler.go index a64ecfe0..9303c5e8 100644 --- a/internal/web_server/handlers/practice_handler.go +++ b/internal/web_server/handlers/practice_handler.go @@ -18,7 +18,6 @@ import ( // @Tags practices // @Accept json // @Param body body domain.CreatePracticeInput true "Practice (optional parents; link later via PUT /practices/:id/parents)" -// @Router /api/v1/practices [post] func (h *Handler) CreatePractice(c *fiber.Ctx) error { var req domain.CreatePracticeInput if err := c.BodyParser(&req); err != nil { @@ -76,7 +75,6 @@ func (h *Handler) CreatePractice(c *fiber.Ctx) error { // @Param limit query int false "Page size (default 20, max 200)" // @Param offset query int false "Page offset (default 0)" // @Param unlinked_only query bool false "When true, return only practices with no parent links (admin)" -// @Router /api/v1/practices [get] func (h *Handler) ListPractices(c *fiber.Ctx) error { limit, _ := strconv.Atoi(c.Query("limit", "20")) offset, _ := strconv.Atoi(c.Query("offset", "0")) @@ -108,7 +106,6 @@ func (h *Handler) ListPractices(c *fiber.Ctx) error { // ListPracticesByCourse godoc // @Tags practices // @Param id path int true "Course ID" -// @Router /api/v1/courses/{id}/practices [get] func (h *Handler) ListPracticesByCourse(c *fiber.Ctx) error { courseID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -143,7 +140,6 @@ func (h *Handler) ListPracticesByCourse(c *fiber.Ctx) error { // ListPracticesByModule godoc // @Tags practices // @Param id path int true "Module ID" -// @Router /api/v1/modules/{id}/practices [get] func (h *Handler) ListPracticesByModule(c *fiber.Ctx) error { moduleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -178,7 +174,6 @@ func (h *Handler) ListPracticesByModule(c *fiber.Ctx) error { // ListPracticesByLesson godoc // @Tags practices // @Param id path int true "Lesson ID" -// @Router /api/v1/lessons/{id}/practices [get] func (h *Handler) ListPracticesByLesson(c *fiber.Ctx) error { lessonID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -218,7 +213,6 @@ type practiceWithStimulusRes struct { // GetPractice godoc // @Tags practices // @Param id path int true "Practice ID" -// @Router /api/v1/practices/{id} [get] func (h *Handler) GetPractice(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -296,7 +290,6 @@ func practiceAccessForQuestionSet(set domain.QuestionSet) *domain.PracticeAccess // @Tags practices // @Param id path int true "Practice ID" // @Param body body domain.UpdatePracticeInput true "Practice metadata fields to update" -// @Router /api/v1/practices/{id} [put] func (h *Handler) UpdatePractice(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -333,7 +326,6 @@ func (h *Handler) UpdatePractice(c *fiber.Ctx) error { // @Accept json // @Param id path int true "Practice ID" // @Param body body domain.UpdatePracticeParentsInput true "Parent links (replaces all; use empty array to detach)" -// @Router /api/v1/practices/{id}/parents [put] func (h *Handler) UpdatePracticeParents(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -387,7 +379,6 @@ func (h *Handler) UpdatePracticeParents(c *fiber.Ctx) error { // @Param id path int true "Practice ID" // @Param parentKind path string true "Parent kind (COURSE, MODULE, LESSON)" // @Param parentId path int true "Parent entity ID" -// @Router /api/v1/practices/{id}/parents/{parentKind}/{parentId} [delete] func (h *Handler) UnlinkPracticeParent(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -431,7 +422,6 @@ func (h *Handler) UnlinkPracticeParent(c *fiber.Ctx) error { // DeletePractice godoc // @Tags practices // @Param id path int true "Practice ID" -// @Router /api/v1/practices/{id} [delete] func (h *Handler) DeletePractice(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/program_handler.go b/internal/web_server/handlers/program_handler.go index 7a778b9a..81541268 100644 --- a/internal/web_server/handlers/program_handler.go +++ b/internal/web_server/handlers/program_handler.go @@ -21,7 +21,6 @@ import ( // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/programs [post] func (h *Handler) CreateProgram(c *fiber.Ctx) error { var req domain.CreateProgramInput if err := c.BodyParser(&req); err != nil { @@ -66,7 +65,6 @@ func (h *Handler) CreateProgram(c *fiber.Ctx) error { // @Param offset query int false "Offset" default(0) // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/programs [get] func (h *Handler) ListPrograms(c *fiber.Ctx) error { limit, _ := strconv.Atoi(c.Query("limit", "20")) offset, _ := strconv.Atoi(c.Query("offset", "0")) @@ -114,7 +112,6 @@ func (h *Handler) ListPrograms(c *fiber.Ctx) error { // @Param id path int true "Program ID" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/programs/{id} [get] func (h *Handler) GetProgram(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -172,7 +169,6 @@ func (h *Handler) GetProgram(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/programs/{id} [put] func (h *Handler) UpdateProgram(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -227,7 +223,6 @@ func (h *Handler) UpdateProgram(c *fiber.Ctx) error { // @Param id path int true "Program ID" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/programs/{id} [delete] func (h *Handler) DeleteProgram(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { diff --git a/internal/web_server/handlers/question_type_builder.go b/internal/web_server/handlers/question_type_builder.go index b105bfe2..af504265 100644 --- a/internal/web_server/handlers/question_type_builder.go +++ b/internal/web_server/handlers/question_type_builder.go @@ -105,7 +105,7 @@ func parseOptionalGroupIDQuery(c *fiber.Ctx) (*int64, error) { // @Tags questions // @Produce json // @Success 200 {object} domain.Response -// @Router /api/v1/questions/component-catalog [get] +// @Router /api/v1/admin/questions/component-catalog [get] func (h *Handler) GetQuestionTypeComponentCatalog(c *fiber.Ctx) error { return c.JSON(domain.Response{ Message: "Component catalog", @@ -125,7 +125,7 @@ func (h *Handler) GetQuestionTypeComponentCatalog(c *fiber.Ctx) error { // @Param body body validateQuestionTypeDefinitionReq true "Stimulus and response component kinds" // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse -// @Router /api/v1/questions/validate-question-type-definition [post] +// @Router /api/v1/admin/questions/validate-question-type-definition [post] func (h *Handler) ValidateQuestionTypeDefinition(c *fiber.Ctx) error { var req validateQuestionTypeDefinitionReq if err := c.BodyParser(&req); err != nil { @@ -158,7 +158,7 @@ func (h *Handler) ValidateQuestionTypeDefinition(c *fiber.Ctx) error { // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions [post] +// @Router /api/v1/admin/questions/type-definitions [post] func (h *Handler) CreateQuestionTypeDefinition(c *fiber.Ctx) error { var req createQuestionTypeDefinitionReq if err := c.BodyParser(&req); err != nil { @@ -222,7 +222,7 @@ func (h *Handler) CreateQuestionTypeDefinition(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions [get] +// @Router /api/v1/admin/questions/type-definitions [get] func (h *Handler) ListQuestionTypeDefinitions(c *fiber.Ctx) error { status := strings.ToUpper(strings.TrimSpace(c.Query("status"))) var statusPtr *string @@ -300,7 +300,7 @@ func (h *Handler) ListQuestionTypeDefinitions(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions/{id} [get] +// @Router /api/v1/admin/questions/type-definitions/{id} [get] func (h *Handler) GetQuestionTypeDefinitionByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -335,7 +335,7 @@ func (h *Handler) GetQuestionTypeDefinitionByID(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions/{id}/practices [get] +// @Router /api/v1/admin/questions/type-definitions/{id}/practices [get] func (h *Handler) ListPracticesByQuestionTypeDefinition(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -382,7 +382,7 @@ func (h *Handler) ListPracticesByQuestionTypeDefinition(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions/{id} [put] +// @Router /api/v1/admin/questions/type-definitions/{id} [put] func (h *Handler) UpdateQuestionTypeDefinition(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -455,7 +455,7 @@ func (h *Handler) UpdateQuestionTypeDefinition(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definitions/{id} [delete] +// @Router /api/v1/admin/questions/type-definitions/{id} [delete] func (h *Handler) DeleteQuestionTypeDefinition(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -490,7 +490,7 @@ func (h *Handler) DeleteQuestionTypeDefinition(c *fiber.Ctx) error { // @Produce json // @Param body body createQuestionTypeDefinitionGroupReq true "Group payload" // @Success 201 {object} domain.Response -// @Router /api/v1/questions/type-definition-groups [post] +// @Router /api/v1/admin/questions/type-definition-groups [post] func (h *Handler) CreateQuestionTypeDefinitionGroup(c *fiber.Ctx) error { var req createQuestionTypeDefinitionGroupReq if err := c.BodyParser(&req); err != nil { @@ -538,7 +538,7 @@ func (h *Handler) CreateQuestionTypeDefinitionGroup(c *fiber.Ctx) error { // @Param limit query int false "Page size (default 20, max 200)" default(20) // @Param offset query int false "Page offset" default(0) // @Success 200 {object} domain.Response -// @Router /api/v1/questions/type-definition-groups [get] +// @Router /api/v1/admin/questions/type-definition-groups [get] func (h *Handler) ListQuestionTypeDefinitionGroups(c *fiber.Ctx) error { status := strings.ToUpper(strings.TrimSpace(c.Query("status"))) var statusPtr *string @@ -592,7 +592,7 @@ func (h *Handler) ListQuestionTypeDefinitionGroups(c *fiber.Ctx) error { // @Param id path int true "Group id" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/questions/type-definition-groups/{id} [get] +// @Router /api/v1/admin/questions/type-definition-groups/{id} [get] func (h *Handler) GetQuestionTypeDefinitionGroupByID(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -630,7 +630,7 @@ func (h *Handler) GetQuestionTypeDefinitionGroupByID(c *fiber.Ctx) error { // @Param id path int true "Group id" // @Param body body updateQuestionTypeDefinitionGroupReq true "Update group payload" // @Success 200 {object} domain.Response -// @Router /api/v1/questions/type-definition-groups/{id} [put] +// @Router /api/v1/admin/questions/type-definition-groups/{id} [put] func (h *Handler) UpdateQuestionTypeDefinitionGroup(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { @@ -686,7 +686,7 @@ func (h *Handler) UpdateQuestionTypeDefinitionGroup(c *fiber.Ctx) error { // @Produce json // @Param id path int true "Group id" // @Success 200 {object} domain.Response -// @Router /api/v1/questions/type-definition-groups/{id} [delete] +// @Router /api/v1/admin/questions/type-definition-groups/{id} [delete] func (h *Handler) DeleteQuestionTypeDefinitionGroup(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || id <= 0 { diff --git a/internal/web_server/handlers/questions.go b/internal/web_server/handlers/questions.go index 497c89b0..9a7df1ec 100644 --- a/internal/web_server/handlers/questions.go +++ b/internal/web_server/handlers/questions.go @@ -215,7 +215,7 @@ func activityLogQuestionSummary(questionType string, stored string, payload *dom // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions [post] +// @Router /api/v1/admin/questions [post] func (h *Handler) CreateQuestion(c *fiber.Ctx) error { var req createQuestionReq if err := c.BodyParser(&req); err != nil { @@ -369,7 +369,7 @@ func (h *Handler) CreateQuestion(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/questions/{id} [get] +// @Router /api/v1/admin/questions/{id} [get] func (h *Handler) GetQuestionByID(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -415,7 +415,7 @@ func (h *Handler) GetQuestionByID(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions [get] +// @Router /api/v1/admin/questions [get] func (h *Handler) ListQuestions(c *fiber.Ctx) error { questionType := c.Query("question_type") difficulty := c.Query("difficulty") @@ -478,7 +478,7 @@ func (h *Handler) ListQuestions(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/search [get] +// @Router /api/v1/admin/questions/search [get] func (h *Handler) SearchQuestions(c *fiber.Ctx) error { query := c.Query("q") if query == "" { @@ -551,7 +551,7 @@ type updateQuestionReq struct { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/{id} [put] +// @Router /api/v1/admin/questions/{id} [put] func (h *Handler) UpdateQuestion(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -721,7 +721,7 @@ func (h *Handler) UpdateQuestion(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/questions/{id} [delete] +// @Router /api/v1/admin/questions/{id} [delete] func (h *Handler) DeleteQuestion(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -841,7 +841,7 @@ func (h *Handler) enforcePracticeSequenceForStudent(c *fiber.Ctx, set domain.Que // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets [post] +// @Router /api/v1/admin/question-sets [post] func (h *Handler) CreateQuestionSet(c *fiber.Ctx) error { var req createQuestionSetReq if err := c.BodyParser(&req); err != nil { @@ -910,7 +910,7 @@ func (h *Handler) CreateQuestionSet(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{id} [get] +// @Router /api/v1/admin/question-sets/{id} [get] func (h *Handler) GetQuestionSetByID(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -975,7 +975,7 @@ func (h *Handler) GetQuestionSetByID(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets [get] +// @Router /api/v1/admin/question-sets [get] func (h *Handler) GetQuestionSetsByType(c *fiber.Ctx) error { setType := c.Query("set_type") if setType == "" { @@ -1038,7 +1038,7 @@ func (h *Handler) GetQuestionSetsByType(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/by-owner [get] +// @Router /api/v1/admin/question-sets/by-owner [get] func (h *Handler) GetQuestionSetsByOwner(c *fiber.Ctx) error { ownerType := c.Query("owner_type") ownerIDStr := c.Query("owner_id") @@ -1116,7 +1116,7 @@ type updateQuestionSetReq struct { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{id} [put] +// @Router /api/v1/admin/question-sets/{id} [put] func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -1198,7 +1198,7 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{id} [delete] +// @Router /api/v1/admin/question-sets/{id} [delete] func (h *Handler) DeleteQuestionSet(c *fiber.Ctx) error { idStr := c.Params("id") id, err := strconv.ParseInt(idStr, 10, 64) @@ -1343,7 +1343,7 @@ func questionSetItemsToRes( // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/questions [post] +// @Router /api/v1/admin/question-sets/{setId}/questions [post] func (h *Handler) AddQuestionToSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -1415,7 +1415,7 @@ func (h *Handler) AddQuestionToSet(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/question-types [get] +// @Router /api/v1/admin/question-sets/{setId}/question-types [get] func (h *Handler) GetQuestionTypesInSet(c *fiber.Ctx) error { setID, err := strconv.ParseInt(c.Params("setId"), 10, 64) if err != nil { @@ -1501,7 +1501,7 @@ func (h *Handler) questionSetStimulusContexts(ctx context.Context, setID int64) // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/questions [get] +// @Router /api/v1/admin/question-sets/{setId}/questions [get] func (h *Handler) GetQuestionsInSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -1760,7 +1760,7 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error { // The exam-prep route is authoritative for the rebuilt hierarchy; legacy IDs // may overlap while both schemas exist during migration. - isExamPrepRoute := strings.HasPrefix(c.Path(), "/api/v1/exam-prep/") + isExamPrepRoute := strings.Contains(c.Route().Path, "/exam-prep/") var ( lmsPractice *domain.Practice examPractice *domain.ExamPrepPractice @@ -1902,7 +1902,7 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/questions/{questionId} [delete] +// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId} [delete] func (h *Handler) RemoveQuestionFromSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -1962,7 +1962,7 @@ type updateQuestionOrderReq struct { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/questions/{questionId}/order [put] +// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId}/order [put] func (h *Handler) UpdateQuestionOrderInSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -2046,7 +2046,7 @@ type addUserPersonaReq struct { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/personas [get] +// @Router /api/v1/admin/question-sets/{setId}/personas [get] func (h *Handler) GetUserPersonasByQuestionSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -2095,7 +2095,7 @@ func (h *Handler) GetUserPersonasByQuestionSet(c *fiber.Ctx) error { // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/personas [post] +// @Router /api/v1/admin/question-sets/{setId}/personas [post] func (h *Handler) AddUserPersonaToQuestionSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) @@ -2148,7 +2148,7 @@ func (h *Handler) AddUserPersonaToQuestionSet(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/question-sets/{setId}/personas/{userId} [delete] +// @Router /api/v1/admin/question-sets/{setId}/personas/{userId} [delete] func (h *Handler) RemoveUserPersonaFromQuestionSet(c *fiber.Ctx) error { setIDStr := c.Params("setId") setID, err := strconv.ParseInt(setIDStr, 10, 64) diff --git a/internal/web_server/handlers/ratings.go b/internal/web_server/handlers/ratings.go index 43b971bc..34cba96c 100644 --- a/internal/web_server/handlers/ratings.go +++ b/internal/web_server/handlers/ratings.go @@ -162,6 +162,7 @@ func (h *Handler) GetMyRating(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/ratings [get] // @Router /api/v1/ratings [get] func (h *Handler) GetRatingsByTarget(c *fiber.Ctx) error { targetType := c.Query("target_type") @@ -228,6 +229,7 @@ func (h *Handler) GetRatingsByTarget(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/ratings/summary [get] // @Router /api/v1/ratings/summary [get] func (h *Handler) GetRatingSummary(c *fiber.Ctx) error { targetType := c.Query("target_type") @@ -305,6 +307,7 @@ func (h *Handler) GetMyRatings(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/ratings/{id} [delete] // @Router /api/v1/ratings/{id} [delete] func (h *Handler) DeleteRating(c *fiber.Ctx) error { userID := c.Locals("user_id").(int64) diff --git a/internal/web_server/handlers/rbac_handler.go b/internal/web_server/handlers/rbac_handler.go index 1f81ea26..6e886d54 100644 --- a/internal/web_server/handlers/rbac_handler.go +++ b/internal/web_server/handlers/rbac_handler.go @@ -25,7 +25,7 @@ import ( // @Param page_size query int false "Page size (default: 20)" // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles [get] +// @Router /api/v1/admin/rbac/roles [get] func (h *Handler) ListRoles(c *fiber.Ctx) error { filter := domain.RoleListFilter{ Query: c.Query("query"), @@ -76,7 +76,7 @@ func (h *Handler) ListRoles(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles/{id} [get] +// @Router /api/v1/admin/rbac/roles/{id} [get] func (h *Handler) GetRoleByID(c *fiber.Ctx) error { roleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || roleID <= 0 { @@ -136,7 +136,7 @@ func (h *Handler) GetRoleByID(c *fiber.Ctx) error { // @Success 201 {object} domain.Response{data=domain.RoleRecord} // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles [post] +// @Router /api/v1/admin/rbac/roles [post] func (h *Handler) CreateRole(c *fiber.Ctx) error { var req domain.CreateRoleReq if err := c.BodyParser(&req); err != nil { @@ -208,7 +208,7 @@ func (h *Handler) CreateRole(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles/{id} [put] +// @Router /api/v1/admin/rbac/roles/{id} [put] func (h *Handler) UpdateRole(c *fiber.Ctx) error { roleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || roleID <= 0 { @@ -285,7 +285,7 @@ func (h *Handler) UpdateRole(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles/{id} [delete] +// @Router /api/v1/admin/rbac/roles/{id} [delete] func (h *Handler) DeleteRole(c *fiber.Ctx) error { roleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || roleID <= 0 { @@ -339,7 +339,7 @@ func (h *Handler) DeleteRole(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles/{id}/permissions [put] +// @Router /api/v1/admin/rbac/roles/{id}/permissions [put] func (h *Handler) SetRolePermissions(c *fiber.Ctx) error { roleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || roleID <= 0 { @@ -416,7 +416,7 @@ func (h *Handler) SetRolePermissions(c *fiber.Ctx) error { // @Success 200 {object} domain.Response{data=[]domain.Permission} // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/roles/{id}/permissions [get] +// @Router /api/v1/admin/rbac/roles/{id}/permissions [get] func (h *Handler) GetRolePermissions(c *fiber.Ctx) error { roleID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || roleID <= 0 { @@ -457,7 +457,7 @@ func (h *Handler) GetRolePermissions(c *fiber.Ctx) error { // @Security Bearer // @Success 200 {object} domain.Response{data=[]domain.Permission} // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/permissions [get] +// @Router /api/v1/admin/rbac/permissions [get] func (h *Handler) ListPermissions(c *fiber.Ctx) error { permissions, err := h.rbacSvc.ListPermissions(c.Context()) if err != nil { @@ -494,7 +494,7 @@ func (h *Handler) ListPermissions(c *fiber.Ctx) error { // @Security Bearer // @Success 200 {object} domain.Response{data=[]string} // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/permissions/groups [get] +// @Router /api/v1/admin/rbac/permissions/groups [get] func (h *Handler) ListPermissionGroups(c *fiber.Ctx) error { groups, err := h.rbacSvc.ListPermissionGroups(c.Context()) if err != nil { @@ -526,7 +526,7 @@ func (h *Handler) ListPermissionGroups(c *fiber.Ctx) error { // @Security Bearer // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/rbac/permissions/sync [post] +// @Router /api/v1/admin/rbac/permissions/sync [post] func (h *Handler) SyncPermissions(c *fiber.Ctx) error { if err := h.rbacSvc.SeedPermissions(c.Context()); err != nil { h.mongoLoggerSvc.Error("Failed to seed permissions", diff --git a/internal/web_server/handlers/referal_handlers.go b/internal/web_server/handlers/referal_handlers.go index bb5206d3..1f969364 100644 --- a/internal/web_server/handlers/referal_handlers.go +++ b/internal/web_server/handlers/referal_handlers.go @@ -57,6 +57,9 @@ func referralPagination(c *fiber.Ctx) (int32, int32, error) { } // CreateReferralCode creates or returns the authenticated learner's stable share code. +// @Router /api/v1/referrals/code [post] +// @Summary CreateReferralCode +// @Tags client func (h *Handler) CreateReferralCode(c *fiber.Ctx) error { id, err := referralLearner(c) if err != nil { @@ -65,7 +68,17 @@ func (h *Handler) CreateReferralCode(c *fiber.Ctx) error { code, err := h.referralSvc.Code(c.Context(), id) return referralResponse(c, fiber.Map{"code": code}, err) } +// GetReferralCode godoc +// @Summary GetReferralCode +// @Tags client +// @Security Bearer +// @Router /api/v1/referrals/code [get] func (h *Handler) GetReferralCode(c *fiber.Ctx) error { return h.CreateReferralCode(c) } +// GetMyReferrals godoc +// @Summary GetMyReferrals +// @Tags client +// @Security Bearer +// @Router /api/v1/referrals/me [get] func (h *Handler) GetMyReferrals(c *fiber.Ctx) error { id, err := referralLearner(c) if err != nil { @@ -74,6 +87,11 @@ func (h *Handler) GetMyReferrals(c *fiber.Ctx) error { data, err := h.referralSvc.Overview(c.Context(), id) return referralResponse(c, data, err) } +// ApplyReferralCode godoc +// @Summary ApplyReferralCode +// @Tags client +// @Security Bearer +// @Router /api/v1/referrals/apply [post] func (h *Handler) ApplyReferralCode(c *fiber.Ctx) error { id, err := referralLearner(c) if err != nil { @@ -87,6 +105,11 @@ func (h *Handler) ApplyReferralCode(c *fiber.Ctx) error { } return referralResponse(c, nil, h.referralSvc.Apply(c.Context(), id, input.Code)) } +// ListMyReferrals godoc +// @Summary ListMyReferrals +// @Tags client +// @Security Bearer +// @Router /api/v1/referrals [get] func (h *Handler) ListMyReferrals(c *fiber.Ctx) error { id, err := referralLearner(c) if err != nil { @@ -99,6 +122,11 @@ func (h *Handler) ListMyReferrals(c *fiber.Ctx) error { data, err := h.referralSvc.List(c.Context(), id, limit, offset) return referralResponse(c, fiber.Map{"items": data, "limit": limit, "offset": offset}, err) } +// GetReferralWallet godoc +// @Summary GetReferralWallet +// @Tags client +// @Security Bearer +// @Router /api/v1/referrals/wallet [get] func (h *Handler) GetReferralWallet(c *fiber.Ctx) error { id, err := referralLearner(c) if err != nil { @@ -115,6 +143,11 @@ func (h *Handler) GetReferralWallet(c *fiber.Ctx) error { entries, err := h.referralSvc.Commissions(c.Context(), id, limit, offset) return referralResponse(c, fiber.Map{"balances": overview.Wallet, "transactions": entries, "limit": limit, "offset": offset}, err) } +// GetReferralSettings godoc +// @Summary GetReferralSettings +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/referrals/settings [get] func (h *Handler) GetReferralSettings(c *fiber.Ctx) error { if _, err := referralAdmin(c); err != nil { return err @@ -122,6 +155,11 @@ func (h *Handler) GetReferralSettings(c *fiber.Ctx) error { data, err := h.referralSvc.Settings(c.Context()) return referralResponse(c, data, err) } +// UpdateReferralSettings godoc +// @Summary UpdateReferralSettings +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/referrals/settings [put] func (h *Handler) UpdateReferralSettings(c *fiber.Ctx) error { id, err := referralAdmin(c) if err != nil { diff --git a/internal/web_server/handlers/settings_handler.go b/internal/web_server/handlers/settings_handler.go index 84221bcf..c38a9e38 100644 --- a/internal/web_server/handlers/settings_handler.go +++ b/internal/web_server/handlers/settings_handler.go @@ -12,6 +12,11 @@ import ( "go.uber.org/zap" ) +// GetGlobalSettingList godoc +// @Summary GetGlobalSettingList +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/settings [get] func (h *Handler) GetGlobalSettingList(c *fiber.Ctx) error { settingsList, err := h.settingSvc.GetGlobalSettingList(c.Context()) @@ -30,6 +35,11 @@ func (h *Handler) GetGlobalSettingList(c *fiber.Ctx) error { return response.WriteJSON(c, fiber.StatusOK, "All Settings retrieved successfully", res, nil) } +// GetGlobalSettingByKey godoc +// @Summary GetGlobalSettingByKey +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/settings/{key} [get] func (h *Handler) GetGlobalSettingByKey(c *fiber.Ctx) error { settingKey := c.Params("key") if settingKey == "" { @@ -57,6 +67,11 @@ func (h *Handler) GetGlobalSettingByKey(c *fiber.Ctx) error { } +// UpdateGlobalSettingList godoc +// @Summary UpdateGlobalSettingList +// @Tags admin +// @Security Bearer +// @Router /api/v1/admin/settings [put] func (h *Handler) UpdateGlobalSettingList(c *fiber.Ctx) error { var req domain.SaveSettingListReq diff --git a/internal/web_server/handlers/subscriptions.go b/internal/web_server/handlers/subscriptions.go index bcbf07c5..f04e54f8 100644 --- a/internal/web_server/handlers/subscriptions.go +++ b/internal/web_server/handlers/subscriptions.go @@ -120,7 +120,7 @@ type autoRenewReq struct { // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/subscription-plans [post] +// @Router /api/v1/admin/subscription-plans [post] func (h *Handler) CreateSubscriptionPlan(c *fiber.Ctx) error { var req createPlanReq if err := c.BodyParser(&req); err != nil { @@ -206,9 +206,13 @@ func (h *Handler) CreateSubscriptionPlan(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/subscription-plans [get] // @Router /api/v1/subscription-plans [get] func (h *Handler) ListSubscriptionPlans(c *fiber.Ctx) error { activeOnly := c.Query("active_only", "true") == "true" + if c.Locals("api_audience") == "client" { + activeOnly = true + } var categoryFilter *string if raw := strings.TrimSpace(c.Query("category")); raw != "" { @@ -249,6 +253,7 @@ func (h *Handler) ListSubscriptionPlans(c *fiber.Ctx) error { // @Param id path int true "Plan ID" // @Success 200 {object} domain.Response // @Failure 404 {object} domain.ErrorResponse +// @Router /api/v1/admin/subscription-plans/{id} [get] // @Router /api/v1/subscription-plans/{id} [get] func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) @@ -265,6 +270,10 @@ func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error { }) } + if c.Locals("api_audience") == "client" && !plan.IsActive { + return fiber.NewError(fiber.StatusNotFound, "Subscription plan not found") + } + return c.JSON(domain.Response{ Message: "Subscription plan retrieved successfully", Data: planToRes(plan), @@ -282,7 +291,7 @@ func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/subscription-plans/{id} [put] +// @Router /api/v1/admin/subscription-plans/{id} [put] func (h *Handler) UpdateSubscriptionPlan(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -383,7 +392,7 @@ func (h *Handler) UpdateSubscriptionPlan(c *fiber.Ctx) error { // @Param id path int true "Plan ID" // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/subscription-plans/{id} [delete] +// @Router /api/v1/admin/subscription-plans/{id} [delete] func (h *Handler) DeleteSubscriptionPlan(c *fiber.Ctx) error { id, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil { @@ -438,8 +447,8 @@ func (h *Handler) DeleteSubscriptionPlan(c *fiber.Ctx) error { // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/subscriptions [post] // @deprecated Use POST /api/v1/payments/subscribe for user subscriptions with payment +// @Router /api/v1/subscriptions [post] func (h *Handler) Subscribe(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) if !ok { diff --git a/internal/web_server/handlers/team_handler.go b/internal/web_server/handlers/team_handler.go index 459fb66c..96343ff2 100644 --- a/internal/web_server/handlers/team_handler.go +++ b/internal/web_server/handlers/team_handler.go @@ -47,7 +47,7 @@ func mapTeamRoleToRole(teamRole domain.TeamRole) domain.Role { // @Failure 400 {object} domain.ErrorResponse // @Failure 401 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/login [post] +// @Router /api/v1/admin/team/login [post] func (h *Handler) TeamMemberLogin(c *fiber.Ctx) error { var req domain.TeamMemberLoginReq if err := c.BodyParser(&req); err != nil { @@ -185,7 +185,7 @@ func (h *Handler) TeamMemberLogin(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 401 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/refresh [post] +// @Router /api/v1/admin/team/refresh [post] func (h *Handler) TeamMemberRefresh(c *fiber.Ctx) error { var req teamMemberRefreshReq if err := c.BodyParser(&req); err != nil { @@ -265,7 +265,7 @@ func (h *Handler) TeamMemberRefresh(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 403 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members [post] +// @Router /api/v1/admin/team/members [post] func (h *Handler) CreateTeamMember(c *fiber.Ctx) error { var req domain.CreateTeamMemberReq if err := c.BodyParser(&req); err != nil { @@ -361,7 +361,7 @@ func (h *Handler) CreateTeamMember(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id} [get] +// @Router /api/v1/admin/team/members/{id} [get] func (h *Handler) GetTeamMember(c *fiber.Ctx) error { memberIDStr := c.Params("id") memberID, err := strconv.ParseInt(memberIDStr, 10, 64) @@ -417,7 +417,7 @@ func (h *Handler) GetTeamMember(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 403 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members [get] +// @Router /api/v1/admin/team/members [get] func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error { filter := domain.TeamMemberFilter{} @@ -505,7 +505,7 @@ func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error { // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id} [put] +// @Router /api/v1/admin/team/members/{id} [put] func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error { memberIDStr := c.Params("id") memberID, err := strconv.ParseInt(memberIDStr, 10, 64) @@ -595,7 +595,7 @@ func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error { // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id}/status [patch] +// @Router /api/v1/admin/team/members/{id}/status [patch] func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error { memberIDStr := c.Params("id") memberID, err := strconv.ParseInt(memberIDStr, 10, 64) @@ -696,7 +696,7 @@ func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error { // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id} [delete] +// @Router /api/v1/admin/team/members/{id} [delete] func (h *Handler) DeleteTeamMember(c *fiber.Ctx) error { memberIDStr := c.Params("id") memberID, err := strconv.ParseInt(memberIDStr, 10, 64) @@ -756,7 +756,7 @@ func (h *Handler) DeleteTeamMember(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 403 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/stats [get] +// @Router /api/v1/admin/team/stats [get] func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error { stats, err := h.teamSvc.GetTeamMemberStats(c.Context()) if err != nil { @@ -793,7 +793,7 @@ func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id}/change-password [post] +// @Router /api/v1/admin/team/members/{id}/change-password [post] func (h *Handler) ChangeTeamMemberPassword(c *fiber.Ctx) error { memberIDStr := c.Params("id") memberID, err := strconv.ParseInt(memberIDStr, 10, 64) @@ -870,7 +870,7 @@ func (h *Handler) ChangeTeamMemberPassword(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/me [get] +// @Router /api/v1/admin/team/me [get] func (h *Handler) GetMyTeamProfile(c *fiber.Ctx) error { memberID, ok := c.Locals("user_id").(int64) if !ok { @@ -921,7 +921,7 @@ func (h *Handler) GetMyTeamProfile(c *fiber.Ctx) error { // @Failure 401 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/me [put] +// @Router /api/v1/admin/team/me [put] func (h *Handler) UpdateMyTeamProfile(c *fiber.Ctx) error { memberID, ok := c.Locals("user_id").(int64) if !ok { diff --git a/internal/web_server/handlers/team_invitation_handler.go b/internal/web_server/handlers/team_invitation_handler.go index 65d4a7e9..a13be0d5 100644 --- a/internal/web_server/handlers/team_invitation_handler.go +++ b/internal/web_server/handlers/team_invitation_handler.go @@ -59,7 +59,7 @@ func mapTeamInvitationListItem(row domain.TeamInvitationWithMember) teamInvitati // @Success 201 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/members/invite [post] +// @Router /api/v1/admin/team/members/invite [post] func (h *Handler) InviteTeamMember(c *fiber.Ctx) error { if err := requireSuperAdminForTeamInvitation(c); err != nil { return err @@ -115,7 +115,7 @@ func (h *Handler) InviteTeamMember(c *fiber.Ctx) error { // @Success 200 {object} domain.Response // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/team/members/{id}/resend-invite [post] +// @Router /api/v1/admin/team/members/{id}/resend-invite [post] func (h *Handler) ResendTeamInvitation(c *fiber.Ctx) error { if err := requireSuperAdminForTeamInvitation(c); err != nil { return err @@ -158,7 +158,7 @@ func (h *Handler) ResendTeamInvitation(c *fiber.Ctx) error { // @Param limit query int false "Limit (default 20)" // @Param offset query int false "Offset (default 0)" // @Success 200 {object} domain.Response -// @Router /api/v1/team/invitations [get] +// @Router /api/v1/admin/team/invitations [get] func (h *Handler) ListTeamInvitations(c *fiber.Ctx) error { status := strings.TrimSpace(c.Query("status")) var statusPtr *string @@ -199,7 +199,7 @@ func (h *Handler) ListTeamInvitations(c *fiber.Ctx) error { // @Produce json // @Param id path int true "Invitation ID" // @Success 200 {object} domain.Response -// @Router /api/v1/team/invitations/{id}/revoke [post] +// @Router /api/v1/admin/team/invitations/{id}/revoke [post] func (h *Handler) RevokeTeamInvitation(c *fiber.Ctx) error { invitationID, err := strconv.ParseInt(c.Params("id"), 10, 64) if err != nil || invitationID <= 0 { @@ -229,7 +229,7 @@ func (h *Handler) RevokeTeamInvitation(c *fiber.Ctx) error { // @Produce json // @Param token query string true "Invitation token" // @Success 200 {object} domain.Response -// @Router /api/v1/team/invitations/verify [get] +// @Router /api/v1/admin/team/invitations/verify [get] func (h *Handler) VerifyTeamInvitation(c *fiber.Ctx) error { token := strings.TrimSpace(c.Query("token")) if token == "" { @@ -261,7 +261,7 @@ func (h *Handler) VerifyTeamInvitation(c *fiber.Ctx) error { // @Produce json // @Param body body domain.AcceptTeamInvitationReq true "Accept invitation payload" // @Success 200 {object} domain.Response -// @Router /api/v1/team/invitations/accept [post] +// @Router /api/v1/admin/team/invitations/accept [post] func (h *Handler) AcceptTeamInvitation(c *fiber.Ctx) error { var req domain.AcceptTeamInvitationReq if err := c.BodyParser(&req); err != nil { diff --git a/internal/web_server/handlers/team_password_reset_handler.go b/internal/web_server/handlers/team_password_reset_handler.go index 4a4133cb..5572ed54 100644 --- a/internal/web_server/handlers/team_password_reset_handler.go +++ b/internal/web_server/handlers/team_password_reset_handler.go @@ -16,7 +16,7 @@ import ( // @Param email query string true "Team member email" // @Param otp query string true "Reset OTP from the email link" // @Success 200 {object} domain.Response -// @Router /api/v1/team/verifyResetCode [get] +// @Router /api/v1/admin/team/verifyResetCode [get] func (h *Handler) VerifyTeamPasswordReset(c *fiber.Ctx) error { email := c.Query("email") otp := c.Query("otp") @@ -39,7 +39,7 @@ func (h *Handler) VerifyTeamPasswordReset(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/sendResetCode [post] +// @Router /api/v1/admin/team/sendResetCode [post] func (h *Handler) SendTeamPasswordReset(c *fiber.Ctx) error { var req domain.TeamSendPasswordResetReq if err := c.BodyParser(&req); err != nil { @@ -76,7 +76,7 @@ func (h *Handler) SendTeamPasswordReset(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/team/resetPassword [post] +// @Router /api/v1/admin/team/resetPassword [post] func (h *Handler) ResetTeamPassword(c *fiber.Ctx) error { var req domain.TeamResetPasswordReq if err := c.BodyParser(&req); err != nil { diff --git a/internal/web_server/handlers/transaction_approver.go b/internal/web_server/handlers/transaction_approver.go index 4c6149b5..e1a0bc5a 100644 --- a/internal/web_server/handlers/transaction_approver.go +++ b/internal/web_server/handlers/transaction_approver.go @@ -284,7 +284,6 @@ type TransactionApproverRes struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/t-approver/{id} [get] func (h *Handler) GetTransactionApproverByID(c *fiber.Ctx) error { userIDstr := c.Params("id") userID, err := strconv.ParseInt(userIDstr, 10, 64) @@ -364,7 +363,6 @@ type updateTransactionApproverReq struct { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/t-approver/{id} [put] func (h *Handler) UpdateTransactionApprover(c *fiber.Ctx) error { var req updateTransactionApproverReq if err := c.BodyParser(&req); err != nil { diff --git a/internal/web_server/handlers/user.go b/internal/web_server/handlers/user.go index ac791cb1..9458039c 100644 --- a/internal/web_server/handlers/user.go +++ b/internal/web_server/handlers/user.go @@ -32,7 +32,7 @@ import ( // @Security Bearer // @Success 200 {object} domain.Response{data=domain.UserSummary} // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/users/summary [get] +// @Router /api/v1/admin/users/summary [get] func (h *Handler) GetUserSummary(c *fiber.Ctx) error { summary, err := h.userSvc.GetUserSummary(c.Context()) if err != nil { @@ -246,7 +246,7 @@ func (h *Handler) UpdateUserKnowledgeLevel(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/otp/resend [post] +// @Router /api/v1/user/resend-otp [post] func (h *Handler) ResendOtp(c *fiber.Ctx) error { var req domain.ResendOtpReq if err := c.BodyParser(&req); err != nil { @@ -386,7 +386,7 @@ func (h *Handler) ResendOtp(c *fiber.Ctx) error { // @Failure 400 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/user/{user_id}/is-pending [get] +// @Router /api/v1/user/{user_name}/is-pending [get] func (h *Handler) CheckUserPending(c *fiber.Ctx) error { userID, err := strconv.ParseInt(c.Params("user_id"), 10, 64) if err != nil { @@ -443,7 +443,7 @@ func (h *Handler) CheckUserPending(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/users [get] +// @Router /api/v1/admin/users [get] func (h *Handler) GetAllUsers(c *fiber.Ctx) error { filter, err := parseUserListFilter(c) if err != nil { @@ -674,7 +674,7 @@ func (h *Handler) ListAccountDeletionRequests(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/user/status [patch] +// @Router /api/v1/admin/user/status [patch] func (h *Handler) UpdateUserStatus(c *fiber.Ctx) error { var req struct { UserID int64 `json:"user_id"` @@ -846,7 +846,6 @@ type GetTenantSlugByToken struct { // @Success 200 {object} CheckPhoneEmailExistRes // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/tenant [get] func (h *Handler) GetTenantSlugByToken(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) if !ok || userID == 0 { @@ -919,7 +918,7 @@ type CheckPhoneEmailExistRes struct { // @Success 200 {object} CheckPhoneEmailExistRes // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user/checkPhoneEmailExist [post] +// @Router /api/v1/user/checkPhoneEmailExist [post] func (h *Handler) CheckPhoneEmailExist(c *fiber.Ctx) error { // companyID := c.Locals("company_id").(domain.ValidInt64) // if !companyID.Valid { @@ -977,7 +976,7 @@ type RegisterCodeReq struct { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user/sendRegisterCode [post] +// @Router /api/v1/user/sendRegisterCode [post] func (h *Handler) SendRegisterCode(c *fiber.Ctx) error { // companyID := c.Locals("company_id").(domain.ValidInt64) // if !companyID.Valid { @@ -1038,7 +1037,7 @@ func (h *Handler) SendRegisterCode(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user/register [post] +// @Router /api/v1/user/register [post] func (h *Handler) RegisterUser(c *fiber.Ctx) error { var req domain.RegisterUserReq if err := c.BodyParser(&req); err != nil { @@ -1231,7 +1230,6 @@ func (h *Handler) SendResetCode(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user/sendResetCode [post] func (h *Handler) SendTenantResetCode(c *fiber.Ctx) error { // companyID := c.Locals("company_id").(domain.ValidInt64) // if !companyID.Valid { @@ -1362,7 +1360,6 @@ func (h *Handler) ResetPassword(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/{tenant_slug}/user/resetPassword [post] func (h *Handler) ResetTenantPassword(c *fiber.Ctx) error { // Reuse the main ResetPassword handler return h.ResetPassword(c) @@ -1378,7 +1375,7 @@ func (h *Handler) ResetTenantPassword(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse // @Security Bearer -// @Router /api/v1/{tenant_slug}/user/user-profile [get] +// @Router /api/v1/user/user-profile [get] func (h *Handler) GetUserProfile(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) @@ -1500,7 +1497,7 @@ type AdminProfileRes struct { // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse // @Security Bearer -// @Router /api/v1/{tenant_slug}/user/admin-profile [get] +// @Router /api/v1/admin/user/admin-profile [get] func (h *Handler) AdminProfile(c *fiber.Ctx) error { userID, ok := c.Locals("user_id").(int64) @@ -1631,7 +1628,7 @@ type SearchUserByNameOrPhoneReq struct { // @Success 200 {object} domain.UserProfileResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/user/search [post] +// @Router /api/v1/admin/user/search [post] func (h *Handler) SearchUserByNameOrPhone(c *fiber.Ctx) error { var req SearchUserByNameOrPhoneReq if err := c.BodyParser(&req); err != nil { @@ -1767,7 +1764,7 @@ func (h *Handler) SearchUserByNameOrPhone(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 401 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/user/single/{id} [get] +// @Router /api/v1/admin/user/single/{id} [get] func (h *Handler) GetUserByID(c *fiber.Ctx) error { userIDstr := c.Params("id") userID, err := strconv.ParseInt(userIDstr, 10, 64) @@ -1885,7 +1882,7 @@ func (h *Handler) GetUserByID(c *fiber.Ctx) error { // @Success 200 {object} response.APIResponse // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse -// @Router /api/v1/user/delete/{id} [delete] +// @Router /api/v1/admin/user/delete/{id} [delete] func (h *Handler) DeleteUser(c *fiber.Ctx) error { userIDstr := c.Params("id") userID, err := strconv.ParseInt(userIDstr, 10, 64) @@ -2047,7 +2044,7 @@ func (h *Handler) CancelMyUserAccountDeletion(c *fiber.Ctx) error { // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse // @Security Bearer -// @Router /api/v1/internal/users/purge-due-deletions [post] +// @Router /api/v1/admin/internal/users/purge-due-deletions [post] func (h *Handler) PurgeDueDeletedUsers(c *fiber.Ctx) error { limit := int32(c.QueryInt("limit", int(defaultDeletePurgeBatchSize))) if limit <= 0 { @@ -2098,6 +2095,7 @@ type UpdateUserSuspendRes struct { // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse // @Security Bearer +// @Router /api/v1/admin/user/{id}/profile-picture [post] // @Router /api/v1/user/{id}/profile-picture [post] func (h *Handler) UploadProfilePicture(c *fiber.Ctx) error { idStr := c.Params("id") @@ -2109,6 +2107,10 @@ func (h *Handler) UploadProfilePicture(c *fiber.Ctx) error { }) } + if c.Locals("api_audience") == "client" && c.Locals("user_id") != userID { + return fiber.NewError(fiber.StatusForbidden, "You can only change your own profile picture") + } + // JSON mode: accept already uploaded URL and set it directly. if strings.Contains(strings.ToLower(c.Get("Content-Type")), "application/json") { var req struct { diff --git a/internal/web_server/handlers/video_engagement_handler.go b/internal/web_server/handlers/video_engagement_handler.go index 20097fdc..5dec166e 100644 --- a/internal/web_server/handlers/video_engagement_handler.go +++ b/internal/web_server/handlers/video_engagement_handler.go @@ -23,7 +23,7 @@ import ( // @Failure 400 {object} domain.ErrorResponse // @Failure 403 {object} domain.ErrorResponse // @Failure 404 {object} domain.ErrorResponse -// @Router /api/v1/videos/engagement/heartbeat [post] +// @Router /api/v1/exam-prep/videos/engagement/heartbeat [post] func (h *Handler) RecordVideoEngagementHeartbeat(c *fiber.Ctx) error { var req domain.VideoEngagementHeartbeatInput if err := c.BodyParser(&req); err != nil { @@ -41,13 +41,13 @@ func (h *Handler) RecordVideoEngagementHeartbeat(c *fiber.Ctx) error { uid := c.Locals("user_id").(int64) role := c.Locals("role").(domain.Role) - if strings.HasPrefix(c.Path(), "/api/v1/exam-prep/") && req.ContentKind != domain.VideoContentKindExamPrepLesson { + if strings.Contains(c.Route().Path, "/exam-prep/") && req.ContentKind != domain.VideoContentKindExamPrepLesson { return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{ Message: "Exam-prep routes accept exam-prep lesson video sessions only", }) } - if req.ContentKind == domain.VideoContentKindLMSLesson && !strings.HasPrefix(c.Path(), "/api/v1/exam-prep/") { + if req.ContentKind == domain.VideoContentKindLMSLesson && !strings.Contains(c.Route().Path, "/exam-prep/") { les, err := h.lessonSvc.GetByID(c.Context(), req.ContentID) if err != nil { if errors.Is(err, lessons.ErrLessonNotFound) { diff --git a/internal/web_server/handlers/vimeo.go b/internal/web_server/handlers/vimeo.go index 66bdb880..02eb262a 100644 --- a/internal/web_server/handlers/vimeo.go +++ b/internal/web_server/handlers/vimeo.go @@ -106,7 +106,7 @@ func vimeoVideoInfoToResponse(info *vimeoservice.VideoInfo) VimeoVideoResponse { // @Success 200 {object} domain.Response{data=[]handlers.VimeoVideoResponse,metadata=handlers.VimeoVideosListMetadata} // @Failure 503 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/videos [get] +// @Router /api/v1/admin/vimeo/videos [get] func (h *Handler) ListVimeoVideos(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -192,7 +192,7 @@ func (h *Handler) ListVimeoVideos(c *fiber.Ctx) error { // @Success 200 {object} VimeoVideoResponse // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/videos/{video_id} [get] +// @Router /api/v1/admin/vimeo/videos/{video_id} [get] func (h *Handler) GetVimeoVideo(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -235,7 +235,7 @@ func (h *Handler) GetVimeoVideo(c *fiber.Ctx) error { // @Success 201 {object} VimeoUploadResponse // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/uploads/pull [post] +// @Router /api/v1/admin/vimeo/uploads/pull [post] func (h *Handler) CreatePullUpload(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -292,7 +292,7 @@ func (h *Handler) CreatePullUpload(c *fiber.Ctx) error { // @Success 201 {object} VimeoUploadResponse // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/uploads/tus [post] +// @Router /api/v1/admin/vimeo/uploads/tus [post] func (h *Handler) CreateTusUpload(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -355,7 +355,7 @@ func (h *Handler) CreateTusUpload(c *fiber.Ctx) error { // @Success 200 {object} VimeoEmbedResponse // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/videos/{video_id}/embed [get] +// @Router /api/v1/admin/vimeo/videos/{video_id}/embed [get] func (h *Handler) GetEmbedCode(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -421,7 +421,7 @@ func (h *Handler) GetEmbedCode(c *fiber.Ctx) error { // @Success 204 // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/videos/{video_id} [delete] +// @Router /api/v1/admin/vimeo/videos/{video_id} [delete] func (h *Handler) DeleteVimeoVideo(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -465,7 +465,7 @@ func (h *Handler) DeleteVimeoVideo(c *fiber.Ctx) error { // @Success 200 {object} map[string]string // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse -// @Router /api/v1/vimeo/videos/{video_id}/status [get] +// @Router /api/v1/admin/vimeo/videos/{video_id}/status [get] func (h *Handler) GetTranscodeStatus(c *fiber.Ctx) error { if h.vimeoSvc == nil { return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{ @@ -512,6 +512,7 @@ func (h *Handler) GetTranscodeStatus(c *fiber.Ctx) error { // @Param height query int false "Player height" default(360) // @Success 200 {object} domain.Response // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/vimeo/sample [get] // @Router /api/v1/vimeo/sample [get] func (h *Handler) GetSampleVideo(c *fiber.Ctx) error { if h.vimeoSvc == nil { @@ -556,6 +557,7 @@ func (h *Handler) GetSampleVideo(c *fiber.Ctx) error { // @Success 200 {object} vimeo.OEmbedResponse // @Failure 400 {object} domain.ErrorResponse // @Failure 500 {object} domain.ErrorResponse +// @Router /api/v1/admin/vimeo/oembed [get] // @Router /api/v1/vimeo/oembed [get] func (h *Handler) GetOEmbed(c *fiber.Ctx) error { if h.vimeoSvc == nil { diff --git a/internal/web_server/middleware.go b/internal/web_server/middleware.go index 3364b52c..1918cf41 100644 --- a/internal/web_server/middleware.go +++ b/internal/web_server/middleware.go @@ -72,6 +72,14 @@ func (a *App) authMiddleware(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusUnauthorized, "Invalid access token") } + audience, _ := c.Locals(apiAudienceKey).(string) + if claim.UserId <= 0 { + return fiber.NewError(fiber.StatusUnauthorized, "Invalid user ID") + } + if err := validateAPIAudience(claim.Role, audience); err != nil { + return err + } + refreshToken := c.Get("Refresh-Token") if refreshToken == "" { @@ -548,6 +556,19 @@ func (a *App) WebsocketAuthMiddleware(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusUnauthorized, "Invalid token") } + audience, _ := c.Locals(apiAudienceKey).(string) + if err := validateAPIAudience(claim.Role, audience); err != nil { + return err + } + if claim.Role.IsCustomerLearnerRole() { + status, err := a.userSvc.GetAuthStatus(c.Context(), claim.UserId) + if err != nil { + return fiber.NewError(fiber.StatusUnauthorized, "Unable to validate customer account") + } + if err := domain.ValidateUserCanAuthenticate(status); err != nil { + return fiber.NewError(fiber.StatusForbidden, "Customer account is not active") + } + } userID := claim.UserId if userID == 0 { a.mongoLoggerSvc.Info("Invalid user ID in token claims", diff --git a/internal/web_server/routes.go b/internal/web_server/routes.go index 0771815e..716697b7 100644 --- a/internal/web_server/routes.go +++ b/internal/web_server/routes.go @@ -1,11 +1,7 @@ package httpserver import ( - "Rezina-Backend/internal/domain" "Rezina-Backend/internal/web_server/handlers" - "context" - "fmt" - "strconv" "github.com/gofiber/fiber/v2" fiberSwagger "github.com/swaggo/fiber-swagger" @@ -55,419 +51,20 @@ func (a *App) initAppRoutes() { ) a.fiber.Get("/", func(c *fiber.Ctx) error { - return c.JSON(fiber.Map{ - "message": "Welcome to Rezina Backend API", - "version": a.cfg.APP_VERSION, - }) + return c.JSON(fiber.Map{"message": "Welcome to Rezina Backend API", "version": a.cfg.APP_VERSION}) }) - - a.fiber.Get("/routes", func(c *fiber.Ctx) error { - return c.JSON(a.fiber.Stack()) // prints all registered routes - }) - - // Groups - groupV1 := a.fiber.Group("/api/v1", a.resolveFileURLsMiddleware) - - // Referrals remain available without a subscription so new learners can participate. - groupV1.Post("/referrals/code", a.authMiddleware, h.CreateReferralCode) - groupV1.Get("/referrals/code", a.authMiddleware, h.GetReferralCode) - groupV1.Get("/referrals/me", a.authMiddleware, h.GetMyReferrals) - groupV1.Post("/referrals/apply", a.authMiddleware, h.ApplyReferralCode) - groupV1.Get("/referrals", a.authMiddleware, h.ListMyReferrals) - groupV1.Get("/referrals/wallet", a.authMiddleware, h.GetReferralWallet) - groupV1.Get("/admin/referrals/settings", a.authMiddleware, a.OnlyAdminAndAbove, h.GetReferralSettings) - groupV1.Put("/admin/referrals/settings", a.authMiddleware, a.OnlyAdminAndAbove, h.UpdateReferralSettings) - - // Serve static files (profile pictures, etc.) a.fiber.Static("/static", "./static") - - // Swagger + a.fiber.Get("/swagger/admin/doc.json", audienceSpecification("admin")) + a.fiber.Get("/swagger/client/doc.json", audienceSpecification("client")) + a.fiber.Get("/swagger/admin/*", fiberSwagger.FiberWrapHandler(fiberSwagger.URL("/swagger/admin/doc.json"))) + a.fiber.Get("/swagger/client/*", fiberSwagger.FiberWrapHandler(fiberSwagger.URL("/swagger/client/doc.json"))) a.fiber.Get("/swagger/*", fiberSwagger.FiberWrapHandler()) - - groupV1.Get("/", func(c *fiber.Ctx) error { - return c.JSON(fiber.Map{ - "message": "Welcome to Rezina Backend API v1", - "version": "1.0.1", - }) + api := a.fiber.Group("/api/v1", a.resolveFileURLsMiddleware) + api.Get("/", func(c *fiber.Ctx) error { + return c.JSON(fiber.Map{"admin_api": "/api/v1/admin", "client_api": "/api/v1"}) }) - - // Learning content uses the exam-prep catalog hierarchy exclusively: - // catalog course -> unit -> module -> lesson. - groupV1.Post("/exam-prep/catalog-courses", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.create"), h.CreateExamPrepCatalogCourse) - groupV1.Get("/exam-prep/catalog-courses", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.list"), h.ListExamPrepCatalogCourses) - groupV1.Put("/exam-prep/catalog-courses/reorder", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.reorder"), h.ReorderExamPrepCatalogCourses) - groupV1.Get("/exam-prep/catalog-courses/:id", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.get"), h.GetExamPrepCatalogCourseByID) - groupV1.Put("/exam-prep/catalog-courses/:id", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.update"), h.UpdateExamPrepCatalogCourse) - groupV1.Delete("/exam-prep/catalog-courses/:id", a.authMiddleware, a.RequirePermission("exam_prep.catalog_courses.delete"), h.DeleteExamPrepCatalogCourse) - groupV1.Post("/exam-prep/catalog-courses/:catalogCourseId/units", a.authMiddleware, a.RequirePermission("exam_prep.units.create"), h.CreateExamPrepUnit) - groupV1.Get("/exam-prep/catalog-courses/:catalogCourseId/units", a.authMiddleware, a.RequirePermission("exam_prep.units.list"), h.ListExamPrepUnitsByCatalogCourse) - groupV1.Put("/exam-prep/catalog-courses/:catalogCourseId/units/reorder", a.authMiddleware, a.RequirePermission("exam_prep.units.reorder"), h.ReorderExamPrepUnitsInCatalogCourse) - groupV1.Get("/exam-prep/units/:id", a.authMiddleware, a.RequirePermission("exam_prep.units.get"), h.GetExamPrepUnitByID) - groupV1.Put("/exam-prep/units/:id", a.authMiddleware, a.RequirePermission("exam_prep.units.update"), h.UpdateExamPrepUnit) - groupV1.Delete("/exam-prep/units/:id", a.authMiddleware, a.RequirePermission("exam_prep.units.delete"), h.DeleteExamPrepUnit) - groupV1.Post("/exam-prep/units/:unitId/modules", a.authMiddleware, a.RequirePermission("exam_prep.modules.create"), h.CreateExamPrepModule) - groupV1.Get("/exam-prep/units/:unitId/modules", a.authMiddleware, a.RequirePermission("exam_prep.modules.list"), h.ListExamPrepModulesByUnit) - groupV1.Put("/exam-prep/units/:unitId/modules/reorder", a.authMiddleware, a.RequirePermission("exam_prep.modules.reorder"), h.ReorderExamPrepModulesInUnit) - groupV1.Get("/exam-prep/modules/:id", a.authMiddleware, a.RequirePermission("exam_prep.modules.get"), h.GetExamPrepModuleByID) - groupV1.Put("/exam-prep/modules/:id", a.authMiddleware, a.RequirePermission("exam_prep.modules.update"), h.UpdateExamPrepModule) - groupV1.Delete("/exam-prep/modules/:id", a.authMiddleware, a.RequirePermission("exam_prep.modules.delete"), h.DeleteExamPrepModule) - groupV1.Post("/exam-prep/modules/:moduleId/lessons", a.authMiddleware, a.RequirePermission("exam_prep.lessons.create"), a.RequireExamPrepSubscription(), h.CreateExamPrepLesson) - groupV1.Get("/exam-prep/modules/:moduleId/lessons", a.authMiddleware, a.RequirePermission("exam_prep.lessons.list_by_module"), a.RequireExamPrepSubscription(), h.ListExamPrepLessonsByUnitModule) - groupV1.Put("/exam-prep/modules/:moduleId/lessons/reorder", a.authMiddleware, a.RequirePermission("exam_prep.lessons.reorder"), a.RequireExamPrepSubscription(), h.ReorderExamPrepLessonsInUnitModule) - groupV1.Get("/exam-prep/lessons/:id", a.authMiddleware, a.RequirePermission("exam_prep.lessons.get"), a.RequireExamPrepSubscription(), h.GetExamPrepLessonByID) - groupV1.Put("/exam-prep/lessons/:id", a.authMiddleware, a.RequirePermission("exam_prep.lessons.update"), a.RequireExamPrepSubscription(), h.UpdateExamPrepLesson) - groupV1.Delete("/exam-prep/lessons/:id", a.authMiddleware, a.RequirePermission("exam_prep.lessons.delete"), a.RequireExamPrepSubscription(), h.DeleteExamPrepLesson) - groupV1.Get("/exam-prep/assessments", a.authMiddleware, a.RequirePermission("question_sets.list"), a.RequireExamPrepSubscription(), h.ListExamPrepAssessments) - groupV1.Post("/exam-prep/assessments", a.authMiddleware, a.RequirePermission("question_sets.update"), a.RequireExamPrepSubscription(), h.LinkExamPrepAssessment) - groupV1.Delete("/exam-prep/assessments/:questionSetId/parents/:parentKind/:parentId", a.authMiddleware, a.RequirePermission("question_sets.update"), a.RequireExamPrepSubscription(), h.UnlinkExamPrepAssessment) - groupV1.Post("/exam-prep/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.create"), a.RequireExamPrepSubscription(), h.CreateExamPrepPracticeFromInput) - groupV1.Get("/exam-prep/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.list"), a.RequireExamPrepSubscription(), h.ListAllExamPrepPractices) - groupV1.Get("/exam-prep/catalog-courses/:catalogCourseId/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.list_by_catalog_course"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByCatalogCourse) - groupV1.Post("/exam-prep/catalog-courses/:catalogCourseId/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.create"), a.RequireExamPrepSubscription(), h.CreateExamPrepPracticeForCatalogCourse) - groupV1.Get("/exam-prep/units/:unitId/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.list_by_unit"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByUnit) - groupV1.Post("/exam-prep/units/:unitId/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.create"), a.RequireExamPrepSubscription(), h.CreateExamPrepPracticeForUnit) - groupV1.Get("/exam-prep/lessons/:lessonId/practices", a.authMiddleware, a.RequirePermission("exam_prep.practices.list_by_lesson"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByLesson) - groupV1.Get("/exam-prep/practices/:id", a.authMiddleware, a.RequirePermission("exam_prep.practices.get"), a.RequireExamPrepSubscription(), h.GetExamPrepPracticeByID) - groupV1.Get("/exam-prep/practices/:id/full", a.authMiddleware, a.RequirePermission("exam_prep.practices.get"), a.RequireExamPrepSubscription(), h.GetExamPrepPracticeFull) - groupV1.Put("/exam-prep/practices/:id", a.authMiddleware, a.RequirePermission("exam_prep.practices.update"), a.RequireExamPrepSubscription(), h.UpdateExamPrepPractice) - groupV1.Put("/exam-prep/practices/:id/full", a.authMiddleware, a.RequirePermission("exam_prep.practices.update"), a.RequireExamPrepSubscription(), h.UpdateExamPrepPracticeFull) - groupV1.Put("/exam-prep/practices/:id/parents", a.authMiddleware, a.RequirePermission("exam_prep.practices.update"), a.RequireExamPrepSubscription(), h.UpdateExamPrepPracticeParents) - groupV1.Delete("/exam-prep/practices/:id/parents/:parentKind/:parentId", a.authMiddleware, a.RequirePermission("exam_prep.practices.update"), a.RequireExamPrepSubscription(), h.UnlinkExamPrepPracticeParent) - groupV1.Delete("/exam-prep/practices/:id", a.authMiddleware, a.RequirePermission("exam_prep.practices.delete"), a.RequireExamPrepSubscription(), h.DeleteExamPrepPractice) - groupV1.Post("/exam-prep/progress/practices/:id/complete", a.authMiddleware, a.RequirePermission("progress.complete"), a.RequireExamPrepSubscription(), h.CompletePractice) - groupV1.Post("/exam-prep/videos/engagement/heartbeat", a.authMiddleware, a.RequirePermission("videos.track_engagement"), a.RequireExamPrepSubscription(), h.RecordVideoEngagementHeartbeat) - groupV1.Get("/exam-prep/progress-summary", a.authMiddleware, a.RequirePermission("lms.get_my_progress"), h.GetMyLMSProgressSummary) - groupV1.Get("/exam-prep/practices/:practiceId/questions", a.authMiddleware, a.RequirePermission("question_set_items.list"), a.RequireExamPrepSubscription(), h.GetQuestionsByPractice) - - // LMS personas (catalog referenced by persona_id on practices) - groupV1.Get("/personas", a.authMiddleware, a.RequirePermission("personas.list"), h.ListPersonas) - groupV1.Post("/personas", a.authMiddleware, a.RequirePermission("personas.create"), h.CreatePersona) - groupV1.Get("/personas/:id", a.authMiddleware, a.RequirePermission("personas.get"), h.GetPersona) - groupV1.Put("/personas/:id", a.authMiddleware, a.RequirePermission("personas.update"), h.UpdatePersona) - groupV1.Delete("/personas/:id", a.authMiddleware, a.RequirePermission("personas.delete"), h.DeletePersona) - - // File storage (MinIO) - groupV1.Get("/files/url", a.authMiddleware, h.GetFileURL) - groupV1.Post("/files/refresh-url", a.authMiddleware, h.RefreshFileURL) - groupV1.Post("/files/presign-upload", a.authMiddleware, h.CreatePresignedUpload) - groupV1.Post("/files/complete-upload", a.authMiddleware, h.CompletePresignedUpload) - groupV1.Post("/files/upload", a.authMiddleware, h.UploadMedia) - groupV1.Post("/files/audio", a.authMiddleware, h.UploadAudio) - groupV1.Post("/questions/audio-answer", a.authMiddleware, h.SubmitAudioAnswer) - - // Assessment questions (public list) + authenticated submit - - // Questions - groupV1.Post("/questions", a.authMiddleware, a.RequirePermission("questions.create"), h.CreateQuestion) - groupV1.Get("/questions", a.authMiddleware, a.RequirePermission("questions.list"), h.ListQuestions) - groupV1.Get("/questions/search", a.authMiddleware, a.RequirePermission("questions.search"), h.SearchQuestions) - groupV1.Get("/questions/component-catalog", a.authMiddleware, a.RequirePermission("questions.list"), h.GetQuestionTypeComponentCatalog) - groupV1.Post("/questions/validate-question-type-definition", a.authMiddleware, a.RequirePermission("questions.create"), h.ValidateQuestionTypeDefinition) - groupV1.Post("/questions/type-definition-groups", a.authMiddleware, a.RequirePermission("questions.create"), h.CreateQuestionTypeDefinitionGroup) - groupV1.Get("/questions/type-definition-groups", a.authMiddleware, a.RequirePermission("questions.list"), h.ListQuestionTypeDefinitionGroups) - groupV1.Get("/questions/type-definition-groups/:id", a.authMiddleware, a.RequirePermission("questions.get"), h.GetQuestionTypeDefinitionGroupByID) - groupV1.Put("/questions/type-definition-groups/:id", a.authMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestionTypeDefinitionGroup) - groupV1.Delete("/questions/type-definition-groups/:id", a.authMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestionTypeDefinitionGroup) - groupV1.Post("/questions/type-definitions", a.authMiddleware, a.RequirePermission("questions.create"), h.CreateQuestionTypeDefinition) - groupV1.Get("/questions/type-definitions", a.authMiddleware, a.RequirePermission("questions.list"), h.ListQuestionTypeDefinitions) - groupV1.Get("/questions/type-definitions/:id", a.authMiddleware, a.RequirePermission("questions.get"), h.GetQuestionTypeDefinitionByID) - groupV1.Get("/questions/type-definitions/:id/practices", a.authMiddleware, a.RequirePermission("practices.list"), h.ListPracticesByQuestionTypeDefinition) - groupV1.Put("/questions/type-definitions/:id", a.authMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestionTypeDefinition) - groupV1.Delete("/questions/type-definitions/:id", a.authMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestionTypeDefinition) - groupV1.Get("/questions/:id", a.authMiddleware, a.RequirePermission("questions.get"), h.GetQuestionByID) - groupV1.Put("/questions/:id", a.authMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestion) - groupV1.Delete("/questions/:id", a.authMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestion) - - // FAQs - groupV1.Get("/faqs", h.ListPublicFAQs) - groupV1.Get("/faqs/:id", h.GetPublicFAQByID) - groupV1.Get("/admin/faqs", a.authMiddleware, a.RequirePermission("faqs.list"), h.ListFAQsAdmin) - groupV1.Get("/admin/faqs/:id", a.authMiddleware, a.RequirePermission("faqs.get"), h.GetFAQByIDAdmin) - groupV1.Post("/admin/faqs", a.authMiddleware, a.RequirePermission("faqs.create"), h.CreateFAQ) - groupV1.Put("/admin/faqs/:id", a.authMiddleware, a.RequirePermission("faqs.update"), h.UpdateFAQ) - groupV1.Delete("/admin/faqs/:id", a.authMiddleware, a.RequirePermission("faqs.delete"), h.DeleteFAQ) - - // Mobile app versions (Play Store / App Store) - groupV1.Get("/app/version/check", h.CheckMobileAppVersion) - groupV1.Get("/admin/app-versions", a.authMiddleware, a.RequirePermission("app_versions.list"), h.ListMobileAppVersionsAdmin) - groupV1.Get("/admin/app-versions/:id", a.authMiddleware, a.RequirePermission("app_versions.get"), h.GetMobileAppVersionByIDAdmin) - groupV1.Post("/admin/app-versions", a.authMiddleware, a.RequirePermission("app_versions.create"), h.CreateMobileAppVersion) - groupV1.Put("/admin/app-versions/:id", a.authMiddleware, a.RequirePermission("app_versions.update"), h.UpdateMobileAppVersion) - groupV1.Delete("/admin/app-versions/:id", a.authMiddleware, a.RequirePermission("app_versions.delete"), h.DeleteMobileAppVersion) - - // Email templates - groupV1.Get("/admin/email-templates", a.authMiddleware, a.RequirePermission("email_templates.list"), h.ListEmailTemplatesAdmin) - groupV1.Get("/admin/email-templates/slug/:slug", a.authMiddleware, a.RequirePermission("email_templates.get"), h.GetEmailTemplateBySlugAdmin) - groupV1.Post("/admin/email-templates/slug/:slug/preview", a.authMiddleware, a.RequirePermission("email_templates.preview"), h.PreviewEmailTemplateBySlug) - groupV1.Get("/admin/email-templates/:id", a.authMiddleware, a.RequirePermission("email_templates.get"), h.GetEmailTemplateByIDAdmin) - groupV1.Post("/admin/email-templates/:id/preview", a.authMiddleware, a.RequirePermission("email_templates.preview"), h.PreviewEmailTemplateByID) - groupV1.Post("/admin/email-templates", a.authMiddleware, a.RequirePermission("email_templates.create"), h.CreateEmailTemplate) - groupV1.Put("/admin/email-templates/:id", a.authMiddleware, a.RequirePermission("email_templates.update"), h.UpdateEmailTemplate) - groupV1.Delete("/admin/email-templates/:id", a.authMiddleware, a.RequirePermission("email_templates.delete"), h.DeleteEmailTemplate) - - // Field options (configurable dropdown values: profile fields, countries, etc.) - groupV1.Get("/field-options", h.ListPublicFieldOptions) - groupV1.Get("/field-options/fields", h.ListFieldKeys) - groupV1.Get("/admin/field-options", a.authMiddleware, a.RequirePermission("field_options.list"), h.ListFieldOptionsAdmin) - groupV1.Get("/admin/field-options/:id", a.authMiddleware, a.RequirePermission("field_options.get"), h.GetFieldOptionByIDAdmin) - groupV1.Post("/admin/field-options", a.authMiddleware, a.RequirePermission("field_options.create"), h.CreateFieldOption) - groupV1.Put("/admin/field-options/:id", a.authMiddleware, a.RequirePermission("field_options.update"), h.UpdateFieldOption) - groupV1.Delete("/admin/field-options/:id", a.authMiddleware, a.RequirePermission("field_options.delete"), h.DeleteFieldOption) - - // Admin payments (register before /admin/:id so "payments" is not captured as an admin id) - groupV1.Get("/admin/payments", a.authMiddleware, a.RequirePermission("payments.list_all"), h.ListAdminPayments) - groupV1.Get("/admin/payments/export", a.authMiddleware, a.RequirePermission("payments.export"), h.ExportAdminPaymentsCSV) - groupV1.Get("/admin/payments/:id", a.authMiddleware, a.RequirePermission("payments.list_all"), h.GetAdminPayment) - - // Question Sets - groupV1.Post("/question-sets", a.authMiddleware, a.RequirePermission("question_sets.create"), h.CreateQuestionSet) - groupV1.Get("/question-sets", a.authMiddleware, a.RequirePermission("question_sets.list"), h.GetQuestionSetsByType) - groupV1.Get("/question-sets/by-owner", a.authMiddleware, a.RequirePermission("question_sets.list_by_owner"), h.GetQuestionSetsByOwner) - groupV1.Get("/question-sets/:id", a.authMiddleware, a.RequirePermission("question_sets.get"), h.GetQuestionSetByID) - groupV1.Put("/question-sets/:id", a.authMiddleware, a.RequirePermission("question_sets.update"), h.UpdateQuestionSet) - groupV1.Delete("/question-sets/:id", a.authMiddleware, a.RequirePermission("question_sets.delete"), h.DeleteQuestionSet) - - // Question Set Items - groupV1.Post("/question-sets/:setId/questions", a.authMiddleware, a.RequirePermission("question_set_items.add"), h.AddQuestionToSet) - groupV1.Get("/question-sets/:setId/question-types", a.authMiddleware, a.RequirePermission("question_set_items.list"), h.GetQuestionTypesInSet) - groupV1.Get("/question-sets/:setId/questions", a.authMiddleware, a.RequirePermission("question_set_items.list"), h.GetQuestionsInSet) - groupV1.Delete("/question-sets/:setId/questions/:questionId", a.authMiddleware, a.RequirePermission("question_set_items.remove"), h.RemoveQuestionFromSet) - groupV1.Put("/question-sets/:setId/questions/:questionId/order", a.authMiddleware, a.RequirePermission("question_set_items.update_order"), h.UpdateQuestionOrderInSet) - - // Question Set Personas - groupV1.Get("/question-sets/:setId/personas", a.authMiddleware, a.RequirePermission("question_set_personas.list"), h.GetUserPersonasByQuestionSet) - groupV1.Post("/question-sets/:setId/personas", a.authMiddleware, a.RequirePermission("question_set_personas.add"), h.AddUserPersonaToQuestionSet) - groupV1.Delete("/question-sets/:setId/personas/:userId", a.authMiddleware, a.RequirePermission("question_set_personas.remove"), h.RemoveUserPersonaFromQuestionSet) - - // Subscription Plans - groupV1.Post("/subscription-plans", a.authMiddleware, a.RequirePermission("subscription_plans.create"), h.CreateSubscriptionPlan) - groupV1.Get("/subscription-plans", h.ListSubscriptionPlans) - groupV1.Get("/subscription-plans/:id", h.GetSubscriptionPlan) - groupV1.Put("/subscription-plans/:id", a.authMiddleware, a.RequirePermission("subscription_plans.update"), h.UpdateSubscriptionPlan) - groupV1.Delete("/subscription-plans/:id", a.authMiddleware, a.RequirePermission("subscription_plans.delete"), h.DeleteSubscriptionPlan) - - // User Subscriptions - groupV1.Post("/subscriptions", a.authMiddleware, a.RequirePermission("subscriptions.create"), h.Subscribe) - groupV1.Post("/subscriptions/checkout", a.authMiddleware, a.RequirePermission("subscriptions.checkout"), h.SubscribeWithPayment) - groupV1.Post("/subscriptions/request-checkout-link", a.authMiddleware, a.RequirePermission("subscriptions.request_checkout_link"), h.RequestSubscriptionCheckoutLink) - groupV1.Get("/subscriptions/me", a.authMiddleware, a.RequirePermission("subscriptions.get_mine"), h.GetMySubscription) - groupV1.Get("/subscriptions/history", a.authMiddleware, a.RequirePermission("subscriptions.history"), h.GetMySubscriptionHistory) - groupV1.Get("/subscriptions/status", a.authMiddleware, a.RequirePermission("subscriptions.status"), h.CheckSubscriptionStatus) - groupV1.Post("/subscriptions/:id/cancel", a.authMiddleware, a.RequirePermission("subscriptions.cancel"), h.CancelSubscription) - groupV1.Put("/subscriptions/:id/auto-renew", a.authMiddleware, a.RequirePermission("subscriptions.set_auto_renew"), h.SetAutoRenew) - - // Payments (Chapa) - groupV1.Post("/payments/subscribe", a.authMiddleware, a.RequirePermission("payments.initiate"), h.InitiateSubscriptionPayment) - groupV1.Get("/payments/verify/:session_id", a.authMiddleware, a.RequirePermission("payments.verify"), h.VerifyPayment) - groupV1.Get("/payments", a.authMiddleware, a.RequirePermission("payments.list_mine"), h.GetMyPayments) - groupV1.Get("/payments/methods", h.GetChapaPaymentMethods) - groupV1.Get("/payments/:id", a.authMiddleware, a.RequirePermission("payments.get"), h.GetPaymentByID) - groupV1.Post("/payments/:id/cancel", a.authMiddleware, a.RequirePermission("payments.cancel"), h.CancelPayment) - groupV1.Post("/payments/webhook", h.HandleChapaWebhook) - groupV1.Get("/payments/arifpay/success", h.HandleArifpaySuccessPage) - groupV1.Get("/payments/chapa/success", h.HandleChapaSuccessPage) - groupV1.Get("/payments/chapa/callback", h.HandleChapaCallback) + a.initAdminRoutes(api.Group("/admin", apiAudience("admin")), h) + a.initClientRoutes(api, h) + a.initIntegrationRoutes(api, h) a.fiber.Get("/payment/success", h.HandleChapaSuccessPage) - - // Chapa Direct Charge (USSD / OTP — separate from hosted checkout and ArifPay direct) - groupV1.Post("/payments/chapa/direct", a.authMiddleware, a.RequirePermission("payments.direct_initiate"), h.InitiateChapaDirectPayment) - groupV1.Post("/payments/chapa/direct/authorize", a.authMiddleware, a.RequirePermission("payments.direct_verify_otp"), h.AuthorizeChapaDirectPayment) - groupV1.Get("/payments/chapa/direct/methods", h.GetChapaDirectPaymentMethods) - - // Direct Payments (ArifPay) - groupV1.Post("/payments/direct", a.authMiddleware, a.RequirePermission("payments.direct_initiate"), h.InitiateDirectPayment) - groupV1.Post("/payments/direct/verify-otp", a.authMiddleware, a.RequirePermission("payments.direct_verify_otp"), h.VerifyDirectPaymentOTP) - groupV1.Get("/payments/direct/methods", h.GetDirectPaymentMethods) - - // Auth Routes (public) - groupV1.Post("/auth/google/android", h.GoogleAndroidLogin) - groupV1.Get("/auth/google/login", h.GoogleLogin) - groupV1.Get("/auth/google/callback", h.GoogleCallback) - groupV1.Post("/auth/apple", h.AppleLogin) - groupV1.Post("/auth/customer-login", h.LoginUser) - groupV1.Post("/auth/admin-login", h.LoginAdmin) - groupV1.Post("/auth/super-login", h.LoginSuper) - groupV1.Post("/auth/refresh", h.RefreshToken) - groupV1.Post("/user/:id/profile-picture", a.authMiddleware, a.RequirePermission("users.upload_profile_picture"), h.UploadProfilePicture) - groupV1.Post("/auth/logout", a.authMiddleware, a.RequirePermission("auth.logout"), h.LogOutuser) - groupV1.Get("/auth/test", a.authMiddleware, func(c *fiber.Ctx) error { - userID, ok := c.Locals("user_id").(int64) - if !ok { - return fiber.NewError(fiber.StatusUnauthorized, "Invalid user ID") - } - role, ok := c.Locals("role").(domain.Role) - if !ok { - return fiber.NewError(fiber.StatusUnauthorized, "Invalid role") - } - refreshToken, ok := c.Locals("refresh_token").(string) - if !ok { - return fiber.NewError(fiber.StatusUnauthorized, "Invalid refresh token") - } - companyID, err := strconv.ParseInt(c.Get("company_id"), 10, 64) - if err != nil { - return fiber.NewError(fiber.StatusBadRequest, "Invalid company_id") - } - - a.logger.Info("User ID: " + strconv.FormatInt(userID, 10)) - fmt.Printf("User ID: %d\n", userID) - a.logger.Info("Role: " + string(role)) - a.logger.Info("Refresh Token: " + refreshToken) - a.logger.Info("Company ID: " + strconv.FormatInt(companyID, 10)) - return c.SendString("Test endpoint") - }) - - // User Routes - groupV1.Get("/user/:user_id/is-profile-completed", a.authMiddleware, a.RequirePermission("users.profile_completed"), h.CheckProfileCompleted) - groupV1.Get("/users", a.authMiddleware, a.RequirePermission("users.list"), h.GetAllUsers) - groupV1.Get("/users/export", a.authMiddleware, a.RequirePermission("users.export"), h.ExportUsersCSV) - groupV1.Get("/admin/users/deletion-requests", a.authMiddleware, a.RequirePermission("users.deletion_requests.list"), h.ListAccountDeletionRequests) - groupV1.Get("/admin/subscriptions/export", a.authMiddleware, a.RequirePermission("subscriptions.export"), h.ExportUserSubscriptionsCSV) - groupV1.Post("/admin/subscriptions/:id/cancel", a.authMiddleware, a.RequirePermission("subscriptions.admin_cancel"), h.AdminCancelUserSubscription) - groupV1.Get("/admin/users/:user_id/recent-activity", a.authMiddleware, a.RequirePermission("progress.get_any_user"), h.AdminGetUserRecentActivity) - groupV1.Get("/admin/users/:user_id/learning-activity", a.authMiddleware, a.RequirePermission("progress.get_any_user"), h.AdminGetUserLearningActivityDetails) - groupV1.Get("/admin/users/:user_id/subscriptions", a.authMiddleware, a.RequirePermission("subscriptions.get_by_user"), h.AdminGetUserSubscriptions) - groupV1.Post("/admin/users/:user_id/subscriptions/extend", a.authMiddleware, a.RequirePermission("subscriptions.admin_extend"), h.AdminExtendOrGrantUserSubscription) - groupV1.Get("/users/summary", a.authMiddleware, a.RequirePermission("users.summary"), h.GetUserSummary) - groupV1.Put("/user", a.authMiddleware, a.RequirePermission("users.update_self"), h.UpdateUser) - groupV1.Patch("/user/status", a.authMiddleware, a.RequirePermission("users.update_status"), h.UpdateUserStatus) - groupV1.Put("/user/knowledge-level", a.authMiddleware, a.RequirePermission("users.update_self"), h.UpdateUserKnowledgeLevel) - groupV1.Get("/user/:user_name/is-pending", h.CheckUserPending) - groupV1.Post("/user/resetPassword", h.ResetPassword) - groupV1.Post("/user/sendResetCode", h.SendResetCode) - groupV1.Post("/user/verify-otp", h.VerifyOtp) - groupV1.Post("/user/resend-otp", h.ResendOtp) - groupV1.Post("/user/register", h.RegisterUser) - groupV1.Post("/user/sendRegisterCode", h.SendRegisterCode) - groupV1.Post("/user/checkPhoneEmailExist", h.CheckPhoneEmailExist) - groupV1.Get("/user/admin-profile", a.authMiddleware, a.RequirePermission("users.admin_profile"), h.AdminProfile) - groupV1.Get("/user/user-profile", a.authMiddleware, a.RequirePermission("users.user_profile"), h.GetUserProfile) - groupV1.Delete("/user/me", a.authMiddleware, a.RequirePermission("users.delete_self"), h.DeleteMyUserAccount) - groupV1.Post("/user/me/deletion/cancel", a.authMiddleware, a.RequirePermission("users.cancel_delete_self"), h.CancelMyUserAccountDeletion) - groupV1.Post("/internal/users/purge-due-deletions", a.authMiddleware, a.RequirePermission("users.purge_due_deletions"), h.PurgeDueDeletedUsers) - groupV1.Get("/user/single/:id", a.authMiddleware, a.RequirePermission("users.get"), h.GetUserByID) - groupV1.Delete("/user/delete/:id", a.authMiddleware, a.RequirePermission("users.delete"), h.DeleteUser) - groupV1.Post("/user/search", a.authMiddleware, a.RequirePermission("users.search"), h.SearchUserByNameOrPhone) - - // Admin management - groupV1.Get("/admin", a.authMiddleware, a.RequirePermission("admins.list"), h.GetAllAdmins) - groupV1.Get("/admin/:id", a.authMiddleware, a.RequirePermission("admins.get"), h.GetAdminByID) - groupV1.Post("/admin", a.authMiddleware, a.RequirePermission("admins.create"), h.CreateAdmin) - groupV1.Put("/admin/:id", a.authMiddleware, a.RequirePermission("admins.update"), h.UpdateAdmin) - groupV1.Post("/admin/roles/:role/bulk-deactivate", a.authMiddleware, h.BulkDeactivateAccountsByRole) - groupV1.Post("/admin/roles/:role/bulk-reactivate", a.authMiddleware, h.BulkReactivateAccountsByRole) - - // Logs - groupV1.Get("/logs", a.authMiddleware, a.RequirePermission("logs.list"), handlers.GetLogsHandler(context.Background())) - groupV1.Get("/activity-logs", a.authMiddleware, a.RequirePermission("activity_logs.list"), h.GetActivityLogs) - groupV1.Get("/activity-logs/export", a.authMiddleware, a.RequirePermission("activity_logs.export"), h.ExportActivityLogsCSV) - groupV1.Get("/activity-logs/:id", a.authMiddleware, a.RequirePermission("activity_logs.get"), h.GetActivityLogByID) - - // Notifications - groupV1.Post("/sendSMS", h.SendSingleAfroSMS) - groupV1.Get("/ws/connect", a.WebsocketAuthMiddleware, h.ConnectSocket) - groupV1.Get("/notifications", a.authMiddleware, a.RequirePermission("notifications.list_mine"), h.GetUserNotification) - groupV1.Get("/notifications/all", a.authMiddleware, a.RequirePermission("notifications.list_all"), h.GetAllNotifications) - groupV1.Patch("/notifications/:id/read", a.authMiddleware, a.RequirePermission("notifications.mark_read"), h.MarkNotificationAsRead) - groupV1.Post("/notifications/mark-all-read", a.authMiddleware, a.RequirePermission("notifications.mark_all_read"), h.MarkAllNotificationsAsRead) - groupV1.Patch("/notifications/:id/unread", a.authMiddleware, a.RequirePermission("notifications.mark_unread"), h.MarkNotificationAsUnread) - groupV1.Post("/notifications/mark-all-unread", a.authMiddleware, a.RequirePermission("notifications.mark_all_unread"), h.MarkAllNotificationsAsUnread) - groupV1.Delete("/notifications", a.authMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteUserNotifications) - groupV1.Post("/notifications/delete-in-app", a.authMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotifications) - groupV1.Get("/notifications/unread", a.authMiddleware, a.RequirePermission("notifications.count_unread"), h.CountUnreadNotifications) - groupV1.Post("/notifications/create", a.authMiddleware, a.RequirePermission("notifications.create"), h.CreateAndSendNotification) - groupV1.Post("/notifications/test-push", a.authMiddleware, a.RequirePermission("notifications.test_push"), h.SendTestPushNotification) - - // Bulk Notifications - groupV1.Post("/notifications/bulk-push", a.authMiddleware, a.RequirePermission("notifications.bulk_push"), h.SendBulkPushNotification) - groupV1.Post("/notifications/bulk-sms", a.authMiddleware, a.RequirePermission("notifications.bulk_sms"), h.SendBulkSMS) - groupV1.Post("/notifications/bulk-in-app", a.authMiddleware, a.RequirePermission("notifications.bulk_in_app"), h.SendBulkInAppNotification) - groupV1.Post("/notifications/send-email", a.authMiddleware, a.RequirePermission("notifications.send_email"), h.SendSingleEmail) - groupV1.Post("/notifications/bulk-email", a.authMiddleware, a.RequirePermission("notifications.bulk_email"), h.SendBulkEmail) - - // Scheduled Notifications - groupV1.Get("/notifications/scheduled", a.authMiddleware, a.RequirePermission("notifications_scheduled.list"), h.ListScheduledNotifications) - groupV1.Get("/notifications/scheduled/:id", a.authMiddleware, a.RequirePermission("notifications_scheduled.get"), h.GetScheduledNotification) - groupV1.Post("/notifications/scheduled/:id/cancel", a.authMiddleware, a.RequirePermission("notifications_scheduled.cancel"), h.CancelScheduledNotification) - groupV1.Delete("/notifications/:id", a.authMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotification) - groupV1.Get("/notifications/:id", a.authMiddleware, a.RequirePermission("notifications.list_mine"), h.GetNotificationByID) - - // Issues - groupV1.Post("/issues", a.authMiddleware, a.RequirePermission("issues.create"), h.CreateIssue) - groupV1.Get("/issues/me", a.authMiddleware, a.RequirePermission("issues.list_mine"), h.GetMyIssues) - groupV1.Get("/issues/user/:user_id", a.authMiddleware, a.RequirePermission("issues.list_by_user"), h.GetUserIssues) - groupV1.Get("/issues", a.authMiddleware, a.RequirePermission("issues.list_all"), h.GetAllIssues) - groupV1.Get("/issues/:id", a.authMiddleware, a.RequirePermission("issues.get"), h.GetIssueByID) - groupV1.Patch("/issues/:id/status", a.authMiddleware, a.RequirePermission("issues.update_status"), h.UpdateIssueStatus) - groupV1.Delete("/issues/:id", a.authMiddleware, a.RequirePermission("issues.delete"), h.DeleteIssue) - - // Devices - groupV1.Post("/devices/register", a.authMiddleware, a.RequirePermission("devices.register"), h.RegisterDeviceToken) - groupV1.Post("/devices/unregister", a.authMiddleware, a.RequirePermission("devices.unregister"), h.UnregisterDeviceToken) - - // Settings - groupV1.Get("/settings", a.authMiddleware, a.RequirePermission("settings.list"), h.GetGlobalSettingList) - groupV1.Get("/settings/:key", a.authMiddleware, a.RequirePermission("settings.get"), h.GetGlobalSettingByKey) - groupV1.Put("/settings", a.authMiddleware, a.RequirePermission("settings.update"), h.UpdateGlobalSettingList) - - // Analytics - groupV1.Get("/analytics/dashboard", a.authMiddleware, a.RequirePermission("analytics.dashboard"), h.GetAnalyticsDashboard) - - // Vimeo - vimeoGroup := groupV1.Group("/vimeo") - vimeoGroup.Get("/videos", a.authMiddleware, a.RequirePermission("vimeo.videos.list"), h.ListVimeoVideos) - vimeoGroup.Get("/videos/:video_id", a.authMiddleware, a.RequirePermission("vimeo.videos.get"), h.GetVimeoVideo) - vimeoGroup.Get("/videos/:video_id/embed", a.authMiddleware, a.RequirePermission("vimeo.videos.embed"), h.GetEmbedCode) - vimeoGroup.Get("/videos/:video_id/status", a.authMiddleware, a.RequirePermission("vimeo.videos.status"), h.GetTranscodeStatus) - vimeoGroup.Delete("/videos/:video_id", a.authMiddleware, a.RequirePermission("vimeo.videos.delete"), h.DeleteVimeoVideo) - vimeoGroup.Post("/uploads/pull", a.authMiddleware, a.RequirePermission("vimeo.uploads.pull"), h.CreatePullUpload) - vimeoGroup.Post("/uploads/tus", a.authMiddleware, a.RequirePermission("vimeo.uploads.tus"), h.CreateTusUpload) - vimeoGroup.Get("/oembed", h.GetOEmbed) - vimeoGroup.Get("/sample", h.GetSampleVideo) - - // Team Management - teamGroup := groupV1.Group("/team") - teamGroup.Post("/login", h.TeamMemberLogin) - teamGroup.Post("/refresh", h.TeamMemberRefresh) - teamGroup.Post("/sendResetCode", h.SendTeamPasswordReset) - teamGroup.Get("/verifyResetCode", h.VerifyTeamPasswordReset) - teamGroup.Post("/resetPassword", h.ResetTeamPassword) - teamGroup.Get("/invitations/verify", h.VerifyTeamInvitation) - teamGroup.Post("/invitations/accept", h.AcceptTeamInvitation) - teamGroup.Get("/me", a.authMiddleware, a.RequirePermission("team.profile.get_mine"), h.GetMyTeamProfile) - teamGroup.Put("/me", a.authMiddleware, a.RequirePermission("team.profile.update_mine"), h.UpdateMyTeamProfile) - teamGroup.Get("/stats", a.authMiddleware, a.RequirePermission("team.stats"), h.GetTeamMemberStats) - teamGroup.Get("/members", a.authMiddleware, a.RequirePermission("team.members.list"), h.GetAllTeamMembers) - teamGroup.Get("/members/export", a.authMiddleware, a.RequirePermission("team.members.export"), h.ExportTeamMembersCSV) - teamGroup.Post("/members/invite", a.authMiddleware, a.RequirePermission("team.members.invite"), h.InviteTeamMember) - teamGroup.Post("/members", a.authMiddleware, a.RequirePermission("team.members.create"), h.CreateTeamMember) - teamGroup.Post("/members/:id/resend-invite", a.authMiddleware, a.RequirePermission("team.invitations.resend"), h.ResendTeamInvitation) - teamGroup.Get("/members/:id", a.authMiddleware, a.RequirePermission("team.members.get"), h.GetTeamMember) - teamGroup.Put("/members/:id", a.authMiddleware, a.RequirePermission("team.members.update"), h.UpdateTeamMember) - teamGroup.Patch("/members/:id/status", a.authMiddleware, a.RequirePermission("team.members.update_status"), h.UpdateTeamMemberStatus) - teamGroup.Delete("/members/:id", a.authMiddleware, a.RequirePermission("team.members.delete"), h.DeleteTeamMember) - teamGroup.Post("/members/:id/change-password", a.authMiddleware, a.RequirePermission("team.members.change_password"), h.ChangeTeamMemberPassword) - teamGroup.Get("/invitations", a.authMiddleware, a.RequirePermission("team.invitations.list"), h.ListTeamInvitations) - teamGroup.Post("/invitations/:id/revoke", a.authMiddleware, a.RequirePermission("team.invitations.revoke"), h.RevokeTeamInvitation) - - // Ratings - groupV1.Post("/ratings", a.authMiddleware, a.RequirePermission("ratings.submit"), h.SubmitRating) - groupV1.Get("/ratings", a.authMiddleware, a.RequirePermission("ratings.list_by_target"), h.GetRatingsByTarget) - groupV1.Get("/ratings/summary", a.authMiddleware, a.RequirePermission("ratings.summary"), h.GetRatingSummary) - groupV1.Get("/ratings/me", a.authMiddleware, a.RequirePermission("ratings.get_mine"), h.GetMyRating) - groupV1.Get("/ratings/me/all", a.authMiddleware, a.RequirePermission("ratings.list_mine"), h.GetMyRatings) - groupV1.Delete("/ratings/:id", a.authMiddleware, a.RequirePermission("ratings.delete"), h.DeleteRating) - - // RBAC Management - rbacGroup := groupV1.Group("/rbac", a.authMiddleware) - rbacGroup.Get("/roles", a.RequirePermission("rbac.roles.list"), h.ListRoles) - rbacGroup.Get("/roles/:id", a.RequirePermission("rbac.roles.get"), h.GetRoleByID) - rbacGroup.Post("/roles", a.RequirePermission("rbac.roles.create"), h.CreateRole) - rbacGroup.Put("/roles/:id", a.RequirePermission("rbac.roles.update"), h.UpdateRole) - rbacGroup.Delete("/roles/:id", a.RequirePermission("rbac.roles.delete"), h.DeleteRole) - rbacGroup.Put("/roles/:id/permissions", a.RequirePermission("rbac.roles.set_permissions"), h.SetRolePermissions) - rbacGroup.Get("/roles/:id/permissions", a.RequirePermission("rbac.roles.get_permissions"), h.GetRolePermissions) - rbacGroup.Get("/permissions", a.RequirePermission("rbac.permissions.list"), h.ListPermissions) - rbacGroup.Get("/permissions/groups", a.RequirePermission("rbac.permissions.groups"), h.ListPermissionGroups) - rbacGroup.Post("/permissions/sync", a.RequirePermission("rbac.permissions.sync"), h.SyncPermissions) - } diff --git a/internal/web_server/routes_admin.go b/internal/web_server/routes_admin.go new file mode 100644 index 00000000..073c5458 --- /dev/null +++ b/internal/web_server/routes_admin.go @@ -0,0 +1,235 @@ +package httpserver + +import ( + "Rezina-Backend/internal/web_server/handlers" + "context" + "github.com/gofiber/fiber/v2" +) + +func (a *App) initAdminRoutes(api fiber.Router, h *handlers.Handler) { + api.Get("/referrals/settings", a.adminAuthMiddleware, a.OnlyAdminAndAbove, h.GetReferralSettings) + api.Put("/referrals/settings", a.adminAuthMiddleware, a.OnlyAdminAndAbove, h.UpdateReferralSettings) + api.Post("/exam-prep/catalog-courses", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.create"), h.CreateExamPrepCatalogCourse) + api.Get("/exam-prep/catalog-courses", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.list"), h.ListExamPrepCatalogCourses) + api.Put("/exam-prep/catalog-courses/reorder", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.reorder"), h.ReorderExamPrepCatalogCourses) + api.Get("/exam-prep/catalog-courses/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.get"), h.GetExamPrepCatalogCourseByID) + api.Put("/exam-prep/catalog-courses/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.update"), h.UpdateExamPrepCatalogCourse) + api.Delete("/exam-prep/catalog-courses/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.delete"), h.DeleteExamPrepCatalogCourse) + api.Post("/exam-prep/catalog-courses/:catalogCourseId/units", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.create"), h.CreateExamPrepUnit) + api.Get("/exam-prep/catalog-courses/:catalogCourseId/units", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.list"), h.ListExamPrepUnitsByCatalogCourse) + api.Put("/exam-prep/catalog-courses/:catalogCourseId/units/reorder", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.reorder"), h.ReorderExamPrepUnitsInCatalogCourse) + api.Get("/exam-prep/units/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.get"), h.GetExamPrepUnitByID) + api.Put("/exam-prep/units/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.update"), h.UpdateExamPrepUnit) + api.Delete("/exam-prep/units/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.units.delete"), h.DeleteExamPrepUnit) + api.Post("/exam-prep/units/:unitId/modules", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.create"), h.CreateExamPrepModule) + api.Get("/exam-prep/units/:unitId/modules", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.list"), h.ListExamPrepModulesByUnit) + api.Put("/exam-prep/units/:unitId/modules/reorder", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.reorder"), h.ReorderExamPrepModulesInUnit) + api.Get("/exam-prep/modules/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.get"), h.GetExamPrepModuleByID) + api.Put("/exam-prep/modules/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.update"), h.UpdateExamPrepModule) + api.Delete("/exam-prep/modules/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.modules.delete"), h.DeleteExamPrepModule) + api.Post("/exam-prep/modules/:moduleId/lessons", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.create"), h.CreateExamPrepLesson) + api.Get("/exam-prep/modules/:moduleId/lessons", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.list_by_module"), h.ListExamPrepLessonsByUnitModule) + api.Put("/exam-prep/modules/:moduleId/lessons/reorder", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.reorder"), h.ReorderExamPrepLessonsInUnitModule) + api.Get("/exam-prep/lessons/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.get"), h.GetExamPrepLessonByID) + api.Put("/exam-prep/lessons/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.update"), h.UpdateExamPrepLesson) + api.Delete("/exam-prep/lessons/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.lessons.delete"), h.DeleteExamPrepLesson) + api.Get("/exam-prep/assessments", a.adminAuthMiddleware, a.RequirePermission("question_sets.list"), h.ListExamPrepAssessments) + api.Post("/exam-prep/assessments", a.adminAuthMiddleware, a.RequirePermission("question_sets.update"), h.LinkExamPrepAssessment) + api.Delete("/exam-prep/assessments/:questionSetId/parents/:parentKind/:parentId", a.adminAuthMiddleware, a.RequirePermission("question_sets.update"), h.UnlinkExamPrepAssessment) + api.Post("/exam-prep/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.create"), h.CreateExamPrepPracticeFromInput) + api.Get("/exam-prep/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.list"), h.ListAllExamPrepPractices) + api.Get("/exam-prep/catalog-courses/:catalogCourseId/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_catalog_course"), h.ListExamPrepPracticesByCatalogCourse) + api.Post("/exam-prep/catalog-courses/:catalogCourseId/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.create"), h.CreateExamPrepPracticeForCatalogCourse) + api.Get("/exam-prep/units/:unitId/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_unit"), h.ListExamPrepPracticesByUnit) + api.Post("/exam-prep/units/:unitId/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.create"), h.CreateExamPrepPracticeForUnit) + api.Get("/exam-prep/lessons/:lessonId/practices", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_lesson"), h.ListExamPrepPracticesByLesson) + api.Get("/exam-prep/practices/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.get"), h.GetExamPrepPracticeByID) + api.Get("/exam-prep/practices/:id/full", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.get"), h.GetExamPrepPracticeFull) + api.Put("/exam-prep/practices/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.update"), h.UpdateExamPrepPractice) + api.Put("/exam-prep/practices/:id/full", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.update"), h.UpdateExamPrepPracticeFull) + api.Put("/exam-prep/practices/:id/parents", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.update"), h.UpdateExamPrepPracticeParents) + api.Delete("/exam-prep/practices/:id/parents/:parentKind/:parentId", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.update"), h.UnlinkExamPrepPracticeParent) + api.Delete("/exam-prep/practices/:id", a.adminAuthMiddleware, a.RequirePermission("exam_prep.practices.delete"), h.DeleteExamPrepPractice) + api.Get("/personas", a.adminAuthMiddleware, a.RequirePermission("personas.list"), h.ListPersonas) + api.Post("/personas", a.adminAuthMiddleware, a.RequirePermission("personas.create"), h.CreatePersona) + api.Get("/personas/:id", a.adminAuthMiddleware, a.RequirePermission("personas.get"), h.GetPersona) + api.Put("/personas/:id", a.adminAuthMiddleware, a.RequirePermission("personas.update"), h.UpdatePersona) + api.Delete("/personas/:id", a.adminAuthMiddleware, a.RequirePermission("personas.delete"), h.DeletePersona) + api.Get("/files/url", a.adminAuthMiddleware, h.GetFileURL) + api.Post("/files/refresh-url", a.adminAuthMiddleware, h.RefreshFileURL) + api.Post("/files/presign-upload", a.adminAuthMiddleware, h.CreatePresignedUpload) + api.Post("/files/complete-upload", a.adminAuthMiddleware, h.CompletePresignedUpload) + api.Post("/files/upload", a.adminAuthMiddleware, h.UploadMedia) + api.Post("/files/audio", a.adminAuthMiddleware, h.UploadAudio) + api.Post("/questions", a.adminAuthMiddleware, a.RequirePermission("questions.create"), h.CreateQuestion) + api.Get("/questions", a.adminAuthMiddleware, a.RequirePermission("questions.list"), h.ListQuestions) + api.Get("/questions/search", a.adminAuthMiddleware, a.RequirePermission("questions.search"), h.SearchQuestions) + api.Get("/questions/component-catalog", a.adminAuthMiddleware, a.RequirePermission("questions.list"), h.GetQuestionTypeComponentCatalog) + api.Post("/questions/validate-question-type-definition", a.adminAuthMiddleware, a.RequirePermission("questions.create"), h.ValidateQuestionTypeDefinition) + api.Post("/questions/type-definition-groups", a.adminAuthMiddleware, a.RequirePermission("questions.create"), h.CreateQuestionTypeDefinitionGroup) + api.Get("/questions/type-definition-groups", a.adminAuthMiddleware, a.RequirePermission("questions.list"), h.ListQuestionTypeDefinitionGroups) + api.Get("/questions/type-definition-groups/:id", a.adminAuthMiddleware, a.RequirePermission("questions.get"), h.GetQuestionTypeDefinitionGroupByID) + api.Put("/questions/type-definition-groups/:id", a.adminAuthMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestionTypeDefinitionGroup) + api.Delete("/questions/type-definition-groups/:id", a.adminAuthMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestionTypeDefinitionGroup) + api.Post("/questions/type-definitions", a.adminAuthMiddleware, a.RequirePermission("questions.create"), h.CreateQuestionTypeDefinition) + api.Get("/questions/type-definitions", a.adminAuthMiddleware, a.RequirePermission("questions.list"), h.ListQuestionTypeDefinitions) + api.Get("/questions/type-definitions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.get"), h.GetQuestionTypeDefinitionByID) + api.Get("/questions/type-definitions/:id/practices", a.adminAuthMiddleware, a.RequirePermission("practices.list"), h.ListPracticesByQuestionTypeDefinition) + api.Put("/questions/type-definitions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestionTypeDefinition) + api.Delete("/questions/type-definitions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestionTypeDefinition) + api.Get("/questions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.get"), h.GetQuestionByID) + api.Put("/questions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.update"), h.UpdateQuestion) + api.Delete("/questions/:id", a.adminAuthMiddleware, a.RequirePermission("questions.delete"), h.DeleteQuestion) + api.Get("/faqs", a.adminAuthMiddleware, a.RequirePermission("faqs.list"), h.ListFAQsAdmin) + api.Get("/faqs/:id", a.adminAuthMiddleware, a.RequirePermission("faqs.get"), h.GetFAQByIDAdmin) + api.Post("/faqs", a.adminAuthMiddleware, a.RequirePermission("faqs.create"), h.CreateFAQ) + api.Put("/faqs/:id", a.adminAuthMiddleware, a.RequirePermission("faqs.update"), h.UpdateFAQ) + api.Delete("/faqs/:id", a.adminAuthMiddleware, a.RequirePermission("faqs.delete"), h.DeleteFAQ) + api.Get("/app-versions", a.adminAuthMiddleware, a.RequirePermission("app_versions.list"), h.ListMobileAppVersionsAdmin) + api.Get("/app-versions/:id", a.adminAuthMiddleware, a.RequirePermission("app_versions.get"), h.GetMobileAppVersionByIDAdmin) + api.Post("/app-versions", a.adminAuthMiddleware, a.RequirePermission("app_versions.create"), h.CreateMobileAppVersion) + api.Put("/app-versions/:id", a.adminAuthMiddleware, a.RequirePermission("app_versions.update"), h.UpdateMobileAppVersion) + api.Delete("/app-versions/:id", a.adminAuthMiddleware, a.RequirePermission("app_versions.delete"), h.DeleteMobileAppVersion) + api.Get("/email-templates", a.adminAuthMiddleware, a.RequirePermission("email_templates.list"), h.ListEmailTemplatesAdmin) + api.Get("/email-templates/slug/:slug", a.adminAuthMiddleware, a.RequirePermission("email_templates.get"), h.GetEmailTemplateBySlugAdmin) + api.Post("/email-templates/slug/:slug/preview", a.adminAuthMiddleware, a.RequirePermission("email_templates.preview"), h.PreviewEmailTemplateBySlug) + api.Get("/email-templates/:id", a.adminAuthMiddleware, a.RequirePermission("email_templates.get"), h.GetEmailTemplateByIDAdmin) + api.Post("/email-templates/:id/preview", a.adminAuthMiddleware, a.RequirePermission("email_templates.preview"), h.PreviewEmailTemplateByID) + api.Post("/email-templates", a.adminAuthMiddleware, a.RequirePermission("email_templates.create"), h.CreateEmailTemplate) + api.Put("/email-templates/:id", a.adminAuthMiddleware, a.RequirePermission("email_templates.update"), h.UpdateEmailTemplate) + api.Delete("/email-templates/:id", a.adminAuthMiddleware, a.RequirePermission("email_templates.delete"), h.DeleteEmailTemplate) + api.Get("/field-options", a.adminAuthMiddleware, a.RequirePermission("field_options.list"), h.ListFieldOptionsAdmin) + api.Get("/field-options/:id", a.adminAuthMiddleware, a.RequirePermission("field_options.get"), h.GetFieldOptionByIDAdmin) + api.Post("/field-options", a.adminAuthMiddleware, a.RequirePermission("field_options.create"), h.CreateFieldOption) + api.Put("/field-options/:id", a.adminAuthMiddleware, a.RequirePermission("field_options.update"), h.UpdateFieldOption) + api.Delete("/field-options/:id", a.adminAuthMiddleware, a.RequirePermission("field_options.delete"), h.DeleteFieldOption) + api.Get("/payments", a.adminAuthMiddleware, a.RequirePermission("payments.list_all"), h.ListAdminPayments) + api.Get("/payments/export", a.adminAuthMiddleware, a.RequirePermission("payments.export"), h.ExportAdminPaymentsCSV) + api.Get("/payments/:id", a.adminAuthMiddleware, a.RequirePermission("payments.list_all"), h.GetAdminPayment) + api.Post("/question-sets", a.adminAuthMiddleware, a.RequirePermission("question_sets.create"), h.CreateQuestionSet) + api.Get("/question-sets", a.adminAuthMiddleware, a.RequirePermission("question_sets.list"), h.GetQuestionSetsByType) + api.Get("/question-sets/by-owner", a.adminAuthMiddleware, a.RequirePermission("question_sets.list_by_owner"), h.GetQuestionSetsByOwner) + api.Get("/question-sets/:id", a.adminAuthMiddleware, a.RequirePermission("question_sets.get"), h.GetQuestionSetByID) + api.Put("/question-sets/:id", a.adminAuthMiddleware, a.RequirePermission("question_sets.update"), h.UpdateQuestionSet) + api.Delete("/question-sets/:id", a.adminAuthMiddleware, a.RequirePermission("question_sets.delete"), h.DeleteQuestionSet) + api.Post("/question-sets/:setId/questions", a.adminAuthMiddleware, a.RequirePermission("question_set_items.add"), h.AddQuestionToSet) + api.Get("/question-sets/:setId/question-types", a.adminAuthMiddleware, a.RequirePermission("question_set_items.list"), h.GetQuestionTypesInSet) + api.Get("/question-sets/:setId/questions", a.adminAuthMiddleware, a.RequirePermission("question_set_items.list"), h.GetQuestionsInSet) + api.Delete("/question-sets/:setId/questions/:questionId", a.adminAuthMiddleware, a.RequirePermission("question_set_items.remove"), h.RemoveQuestionFromSet) + api.Put("/question-sets/:setId/questions/:questionId/order", a.adminAuthMiddleware, a.RequirePermission("question_set_items.update_order"), h.UpdateQuestionOrderInSet) + api.Get("/question-sets/:setId/personas", a.adminAuthMiddleware, a.RequirePermission("question_set_personas.list"), h.GetUserPersonasByQuestionSet) + api.Post("/question-sets/:setId/personas", a.adminAuthMiddleware, a.RequirePermission("question_set_personas.add"), h.AddUserPersonaToQuestionSet) + api.Delete("/question-sets/:setId/personas/:userId", a.adminAuthMiddleware, a.RequirePermission("question_set_personas.remove"), h.RemoveUserPersonaFromQuestionSet) + api.Post("/subscription-plans", a.adminAuthMiddleware, a.RequirePermission("subscription_plans.create"), h.CreateSubscriptionPlan) + api.Get("/subscription-plans", a.adminAuthMiddleware, h.ListSubscriptionPlans) + api.Get("/subscription-plans/:id", a.adminAuthMiddleware, h.GetSubscriptionPlan) + api.Put("/subscription-plans/:id", a.adminAuthMiddleware, a.RequirePermission("subscription_plans.update"), h.UpdateSubscriptionPlan) + api.Delete("/subscription-plans/:id", a.adminAuthMiddleware, a.RequirePermission("subscription_plans.delete"), h.DeleteSubscriptionPlan) + api.Post("/auth/admin-login", h.LoginAdmin) + api.Post("/auth/super-login", h.LoginSuper) + api.Get("/users", a.adminAuthMiddleware, a.RequirePermission("users.list"), h.GetAllUsers) + api.Get("/users/export", a.adminAuthMiddleware, a.RequirePermission("users.export"), h.ExportUsersCSV) + api.Get("/users/deletion-requests", a.adminAuthMiddleware, a.RequirePermission("users.deletion_requests.list"), h.ListAccountDeletionRequests) + api.Get("/subscriptions/export", a.adminAuthMiddleware, a.RequirePermission("subscriptions.export"), h.ExportUserSubscriptionsCSV) + api.Post("/subscriptions/:id/cancel", a.adminAuthMiddleware, a.RequirePermission("subscriptions.admin_cancel"), h.AdminCancelUserSubscription) + api.Get("/users/:user_id/recent-activity", a.adminAuthMiddleware, a.RequirePermission("progress.get_any_user"), h.AdminGetUserRecentActivity) + api.Get("/users/:user_id/learning-activity", a.adminAuthMiddleware, a.RequirePermission("progress.get_any_user"), h.AdminGetUserLearningActivityDetails) + api.Get("/users/:user_id/subscriptions", a.adminAuthMiddleware, a.RequirePermission("subscriptions.get_by_user"), h.AdminGetUserSubscriptions) + api.Post("/users/:user_id/subscriptions/extend", a.adminAuthMiddleware, a.RequirePermission("subscriptions.admin_extend"), h.AdminExtendOrGrantUserSubscription) + api.Get("/users/summary", a.adminAuthMiddleware, a.RequirePermission("users.summary"), h.GetUserSummary) + api.Patch("/user/status", a.adminAuthMiddleware, a.RequirePermission("users.update_status"), h.UpdateUserStatus) + api.Post("/user/:id/profile-picture", a.adminAuthMiddleware, a.RequirePermission("users.upload_profile_picture"), h.UploadProfilePicture) + api.Get("/user/admin-profile", a.adminAuthMiddleware, a.RequirePermission("users.admin_profile"), h.AdminProfile) + api.Post("/internal/users/purge-due-deletions", a.adminAuthMiddleware, a.RequirePermission("users.purge_due_deletions"), h.PurgeDueDeletedUsers) + api.Get("/user/single/:id", a.adminAuthMiddleware, a.RequirePermission("users.get"), h.GetUserByID) + api.Delete("/user/delete/:id", a.adminAuthMiddleware, a.RequirePermission("users.delete"), h.DeleteUser) + api.Post("/user/search", a.adminAuthMiddleware, a.RequirePermission("users.search"), h.SearchUserByNameOrPhone) + api.Get("/admins", a.adminAuthMiddleware, a.RequirePermission("admins.list"), h.GetAllAdmins) + api.Get("/admins/:id", a.adminAuthMiddleware, a.RequirePermission("admins.get"), h.GetAdminByID) + api.Post("/admins", a.adminAuthMiddleware, a.RequirePermission("admins.create"), h.CreateAdmin) + api.Put("/admins/:id", a.adminAuthMiddleware, a.RequirePermission("admins.update"), h.UpdateAdmin) + api.Post("/admins/roles/:role/bulk-deactivate", a.adminAuthMiddleware, h.BulkDeactivateAccountsByRole) + api.Post("/admins/roles/:role/bulk-reactivate", a.adminAuthMiddleware, h.BulkReactivateAccountsByRole) + api.Get("/logs", a.adminAuthMiddleware, a.RequirePermission("logs.list"), handlers.GetLogsHandler(context.Background())) + api.Get("/activity-logs", a.adminAuthMiddleware, a.RequirePermission("activity_logs.list"), h.GetActivityLogs) + api.Get("/activity-logs/export", a.adminAuthMiddleware, a.RequirePermission("activity_logs.export"), h.ExportActivityLogsCSV) + api.Get("/activity-logs/:id", a.adminAuthMiddleware, a.RequirePermission("activity_logs.get"), h.GetActivityLogByID) + api.Post("/sendSMS", a.adminAuthMiddleware, h.SendSingleAfroSMS) + api.Get("/ws/connect", a.adminWebsocketAuthMiddleware, h.ConnectSocket) + api.Get("/notifications", a.adminAuthMiddleware, a.RequirePermission("notifications.list_mine"), h.GetUserNotification) + api.Get("/notifications/all", a.adminAuthMiddleware, a.RequirePermission("notifications.list_all"), h.GetAllNotifications) + api.Patch("/notifications/:id/read", a.adminAuthMiddleware, a.RequirePermission("notifications.mark_read"), h.MarkNotificationAsRead) + api.Post("/notifications/mark-all-read", a.adminAuthMiddleware, a.RequirePermission("notifications.mark_all_read"), h.MarkAllNotificationsAsRead) + api.Patch("/notifications/:id/unread", a.adminAuthMiddleware, a.RequirePermission("notifications.mark_unread"), h.MarkNotificationAsUnread) + api.Post("/notifications/mark-all-unread", a.adminAuthMiddleware, a.RequirePermission("notifications.mark_all_unread"), h.MarkAllNotificationsAsUnread) + api.Delete("/notifications", a.adminAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteUserNotifications) + api.Post("/notifications/delete-in-app", a.adminAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotifications) + api.Get("/notifications/unread", a.adminAuthMiddleware, a.RequirePermission("notifications.count_unread"), h.CountUnreadNotifications) + api.Post("/notifications/create", a.adminAuthMiddleware, a.RequirePermission("notifications.create"), h.CreateAndSendNotification) + api.Post("/notifications/test-push", a.adminAuthMiddleware, a.RequirePermission("notifications.test_push"), h.SendTestPushNotification) + api.Post("/notifications/bulk-push", a.adminAuthMiddleware, a.RequirePermission("notifications.bulk_push"), h.SendBulkPushNotification) + api.Post("/notifications/bulk-sms", a.adminAuthMiddleware, a.RequirePermission("notifications.bulk_sms"), h.SendBulkSMS) + api.Post("/notifications/bulk-in-app", a.adminAuthMiddleware, a.RequirePermission("notifications.bulk_in_app"), h.SendBulkInAppNotification) + api.Post("/notifications/send-email", a.adminAuthMiddleware, a.RequirePermission("notifications.send_email"), h.SendSingleEmail) + api.Post("/notifications/bulk-email", a.adminAuthMiddleware, a.RequirePermission("notifications.bulk_email"), h.SendBulkEmail) + api.Get("/notifications/scheduled", a.adminAuthMiddleware, a.RequirePermission("notifications_scheduled.list"), h.ListScheduledNotifications) + api.Get("/notifications/scheduled/:id", a.adminAuthMiddleware, a.RequirePermission("notifications_scheduled.get"), h.GetScheduledNotification) + api.Post("/notifications/scheduled/:id/cancel", a.adminAuthMiddleware, a.RequirePermission("notifications_scheduled.cancel"), h.CancelScheduledNotification) + api.Delete("/notifications/:id", a.adminAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotification) + api.Get("/notifications/:id", a.adminAuthMiddleware, a.RequirePermission("notifications.list_mine"), h.GetNotificationByID) + api.Get("/issues/user/:user_id", a.adminAuthMiddleware, a.RequirePermission("issues.list_by_user"), h.GetUserIssues) + api.Get("/issues", a.adminAuthMiddleware, a.RequirePermission("issues.list_all"), h.GetAllIssues) + api.Get("/issues/:id", a.adminAuthMiddleware, a.RequirePermission("issues.get"), h.GetIssueByID) + api.Patch("/issues/:id/status", a.adminAuthMiddleware, a.RequirePermission("issues.update_status"), h.UpdateIssueStatus) + api.Delete("/issues/:id", a.adminAuthMiddleware, a.RequirePermission("issues.delete"), h.DeleteIssue) + api.Post("/devices/register", a.adminAuthMiddleware, a.RequirePermission("devices.register"), h.RegisterDeviceToken) + api.Post("/devices/unregister", a.adminAuthMiddleware, a.RequirePermission("devices.unregister"), h.UnregisterDeviceToken) + api.Get("/settings", a.adminAuthMiddleware, a.RequirePermission("settings.list"), h.GetGlobalSettingList) + api.Get("/settings/:key", a.adminAuthMiddleware, a.RequirePermission("settings.get"), h.GetGlobalSettingByKey) + api.Put("/settings", a.adminAuthMiddleware, a.RequirePermission("settings.update"), h.UpdateGlobalSettingList) + api.Get("/analytics/dashboard", a.adminAuthMiddleware, a.RequirePermission("analytics.dashboard"), h.GetAnalyticsDashboard) + api.Get("/vimeo/videos", a.adminAuthMiddleware, a.RequirePermission("vimeo.videos.list"), h.ListVimeoVideos) + api.Get("/vimeo/videos/:video_id", a.adminAuthMiddleware, a.RequirePermission("vimeo.videos.get"), h.GetVimeoVideo) + api.Get("/vimeo/videos/:video_id/embed", a.adminAuthMiddleware, a.RequirePermission("vimeo.videos.embed"), h.GetEmbedCode) + api.Get("/vimeo/videos/:video_id/status", a.adminAuthMiddleware, a.RequirePermission("vimeo.videos.status"), h.GetTranscodeStatus) + api.Delete("/vimeo/videos/:video_id", a.adminAuthMiddleware, a.RequirePermission("vimeo.videos.delete"), h.DeleteVimeoVideo) + api.Post("/vimeo/uploads/pull", a.adminAuthMiddleware, a.RequirePermission("vimeo.uploads.pull"), h.CreatePullUpload) + api.Post("/vimeo/uploads/tus", a.adminAuthMiddleware, a.RequirePermission("vimeo.uploads.tus"), h.CreateTusUpload) + api.Get("/vimeo/oembed", a.adminAuthMiddleware, h.GetOEmbed) + api.Get("/vimeo/sample", a.adminAuthMiddleware, h.GetSampleVideo) + api.Post("/team/login", h.TeamMemberLogin) + api.Post("/team/refresh", h.TeamMemberRefresh) + api.Post("/team/sendResetCode", h.SendTeamPasswordReset) + api.Get("/team/verifyResetCode", h.VerifyTeamPasswordReset) + api.Post("/team/resetPassword", h.ResetTeamPassword) + api.Get("/team/invitations/verify", h.VerifyTeamInvitation) + api.Post("/team/invitations/accept", h.AcceptTeamInvitation) + api.Get("/team/me", a.adminAuthMiddleware, a.RequirePermission("team.profile.get_mine"), h.GetMyTeamProfile) + api.Put("/team/me", a.adminAuthMiddleware, a.RequirePermission("team.profile.update_mine"), h.UpdateMyTeamProfile) + api.Get("/team/stats", a.adminAuthMiddleware, a.RequirePermission("team.stats"), h.GetTeamMemberStats) + api.Get("/team/members", a.adminAuthMiddleware, a.RequirePermission("team.members.list"), h.GetAllTeamMembers) + api.Get("/team/members/export", a.adminAuthMiddleware, a.RequirePermission("team.members.export"), h.ExportTeamMembersCSV) + api.Post("/team/members/invite", a.adminAuthMiddleware, a.RequirePermission("team.members.invite"), h.InviteTeamMember) + api.Post("/team/members", a.adminAuthMiddleware, a.RequirePermission("team.members.create"), h.CreateTeamMember) + api.Post("/team/members/:id/resend-invite", a.adminAuthMiddleware, a.RequirePermission("team.invitations.resend"), h.ResendTeamInvitation) + api.Get("/team/members/:id", a.adminAuthMiddleware, a.RequirePermission("team.members.get"), h.GetTeamMember) + api.Put("/team/members/:id", a.adminAuthMiddleware, a.RequirePermission("team.members.update"), h.UpdateTeamMember) + api.Patch("/team/members/:id/status", a.adminAuthMiddleware, a.RequirePermission("team.members.update_status"), h.UpdateTeamMemberStatus) + api.Delete("/team/members/:id", a.adminAuthMiddleware, a.RequirePermission("team.members.delete"), h.DeleteTeamMember) + api.Post("/team/members/:id/change-password", a.adminAuthMiddleware, a.RequirePermission("team.members.change_password"), h.ChangeTeamMemberPassword) + api.Get("/team/invitations", a.adminAuthMiddleware, a.RequirePermission("team.invitations.list"), h.ListTeamInvitations) + api.Post("/team/invitations/:id/revoke", a.adminAuthMiddleware, a.RequirePermission("team.invitations.revoke"), h.RevokeTeamInvitation) + api.Get("/ratings", a.adminAuthMiddleware, a.RequirePermission("ratings.list_by_target"), h.GetRatingsByTarget) + api.Get("/ratings/summary", a.adminAuthMiddleware, a.RequirePermission("ratings.summary"), h.GetRatingSummary) + api.Delete("/ratings/:id", a.adminAuthMiddleware, a.RequirePermission("ratings.delete"), h.DeleteRating) + api.Get("/rbac/roles", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.list"), h.ListRoles) + api.Get("/rbac/roles/:id", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.get"), h.GetRoleByID) + api.Post("/rbac/roles", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.create"), h.CreateRole) + api.Put("/rbac/roles/:id", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.update"), h.UpdateRole) + api.Delete("/rbac/roles/:id", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.delete"), h.DeleteRole) + api.Put("/rbac/roles/:id/permissions", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.set_permissions"), h.SetRolePermissions) + api.Get("/rbac/roles/:id/permissions", a.adminAuthMiddleware, a.RequirePermission("rbac.roles.get_permissions"), h.GetRolePermissions) + api.Get("/rbac/permissions", a.adminAuthMiddleware, a.RequirePermission("rbac.permissions.list"), h.ListPermissions) + api.Get("/rbac/permissions/groups", a.adminAuthMiddleware, a.RequirePermission("rbac.permissions.groups"), h.ListPermissionGroups) + api.Post("/rbac/permissions/sync", a.adminAuthMiddleware, a.RequirePermission("rbac.permissions.sync"), h.SyncPermissions) +} diff --git a/internal/web_server/routes_client.go b/internal/web_server/routes_client.go new file mode 100644 index 00000000..6ab7252f --- /dev/null +++ b/internal/web_server/routes_client.go @@ -0,0 +1,113 @@ +package httpserver + +import ( + "Rezina-Backend/internal/web_server/handlers" + "github.com/gofiber/fiber/v2" +) + +func (a *App) initClientRoutes(api fiber.Router, h *handlers.Handler) { + api.Post("/referrals/code", apiAudience("client"), a.clientAuthMiddleware, h.CreateReferralCode) + api.Get("/referrals/code", apiAudience("client"), a.clientAuthMiddleware, h.GetReferralCode) + api.Get("/referrals/me", apiAudience("client"), a.clientAuthMiddleware, h.GetMyReferrals) + api.Post("/referrals/apply", apiAudience("client"), a.clientAuthMiddleware, h.ApplyReferralCode) + api.Get("/referrals", apiAudience("client"), a.clientAuthMiddleware, h.ListMyReferrals) + api.Get("/referrals/wallet", apiAudience("client"), a.clientAuthMiddleware, h.GetReferralWallet) + api.Get("/exam-prep/catalog-courses", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.list"), h.ListExamPrepCatalogCourses) + api.Get("/exam-prep/catalog-courses/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.catalog_courses.get"), h.GetExamPrepCatalogCourseByID) + api.Get("/exam-prep/catalog-courses/:catalogCourseId/units", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.units.list"), h.ListExamPrepUnitsByCatalogCourse) + api.Get("/exam-prep/units/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.units.get"), h.GetExamPrepUnitByID) + api.Get("/exam-prep/units/:unitId/modules", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.modules.list"), h.ListExamPrepModulesByUnit) + api.Get("/exam-prep/modules/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.modules.get"), h.GetExamPrepModuleByID) + api.Get("/exam-prep/modules/:moduleId/lessons", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.lessons.list_by_module"), a.RequireExamPrepSubscription(), h.ListExamPrepLessonsByUnitModule) + api.Get("/exam-prep/lessons/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.lessons.get"), a.RequireExamPrepSubscription(), h.GetExamPrepLessonByID) + api.Get("/exam-prep/assessments", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("question_sets.list"), a.RequireExamPrepSubscription(), h.ListExamPrepAssessments) + api.Get("/exam-prep/practices", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.practices.list"), a.RequireExamPrepSubscription(), h.ListAllExamPrepPractices) + api.Get("/exam-prep/catalog-courses/:catalogCourseId/practices", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_catalog_course"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByCatalogCourse) + api.Get("/exam-prep/units/:unitId/practices", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_unit"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByUnit) + api.Get("/exam-prep/lessons/:lessonId/practices", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.practices.list_by_lesson"), a.RequireExamPrepSubscription(), h.ListExamPrepPracticesByLesson) + api.Get("/exam-prep/practices/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("exam_prep.practices.get"), a.RequireExamPrepSubscription(), h.GetExamPrepPracticeByID) + api.Post("/exam-prep/progress/practices/:id/complete", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("progress.complete"), a.RequireExamPrepSubscription(), h.CompletePractice) + api.Post("/exam-prep/videos/engagement/heartbeat", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("videos.track_engagement"), a.RequireExamPrepSubscription(), h.RecordVideoEngagementHeartbeat) + api.Get("/exam-prep/progress-summary", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("lms.get_my_progress"), h.GetMyLMSProgressSummary) + api.Get("/exam-prep/practices/:practiceId/questions", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("question_set_items.list"), a.RequireExamPrepSubscription(), h.GetQuestionsByPractice) + api.Get("/personas", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("personas.list"), h.ListPersonas) + api.Get("/personas/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("personas.get"), h.GetPersona) + api.Get("/files/url", apiAudience("client"), a.clientAuthMiddleware, h.GetFileURL) + api.Post("/files/refresh-url", apiAudience("client"), a.clientAuthMiddleware, h.RefreshFileURL) + api.Post("/files/presign-upload", apiAudience("client"), a.clientAuthMiddleware, h.CreatePresignedUpload) + api.Post("/files/complete-upload", apiAudience("client"), a.clientAuthMiddleware, h.CompletePresignedUpload) + api.Post("/files/upload", apiAudience("client"), a.clientAuthMiddleware, h.UploadMedia) + api.Post("/files/audio", apiAudience("client"), a.clientAuthMiddleware, h.UploadAudio) + api.Post("/questions/audio-answer", apiAudience("client"), a.clientAuthMiddleware, h.SubmitAudioAnswer) + api.Get("/faqs", apiAudience("client"), h.ListPublicFAQs) + api.Get("/faqs/:id", apiAudience("client"), h.GetPublicFAQByID) + api.Get("/app/version/check", apiAudience("client"), h.CheckMobileAppVersion) + api.Get("/field-options", apiAudience("client"), h.ListPublicFieldOptions) + api.Get("/field-options/fields", apiAudience("client"), h.ListFieldKeys) + api.Get("/subscription-plans", apiAudience("client"), h.ListSubscriptionPlans) + api.Get("/subscription-plans/:id", apiAudience("client"), h.GetSubscriptionPlan) + api.Post("/subscriptions", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.create"), h.Subscribe) + api.Post("/subscriptions/checkout", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.checkout"), h.SubscribeWithPayment) + api.Post("/subscriptions/request-checkout-link", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.request_checkout_link"), h.RequestSubscriptionCheckoutLink) + api.Get("/subscriptions/me", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.get_mine"), h.GetMySubscription) + api.Get("/subscriptions/history", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.history"), h.GetMySubscriptionHistory) + api.Get("/subscriptions/status", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.status"), h.CheckSubscriptionStatus) + api.Post("/subscriptions/:id/cancel", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.cancel"), h.CancelSubscription) + api.Put("/subscriptions/:id/auto-renew", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("subscriptions.set_auto_renew"), h.SetAutoRenew) + api.Post("/payments/subscribe", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.initiate"), h.InitiateSubscriptionPayment) + api.Get("/payments/verify/:session_id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.verify"), h.VerifyPayment) + api.Get("/payments", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.list_mine"), h.GetMyPayments) + api.Get("/payments/methods", apiAudience("client"), h.GetChapaPaymentMethods) + api.Get("/payments/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.get"), h.GetPaymentByID) + api.Post("/payments/:id/cancel", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.cancel"), h.CancelPayment) + api.Post("/payments/chapa/direct", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.direct_initiate"), h.InitiateChapaDirectPayment) + api.Post("/payments/chapa/direct/authorize", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.direct_verify_otp"), h.AuthorizeChapaDirectPayment) + api.Get("/payments/chapa/direct/methods", apiAudience("client"), h.GetChapaDirectPaymentMethods) + api.Post("/payments/direct", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.direct_initiate"), h.InitiateDirectPayment) + api.Post("/payments/direct/verify-otp", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("payments.direct_verify_otp"), h.VerifyDirectPaymentOTP) + api.Get("/payments/direct/methods", apiAudience("client"), h.GetDirectPaymentMethods) + api.Post("/auth/google/android", apiAudience("client"), h.GoogleAndroidLogin) + api.Get("/auth/google/login", apiAudience("client"), h.GoogleLogin) + api.Post("/auth/apple", apiAudience("client"), h.AppleLogin) + api.Post("/auth/customer-login", apiAudience("client"), h.LoginUser) + api.Post("/auth/refresh", apiAudience("client"), h.RefreshToken) + api.Post("/user/:id/profile-picture", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.upload_profile_picture"), h.UploadProfilePicture) + api.Post("/auth/logout", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("auth.logout"), h.LogOutuser) + api.Get("/user/:user_id/is-profile-completed", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.profile_completed"), h.CheckProfileCompleted) + api.Put("/user", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.update_self"), h.UpdateUser) + api.Put("/user/knowledge-level", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.update_self"), h.UpdateUserKnowledgeLevel) + api.Get("/user/:user_name/is-pending", apiAudience("client"), h.CheckUserPending) + api.Post("/user/resetPassword", apiAudience("client"), h.ResetPassword) + api.Post("/user/sendResetCode", apiAudience("client"), h.SendResetCode) + api.Post("/user/verify-otp", apiAudience("client"), h.VerifyOtp) + api.Post("/user/resend-otp", apiAudience("client"), h.ResendOtp) + api.Post("/user/register", apiAudience("client"), h.RegisterUser) + api.Post("/user/sendRegisterCode", apiAudience("client"), h.SendRegisterCode) + api.Post("/user/checkPhoneEmailExist", apiAudience("client"), h.CheckPhoneEmailExist) + api.Get("/user/user-profile", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.user_profile"), h.GetUserProfile) + api.Delete("/user/me", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.delete_self"), h.DeleteMyUserAccount) + api.Post("/user/me/deletion/cancel", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("users.cancel_delete_self"), h.CancelMyUserAccountDeletion) + api.Get("/ws/connect", apiAudience("client"), a.clientWebsocketAuthMiddleware, h.ConnectSocket) + api.Get("/notifications", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.list_mine"), h.GetUserNotification) + api.Patch("/notifications/:id/read", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.mark_read"), h.MarkNotificationAsRead) + api.Post("/notifications/mark-all-read", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.mark_all_read"), h.MarkAllNotificationsAsRead) + api.Patch("/notifications/:id/unread", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.mark_unread"), h.MarkNotificationAsUnread) + api.Post("/notifications/mark-all-unread", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.mark_all_unread"), h.MarkAllNotificationsAsUnread) + api.Delete("/notifications", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteUserNotifications) + api.Post("/notifications/delete-in-app", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotifications) + api.Get("/notifications/unread", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.count_unread"), h.CountUnreadNotifications) + api.Delete("/notifications/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.delete_mine"), h.DeleteInAppNotification) + api.Get("/notifications/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("notifications.list_mine"), h.GetNotificationByID) + api.Post("/issues", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("issues.create"), h.CreateIssue) + api.Get("/issues/me", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("issues.list_mine"), h.GetMyIssues) + api.Post("/devices/register", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("devices.register"), h.RegisterDeviceToken) + api.Post("/devices/unregister", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("devices.unregister"), h.UnregisterDeviceToken) + api.Get("/vimeo/oembed", apiAudience("client"), h.GetOEmbed) + api.Get("/vimeo/sample", apiAudience("client"), h.GetSampleVideo) + api.Post("/ratings", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.submit"), h.SubmitRating) + api.Get("/ratings", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.list_by_target"), h.GetRatingsByTarget) + api.Get("/ratings/summary", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.summary"), h.GetRatingSummary) + api.Get("/ratings/me", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.get_mine"), h.GetMyRating) + api.Get("/ratings/me/all", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.list_mine"), h.GetMyRatings) + api.Delete("/ratings/:id", apiAudience("client"), a.clientAuthMiddleware, a.RequirePermission("ratings.delete"), h.DeleteRating) +} diff --git a/internal/web_server/routes_integration.go b/internal/web_server/routes_integration.go new file mode 100644 index 00000000..7eb2152f --- /dev/null +++ b/internal/web_server/routes_integration.go @@ -0,0 +1,14 @@ +package httpserver + +import ( + "Rezina-Backend/internal/web_server/handlers" + "github.com/gofiber/fiber/v2" +) + +func (a *App) initIntegrationRoutes(api fiber.Router, h *handlers.Handler) { + api.Post("/payments/webhook", h.HandleChapaWebhook) + api.Get("/payments/arifpay/success", h.HandleArifpaySuccessPage) + api.Get("/payments/chapa/success", h.HandleChapaSuccessPage) + api.Get("/payments/chapa/callback", h.HandleChapaCallback) + api.Get("/auth/google/callback", h.GoogleCallback) +} diff --git a/internal/web_server/ws/ws.go b/internal/web_server/ws/ws.go index 55c7dd80..9c235b6f 100644 --- a/internal/web_server/ws/ws.go +++ b/internal/web_server/ws/ws.go @@ -1,6 +1,7 @@ package ws import ( + "Rezina-Backend/internal/domain" "net/http" "strconv" "sync" @@ -12,8 +13,24 @@ import ( ) type Client struct { - Conn *websocket.Conn - RecipientID int64 + ReceiverType domain.ReceiverType + Conn *websocket.Conn + RecipientID int64 +} + +func (client *Client) receives(payload map[string]interface{}) bool { + recipient, ok := payload["recipient_id"].(int64) + if !ok || recipient != client.RecipientID { + return false + } + var receiver domain.ReceiverType + switch value := payload["receiver_type"].(type) { + case string: + receiver = domain.ReceiverType(value) + case domain.ReceiverType: + receiver = value + } + return receiver != "" && receiver == client.ReceiverType } type NotificationHub struct { @@ -51,7 +68,7 @@ func (h *NotificationHub) Run() { h.mu.Lock() for client := range h.Clients { if payload, ok := message.(map[string]interface{}); ok { - if recipient, ok := payload["recipient_id"].(int64); ok && recipient == client.RecipientID { + if client.receives(payload) { err := client.Conn.WriteJSON(payload) if err != nil { delete(h.Clients, client) diff --git a/internal/web_server/ws/ws_test.go b/internal/web_server/ws/ws_test.go new file mode 100644 index 00000000..55bdd55f --- /dev/null +++ b/internal/web_server/ws/ws_test.go @@ -0,0 +1,28 @@ +package ws + +import ( + "Rezina-Backend/internal/domain" + "testing" +) + +func TestNotificationRecipientIsolation(t *testing.T) { + customer := &Client{RecipientID: 42, ReceiverType: domain.ReceiverTypeUser} + staff := &Client{RecipientID: 42, ReceiverType: domain.ReceiverTypeTeamMember} + for _, tc := range []struct { + name string + payload map[string]interface{} + customer, staff bool + }{ + {"customer event", map[string]interface{}{"recipient_id": int64(42), "receiver_type": domain.ReceiverTypeUser}, true, false}, + {"staff event", map[string]interface{}{"recipient_id": int64(42), "receiver_type": domain.ReceiverTypeTeamMember}, false, true}, + {"serialized type", map[string]interface{}{"recipient_id": int64(42), "receiver_type": "team_member"}, false, true}, + {"another recipient", map[string]interface{}{"recipient_id": int64(99), "receiver_type": domain.ReceiverTypeUser}, false, false}, + {"unscoped event", map[string]interface{}{"recipient_id": int64(42)}, false, false}, + } { + t.Run(tc.name, func(t *testing.T) { + if customer.receives(tc.payload) != tc.customer || staff.receives(tc.payload) != tc.staff { + t.Fatal("notification crossed account boundary") + } + }) + } +}