syntax = "v1"

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

import "../types.api"

type (
	GetUserTicketListResponse {
		Total int64    `json:"total"`
		List  []Ticket `json:"list"`
	}
	CreateUserTicketRequest {
		Title       string `json:"title"`
		Description string `json:"description"`
	}
	GetUserTicketListRequest {
		Page   int    `form:"page"`
		Size   int    `form:"size"`
		Status *uint8 `form:"status,omitempty"`
		Search string `form:"search,omitempty"`
	}
	GetUserTicketDetailRequest {
		Id int64 `form:"id" validate:"required"`
	}
	UpdateUserTicketStatusRequest {
		Id     int64  `json:"id" validate:"required"`
		Status *uint8 `json:"status" validate:"required"`
	}
	CreateUserTicketFollowRequest {
		TicketId int64  `json:"ticket_id"`
		From     string `json:"from"`
		Type     uint8  `json:"type"`
		Content  string `json:"content"`
	}
)

@server (
	prefix:     v1/public/ticket
	group:      public/ticket
	middleware: AuthMiddleware,DeviceMiddleware
)
service ppanel {
	@doc "Get ticket list"
	@handler GetUserTicketList
	get /list (GetUserTicketListRequest) returns (GetUserTicketListResponse)

	@doc "Get ticket detail"
	@handler GetUserTicketDetails
	get /detail (GetUserTicketDetailRequest) returns (Ticket)

	@doc "Update ticket status"
	@handler UpdateUserTicketStatus
	put / (UpdateUserTicketStatusRequest)

	@doc "Create ticket follow"
	@handler CreateUserTicketFollow
	post /follow (CreateUserTicketFollowRequest)

	@doc "Create ticket"
	@handler CreateUserTicket
	post / (CreateUserTicketRequest)
}

