<commit_before>class CollectionsService {
  /**
   * Retrieve all collections of the user
   * @param {*} token User's token
   */
  static getAllCollections(token) {
    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection`, {
        method: 'GET',
        headers: {
          Authorization: token
        }
      })
        .then((response) => {
          const { status, statusText } = response;
          if (status === 200) return response.json();

          const errorObject = {
            errors: {
              status,
              details: statusText
            }
          };
          throw errorObject;
        })
        .then(data => resolve(data))
        .catch(errors => reject(errors));
    });
  }

  /**
   * Retrieve data of a specific collection
   * @param {*} token User's token
   * @param {*} collectionId Id of the collection we are asking for.
   */
  static getCollection(token, collectionId) {
    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection/${collectionId}`, {
        method: 'GET',
        headers: {
          Authorization: token
        }
      })
        .then((response) => {
          const { status, statusText } = response;
          if (status === 200) return response.json();

          const errorObject = {
            errors: {
              status,
              details: statusText
            }
          };
          throw errorObject;
        })
        .then(data => resolve(data))
        .catch(errors => reject(errors));
    });
  }

  /**
   * Creates a new collection attached to the current user
   * @param {*} token User's token
   * @param {*} name Name of the new collection
   * @param {*} resources List of resources attached to the new collection (optional)
   */
  static createCollection(token, name, resources = []) {
    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection`, {<commit_msg>Updates collection service with application filter<commit_after>import * as queryString from 'query-string';

class CollectionsService {
  /**
   * Retrieve all collections of the user
   * @param {*} token User's token
   */
  static getAllCollections(token) {
    const queryParams = queryString.stringify({
      application: process.env.APPLICATIONS
    });

    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection?${queryParams}`, {
        method: 'GET',
        headers: {
          Authorization: token
        }
      })
        .then((response) => {
          const { status, statusText } = response;
          if (status === 200) return response.json();

          const errorObject = {
            errors: {
              status,
              details: statusText
            }
          };
          throw errorObject;
        })
        .then(data => resolve(data))
        .catch(errors => reject(errors));
    });
  }

  /**
   * Retrieve data of a specific collection
   * @param {*} token User's token
   * @param {*} collectionId Id of the collection we are asking for.
   */
  static getCollection(token, collectionId) {
    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection/${collectionId}`, {
        method: 'GET',
        headers: {
          Authorization: token
        }
      })
        .then((response) => {
          const { status, statusText } = response;
          if (status === 200) return response.json();

          const errorObject = {
            errors: {
              status,
              details: statusText
            }
          };
          throw errorObject;
        })
        .then(data => resolve(data))
        .catch(errors => reject(errors));
    });
  }

  /**
   * Creates a new collection attached to the current user
   * @param {*} token User's token
   * @param {*} name Name of the new collection
   * @param {*} resources List of resources attached to the new collection (optional)
   */
  static createCollection(token, name, resources = []) {
    const queryParams = queryString.stringify({
      application: process.env.APPLICATIONS
    });

    return new Promise((resolve, reject) => {
      fetch(`${process.env.RW_API_URL}/collection?${queryParams}`, {
{'fraction_non_alphanumeric': 0.1263672329532232, 'fraction_numerical': 0.0027926460321154294, 'mean_word_length': 2.014025245441795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1777898', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1125, 'n_words': 302}