From fe70c7170b0d4db8581596ba6bf54c5771a1ff50 Mon Sep 17 00:00:00 2001 From: "n.nakhostin" Date: Mon, 22 Sep 2025 13:05:10 +0330 Subject: [PATCH] Add Notification Filters and AllMarkSeen Endpoint to API Documentation - Introduced new query parameters for filtering notifications by 'seen' status and 'priority' in the API documentation, enhancing the flexibility of notification retrieval. - Added a new endpoint to mark all notifications as seen for a user, including detailed Swagger documentation for the new functionality. - Updated existing API documentation to reflect the changes, ensuring clarity for API consumers and improving overall documentation quality. --- cmd/web/docs/docs.go | 85 +++++++++++++++++++++++++++++++++++++++ cmd/web/docs/swagger.json | 85 +++++++++++++++++++++++++++++++++++++++ cmd/web/docs/swagger.yaml | 55 +++++++++++++++++++++++++ internal/customer/form.go | 5 +++ 4 files changed, 230 insertions(+) diff --git a/cmd/web/docs/docs.go b/cmd/web/docs/docs.go index 8ff0e2b..d9611ca 100644 --- a/cmd/web/docs/docs.go +++ b/cmd/web/docs/docs.go @@ -2499,6 +2499,18 @@ const docTemplate = `{ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -2717,6 +2729,18 @@ const docTemplate = `{ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -5422,6 +5446,18 @@ const docTemplate = `{ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -5493,6 +5529,55 @@ const docTemplate = `{ } } }, + "/api/v1/notifications/all-seen/{user_id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Mark all notifications as seen for a user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notification" + ], + "summary": "Mark all notifications as seen for a user", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "user_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/notifications/mark-seen/{id}": { "get": { "security": [ diff --git a/cmd/web/docs/swagger.json b/cmd/web/docs/swagger.json index cf8592f..da7e134 100644 --- a/cmd/web/docs/swagger.json +++ b/cmd/web/docs/swagger.json @@ -2493,6 +2493,18 @@ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -2711,6 +2723,18 @@ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -5416,6 +5440,18 @@ "name": "recipient", "in": "query" }, + { + "type": "boolean", + "description": "Seen filter", + "name": "seen", + "in": "query" + }, + { + "type": "string", + "description": "Priority filter", + "name": "priority", + "in": "query" + }, { "type": "integer", "description": "Limit results", @@ -5487,6 +5523,55 @@ } } }, + "/api/v1/notifications/all-seen/{user_id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Mark all notifications as seen for a user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Notification" + ], + "summary": "Mark all notifications as seen for a user", + "parameters": [ + { + "type": "string", + "description": "User ID", + "name": "user_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/notifications/mark-seen/{id}": { "get": { "security": [ diff --git a/cmd/web/docs/swagger.yaml b/cmd/web/docs/swagger.yaml index b1e6bfd..b41ca31 100644 --- a/cmd/web/docs/swagger.yaml +++ b/cmd/web/docs/swagger.yaml @@ -2849,6 +2849,14 @@ paths: in: query name: recipient type: string + - description: Seen filter + in: query + name: seen + type: boolean + - description: Priority filter + in: query + name: priority + type: string - description: Limit results in: query name: limit @@ -2986,6 +2994,14 @@ paths: in: query name: recipient type: string + - description: Seen filter + in: query + name: seen + type: boolean + - description: Priority filter + in: query + name: priority + type: string - description: Limit results in: query name: limit @@ -4670,6 +4686,14 @@ paths: in: query name: recipient type: string + - description: Seen filter + in: query + name: seen + type: boolean + - description: Priority filter + in: query + name: priority + type: string - description: Limit results in: query name: limit @@ -4719,6 +4743,37 @@ paths: summary: Get notifications for the user tags: - Notification + /api/v1/notifications/all-seen/{user_id}: + get: + consumes: + - application/json + description: Mark all notifications as seen for a user + parameters: + - description: User ID + in: path + name: user_id + required: true + 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' + security: + - BearerAuth: [] + summary: Mark all notifications as seen for a user + tags: + - Notification /api/v1/notifications/mark-seen/{id}: get: consumes: diff --git a/internal/customer/form.go b/internal/customer/form.go index e4cb328..59e8262 100644 --- a/internal/customer/form.go +++ b/internal/customer/form.go @@ -2,6 +2,11 @@ package customer import "tm/pkg/response" +// DeviceTokenForm represents the form for adding a device token to a customer +type DeviceTokenForm struct { + DeviceToken string `json:"device_token" valid:"required" example:"device_token"` +} + // CreateCustomerForm represents the form for creating a new customer type CreateCustomerForm struct { FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)" example:"User"`