syntax = "v1"

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

import "../types.api"

type (
	QueryUserSubscribeResp {
		Data []UserSubscribeData `json:"data"`
	}
	UserSubscribeData {
		SubscribeId     int64 `json:"subscribe_id"`
		UserSubscribeId int64 `json:"user_subscribe_id"`
	}
	UserSubscribeResetPeriodRequest {
		UserSubscribeId int64 `json:"user_subscribe_id"`
	}
	UserSubscribeResetPeriodResponse {
		Status bool `json:"status"`
	}
	AppUserSubscribeRequest {
		ContainsNodes *bool `form:"contains_nodes"`
	}
	AppUserSubscbribeResponse {
		List []AppUserSubcbribe `json:"list"`
	}
)

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

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

	@doc "Get application config"
	@handler QueryApplicationConfig
	get /application/config returns (ApplicationResponse)

	@doc "Get  Already subscribed to package"
	@handler QueryUserAlreadySubscribe
	get /user/already_subscribe returns (QueryUserSubscribeResp)

	@doc "Get Available subscriptions for users"
	@handler QueryUserAvailableUserSubscribe
	get /user/available_subscribe (AppUserSubscribeRequest) returns (AppUserSubscbribeResponse)

	@doc "Reset user subscription period"
	@handler ResetUserSubscribePeriod
	post /reset/period (UserSubscribeResetPeriodRequest) returns (UserSubscribeResetPeriodResponse)
}

