package client

import (
	"context"

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

	"google.golang.org/grpc"
)

// WheelClient abstracts gateway access to activity-service wheel config and draw execution.
type WheelClient interface {
	ExecuteWheelDraw(ctx context.Context, req *activityv1.ExecuteWheelDrawRequest) (*activityv1.ExecuteWheelDrawResponse, error)
	GetWheelConfig(ctx context.Context, req *activityv1.GetWheelConfigRequest) (*activityv1.GetWheelConfigResponse, error)
	ListWheelDraws(ctx context.Context, req *activityv1.ListWheelDrawsRequest) (*activityv1.ListWheelDrawsResponse, error)
}

type grpcWheelClient struct {
	wheel activityv1.WheelServiceClient
	admin activityv1.AdminWheelServiceClient
}

func NewGRPCWheelClient(conn *grpc.ClientConn) WheelClient {
	return &grpcWheelClient{
		wheel: activityv1.NewWheelServiceClient(conn),
		admin: activityv1.NewAdminWheelServiceClient(conn),
	}
}

func (c *grpcWheelClient) ExecuteWheelDraw(ctx context.Context, req *activityv1.ExecuteWheelDrawRequest) (*activityv1.ExecuteWheelDrawResponse, error) {
	return c.wheel.ExecuteWheelDraw(ctx, req)
}

func (c *grpcWheelClient) GetWheelConfig(ctx context.Context, req *activityv1.GetWheelConfigRequest) (*activityv1.GetWheelConfigResponse, error) {
	return c.admin.GetWheelConfig(ctx, req)
}

func (c *grpcWheelClient) ListWheelDraws(ctx context.Context, req *activityv1.ListWheelDrawsRequest) (*activityv1.ListWheelDrawsResponse, error) {
	return c.admin.ListWheelDraws(ctx, req)
}
