syntax = "v1"

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

import "../types.api"

type (
	QuerySubscribeListRequest {
		Language string `form:"language"`
	}
	QueryUserSubscribeNodeListResponse {
		List []UserSubscribeInfo `json:"list"`
	}
	UserSubscribeInfo {
		Id                     int64                    `json:"id"`
		UserId                 int64                    `json:"user_id"`
		OrderId                int64                    `json:"order_id"`
		SubscribeId            int64                    `json:"subscribe_id"`
		StartTime              int64                    `json:"start_time"`
		ExpireTime             int64                    `json:"expire_time"`
		FinishedAt             int64                    `json:"finished_at"`
		ResetTime              int64                    `json:"reset_time"`
		Traffic                int64                    `json:"traffic"`
		Download               int64                    `json:"download"`
		Upload                 int64                    `json:"upload"`
		Token                  string                   `json:"token"`
		Status                 uint8                    `json:"status"`
		EntitlementSource      string                   `json:"entitlement_source"`
		EntitlementOwnerUserId int64                    `json:"entitlement_owner_user_id"`
		ReadOnly               bool                     `json:"read_only"`
		CreatedAt              int64                    `json:"created_at"`
		UpdatedAt              int64                    `json:"updated_at"`
		IsTryOut               bool                     `json:"is_try_out"`
		Nodes                  []*UserSubscribeNodeInfo `json:"nodes"`
	}
	UserSubscribeNodeInfo {
		Id              int64    `json:"id"`
		Name            string   `json:"name"`
		Uuid            string   `json:"uuid"`
		Protocol        string   `json:"protocol"`
		Protocols       string   `json:"protocols"`
		Port            uint16   `json:"port"`
		Address         string   `json:"address"`
		Tags            []string `json:"tags"`
		Country         string   `json:"country"`
		City            string   `json:"city"`
		Longitude       string   `json:"longitude"`
		Latitude        string   `json:"latitude"`
		LatitudeCenter  string   `json:"latitude_center"`
		LongitudeCenter string   `json:"longitude_center"`
		CreatedAt       int64    `json:"created_at"`
	}
)

@server (
	prefix:     v1/public/subscribe
	group:      public/subscribe
	middleware: AuthMiddleware,DeviceMiddleware
)
service ppanel {
	@doc "Get subscribe list"
	@handler QuerySubscribeList
	get /list (QuerySubscribeListRequest) returns (QuerySubscribeListResponse)

	@doc "Get user subscribe node info"
	@handler QueryUserSubscribeNodeList
	get /node/list returns (QueryUserSubscribeNodeListResponse)

	@doc "Get subscribe group list"
	@handler QuerySubscribeGroupList
	get /group/list returns (QuerySubscribeGroupListResponse)
}

