Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate countryCode in favor of country param for autocomplete #180

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SearchAPI {
near,
limit,
layers,
country,
countryCode,
expandUnits,
mailable,
Expand All @@ -33,6 +34,11 @@ class SearchAPI {
}
}

// replace countryCode with country
if (countryCode && !country) {
country = countryCode;
}

const response: any = await Http.request({
method: 'GET',
path: 'search/autocomplete',
Expand All @@ -41,7 +47,7 @@ class SearchAPI {
near,
limit,
layers,
countryCode,
country,
expandUnits,
mailable,
},
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ export interface RadarAutocompleteParams {
near?: Location | string;
limit?: number;
layers?: RadarGeocodeLayer[];
country?: string;
/** @deprecated use country */
countryCode?: string;
/** @deprecated this is always true, regardless of the value passed here */
expandUnits?: boolean;
Expand Down Expand Up @@ -535,10 +537,13 @@ export interface RadarAutocompleteUIOptions {
container: string | HTMLElement;
near?: string | Location; // bias for location results
debounceMS?: number, // Debounce time in milliseconds
threshold?: number, // DEPRECATED(use minCharacters instead)
/** deprecated use minCharacters */
threshold?: number,
minCharacters?: number, // Minimum number of characters to trigger autocomplete
limit?: number, // Maximum number of autocomplete results
layers?: RadarGeocodeLayer[];
country?: string;
/** @deprecated use country */
countryCode?: string;
expandUnits?: boolean;
mailable?: boolean;
Expand Down
8 changes: 6 additions & 2 deletions src/ui/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ class AutocompleteUI {
}

public async fetchResults(query: string) {
const { limit, layers, countryCode, expandUnits, mailable, onRequest } = this.config;
let { limit, layers, country, countryCode, expandUnits, mailable, onRequest } = this.config;

if (countryCode && !country) {
country = countryCode;
}

const params: RadarAutocompleteParams = {
query,
limit,
layers,
countryCode,
country,
expandUnits,
mailable,
}
Expand Down
Loading