syntax = "v1"

info (
	title:   "Ticket API"
	desc:    "API for ppanel"
	author:  "Tension"
	email:   "tension@ppanel.com"
	version: "0.0.1"
)

import "../types.api"

type (
	UpdateTicketStatusRequest {
		Id     int64  `json:"id" validate:"required"`
		Status *uint8 `json:"status" validate:"required"`
	}
	GetTicketListRequest {
		Page      int64  `form:"page"`
		Size      int64  `form:"size"`
		UserId    int64  `form:"user_id,omitempty"`
		Status    *uint8 `form:"status,omitempty"`
		IssueType *uint8 `form:"issue_type,omitempty"`
		Search    string `form:"search,omitempty"`
	}
	GetTicketListResponse {
		Total int64    `json:"total"`
		List  []Ticket `json:"list"`
	}
	GetTicketRequest {
		Id int64 `form:"id" validate:"required"`
	}
	CreateTicketFollowRequest {
		TicketId int64  `json:"ticket_id" validate:"required"`
		From     string `json:"from" validate:"required"`
		Type     uint8  `json:"type" validate:"required"`
		Content  string `json:"content" validate:"required"`
	}
)

@server (
	prefix:     v1/admin/ticket
	group:      admin/ticket
	middleware: AuthMiddleware
)
service ppanel {
	@doc "Get ticket list"
	@handler GetTicketList
	get /list (GetTicketListRequest) returns (GetTicketListResponse)

	@doc "Get ticket detail"
	@handler GetTicket
	get /detail (GetTicketRequest) returns (Ticket)

	@doc "Update ticket status"
	@handler UpdateTicketStatus
	put / (UpdateTicketStatusRequest)

	@doc "Create ticket follow"
	@handler CreateTicketFollow
	post /follow (CreateTicketFollowRequest)
}

