syntax = "v1"

info (
	title:   "Auth Method Management"
	desc:    "System auth method management"
	author:  "Tension"
	email:   "tension@ppanel.com"
	version: "0.1.2"
)

import (
	"../types.api"
)

type (
	UpdateAuthMethodConfigRequest {
		Id      int64       `json:"id"`
		Method  string      `json:"method"`
		Config  interface{} `json:"config"`
		Enabled *bool       `json:"enabled"`
	}
	GetAuthMethodConfigRequest {
		Method string `form:"method"`
	}
	GetAuthMethodListResponse {
		List []AuthMethodConfig `json:"list"`
	}
	TestSmsSendRequest {
		AreaCode  string `json:"area_code" validate:"required"`
		Telephone string `json:"telephone" validate:"required"`
	}
	// Test email smtp request
	TestEmailSendRequest {
		Email string `json:"email" validate:"required"`
	}
)

@server (
	prefix:     v1/admin/auth-method
	group:      admin/authMethod
	middleware: AuthMiddleware
)
service ppanel {
	@doc "Get auth method list"
	@handler GetAuthMethodList
	get /list returns (GetAuthMethodListResponse)

	@doc "Get auth method config"
	@handler GetAuthMethodConfig
	get /config (GetAuthMethodConfigRequest) returns (AuthMethodConfig)

	@doc "Update auth method config"
	@handler UpdateAuthMethodConfig
	put /config (UpdateAuthMethodConfigRequest) returns (AuthMethodConfig)

	@doc "Test sms send"
	@handler TestSmsSend
	post /test_sms_send (TestSmsSendRequest)

	@doc "Test email send"
	@handler TestEmailSend
	post /test_email_send (TestEmailSendRequest)

	@doc "Get sms support platform"
	@handler GetSmsPlatform
	get /sms_platform returns (PlatformResponse)

	@doc "Get email support platform"
	@handler GetEmailPlatform
	get /email_platform returns (PlatformResponse)
}

