package client

import (
	"context"

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

// MessageInboxClient abstracts gateway access to the backend-owned system/activity inbox.
type MessageInboxClient interface {
	ListMessageTabs(ctx context.Context, req *activityv1.ListMessageTabsRequest) (*activityv1.ListMessageTabsResponse, error)
	ListInboxMessages(ctx context.Context, req *activityv1.ListInboxMessagesRequest) (*activityv1.ListInboxMessagesResponse, error)
	MarkInboxMessageRead(ctx context.Context, req *activityv1.MarkInboxMessageReadRequest) (*activityv1.MarkInboxMessageReadResponse, error)
	MarkInboxSectionRead(ctx context.Context, req *activityv1.MarkInboxSectionReadRequest) (*activityv1.MarkInboxSectionReadResponse, error)
	DeleteInboxMessage(ctx context.Context, req *activityv1.DeleteInboxMessageRequest) (*activityv1.DeleteInboxMessageResponse, error)
}

type grpcMessageInboxClient struct {
	client activityv1.MessageInboxServiceClient
}

// NewGRPCMessageInboxClient builds an inbox client backed by activity-service MessageInboxService.
func NewGRPCMessageInboxClient(conn *grpc.ClientConn) MessageInboxClient {
	return &grpcMessageInboxClient{client: activityv1.NewMessageInboxServiceClient(conn)}
}

func (c *grpcMessageInboxClient) ListMessageTabs(ctx context.Context, req *activityv1.ListMessageTabsRequest) (*activityv1.ListMessageTabsResponse, error) {
	return c.client.ListMessageTabs(ctx, req)
}

func (c *grpcMessageInboxClient) ListInboxMessages(ctx context.Context, req *activityv1.ListInboxMessagesRequest) (*activityv1.ListInboxMessagesResponse, error) {
	return c.client.ListInboxMessages(ctx, req)
}

func (c *grpcMessageInboxClient) MarkInboxMessageRead(ctx context.Context, req *activityv1.MarkInboxMessageReadRequest) (*activityv1.MarkInboxMessageReadResponse, error) {
	return c.client.MarkInboxMessageRead(ctx, req)
}

func (c *grpcMessageInboxClient) MarkInboxSectionRead(ctx context.Context, req *activityv1.MarkInboxSectionReadRequest) (*activityv1.MarkInboxSectionReadResponse, error) {
	return c.client.MarkInboxSectionRead(ctx, req)
}

func (c *grpcMessageInboxClient) DeleteInboxMessage(ctx context.Context, req *activityv1.DeleteInboxMessageRequest) (*activityv1.DeleteInboxMessageResponse, error) {
	return c.client.DeleteInboxMessage(ctx, req)
}
