package client

import (
	"context"

	activityv1 "hyapp.local/api/proto/activity/v1"

	"google.golang.org/grpc"
)

// TaskClient abstracts gateway access to activity-service task read and claim APIs.
type TaskClient interface {
	ListUserTasks(ctx context.Context, req *activityv1.ListUserTasksRequest) (*activityv1.ListUserTasksResponse, error)
	ClaimTaskReward(ctx context.Context, req *activityv1.ClaimTaskRewardRequest) (*activityv1.ClaimTaskRewardResponse, error)
}

type grpcTaskClient struct {
	client activityv1.TaskServiceClient
}

// NewGRPCTaskClient builds a task client backed by activity-service TaskService.
func NewGRPCTaskClient(conn *grpc.ClientConn) TaskClient {
	return &grpcTaskClient{client: activityv1.NewTaskServiceClient(conn)}
}

func (c *grpcTaskClient) ListUserTasks(ctx context.Context, req *activityv1.ListUserTasksRequest) (*activityv1.ListUserTasksResponse, error) {
	return c.client.ListUserTasks(ctx, req)
}

func (c *grpcTaskClient) ClaimTaskReward(ctx context.Context, req *activityv1.ClaimTaskRewardRequest) (*activityv1.ClaimTaskRewardResponse, error) {
	return c.client.ClaimTaskReward(ctx, req)
}
