-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-usage.ts
More file actions
41 lines (35 loc) · 1.11 KB
/
basic-usage.ts
File metadata and controls
41 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { EcontClient } from "../src";
/**
* Basic usage example
*/
async function main() {
// Initialize the client
const client = new EcontClient({
apiKey: "your-api-key-here",
environment: "demo", // or "production"
});
try {
// Get list of offices
console.log("Fetching offices...");
const offices = await client.offices.list();
console.log(`Found ${offices.length} offices`);
console.log("First office:", offices[0]);
// Get a specific office by code
console.log("\nFetching specific office...");
const office = await client.offices.get("1234");
if (office) {
console.log("Office details:", office);
}
// Get list of cities
console.log("\nFetching cities...");
const cities = await client.offices.getCities({ countryCode: "BGR" });
console.log(`Found ${cities.length} cities in Bulgaria`);
// Get list of countries
console.log("\nFetching countries...");
const countries = await client.offices.getCountries();
console.log(`Found ${countries.length} countries`);
} catch (error) {
console.error("Error:", error);
}
}
main();