/*****************************************************************************
* Corpora                                                                    *
* Fetch requests for /corpora routes                                         *
*****************************************************************************/
Requests.corpora = {};

Requests.corpora.entity = {};

Requests.corpora.entity.delete = (corpusId) => {
  let input = `/corpora/${corpusId}`;
  let init = {
    method: 'DELETE'
  };
  return Requests.JSONfetch(input, init);
};

Requests.corpora.entity.build = (corpusId) => {
  let input = `/corpora/${corpusId}/build`;
  let init = {
    method: 'POST',
  };
  return Requests.JSONfetch(input, init);
};

Requests.corpora.entity.generateShareLink = (corpusId, role, expiration) => {
  let input = `/corpora/${corpusId}/generate-corpus-share-link`;
  let init = {
    method: 'POST',
    body: JSON.stringify({role: role, expiration: expiration})
  };
  return Requests.JSONfetch(input, init);
};

Requests.corpora.entity.isPublic = {};

Requests.corpora.entity.isPublic.update = (corpusId, isPublic) => {
  let input = `/corpora/${corpusId}/is_public`;
  let init = {
    method: 'PUT',
    body: JSON.stringify(isPublic)
  };
  return Requests.JSONfetch(input, init);
};



