// @flow
export const ACCEPT_TYPE: string = 'application/json';

export function buildHeaders(token: string, custom: Object = {}) {
  const headers = new Headers();

  headers.append('Accept', 'application/json');
  headers.append('Authorization', `Bearer ${token}`);

  if (custom) {
    Object.keys(custom).forEach(key => headers.append(key, custom[key]));
  }

  return headers;
}

export function toFormData(data: Object): FormData {
  const formData = new FormData();

  Object.keys(data).forEach(key => formData.append(key, data[key]));

  return formData;
}
