Spaces:
Running
Running
| // Package docs Code generated by swaggo/swag. DO NOT EDIT | |
| package docs | |
| import "github.com/swaggo/swag" | |
| const docTemplate = `{ | |
| "schemes": {{ marshal .Schemes }}, | |
| "swagger": "2.0", | |
| "info": { | |
| "description": "{{escape .Description}}", | |
| "title": "{{.Title}}", | |
| "termsOfService": "http://swagger.io/terms/", | |
| "contact": { | |
| "name": "API Support", | |
| "url": "http://www.swagger.io/support", | |
| "email": "support@swagger.io" | |
| }, | |
| "license": { | |
| "name": "Apache 2.0", | |
| "url": "http://www.apache.org/licenses/LICENSE-2.0.html" | |
| }, | |
| "version": "{{.Version}}" | |
| }, | |
| "host": "{{.Host}}", | |
| "basePath": "{{.BasePath}}", | |
| "paths": { | |
| "/admin/create": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Create a new user with specific role", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "admin" | |
| ], | |
| "summary": "Create a new user (Admin)", | |
| "parameters": [ | |
| { | |
| "description": "Create User Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.CreateUserRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.UserResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/admin/delete": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Delete a user by ID", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "admin" | |
| ], | |
| "summary": "Delete a user (Admin)", | |
| "parameters": [ | |
| { | |
| "type": "string", | |
| "description": "User ID", | |
| "name": "id", | |
| "in": "query", | |
| "required": true | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK" | |
| } | |
| } | |
| } | |
| }, | |
| "/admin/set_registration": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Enable or disable user registration", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "admin" | |
| ], | |
| "summary": "Toggle registration enabled", | |
| "parameters": [ | |
| { | |
| "description": "Set Registration Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.SetRegistrationRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.RegisterEnabledResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/admin/update": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Update user details", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "admin" | |
| ], | |
| "summary": "Update a user (Admin)", | |
| "parameters": [ | |
| { | |
| "description": "Update User Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.UpdateUserRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.UserResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/assign": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Assign a role to a user", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Assign Role (SuperAdmin)", | |
| "parameters": [ | |
| { | |
| "description": "Assign Role Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.AssignRoleRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK" | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/login": { | |
| "post": { | |
| "description": "Login a user with credentials", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Login a user", | |
| "parameters": [ | |
| { | |
| "description": "Login Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.LoginRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.AuthResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/logout": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Logout the current user", | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Logout a user", | |
| "responses": { | |
| "200": { | |
| "description": "OK" | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/me": { | |
| "get": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Get the profile of the currently logged-in user", | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Get current user profile", | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.MeResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/refresh": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Refresh the access token using the refresh token cookie", | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Refresh access token", | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.AuthResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/register": { | |
| "post": { | |
| "description": "Register a new user with the provided details", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Register a new user", | |
| "parameters": [ | |
| { | |
| "description": "Register Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.RegisterRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.AuthResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/auth/register_enabled": { | |
| "get": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Check if user registration is enabled", | |
| "tags": [ | |
| "auth" | |
| ], | |
| "summary": "Check if registration is enabled", | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.RegisterEnabledResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/chat/contacts": { | |
| "get": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Fetch list of contacts from the connected WhatsApp account", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "chat" | |
| ], | |
| "summary": "Fetch WhatsApp contacts", | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.FetchContactsResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/chat/send_img": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Send an image to a WhatsApp number via file upload", | |
| "consumes": [ | |
| "multipart/form-data" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "chat" | |
| ], | |
| "summary": "Send WhatsApp image", | |
| "parameters": [ | |
| { | |
| "type": "file", | |
| "description": "Image file to send", | |
| "name": "image", | |
| "in": "formData", | |
| "required": true | |
| }, | |
| { | |
| "type": "string", | |
| "example": "628123456789", | |
| "description": "Recipient phone number", | |
| "name": "recipient", | |
| "in": "formData", | |
| "required": true | |
| }, | |
| { | |
| "type": "string", | |
| "description": "Image caption", | |
| "name": "caption", | |
| "in": "formData" | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.SendMessageResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/chat/send_msg": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Send a text message to a WhatsApp number", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "chat" | |
| ], | |
| "summary": "Send WhatsApp text message", | |
| "parameters": [ | |
| { | |
| "description": "Send Message Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.SendMessageRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.SendMessageResponse" | |
| } | |
| }, | |
| "400": { | |
| "description": "Bad Request", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/whatsapp/connect": { | |
| "post": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Initiate a connection request for a new WhatsApp account. Returns a QR code if not connected.", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "whatsapp" | |
| ], | |
| "summary": "Connect new WhatsApp account", | |
| "parameters": [ | |
| { | |
| "description": "Connect Request", | |
| "name": "request", | |
| "in": "body", | |
| "required": true, | |
| "schema": { | |
| "$ref": "#/definitions/dto.ConnectRequest" | |
| } | |
| } | |
| ], | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ConnectResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| }, | |
| "500": { | |
| "description": "Internal Server Error", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "/whatsapp/socket": { | |
| "get": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Upgrade HTTP connection to WebSocket for real-time updates", | |
| "tags": [ | |
| "whatsapp" | |
| ], | |
| "summary": "Connect to WebSocket", | |
| "responses": { | |
| "101": { | |
| "description": "Switching Protocols" | |
| } | |
| } | |
| } | |
| }, | |
| "/whatsapp/status": { | |
| "get": { | |
| "security": [ | |
| { | |
| "BearerAuth": [] | |
| } | |
| ], | |
| "description": "Get the current status of the WhatsApp connection", | |
| "consumes": [ | |
| "application/json" | |
| ], | |
| "produces": [ | |
| "application/json" | |
| ], | |
| "tags": [ | |
| "whatsapp" | |
| ], | |
| "summary": "Get WhatsApp connection status", | |
| "responses": { | |
| "200": { | |
| "description": "OK", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ConnectionStatusResponse" | |
| } | |
| }, | |
| "401": { | |
| "description": "Unauthorized", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| }, | |
| "500": { | |
| "description": "Internal Server Error", | |
| "schema": { | |
| "$ref": "#/definitions/dto.ErrorResponse" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "definitions": { | |
| "dto.AssignRoleRequest": { | |
| "type": "object", | |
| "required": [ | |
| "role", | |
| "user_id" | |
| ], | |
| "properties": { | |
| "role": { | |
| "type": "string" | |
| }, | |
| "user_id": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.AuthResponse": { | |
| "type": "object", | |
| "properties": { | |
| "access_token": { | |
| "type": "string" | |
| }, | |
| "success_msg": { | |
| "type": "string" | |
| }, | |
| "user_id": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.ConnectRequest": { | |
| "type": "object" | |
| }, | |
| "dto.ConnectResponse": { | |
| "type": "object", | |
| "properties": { | |
| "account_id": { | |
| "type": "string" | |
| }, | |
| "details": { | |
| "type": "string" | |
| }, | |
| "message": { | |
| "type": "string" | |
| }, | |
| "qr_code": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.ConnectionStatusResponse": { | |
| "type": "object", | |
| "properties": { | |
| "account_id": { | |
| "type": "string" | |
| }, | |
| "jid": { | |
| "type": "string" | |
| }, | |
| "status": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.ContactResponse": { | |
| "type": "object", | |
| "properties": { | |
| "full_name": { | |
| "type": "string" | |
| }, | |
| "jid": { | |
| "type": "string" | |
| }, | |
| "name": { | |
| "type": "string" | |
| }, | |
| "phone_number": { | |
| "type": "string" | |
| }, | |
| "push_name": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.CreateUserRequest": { | |
| "type": "object", | |
| "required": [ | |
| "password", | |
| "role", | |
| "username" | |
| ], | |
| "properties": { | |
| "password": { | |
| "type": "string", | |
| "minLength": 6 | |
| }, | |
| "role": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.ErrorResponse": { | |
| "type": "object", | |
| "properties": { | |
| "errors": {}, | |
| "message": {}, | |
| "meta_data": {}, | |
| "status": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.FetchContactsResponse": { | |
| "type": "object", | |
| "properties": { | |
| "account_id": { | |
| "type": "string" | |
| }, | |
| "contacts": { | |
| "type": "array", | |
| "items": { | |
| "$ref": "#/definitions/dto.ContactResponse" | |
| } | |
| } | |
| } | |
| }, | |
| "dto.LoginRequest": { | |
| "type": "object", | |
| "required": [ | |
| "password", | |
| "username" | |
| ], | |
| "properties": { | |
| "password": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.MeResponse": { | |
| "type": "object", | |
| "properties": { | |
| "account_name": { | |
| "type": "string" | |
| }, | |
| "is_active": { | |
| "type": "boolean" | |
| }, | |
| "jid": { | |
| "type": "string" | |
| }, | |
| "phone": { | |
| "type": "string" | |
| }, | |
| "role": { | |
| "type": "string" | |
| }, | |
| "user_id": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.RegisterEnabledResponse": { | |
| "type": "object", | |
| "properties": { | |
| "register": { | |
| "type": "boolean" | |
| } | |
| } | |
| }, | |
| "dto.RegisterRequest": { | |
| "type": "object", | |
| "required": [ | |
| "password", | |
| "username" | |
| ], | |
| "properties": { | |
| "password": { | |
| "type": "string", | |
| "minLength": 6 | |
| }, | |
| "username": { | |
| "type": "string", | |
| "minLength": 3 | |
| } | |
| } | |
| }, | |
| "dto.SendMessageRequest": { | |
| "type": "object", | |
| "required": [ | |
| "message", | |
| "recipient" | |
| ], | |
| "properties": { | |
| "message": { | |
| "type": "string", | |
| "example": "Hello world" | |
| }, | |
| "recipient": { | |
| "type": "string", | |
| "example": "628123456789" | |
| } | |
| } | |
| }, | |
| "dto.SendMessageResponse": { | |
| "type": "object", | |
| "properties": { | |
| "message_id": { | |
| "type": "string" | |
| }, | |
| "status": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.SetRegistrationRequest": { | |
| "type": "object", | |
| "properties": { | |
| "enabled": { | |
| "type": "boolean" | |
| } | |
| } | |
| }, | |
| "dto.UpdateUserRequest": { | |
| "type": "object", | |
| "required": [ | |
| "id" | |
| ], | |
| "properties": { | |
| "id": { | |
| "type": "string" | |
| }, | |
| "password": { | |
| "type": "string", | |
| "minLength": 6 | |
| }, | |
| "role": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "dto.UserResponse": { | |
| "type": "object", | |
| "properties": { | |
| "created_at": { | |
| "type": "string" | |
| }, | |
| "id": { | |
| "type": "string" | |
| }, | |
| "role": { | |
| "type": "string" | |
| }, | |
| "username": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, | |
| "securityDefinitions": { | |
| "BearerAuth": { | |
| "type": "apiKey", | |
| "name": "Authorization", | |
| "in": "header" | |
| } | |
| } | |
| }` | |
| // SwaggerInfo holds exported Swagger Info so clients can modify it | |
| var SwaggerInfo = &swag.Spec{ | |
| Version: "1.0", | |
| Host: "", | |
| BasePath: "/api", | |
| Schemes: []string{}, | |
| Title: "Whatsapp Backend API", | |
| Description: "This is the API documentation for the Whatsapp Backend.", | |
| InfoInstanceName: "swagger", | |
| SwaggerTemplate: docTemplate, | |
| LeftDelim: "{{", | |
| RightDelim: "}}", | |
| } | |
| func init() { | |
| swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | |
| } | |