syntax = "v1"

type (
	AdminListMembersReq {
		Page     int    `form:"page,optional"`
		PageSize int    `form:"pageSize,optional"`
		Query    string `form:"query,optional"`
		Status   string `form:"status,optional"`
	}

	AdminUidPath {
		Uid string `path:"uid"`
	}

	AdminCreateMemberReq {
		DisplayName   string   `json:"display_name"`
		Email         string   `json:"email"`
		Phone         string   `json:"phone,optional"`
		Password      string   `json:"password,optional"`
		Roles         []string `json:"roles,optional"`
		EmailVerified bool     `json:"email_verified,optional"`
		Bio           string   `json:"bio,optional"`
		Nickname      string   `json:"nickname,optional"`
		FullName      string   `json:"full_name,optional"`
	}

	AdminCreateMemberData {
		User              MemberPublic `json:"user"`
		TemporaryPassword string       `json:"temporary_password"`
	}

	AdminSuspendReq {
		Uid       string `path:"uid"`
		Suspended bool   `json:"suspended"`
	}

	AdminRolesReq {
		Uid   string   `path:"uid"`
		Roles []string `json:"roles"`
	}

	AdminEmailVerifiedReq {
		Uid      string `path:"uid"`
		Verified bool   `json:"verified"`
	}

	AdminResetPasswordReq {
		Uid         string `path:"uid"`
		NewPassword string `json:"new_password,optional"`
		Password    string `json:"password,optional"`
	}

	AdminStatusReq {
		Uid    string `path:"uid"`
		Status string `json:"status"`
	}

	AdminListData {
		List       []MemberPublic `json:"list"`
		Pagination Pagination     `json:"pagination"`
	}

	AdminMemberIdentitiesData {
		List []IdentityPublic `json:"list"`
	}
)

@server (
	group:      admin
	prefix:     /api/v1/admin
	middleware: AuthJWT,AdminAuth
)
service gateway {
	@handler ListMembers
	get /members (AdminListMembersReq) returns (AdminListData)

	@handler CreateMember
	post /members (AdminCreateMemberReq) returns (AdminCreateMemberData)

	@handler GetMember
	get /members/:uid (AdminUidPath) returns (MemberPublic)

	@handler SetSuspended
	post /members/:uid/suspend (AdminSuspendReq) returns (MemberPublic)

	@handler SetRoles
	post /members/:uid/roles (AdminRolesReq) returns (MemberPublic)

	@handler SetEmailVerified
	post /members/:uid/email-verified (AdminEmailVerifiedReq) returns (MemberPublic)

	@handler AdminResetPassword
	post /members/:uid/reset-password (AdminResetPasswordReq) returns (AdminCreateMemberData)

	@handler SetStatus
	post /members/:uid/status (AdminStatusReq) returns (MemberPublic)

	@handler ListMemberIdentities
	get /members/:uid/identities (AdminUidPath) returns (AdminMemberIdentitiesData)
}
