import apiClient from "@/lib/axiosClient";
import { API_ENDPOINTS } from "@/lib/apiEndpoints";

export interface SubscribeResponse {
  status: number;
  message: string;
  result: unknown[];
}

/**
 * Toggle subscribe / unsubscribe for a channel.
 * @param toUserId  The user_id of the channel owner (number or string).
 * @param type      User type from subscriber list: 1 = regular user, 2 = creator.
 *                  Pass 1 if unknown.
 */
export const subscribeService = {
  toggle: (toUserId: string | number, type = 1): Promise<SubscribeResponse> =>
    apiClient
      .post(API_ENDPOINTS.ADD_REMOVE_SUBSCRIBE, {
        to_user_id: toUserId,
        type,
      })
      .then((r) => r.data),
};
