import { baseClient } from './base.js';

export const qrcodesApi = {
  list(workspaceId) {
    return baseClient.get(`/workspaces/${workspaceId}/qrcodes`);
  },

  create(workspaceId, data) {
    return baseClient.post(`/workspaces/${workspaceId}/qrcodes`, data);
  },

  get(workspaceId, id) {
    return baseClient.get(`/workspaces/${workspaceId}/qrcodes/${id}`);
  },

  update(workspaceId, id, data) {
    return baseClient.put(`/workspaces/${workspaceId}/qrcodes/${id}`, data);
  },

  delete(workspaceId, id) {
    return baseClient.delete(`/workspaces/${workspaceId}/qrcodes/${id}`);
  },

  getPreview(workspaceId, id) {
    return baseClient.get(`/workspaces/${workspaceId}/qrcodes/${id}/preview`);
  },

  getExportUrl(workspaceId, id, format = 'png', size = 512) {
    return `${baseClient.getBaseUrl()}/workspaces/${workspaceId}/qrcodes/${id}/export?format=${format}&size=${size}`;
  },

  getAnalytics(workspaceId, qrCodeId, period = '7d') {
    return baseClient.get(`/workspaces/${workspaceId}/qrcodes/${qrCodeId}/analytics?period=${period}`);
  },
};
