package client

import (
	"context"

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

	"google.golang.org/grpc"
)

// BroadcastClient abstracts gateway access to activity-service IM broadcast membership operations.
type BroadcastClient interface {
	PublishGlobalBroadcast(ctx context.Context, req *activityv1.PublishGlobalBroadcastRequest) (*activityv1.PublishBroadcastResponse, error)
	RemoveRegionBroadcastMember(ctx context.Context, req *activityv1.RemoveRegionBroadcastMemberRequest) (*activityv1.RemoveRegionBroadcastMemberResponse, error)
}

type grpcBroadcastClient struct {
	client activityv1.BroadcastServiceClient
}

// NewGRPCBroadcastClient builds a broadcast client backed by activity-service BroadcastService.
func NewGRPCBroadcastClient(conn *grpc.ClientConn) BroadcastClient {
	return &grpcBroadcastClient{client: activityv1.NewBroadcastServiceClient(conn)}
}

func (c *grpcBroadcastClient) PublishGlobalBroadcast(ctx context.Context, req *activityv1.PublishGlobalBroadcastRequest) (*activityv1.PublishBroadcastResponse, error) {
	return c.client.PublishGlobalBroadcast(ctx, req)
}

func (c *grpcBroadcastClient) RemoveRegionBroadcastMember(ctx context.Context, req *activityv1.RemoveRegionBroadcastMemberRequest) (*activityv1.RemoveRegionBroadcastMemberResponse, error) {
	return c.client.RemoveRegionBroadcastMember(ctx, req)
}
