//native
type Foxentry = {
apiKey: string;
};
/**
* Validate location data
* This endpoint requires at least 1 query parameter and will check if the parameters and their combinations are valid.
*/
export async function main(
auth: Foxentry,
api_version: string | undefined,
foxentry_include_request_details: string | undefined,
body: {
request: {
customId?: string;
query: {
street?: string;
streetWithNumber?: string;
"number.full"?: string;
"number.part1"?: string;
"number.part1Number"?: string;
"number.part1Letter"?: string;
"number.part2"?: string;
"number.part2Number"?: string;
"number.part2Letter"?: string;
city?: string;
zip?: string;
full?: string;
country?: string;
};
options?: {
dataScope?: "basic" | "full";
dataSource?: string[];
zipFormat?: false | true;
countryFormat?:
| "alpha2"
| "alpha3"
| "local"
| "localShortened"
| "international"
| "internationalShortened";
cityFormat?: "basic" | "minimal" | "extended";
} & { resultsLimit?: number; acceptPostOfficeAsCity?: false | true };
client?: {
ip?: string;
country?: string;
location?: { lat?: number; lon?: number };
};
};
},
) {
const url = new URL(`https://api.foxentry.com/location/validate`);
const headers: Record<string, string> = {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
};
if (api_version) {
headers["api-version"] = api_version;
}
if (foxentry_include_request_details) {
headers["foxentry-include-request-details"] = foxentry_include_request_details;
}
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago