1 | |
2 | type Foxentry = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Get company data |
7 | * Foxentry allows you to get information about company based on the dataScope option. Country and registrationNumber parameters are required. |
8 | */ |
9 | export async function main( |
10 | auth: Foxentry, |
11 | api_version: string | undefined, |
12 | foxentry_include_request_details: string | undefined, |
13 | body: { |
14 | request: { |
15 | customId?: string; |
16 | query: { country: string; registrationNumber: string }; |
17 | options?: { |
18 | dataScope?: "basic" | "extended" | "full"; |
19 | dataSource?: string[]; |
20 | includeTerminatedSubjects?: false | true; |
21 | zipFormat?: false | true; |
22 | cityFormat?: "basic" | "extended" | "minimal"; |
23 | countryFormat?: |
24 | | "alpha2" |
25 | | "alpha3" |
26 | | "local" |
27 | | "localShortened" |
28 | | "international" |
29 | | "internationalShortened"; |
30 | legalFormType?: "juridical" | "physical" | "any"; |
31 | }; |
32 | client?: { |
33 | ip?: string; |
34 | country?: string; |
35 | location?: { lat?: number; lon?: number }; |
36 | }; |
37 | }; |
38 | }, |
39 | ) { |
40 | const url = new URL(`https://api.foxentry.com/company/get`); |
41 |
|
42 | const headers: Record<string, string> = { |
43 | "Content-Type": "application/json", |
44 | Authorization: "Bearer " + auth.apiKey, |
45 | }; |
46 |
|
47 | if (api_version) { |
48 | headers["api-version"] = api_version; |
49 | } |
50 | if (foxentry_include_request_details) { |
51 | headers["foxentry-include-request-details"] = foxentry_include_request_details; |
52 | } |
53 |
|
54 | const response = await fetch(url, { |
55 | method: "POST", |
56 | headers, |
57 | body: JSON.stringify(body), |
58 | }); |
59 | if (!response.ok) { |
60 | const text = await response.text(); |
61 | throw new Error(`${response.status} ${text}`); |
62 | } |
63 | return await response.json(); |
64 | } |
65 |
|