Commit 432dc205 authored by Matija Obreza's avatar Matija Obreza
Browse files

Sensible code updates from Catalog

parent 8acf6508
import * as UrlTemplate from 'url-template';
import * as QueryString from 'query-string';
import { axiosBackend } from 'utilities/requestUtils';
import Country from 'model/geo/Country';
import CountryDetails from 'model/geo/CountryDetails';
import GeoRegion from 'model/geo/GeoRegion';
import RegionDetails from 'model/geo/RegionDetails';
import VocabularyTerm from 'model/vocabulary/VocabularyTerm';
const URL_LIST_COUNTRIES = `/api/v1/geo/countries`;
......@@ -12,6 +14,7 @@ const URL_GET_COUNTRY_DETAILS = UrlTemplate.parse(`/api/v1/geo/country/details/{
const URL_GET_GEO_REGIONS = `/api/v1/geo/regions`;
const URL_GET_GEO_REGION = UrlTemplate.parse(`/api/v1/geo/region/details/{isoCode}`);
const URL_AUTOCOMPLETE_GEO_TERM = `/api/v0/geo/iso3166/autocomplete`;
const URL_GET = UrlTemplate.parse(`/api/v0/geo/iso3166/{code}`);
const URL_GET_COUNTRY = UrlTemplate.parse(`/api/v1/geo/country/{iso3code}`);
......@@ -87,6 +90,27 @@ class GeoService {
}).then(({ data }) => data as RegionDetails);
}
/**
* autocompleteGeoTerm at /api/v0/geo/iso3166/autocomplete
*
* @param c code
*/
public static autocompleteGeoTerm(c: string): Promise<VocabularyTerm[]> {
const qs = QueryString.stringify({
c: c || undefined,
}, {});
const apiUrl = URL_AUTOCOMPLETE_GEO_TERM + (qs ? `?${qs}` : '');
// console.log(`Fetching from ${apiUrl}`);
const content = {/* No content in request body */};
return axiosBackend.request({
url: apiUrl,
method: 'GET',
...content,
}).then(({data}) => data as VocabularyTerm[]);
}
/**
* get at /api/v0/geo/iso3166/{code}
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment