<commit_before>export default class ApiClient {
  private baseUrl;
  private headers;

  constructor(baseUrl = "") {
    this.baseUrl = baseUrl;
    this.headers = {};
  }

  async _fetch(route, method, body) {
    if (!route) throw new Error("Route is undefined");

    const fullRoute = `${this.baseUrl}${route}`;

    const opts = {
      method,
      headers: Object.assign(this.headers),
    };
    if (body) {
      opts.body = JSON.stringify(body);
    }
    return fetch(fullRoute, opts);
  }

  GET(route) { return this._fetch(route, "GET", null); }

  POST(route, body) { return this._fetch(route, "POST", body); }

  PUT(route, body) { return this._fetch(route, "PUT", body); }

  PATCH(route, body) { return this._fetch(route, "PATCH", body); }

  DELETE(route) { return this._fetch(route, "DELETE", null); }

  saveLayout = (id, layout) => {
    const strippedLayout = layout.map(widget => ({ ...widget, moved: undefined }));
    return this.POST(`/dashboard/${id}`, strippedLayout);
  }

  createWidget = type => this.POST(`/widget?type=${type}`, null)

  getWidgetHtml = id => this.GET(`/widget/${id}`)

  deleteWidget = id => this.DELETE(`/widget/${id}`)

  getEditFormHtml = async id => {
    const html = await this.GET(`/widget/${id}/edit`);
    return html.text();
  }

  saveWidget = (url, params) => this.PUT(`${url}?${params}`, null)
}<commit_msg>Change save layout api call to use PUT<commit_after>export default class ApiClient {
  private baseUrl;
  private headers;

  constructor(baseUrl = "") {
    this.baseUrl = baseUrl;
    this.headers = {};
  }

  async _fetch(route, method, body) {
    if (!route) throw new Error("Route is undefined");

    const fullRoute = `${this.baseUrl}${route}`;

    const opts = {
      method,
      headers: Object.assign(this.headers),
    };
    if (body) {
      opts.body = JSON.stringify(body);
    }
    return fetch(fullRoute, opts);
  }

  GET(route) { return this._fetch(route, "GET", null); }

  POST(route, body) { return this._fetch(route, "POST", body); }

  PUT(route, body) { return this._fetch(route, "PUT", body); }

  PATCH(route, body) { return this._fetch(route, "PATCH", body); }

  DELETE(route) { return this._fetch(route, "DELETE", null); }

  saveLayout = (id, layout) => {
    const strippedLayout = layout.map(widget => ({ ...widget, moved: undefined }));
    return this.PUT(`/dashboard/${id}`, strippedLayout);
  }

  createWidget = type => this.POST(`/widget?type=${type}`, null)

  getWidgetHtml = id => this.GET(`/widget/${id}`)

  deleteWidget = id => this.DELETE(`/widget/${id}`)

  getEditFormHtml = async id => {
    const html = await this.GET(`/widget/${id}/edit`);
    return html.text();
  }

  saveWidget = (url, params) => this.PUT(`${url}?${params}`, null)
}
{'fraction_non_alphanumeric': 0.1829356471438901, 'fraction_numerical': 0.0, 'mean_word_length': 3.4629032258064516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1003819', 'n_tokens_mistral': 919, 'n_tokens_neox': 899, 'n_words': 211}