//native
type Foxentry = {
apiKey: string;
};
/**
* Search company
* This enpoint mainly serves as autocomplete but can be used to search for specific companies based on filter criteria as well. Foxentry will automatically offer you suggestions to complete the company you are writing down. Pay attention to the client section in the request body. You can specify the user's location in order to receive more relevant suggestions.
*/
export async function main(
auth: Foxentry,
api_version: string | undefined,
foxentry_include_request_details: string | undefined,
body: {
request: {
customId?: string;
query: {
type: "name" | "registrationNumber" | "taxNumber" | "vatNumber";
value: string;
filter?: {
name?: string;
country?: string;
registrationNumber?: string;
taxNumber?: string;
vatNumber?: string;
};
};
options?: {
dataScope?: "basic" | "extended" | "full";
dataSource?: string[];
includeTerminatedSubjects?: false | true;
zipFormat?: false | true;
cityFormat?: "basic" | "extended" | "minimal";
countryFormat?:
| "alpha2"
| "alpha3"
| "local"
| "localShortened"
| "international"
| "internationalShortened";
legalFormType?: "juridical" | "physical" | "any";
} & {
resultsLimit?: number;
filterMode?: "limit" | "prefer";
filterAcceptFormat?: false | true;
filterAcceptAlternatives?: false | true;
filterExactMatch?: false | true;
};
client?: {
ip?: string;
country?: string;
location?: { lat?: number; lon?: number };
};
};
},
) {
const url = new URL(`https://api.foxentry.com/company/search`);
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