import request from 'utils/request';
import axios from 'axios';

const REQUEST_URL = `${process.env.GFW_API}`;
const QUERIES = {
  geostore: '/geostore',
  admin: '/v2/geostore/admin/'
};

export const getGeostoreProvider = (country, region, subRegion) => {
  const url = `${REQUEST_URL}${QUERIES.admin}${country}${
    region ? `/${region}` : ''
  }${subRegion ? `/${subRegion}` : ''}`;
  return request.get(url);
};

export const getGeostoreKey = geojson => {
  const url = REQUEST_URL + QUERIES.geostore;
  return axios({
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    data: {
      geojson
    },
    url
  });
};

export default {
  getGeostoreProvider
};

/*
save: function(geojson) {
      return new Promise(function(resolve, reject) {

        var url = new UriTemplate(URL).fillFromObject({});

        ds.define(SAVE_REQUEST_ID, {
          cache: false,
          url: url,
          type: 'POST',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8'
        });

        var requestConfig = {
          resourceId: SAVE_REQUEST_ID,
          data: JSON.stringify({
            geojson: geojson
          }),
          success: function(response) {
            resolve(response.data.id);
          },
          error: reject
        };

        ds.request(requestConfig);

      });
    },
*/

@@ -688,680 +688,4 @@
 %0A%7D;%0A
-%0A/*%0Asave: function(geojson) %7B%0A      return new Promise(function(resolve, reject) %7B%0A%0A        var url = new UriTemplate(URL).fillFromObject(%7B%7D);%0A%0A        ds.define(SAVE_REQUEST_ID, %7B%0A          cache: false,%0A          url: url,%0A          type: 'POST',%0A          dataType: 'json',%0A          contentType: 'application/json; charset=utf-8'%0A        %7D);%0A%0A        var requestConfig = %7B%0A          resourceId: SAVE_REQUEST_ID,%0A          data: JSON.stringify(%7B%0A            geojson: geojson%0A          %7D),%0A          success: function(response) %7B%0A            resolve(response.data.id);%0A          %7D,%0A          error: reject%0A        %7D;%0A%0A        ds.request(requestConfig);%0A%0A      %7D);%0A    %7D,%0A*/%0A

remove commented code