package threads_account

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"
)

type DisconnectThreadsApiLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDisconnectThreadsApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisconnectThreadsApiLogic {
	return &DisconnectThreadsApiLogic{ctx: ctx, svcCtx: svcCtx}
}

func (l *DisconnectThreadsApiLogic) DisconnectThreadsApi(req *types.ThreadsAccountPath) (*types.ThreadsAccountData, error) {
	tenantID, uid, err := actorFrom(l.ctx)
	if err != nil {
		return nil, err
	}
	item, err := l.svcCtx.ThreadsAccount.DisconnectThreadsAPI(l.ctx, tenantID, uid, req.ID)
	if err != nil {
		return nil, err
	}
	out := toThreadsAccountData(*item)
	return &out, nil
}
