diff --git a/internal/api/http/auth/login.go b/internal/api/http/auth/login.go index 77ebc07..b8d1146 100644 --- a/internal/api/http/auth/login.go +++ b/internal/api/http/auth/login.go @@ -58,7 +58,7 @@ func LoginStaff( return } - responsePayload := &authdomain.LoginResponse{ + responsePayload := &authdomain.AuthResponse{ Token: token, } @@ -113,7 +113,7 @@ func LoginUser( return } - responsePayload := &authdomain.LoginResponse{ + responsePayload := &authdomain.AuthResponse{ Token: token, } diff --git a/internal/api/http/auth/register.go b/internal/api/http/auth/register.go index d60d216..fe75cac 100644 --- a/internal/api/http/auth/register.go +++ b/internal/api/http/auth/register.go @@ -58,7 +58,11 @@ func RegisterUser( return } - response.RespondJsonSuccess(ctx, w, token) + responsePayload := &authdomain.AuthResponse{ + Token: token, + } + + response.RespondJsonSuccess(ctx, w, responsePayload) }) } @@ -108,7 +112,9 @@ func RegisterStaff( ) return } - - response.RespondJsonSuccess(ctx, w, token) + responsePayload := &authdomain.AuthResponse{ + Token: token, + } + response.RespondJsonSuccess(ctx, w, responsePayload) }) } diff --git a/internal/api/http/subscribe_plan/create.go b/internal/api/http/subscribe_plan/create.go index 3de13ea..e55fa97 100644 --- a/internal/api/http/subscribe_plan/create.go +++ b/internal/api/http/subscribe_plan/create.go @@ -60,7 +60,7 @@ func CreateSubscribePlan( response.RespondJsonSuccess(ctx, w, struct { Message string }{ - Message: "success", + Message: "subscription plan created successfully.", }) }) } diff --git a/internal/domain/auth/login.go b/internal/domain/auth/login.go index f216642..8f515b8 100644 --- a/internal/domain/auth/login.go +++ b/internal/domain/auth/login.go @@ -7,7 +7,7 @@ type LoginReq struct { Password string `json:"password" validate:"required"` } -type LoginResponse struct { +type AuthResponse struct { Token string `json:"token"` } diff --git a/openapi.yml b/openapi.yml index eb2bbff..44ca381 100644 --- a/openapi.yml +++ b/openapi.yml @@ -8,6 +8,8 @@ paths: /staff/login: post: summary: Login for staff + tags: + - Staff requestBody: required: true content: @@ -26,12 +28,37 @@ paths: responses: "200": description: Successful login + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + token: + type: string + description: JWT token for staff authentication "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string /staff/register: post: summary: Register a new staff member + tags: + - Staff requestBody: required: true content: @@ -50,14 +77,51 @@ paths: responses: "201": description: Staff member created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + token: + type: string + description: JWT token for staff authentication "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string "409": description: Conflict (email already registered) + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string /user/login: post: summary: Login for user + tags: + - User requestBody: required: true content: @@ -76,12 +140,37 @@ paths: responses: "200": description: Successful login + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + token: + type: string + description: JWT token for user authentication "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string /user/register: post: summary: Register a new user + tags: + - User requestBody: required: true content: @@ -107,14 +196,51 @@ paths: responses: "201": description: User created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + token: + type: string + description: JWT token for user authentication "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string "409": description: Conflict (email already registered) + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string /subscribe-plan/create: post: summary: Create a new subscription plan + tags: + - Subscribe Plan requestBody: required: true content: @@ -122,23 +248,91 @@ paths: schema: type: object properties: + name: + type: string code: type: string required: - code + - name responses: "201": description: Subscription plan created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + message: + type: string + example: "Subscription plan created successfully." "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string "409": description: Conflict (plan code already exists) + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string /subscribe-plan/get-all: get: - summary: Get all subscription plan + summary: Get all subscription plans + tags: + - Subscribe Plan responses: - "201": - description: Subscription plan created + "200": + description: Successfully retrieved all subscription plans + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + type: object + properties: + id: + type: string + code: + type: string + name: + type: string "400": description: Bad request + content: + application/json: + schema: + type: object + properties: + error: + type: object + properties: + code: + type: string + message: + type: string