import { Client } from "@larksuiteoapi/node-sdk";
import { config } from "./config.js";
export class LarkClient {
client;
constructor() {
this.client = new Client({
appId: config.appId,
appSecret: config.appSecret,
disableTokenCache: false // Enable SDK's automatic token management
});
}
// Get user information by employee ID
async getUserInfo(employeeId) {
try {
const response = await this.client.contact.v3.user.get({
path: {
user_id: employeeId,
},
params: {
user_id_type: 'user_id', // Using open_id as the lookup type
department_id_type: 'open_department_id',
}
});
return response.data;
}
catch (error) {
console.error('Error fetching user info:', error);
throw error;
}
}
// This method will be used to get the client instance
getClient() {
return this.client;
}
}