package client

import (
	"context"

	"google.golang.org/grpc"
	activityv1 "hyapp.local/api/proto/activity/v1"
)

// ActivityTemplateRuntimeClient 是 gateway 对活动模版 App 运行态的唯一内部依赖。
// gateway 只负责鉴权身份、可信区域和 HTTP 协议转换；版本命中、UTC 日任务、领奖幂等和榜单事实都由 activity-service 决定。
type ActivityTemplateRuntimeClient interface {
	GetCurrentActivityTemplate(ctx context.Context, req *activityv1.GetCurrentActivityTemplateRequest) (*activityv1.GetCurrentActivityTemplateResponse, error)
	VisitActivityTemplate(ctx context.Context, req *activityv1.VisitActivityTemplateRequest) (*activityv1.VisitActivityTemplateResponse, error)
	ListActivityTemplateTasks(ctx context.Context, req *activityv1.ListActivityTemplateTasksRequest) (*activityv1.ListActivityTemplateTasksResponse, error)
	ClaimActivityTemplateTaskReward(ctx context.Context, req *activityv1.ClaimActivityTemplateTaskRewardRequest) (*activityv1.ClaimActivityTemplateTaskRewardResponse, error)
	ListActivityTemplateLeaderboard(ctx context.Context, req *activityv1.ListActivityTemplateLeaderboardRequest) (*activityv1.ListActivityTemplateLeaderboardResponse, error)
}

type grpcActivityTemplateRuntimeClient struct {
	client activityv1.ActivityTemplateRuntimeServiceClient
}

func NewGRPCActivityTemplateRuntimeClient(conn *grpc.ClientConn) ActivityTemplateRuntimeClient {
	return &grpcActivityTemplateRuntimeClient{client: activityv1.NewActivityTemplateRuntimeServiceClient(conn)}
}

func (c *grpcActivityTemplateRuntimeClient) GetCurrentActivityTemplate(ctx context.Context, req *activityv1.GetCurrentActivityTemplateRequest) (*activityv1.GetCurrentActivityTemplateResponse, error) {
	return c.client.GetCurrentActivityTemplate(ctx, req)
}

func (c *grpcActivityTemplateRuntimeClient) VisitActivityTemplate(ctx context.Context, req *activityv1.VisitActivityTemplateRequest) (*activityv1.VisitActivityTemplateResponse, error) {
	return c.client.VisitActivityTemplate(ctx, req)
}

func (c *grpcActivityTemplateRuntimeClient) ListActivityTemplateTasks(ctx context.Context, req *activityv1.ListActivityTemplateTasksRequest) (*activityv1.ListActivityTemplateTasksResponse, error) {
	return c.client.ListActivityTemplateTasks(ctx, req)
}

func (c *grpcActivityTemplateRuntimeClient) ClaimActivityTemplateTaskReward(ctx context.Context, req *activityv1.ClaimActivityTemplateTaskRewardRequest) (*activityv1.ClaimActivityTemplateTaskRewardResponse, error) {
	return c.client.ClaimActivityTemplateTaskReward(ctx, req)
}

func (c *grpcActivityTemplateRuntimeClient) ListActivityTemplateLeaderboard(ctx context.Context, req *activityv1.ListActivityTemplateLeaderboardRequest) (*activityv1.ListActivityTemplateLeaderboardResponse, error) {
	return c.client.ListActivityTemplateLeaderboard(ctx, req)
}
