// src/api/TagTypeApi.js
export default class TagTypeApi {
  constructor(token) {
    this.baseUrl = 'https://inventory-bff.dream-views.com/api/v1/TagType';
    this.token = token;
  }

  headers(json = true) {
    return {
      accept: 'application/json',
      ...(json ? { 'Content-Type': 'application/json' } : {}),
      ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
    };
  }

  async getAll() {
    const res = await fetch(`${this.baseUrl}/GetAll`, {
      method: 'GET',
      headers: this.headers(false),
    });
    if (!res.ok) {
      throw new Error(`TagType.GetAll ${res.status}: ${await res.text()}`);
    }
    return res.json();
  }
}
