syntax = "v1"

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

import "../types.api"

type (
	// Update application request
	UpdateApplicationRequest {
		Id            int64               `json:"id" validate:"required"`
		Icon          string              `json:"icon"`
		Name          string              `json:"name"`
		Description   string              `json:"description"`
		SubscribeType string              `json:"subscribe_type"`
		Platform      ApplicationPlatform `json:"platform"`
	}
	// Create application request
	CreateApplicationRequest {
		Icon          string              `json:"icon"`
		Name          string              `json:"name"`
		Description   string              `json:"description"`
		SubscribeType string              `json:"subscribe_type"`
		Platform      ApplicationPlatform `json:"platform"`
	}
	// Update application request
	UpdateApplicationVersionRequest {
		Id            int64  `json:"id" validate:"required"`
		Url           string `json:"url"`
		Version       string `json:"version" validate:"required"`
		Description   string `json:"description"`
		Platform      string `json:"platform" validate:"required,oneof=windows mac linux android ios harmony"`
		IsDefault     bool   `json:"is_default"`
		ApplicationId int64  `json:"application_id" validate:"required"`
	}
	// Create application request
	CreateApplicationVersionRequest {
		Url           string `json:"url"`
		Version       string `json:"version" validate:"required"`
		Description   string `json:"description"`
		Platform      string `json:"platform" validate:"required,oneof=windows mac linux android ios harmony"`
		IsDefault     bool   `json:"is_default"`
		ApplicationId int64  `json:"application_id" validate:"required"`
	}
	// Delete application request
	DeleteApplicationRequest {
		Id int64 `json:"id" validate:"required"`
	}
	// Delete application request
	DeleteApplicationVersionRequest {
		Id int64 `json:"id" validate:"required"`
	}
	GetNodeMultiplierResponse {
		Periods []TimePeriod `json:"periods"`
	}
	// SetNodeMultiplierRequest
	SetNodeMultiplierRequest {
		Periods []TimePeriod `json:"periods"`
	}
)

@server (
	prefix:     v1/admin/system
	group:      admin/system
	middleware: AuthMiddleware
)
service ppanel {
	@doc "Get site config"
	@handler GetSiteConfig
	get /site_config returns (SiteConfig)

	@doc "Update site config"
	@handler UpdateSiteConfig
	put /site_config (SiteConfig)

	@doc "Get subscribe config"
	@handler GetSubscribeConfig
	get /subscribe_config returns (SubscribeConfig)

	@doc "Update subscribe config"
	@handler UpdateSubscribeConfig
	put /subscribe_config (SubscribeConfig)

	@doc "Get subscribe type"
	@handler GetSubscribeType
	get /subscribe_type returns (SubscribeType)

	@doc "update application config"
	@handler UpdateApplicationConfig
	put /application_config (ApplicationConfig)

	@doc "get application config"
	@handler GetApplicationConfig
	get /application_config returns (ApplicationConfig)

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

	@doc "Update application"
	@handler UpdateApplication
	put /application (UpdateApplicationRequest)

	@doc "Create application"
	@handler CreateApplication
	post /application (CreateApplicationRequest)

	@doc "Delete application"
	@handler DeleteApplication
	delete /application (DeleteApplicationRequest)

	@doc "Update application version"
	@handler UpdateApplicationVersion
	put /application_version (UpdateApplicationVersionRequest)

	@doc "Create application version"
	@handler CreateApplicationVersion
	post /application_version (CreateApplicationVersionRequest)

	@doc "Delete application"
	@handler DeleteApplicationVersion
	delete /application_version (DeleteApplicationVersionRequest)

	@doc "Get register config"
	@handler GetRegisterConfig
	get /register_config returns (RegisterConfig)

	@doc "Update register config"
	@handler UpdateRegisterConfig
	put /register_config (RegisterConfig)

	@doc "Get verify config"
	@handler GetVerifyConfig
	get /verify_config returns (VerifyConfig)

	@doc "Update verify config"
	@handler UpdateVerifyConfig
	put /verify_config (VerifyConfig)

	@doc "Get node config"
	@handler GetNodeConfig
	get /node_config returns (NodeConfig)

	@doc "Update node config"
	@handler UpdateNodeConfig
	put /node_config (NodeConfig)

	@doc "Get invite config"
	@handler GetInviteConfig
	get /invite_config returns (InviteConfig)

	@doc "Update invite config"
	@handler UpdateInviteConfig
	put /invite_config (InviteConfig)

	@doc "Get Team of Service Config"
	@handler GetTosConfig
	get /tos_config returns (TosConfig)

	@doc "Update Team of Service Config"
	@handler UpdateTosConfig
	put /tos_config (TosConfig)

	@doc "get Privacy Policy Config"
	@handler GetPrivacyPolicyConfig
	get /privacy returns (PrivacyPolicyConfig)

	@doc "Update Privacy Policy Config"
	@handler UpdatePrivacyPolicyConfig
	put /privacy (PrivacyPolicyConfig)

	@doc "Get Currency Config"
	@handler GetCurrencyConfig
	get /currency_config returns (CurrencyConfig)

	@doc "Update Currency Config"
	@handler UpdateCurrencyConfig
	put /currency_config (CurrencyConfig)

	@doc "setting telegram bot"
	@handler SettingTelegramBot
	post /setting_telegram_bot

	@doc "Get Node Multiplier"
	@handler GetNodeMultiplier
	get /get_node_multiplier returns (GetNodeMultiplierResponse)

	@doc "Set Node Multiplier"
	@handler SetNodeMultiplier
	post /set_node_multiplier (SetNodeMultiplierRequest)

	@doc "Get Verify Code Config"
	@handler GetVerifyCodeConfig
	get /verify_code_config returns (VerifyCodeConfig)

	@doc "Update Verify Code Config"
	@handler UpdateVerifyCodeConfig
	put /verify_code_config (VerifyCodeConfig)
}