syntax = "v1"

type (
	MemberMeData {
		TenantID              string   `json:"tenant_id"`
		UID                   string   `json:"uid"`
		Email                 string   `json:"email"`
		DisplayName           string   `json:"display_name,omitempty"`
		Avatar                string   `json:"avatar,omitempty"`
		Phone                 string   `json:"phone,omitempty"`
		Language              string   `json:"language,omitempty"`
		Currency              string   `json:"currency,omitempty"`
		Status                string   `json:"status"`
		Origin                string   `json:"origin"`
		Roles                 []string `json:"roles,omitempty"`
		BusinessEmail         string   `json:"business_email,omitempty"`
		BusinessEmailVerified bool     `json:"business_email_verified"`
		BusinessPhone         string   `json:"business_phone,omitempty"`
		BusinessPhoneVerified bool     `json:"business_phone_verified"`
		CreateAt              int64    `json:"create_at"`
		UpdateAt              int64    `json:"update_at"`
	}

	UpdateMemberMeReq {
		DisplayName string `json:"display_name,optional"`
		Avatar      string `json:"avatar,optional"`
		Language    string `json:"language,optional"`
		Currency    string `json:"currency,optional"`
		Phone       string `json:"phone,optional"`
	}

	MemberPlacementSettingsData {
		WebSearchProvider       string `json:"web_search_provider"` // brave | exa
		BraveAPIKey             string `json:"brave_api_key,omitempty"`
		BraveAPIKeyConfigured   bool   `json:"brave_api_key_configured"`
		ExaAPIKey               string `json:"exa_api_key,omitempty"`
		ExaAPIKeyConfigured     bool   `json:"exa_api_key_configured"`
		BraveCountry            string `json:"brave_country"`
		BraveSearchLang         string `json:"brave_search_lang"`
		ExaUserLocation         string `json:"exa_user_location"`
		ExpandStrategy          string `json:"expand_strategy"` // brave | llm | hybrid
	}

	UpdateMemberPlacementSettingsReq {
		WebSearchProvider *string `json:"web_search_provider,optional"`
		BraveAPIKey       *string `json:"brave_api_key,optional"`
		ExaAPIKey         *string `json:"exa_api_key,optional"`
		BraveCountry      *string `json:"brave_country,optional"`
		BraveSearchLang   *string `json:"brave_search_lang,optional"`
		ExaUserLocation   *string `json:"exa_user_location,optional"`
		ExpandStrategy    *string `json:"expand_strategy,optional"`
	}

	MemberCapabilitiesData {
		DiscoverReady          bool   `json:"discover_ready"`
		AiReady                bool   `json:"ai_ready"`
		PublishReady           bool   `json:"publish_ready"`
		DiscoverHint           string `json:"discover_hint,omitempty"`
		AiHint                 string `json:"ai_hint,omitempty"`
		PublishHint            string `json:"publish_hint,omitempty"`
		ActiveThreadsAccountId string `json:"active_threads_account_id,omitempty"`
	}
)

@server(
	group:      member
	prefix:     /api/v1/members
	middleware: AuthJWT
	tags:       "Member"
	summary:    "Current member profile endpoints. Requires Bearer JWT or dev headers."
)
service gateway {
	@handler getMemberMe
	get /me returns (MemberMeData)

	@handler updateMemberMe
	patch /me (UpdateMemberMeReq) returns (MemberMeData)

	@handler getMemberPlacementSettings
	get /me/placement-settings returns (MemberPlacementSettingsData)

	@handler updateMemberPlacementSettings
	patch /me/placement-settings (UpdateMemberPlacementSettingsReq) returns (MemberPlacementSettingsData)

	@handler getMemberCapabilities
	get /me/capabilities returns (MemberCapabilitiesData)
}
