@coretext-ai/qa-greenhouse-b9c0d1e2-f3a4-4567-a890-901234567890
Version:
MCP server with greenhouse integration
2,530 lines • 115 kB
JavaScript
import axios from 'axios';
import { Logger } from '../services/logger.js';
export class GreenhouseClient {
constructor(config) {
this.config = config;
// Generate unique session ID for this client instance
this.sessionId = `greenhouse-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
// Initialize logger (fallback to console if not provided)
this.logger = config.logger || new Logger({
logLevel: 'ERROR',
component: 'client',
enableConsole: true,
enableShipping: false,
serverName: 'greenhouse-mcp-server'
});
this.logger.info('CLIENT_INIT', 'Client instance created', {
baseUrl: this.resolveBaseUrl(),
timeout: this.config.timeout || 30000,
hasRateLimit: !!this.config.rateLimit,
configKeys: Object.keys(config)
});
this.httpClient = axios.create({
baseURL: this.resolveBaseUrl(),
timeout: this.config.timeout || 30000,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'greenhouse-mcp-server/1.0.0',
...this.getAuthHeaders()
},
});
// Add request interceptor for rate limiting
if (this.config.rateLimit) {
this.setupRateLimit(this.config.rateLimit);
}
// Add request interceptor for logging
this.httpClient.interceptors.request.use((config) => {
this.logger.logRequestStart(config.method?.toUpperCase() || 'GET', `${config.baseURL}${config.url}`, {
hasData: !!config.data,
hasParams: !!(config.params && Object.keys(config.params).length > 0),
headers: Object.keys(config.headers || {})
});
if (config.data) {
this.logger.debug('HTTP_REQUEST_BODY', 'Request body data', {
dataType: typeof config.data,
dataSize: JSON.stringify(config.data).length
});
}
if (config.params && Object.keys(config.params).length > 0) {
this.logger.debug('HTTP_REQUEST_PARAMS', 'Query parameters', {
paramCount: Object.keys(config.params).length,
paramKeys: Object.keys(config.params)
});
}
return config;
}, (error) => {
this.logger.error('HTTP_REQUEST_ERROR', 'Request interceptor error', {
error: error.message,
code: error.code
});
return Promise.reject(error);
});
// Add response interceptor for logging and error handling
this.httpClient.interceptors.response.use((response) => {
this.logger.logRequestSuccess(response.config?.method?.toUpperCase() || 'GET', `${response.config?.baseURL}${response.config?.url}`, response.status, 0, // Duration will be calculated in endpoint methods
{
statusText: response.statusText,
responseSize: JSON.stringify(response.data).length,
headers: Object.keys(response.headers || {})
});
return response;
}, (error) => {
this.logger.logRequestError(error.config?.method?.toUpperCase() || 'GET', `${error.config?.baseURL}${error.config?.url}`, error, 0, // Duration will be calculated in endpoint methods
{
hasResponseData: !!error.response?.data
});
throw error;
});
}
setupRateLimit(requestsPerMinute) {
const interval = 60000 / requestsPerMinute; // ms between requests
let lastRequestTime = 0;
this.logger.info('RATE_LIMIT_SETUP', 'Rate limiting configured', {
requestsPerMinute,
intervalMs: interval
});
this.httpClient.interceptors.request.use(async (config) => {
const now = Date.now();
const timeSinceLastRequest = now - lastRequestTime;
if (timeSinceLastRequest < interval) {
const delayMs = interval - timeSinceLastRequest;
this.logger.logRateLimit('HTTP_REQUEST', delayMs, {
timeSinceLastRequest,
requiredInterval: interval
});
await new Promise(resolve => setTimeout(resolve, delayMs));
}
lastRequestTime = Date.now();
return config;
});
}
resolveBaseUrl() {
let baseUrl = 'https://harvest.greenhouse.io/v1';
// Handle dynamic domain replacement (e.g., YOUR_DOMAIN placeholder)
if (baseUrl.includes('YOUR_DOMAIN')) {
const domainEnvVar = `GREENHOUSE_DOMAIN`;
const domain = process.env[domainEnvVar];
if (!domain) {
throw new Error(`Missing domain configuration. Please set ${domainEnvVar} environment variable.`);
}
baseUrl = baseUrl.replace('YOUR_DOMAIN', domain);
console.error(`[GREENHOUSE] Resolved base URL: ${baseUrl}`);
}
return baseUrl;
}
getAuthHeaders() {
// Basic authentication - requires username and password/token
const credential = this.config.authToken || this.config['gREENHOUSEAPIKEY'] || process.env.GREENHOUSE_API_KEY;
const username = process.env.GREENHOUSE_EMAIL || process.env.GREENHOUSE_USERNAME;
if (credential && username) {
const basicAuth = Buffer.from(`${username}:${credential}`).toString('base64');
this.logger.logAuthEvent('basic_auth_setup', true, {
authType: 'basic',
username: username.substring(0, 8) + '...',
hasCredential: !!credential,
header: 'authorization'
});
return {
'authorization': `Basic ${basicAuth}`
};
}
this.logger.logAuthEvent('basic_auth_setup', false, {
authType: 'basic',
requiredEnvVars: ['GREENHOUSE_EMAIL', 'GREENHOUSE_API_KEY']
});
return {};
}
/**
* Initialize the client (for OAuth clients that need initialization)
*/
async initialize() {
this.logger.debug('CLIENT_INITIALIZE', 'No initialization required for this auth type');
}
/**
* Get the session ID for this client instance
*/
getSessionId() {
return this.sessionId;
}
/**
* Make an authenticated request with proper headers
*/
async makeAuthenticatedRequest(config) {
return this.httpClient.request(config);
}
buildPath(template, params) {
let path = template;
for (const [key, value] of Object.entries(params)) {
path = path.replace(`{${key}}`, encodeURIComponent(String(value)));
}
this.logger.debug('PATH_BUILD', 'Built API path from template', {
template,
resultPath: path,
paramCount: Object.keys(params).length,
paramKeys: Object.keys(params)
});
return path;
}
async listApplications(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_applications',
method: 'GET',
path: '/applications',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/applications', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_applications',
method: 'GET',
path: '/applications',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_applications',
method: 'GET',
path: '/applications',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_applications: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_application',
method: 'GET',
path: '/applications/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/applications/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_application',
method: 'GET',
path: '/applications/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_application',
method: 'GET',
path: '/applications/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async createApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'create_application',
method: 'POST',
path: '/applications',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.candidate_id) {
throw new Error(`Missing required parameter: candidate_id`);
}
if (!params.job_id) {
throw new Error(`Missing required parameter: job_id`);
}
const path = this.buildPath('/applications', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'create_application',
method: 'POST',
path: '/applications',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'create_application',
method: 'POST',
path: '/applications',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute create_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async updateApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'update_application',
method: 'PATCH',
path: '/applications/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/applications/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'update_application',
method: 'PATCH',
path: '/applications/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'update_application',
method: 'PATCH',
path: '/applications/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute update_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async moveApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'move_application',
method: 'POST',
path: '/applications/{id}/move',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/move'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
if (!params.from_stage_id) {
throw new Error(`Missing required parameter: from_stage_id`);
}
if (!params.to_stage_id) {
throw new Error(`Missing required parameter: to_stage_id`);
}
const path = this.buildPath('/applications/{id}/move', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'move_application',
method: 'POST',
path: '/applications/{id}/move',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'move_application',
method: 'POST',
path: '/applications/{id}/move',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute move_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async transferApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'transfer_application',
method: 'POST',
path: '/applications/{id}/transfer_to_job',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/transfer_to_job'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
if (!params.new_job_id) {
throw new Error(`Missing required parameter: new_job_id`);
}
const path = this.buildPath('/applications/{id}/transfer_to_job', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'transfer_application',
method: 'POST',
path: '/applications/{id}/transfer_to_job',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'transfer_application',
method: 'POST',
path: '/applications/{id}/transfer_to_job',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute transfer_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async rejectApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'reject_application',
method: 'POST',
path: '/applications/{id}/reject',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/reject'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
if (!params.rejection_reason_id) {
throw new Error(`Missing required parameter: rejection_reason_id`);
}
const path = this.buildPath('/applications/{id}/reject', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'reject_application',
method: 'POST',
path: '/applications/{id}/reject',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'reject_application',
method: 'POST',
path: '/applications/{id}/reject',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute reject_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async hireApplication(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'hire_application',
method: 'POST',
path: '/applications/{id}/hire',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/hire'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/applications/{id}/hire', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'hire_application',
method: 'POST',
path: '/applications/{id}/hire',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'hire_application',
method: 'POST',
path: '/applications/{id}/hire',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute hire_application: ${error instanceof Error ? error.message : String(error)}`);
}
}
async convertProspect(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'convert_prospect',
method: 'PATCH',
path: '/applications/{id}/convert_prospect',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/convert_prospect'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
if (!params.job_id) {
throw new Error(`Missing required parameter: job_id`);
}
const path = this.buildPath('/applications/{id}/convert_prospect', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'convert_prospect',
method: 'PATCH',
path: '/applications/{id}/convert_prospect',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'convert_prospect',
method: 'PATCH',
path: '/applications/{id}/convert_prospect',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute convert_prospect: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listCandidates(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_candidates',
method: 'GET',
path: '/candidates',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/candidates', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_candidates',
method: 'GET',
path: '/candidates',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_candidates',
method: 'GET',
path: '/candidates',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_candidates: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getCandidate(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_candidate',
method: 'GET',
path: '/candidates/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/candidates/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_candidate',
method: 'GET',
path: '/candidates/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_candidate',
method: 'GET',
path: '/candidates/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_candidate: ${error instanceof Error ? error.message : String(error)}`);
}
}
async createCandidate(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'create_candidate',
method: 'POST',
path: '/candidates',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/candidates', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'create_candidate',
method: 'POST',
path: '/candidates',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'create_candidate',
method: 'POST',
path: '/candidates',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute create_candidate: ${error instanceof Error ? error.message : String(error)}`);
}
}
async updateCandidate(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'update_candidate',
method: 'PATCH',
path: '/candidates/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/candidates/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'update_candidate',
method: 'PATCH',
path: '/candidates/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'update_candidate',
method: 'PATCH',
path: '/candidates/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute update_candidate: ${error instanceof Error ? error.message : String(error)}`);
}
}
async deleteCandidate(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'delete_candidate',
method: 'DELETE',
path: '/candidates/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/candidates/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.delete(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'delete_candidate',
method: 'DELETE',
path: '/candidates/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'delete_candidate',
method: 'DELETE',
path: '/candidates/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute delete_candidate: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listJobs(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_jobs',
method: 'GET',
path: '/jobs',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/jobs'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/jobs', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_jobs',
method: 'GET',
path: '/jobs',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_jobs',
method: 'GET',
path: '/jobs',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_jobs: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getJob(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_job',
method: 'GET',
path: '/jobs/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/jobs/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/jobs/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_job',
method: 'GET',
path: '/jobs/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_job',
method: 'GET',
path: '/jobs/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_job: ${error instanceof Error ? error.message : String(error)}`);
}
}
async createJob(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'create_job',
method: 'POST',
path: '/jobs',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/jobs'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.job_name) {
throw new Error(`Missing required parameter: job_name`);
}
const path = this.buildPath('/jobs', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'create_job',
method: 'POST',
path: '/jobs',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'create_job',
method: 'POST',
path: '/jobs',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute create_job: ${error instanceof Error ? error.message : String(error)}`);
}
}
async updateJob(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'update_job',
method: 'PATCH',
path: '/jobs/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/jobs/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/jobs/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'update_job',
method: 'PATCH',
path: '/jobs/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'update_job',
method: 'PATCH',
path: '/jobs/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute update_job: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getJobPost(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_job_post',
method: 'GET',
path: '/jobs/{id}/job_post',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/jobs/{id}/job_post'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/jobs/{id}/job_post', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_job_post',
method: 'GET',
path: '/jobs/{id}/job_post',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_job_post',
method: 'GET',
path: '/jobs/{id}/job_post',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_job_post: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listJobStages(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_job_stages',
method: 'GET',
path: '/job_stages',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/job_stages'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/job_stages', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_job_stages',
method: 'GET',
path: '/job_stages',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_job_stages',
method: 'GET',
path: '/job_stages',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_job_stages: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getJobStage(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_job_stage',
method: 'GET',
path: '/job_stages/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/job_stages/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/job_stages/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_job_stage',
method: 'GET',
path: '/job_stages/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_job_stage',
method: 'GET',
path: '/job_stages/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_job_stage: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listScheduledInterviews(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_scheduled_interviews',
method: 'GET',
path: '/scheduled_interviews',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scheduled_interviews'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/scheduled_interviews', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_scheduled_interviews',
method: 'GET',
path: '/scheduled_interviews',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_scheduled_interviews',
method: 'GET',
path: '/scheduled_interviews',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_scheduled_interviews: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getScheduledInterview(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_scheduled_interview',
method: 'GET',
path: '/scheduled_interviews/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scheduled_interviews/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/scheduled_interviews/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_scheduled_interview',
method: 'GET',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_scheduled_interview',
method: 'GET',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_scheduled_interview: ${error instanceof Error ? error.message : String(error)}`);
}
}
async createScheduledInterview(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'create_scheduled_interview',
method: 'POST',
path: '/scheduled_interviews',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scheduled_interviews'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.application_id) {
throw new Error(`Missing required parameter: application_id`);
}
if (!params.interview_id) {
throw new Error(`Missing required parameter: interview_id`);
}
if (!params.start) {
throw new Error(`Missing required parameter: start`);
}
if (!params.end) {
throw new Error(`Missing required parameter: end`);
}
const path = this.buildPath('/scheduled_interviews', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'create_scheduled_interview',
method: 'POST',
path: '/scheduled_interviews',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'create_scheduled_interview',
method: 'POST',
path: '/scheduled_interviews',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute create_scheduled_interview: ${error instanceof Error ? error.message : String(error)}`);
}
}
async updateScheduledInterview(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'update_scheduled_interview',
method: 'PATCH',
path: '/scheduled_interviews/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scheduled_interviews/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/scheduled_interviews/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'update_scheduled_interview',
method: 'PATCH',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'update_scheduled_interview',
method: 'PATCH',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute update_scheduled_interview: ${error instanceof Error ? error.message : String(error)}`);
}
}
async deleteScheduledInterview(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'delete_scheduled_interview',
method: 'DELETE',
path: '/scheduled_interviews/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scheduled_interviews/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/scheduled_interviews/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.delete(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'delete_scheduled_interview',
method: 'DELETE',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'delete_scheduled_interview',
method: 'DELETE',
path: '/scheduled_interviews/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute delete_scheduled_interview: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getApplicationInterviews(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_application_interviews',
method: 'GET',
path: '/applications/{id}/scheduled_interviews',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{id}/scheduled_interviews'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/applications/{id}/scheduled_interviews', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_application_interviews',
method: 'GET',
path: '/applications/{id}/scheduled_interviews',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_application_interviews',
method: 'GET',
path: '/applications/{id}/scheduled_interviews',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_application_interviews: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listOffers(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_offers',
method: 'GET',
path: '/offers',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/offers'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/offers', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_offers',
method: 'GET',
path: '/offers',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_offers',
method: 'GET',
path: '/offers',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_offers: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getOffer(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_offer',
method: 'GET',
path: '/offers/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/offers/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/offers/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_offer',
method: 'GET',
path: '/offers/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_offer',
method: 'GET',
path: '/offers/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_offer: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getCurrentOffer(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_current_offer',
method: 'GET',
path: '/applications/{application_id}/offers/current_offer',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/applications/{application_id}/offers/current_offer'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.application_id) {
throw new Error(`Missing required parameter: application_id`);
}
const path = this.buildPath('/applications/{application_id}/offers/current_offer', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_current_offer',
method: 'GET',
path: '/applications/{application_id}/offers/current_offer',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_current_offer',
method: 'GET',
path: '/applications/{application_id}/offers/current_offer',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_current_offer: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listScorecards(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_scorecards',
method: 'GET',
path: '/scorecards',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scorecards'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/scorecards', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_scorecards',
method: 'GET',
path: '/scorecards',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_scorecards',
method: 'GET',
path: '/scorecards',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_scorecards: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getScorecard(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_scorecard',
method: 'GET',
path: '/scorecards/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/scorecards/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/scorecards/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_scorecard',
method: 'GET',
path: '/scorecards/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_scorecard',
method: 'GET',
path: '/scorecards/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_scorecard: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listUsers(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_users',
method: 'GET',
path: '/users',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/users'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/users', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_users',
method: 'GET',
path: '/users',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_users',
method: 'GET',
path: '/users',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_users: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getUser(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_user',
method: 'GET',
path: '/users/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/users/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/users/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_user',
method: 'GET',
path: '/users/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_user',
method: 'GET',
path: '/users/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_user: ${error instanceof Error ? error.message : String(error)}`);
}
}
async createUser(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'create_user',
method: 'POST',
path: '/users',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/users'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.first_name) {
throw new Error(`Missing required parameter: first_name`);
}
if (!params.last_name) {
throw new Error(`Missing required parameter: last_name`);
}
if (!params.email) {
throw new Error(`Missing required parameter: email`);
}
const path = this.buildPath('/users', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.post(path, remainingParams);
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'create_user',
method: 'POST',
path: '/users',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'create_user',
method: 'POST',
path: '/users',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute create_user: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listDepartments(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_departments',
method: 'GET',
path: '/departments',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/departments'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/departments', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_departments',
method: 'GET',
path: '/departments',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_departments',
method: 'GET',
path: '/departments',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_departments: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getDepartment(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_department',
method: 'GET',
path: '/departments/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/departments/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/departments/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_department',
method: 'GET',
path: '/departments/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_department',
method: 'GET',
path: '/departments/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_department: ${error instanceof Error ? error.message : String(error)}`);
}
}
async listOffices(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'list_offices',
method: 'GET',
path: '/offices',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/offices'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
const path = this.buildPath('/offices', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'list_offices',
method: 'GET',
path: '/offices',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'list_offices',
method: 'GET',
path: '/offices',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute list_offices: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getOffice(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_office',
method: 'GET',
path: '/offices/{id}',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/offices/{id}'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/offices/{id}', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_office',
method: 'GET',
path: '/offices/{id}',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_office',
method: 'GET',
path: '/offices/{id}',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_office: ${error instanceof Error ? error.message : String(error)}`);
}
}
async getActivityFeed(params) {
const startTime = Date.now();
this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
endpoint: 'get_activity_feed',
method: 'GET',
path: '/candidates/{id}/activity_feed',
paramCount: Object.keys(params || {}).length,
paramKeys: Object.keys(params || {})
});
try {
// Extract path parameters from URL template and separate from query/body params
const pathParamNames = '/candidates/{id}/activity_feed'.match(/{([^}]+)}/g) || [];
const pathParams = {};
const remainingParams = { ...params };
// Extract path parameters
pathParamNames.forEach(paramTemplate => {
const paramName = paramTemplate.slice(1, -1); // Remove { }
if (params[paramName] !== undefined) {
pathParams[paramName] = params[paramName];
delete remainingParams[paramName];
}
});
// Validate required parameters
if (!params.id) {
throw new Error(`Missing required parameter: id`);
}
const path = this.buildPath('/candidates/{id}/activity_feed', pathParams);
// Use standard HTTP client for other auth types
const response = await this.httpClient.get(path, { params: remainingParams });
const duration = Date.now() - startTime;
this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
endpoint: 'get_activity_feed',
method: 'GET',
path: '/candidates/{id}/activity_feed',
duration_ms: duration,
responseDataSize: JSON.stringify(response.data).length
});
return {
content: [
{
type: 'text',
text: JSON.stringify(response.data, null, 2)
}
]
};
}
catch (error) {
const duration = Date.now() - startTime;
this.logger.error('ENDPOINT_ERROR', 'Endpoint execution failed', {
endpoint: 'get_activity_feed',
method: 'GET',
path: '/candidates/{id}/activity_feed',
duration_ms: duration,
error: error instanceof Error ? error.message : String(error),
errorType: error instanceof Error ? error.constructor.name : 'unknown'
});
throw new Error(`Failed to execute get_activity_feed: ${error instanceof Error ? error.message : String(error)}`);
}
}
}
//# sourceMappingURL=greenhouse-client.js.map