UNPKG

@coretext-ai/qa-gusto-c0d1e2f3-a4b5-4678-b901-012345678901

Version:
1,968 lines 91.4 kB
import axios from 'axios';
import { Logger } from '../services/logger.js';
export class GustoClient {
    constructor(config) {
        this.config = config;
        // Generate unique session ID for this client instance
        this.sessionId = `gusto-${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: 'gusto-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': 'gusto-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://api.gusto-demo.com/v1';
        // Handle dynamic domain replacement (e.g., YOUR_DOMAIN placeholder)
        if (baseUrl.includes('YOUR_DOMAIN')) {
            const domainEnvVar = `GUSTO_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(`[GUSTO] Resolved base URL: ${baseUrl}`);
        }
        return baseUrl;
    }
    getAuthHeaders() {
        // Bearer/API key authentication
        const token = this.config.authToken || this.config['gUSTOAPITOKEN'] || process.env.GUSTO_API_TOKEN;
        if (token) {
            this.logger.logAuthEvent('bearer_auth_setup', true, {
                authType: 'bearer',
                tokenPreview: token.substring(0, 8) + '...',
                header: 'authorization'
            });
            return {
                'authorization': `Bearer ${token}`
            };
        }
        this.logger.warn('AUTH_WARNING', 'No authentication token found', {
            authType: 'bearer',
            warning: 'API calls may be rate limited',
            checkedSources: ['config.authToken', 'environment variables']
        });
        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 createCompany(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_company',
            method: 'POST',
            path: '/partner_managed_companies',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/partner_managed_companies'.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.name) {
                throw new Error(`Missing required parameter: name`);
            }
            const path = this.buildPath('/partner_managed_companies', 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_company',
                method: 'POST',
                path: '/partner_managed_companies',
                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_company',
                method: 'POST',
                path: '/partner_managed_companies',
                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_company: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getCompany(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_company',
            method: 'GET',
            path: '/companies/{company_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}', 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_company',
                method: 'GET',
                path: '/companies/{company_uuid}',
                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_company',
                method: 'GET',
                path: '/companies/{company_uuid}',
                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_company: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async updateCompany(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'update_company',
            method: 'PUT',
            path: '/companies/{company_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}', pathParams);
            // Use standard HTTP client for other auth types
            const response = await this.httpClient.put(path, remainingParams);
            const duration = Date.now() - startTime;
            this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
                endpoint: 'update_company',
                method: 'PUT',
                path: '/companies/{company_uuid}',
                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_company',
                method: 'PUT',
                path: '/companies/{company_uuid}',
                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_company: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createLocation(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_location',
            method: 'POST',
            path: '/companies/{company_uuid}/locations',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/locations'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.street_1) {
                throw new Error(`Missing required parameter: street_1`);
            }
            if (!params.city) {
                throw new Error(`Missing required parameter: city`);
            }
            if (!params.state) {
                throw new Error(`Missing required parameter: state`);
            }
            if (!params.zip) {
                throw new Error(`Missing required parameter: zip`);
            }
            const path = this.buildPath('/companies/{company_uuid}/locations', 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_location',
                method: 'POST',
                path: '/companies/{company_uuid}/locations',
                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_location',
                method: 'POST',
                path: '/companies/{company_uuid}/locations',
                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_location: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listLocations(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_locations',
            method: 'GET',
            path: '/companies/{company_uuid}/locations',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/locations'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/locations', 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_locations',
                method: 'GET',
                path: '/companies/{company_uuid}/locations',
                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_locations',
                method: 'GET',
                path: '/companies/{company_uuid}/locations',
                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_locations: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createEmployee(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_employee',
            method: 'POST',
            path: '/companies/{company_uuid}/employees',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/employees'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            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`);
            }
            if (!params.work_location_uuid) {
                throw new Error(`Missing required parameter: work_location_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/employees', 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_employee',
                method: 'POST',
                path: '/companies/{company_uuid}/employees',
                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_employee',
                method: 'POST',
                path: '/companies/{company_uuid}/employees',
                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_employee: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getEmployee(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_employee',
            method: 'GET',
            path: '/employees/{employee_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/employees/{employee_uuid}'.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.employee_uuid) {
                throw new Error(`Missing required parameter: employee_uuid`);
            }
            const path = this.buildPath('/employees/{employee_uuid}', 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_employee',
                method: 'GET',
                path: '/employees/{employee_uuid}',
                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_employee',
                method: 'GET',
                path: '/employees/{employee_uuid}',
                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_employee: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async updateEmployee(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'update_employee',
            method: 'PUT',
            path: '/employees/{employee_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/employees/{employee_uuid}'.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.employee_uuid) {
                throw new Error(`Missing required parameter: employee_uuid`);
            }
            const path = this.buildPath('/employees/{employee_uuid}', pathParams);
            // Use standard HTTP client for other auth types
            const response = await this.httpClient.put(path, remainingParams);
            const duration = Date.now() - startTime;
            this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
                endpoint: 'update_employee',
                method: 'PUT',
                path: '/employees/{employee_uuid}',
                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_employee',
                method: 'PUT',
                path: '/employees/{employee_uuid}',
                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_employee: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listEmployees(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_employees',
            method: 'GET',
            path: '/companies/{company_uuid}/employees',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/employees'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/employees', 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_employees',
                method: 'GET',
                path: '/companies/{company_uuid}/employees',
                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_employees',
                method: 'GET',
                path: '/companies/{company_uuid}/employees',
                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_employees: ${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: '/employees/{employee_uuid}/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 = '/employees/{employee_uuid}/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.employee_uuid) {
                throw new Error(`Missing required parameter: employee_uuid`);
            }
            if (!params.title) {
                throw new Error(`Missing required parameter: title`);
            }
            if (!params.hire_date) {
                throw new Error(`Missing required parameter: hire_date`);
            }
            if (!params.location_uuid) {
                throw new Error(`Missing required parameter: location_uuid`);
            }
            if (!params.rate) {
                throw new Error(`Missing required parameter: rate`);
            }
            if (!params.payment_unit) {
                throw new Error(`Missing required parameter: payment_unit`);
            }
            const path = this.buildPath('/employees/{employee_uuid}/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: '/employees/{employee_uuid}/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: '/employees/{employee_uuid}/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 getJob(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_job',
            method: 'GET',
            path: '/jobs/{job_uuid}',
            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/{job_uuid}'.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_uuid) {
                throw new Error(`Missing required parameter: job_uuid`);
            }
            const path = this.buildPath('/jobs/{job_uuid}', 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/{job_uuid}',
                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/{job_uuid}',
                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 updateJob(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'update_job',
            method: 'PUT',
            path: '/jobs/{job_uuid}',
            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/{job_uuid}'.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_uuid) {
                throw new Error(`Missing required parameter: job_uuid`);
            }
            const path = this.buildPath('/jobs/{job_uuid}', pathParams);
            // Use standard HTTP client for other auth types
            const response = await this.httpClient.put(path, remainingParams);
            const duration = Date.now() - startTime;
            this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
                endpoint: 'update_job',
                method: 'PUT',
                path: '/jobs/{job_uuid}',
                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: 'PUT',
                path: '/jobs/{job_uuid}',
                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 listPayrolls(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_payrolls',
            method: 'GET',
            path: '/companies/{company_uuid}/payrolls',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/payrolls'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/payrolls', 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_payrolls',
                method: 'GET',
                path: '/companies/{company_uuid}/payrolls',
                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_payrolls',
                method: 'GET',
                path: '/companies/{company_uuid}/payrolls',
                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_payrolls: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getPayroll(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_payroll',
            method: 'GET',
            path: '/payrolls/{payroll_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/payrolls/{payroll_uuid}'.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.payroll_uuid) {
                throw new Error(`Missing required parameter: payroll_uuid`);
            }
            const path = this.buildPath('/payrolls/{payroll_uuid}', 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_payroll',
                method: 'GET',
                path: '/payrolls/{payroll_uuid}',
                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_payroll',
                method: 'GET',
                path: '/payrolls/{payroll_uuid}',
                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_payroll: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createPayroll(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_payroll',
            method: 'POST',
            path: '/companies/{company_uuid}/payrolls',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/payrolls'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.start_date) {
                throw new Error(`Missing required parameter: start_date`);
            }
            if (!params.end_date) {
                throw new Error(`Missing required parameter: end_date`);
            }
            if (!params.check_date) {
                throw new Error(`Missing required parameter: check_date`);
            }
            const path = this.buildPath('/companies/{company_uuid}/payrolls', 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_payroll',
                method: 'POST',
                path: '/companies/{company_uuid}/payrolls',
                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_payroll',
                method: 'POST',
                path: '/companies/{company_uuid}/payrolls',
                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_payroll: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async submitPayroll(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'submit_payroll',
            method: 'PUT',
            path: '/payrolls/{payroll_uuid}/submit',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/payrolls/{payroll_uuid}/submit'.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.payroll_uuid) {
                throw new Error(`Missing required parameter: payroll_uuid`);
            }
            const path = this.buildPath('/payrolls/{payroll_uuid}/submit', pathParams);
            // Use standard HTTP client for other auth types
            const response = await this.httpClient.put(path, remainingParams);
            const duration = Date.now() - startTime;
            this.logger.info('ENDPOINT_SUCCESS', 'Endpoint execution completed successfully', {
                endpoint: 'submit_payroll',
                method: 'PUT',
                path: '/payrolls/{payroll_uuid}/submit',
                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: 'submit_payroll',
                method: 'PUT',
                path: '/payrolls/{payroll_uuid}/submit',
                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 submit_payroll: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listPaySchedules(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_pay_schedules',
            method: 'GET',
            path: '/companies/{company_uuid}/pay_schedules',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/pay_schedules'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/pay_schedules', 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_pay_schedules',
                method: 'GET',
                path: '/companies/{company_uuid}/pay_schedules',
                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_pay_schedules',
                method: 'GET',
                path: '/companies/{company_uuid}/pay_schedules',
                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_pay_schedules: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createPaySchedule(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_pay_schedule',
            method: 'POST',
            path: '/companies/{company_uuid}/pay_schedules',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/pay_schedules'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.frequency) {
                throw new Error(`Missing required parameter: frequency`);
            }
            if (!params.anchor_pay_date) {
                throw new Error(`Missing required parameter: anchor_pay_date`);
            }
            if (!params.anchor_end_of_pay_period) {
                throw new Error(`Missing required parameter: anchor_end_of_pay_period`);
            }
            const path = this.buildPath('/companies/{company_uuid}/pay_schedules', 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_pay_schedule',
                method: 'POST',
                path: '/companies/{company_uuid}/pay_schedules',
                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_pay_schedule',
                method: 'POST',
                path: '/companies/{company_uuid}/pay_schedules',
                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_pay_schedule: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listContractors(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_contractors',
            method: 'GET',
            path: '/companies/{company_uuid}/contractors',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/contractors'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/contractors', 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_contractors',
                method: 'GET',
                path: '/companies/{company_uuid}/contractors',
                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_contractors',
                method: 'GET',
                path: '/companies/{company_uuid}/contractors',
                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_contractors: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createContractor(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_contractor',
            method: 'POST',
            path: '/companies/{company_uuid}/contractors',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/contractors'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            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`);
            }
            if (!params.start_date) {
                throw new Error(`Missing required parameter: start_date`);
            }
            const path = this.buildPath('/companies/{company_uuid}/contractors', 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_contractor',
                method: 'POST',
                path: '/companies/{company_uuid}/contractors',
                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_contractor',
                method: 'POST',
                path: '/companies/{company_uuid}/contractors',
                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_contractor: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getContractor(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_contractor',
            method: 'GET',
            path: '/contractors/{contractor_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/contractors/{contractor_uuid}'.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.contractor_uuid) {
                throw new Error(`Missing required parameter: contractor_uuid`);
            }
            const path = this.buildPath('/contractors/{contractor_uuid}', 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_contractor',
                method: 'GET',
                path: '/contractors/{contractor_uuid}',
                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_contractor',
                method: 'GET',
                path: '/contractors/{contractor_uuid}',
                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_contractor: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createContractorPayment(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_contractor_payment',
            method: 'POST',
            path: '/companies/{company_uuid}/contractor_payments',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/contractor_payments'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.contractor_uuid) {
                throw new Error(`Missing required parameter: contractor_uuid`);
            }
            if (!params.wage) {
                throw new Error(`Missing required parameter: wage`);
            }
            if (!params.start_date) {
                throw new Error(`Missing required parameter: start_date`);
            }
            if (!params.end_date) {
                throw new Error(`Missing required parameter: end_date`);
            }
            if (!params.payment_date) {
                throw new Error(`Missing required parameter: payment_date`);
            }
            const path = this.buildPath('/companies/{company_uuid}/contractor_payments', 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_contractor_payment',
                method: 'POST',
                path: '/companies/{company_uuid}/contractor_payments',
                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_contractor_payment',
                method: 'POST',
                path: '/companies/{company_uuid}/contractor_payments',
                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_contractor_payment: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getContractorPayment(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_contractor_payment',
            method: 'GET',
            path: '/companies/{company_uuid}/contractor_payments/{contractor_payment_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/contractor_payments/{contractor_payment_uuid}'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.contractor_payment_uuid) {
                throw new Error(`Missing required parameter: contractor_payment_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/contractor_payments/{contractor_payment_uuid}', 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_contractor_payment',
                method: 'GET',
                path: '/companies/{company_uuid}/contractor_payments/{contractor_payment_uuid}',
                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_contractor_payment',
                method: 'GET',
                path: '/companies/{company_uuid}/contractor_payments/{contractor_payment_uuid}',
                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_contractor_payment: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listCompanyBenefits(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_company_benefits',
            method: 'GET',
            path: '/companies/{company_uuid}/company_benefits',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/company_benefits'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/company_benefits', 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_company_benefits',
                method: 'GET',
                path: '/companies/{company_uuid}/company_benefits',
                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_company_benefits',
                method: 'GET',
                path: '/companies/{company_uuid}/company_benefits',
                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_company_benefits: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getCompanyBenefit(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_company_benefit',
            method: 'GET',
            path: '/company_benefits/{company_benefit_uuid}',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/company_benefits/{company_benefit_uuid}'.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.company_benefit_uuid) {
                throw new Error(`Missing required parameter: company_benefit_uuid`);
            }
            const path = this.buildPath('/company_benefits/{company_benefit_uuid}', 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_company_benefit',
                method: 'GET',
                path: '/company_benefits/{company_benefit_uuid}',
                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_company_benefit',
                method: 'GET',
                path: '/company_benefits/{company_benefit_uuid}',
                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_company_benefit: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getCompanyBenefitSummary(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_company_benefit_summary',
            method: 'GET',
            path: '/company_benefits/{company_benefit_uuid}/summary',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/company_benefits/{company_benefit_uuid}/summary'.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.company_benefit_uuid) {
                throw new Error(`Missing required parameter: company_benefit_uuid`);
            }
            const path = this.buildPath('/company_benefits/{company_benefit_uuid}/summary', 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_company_benefit_summary',
                method: 'GET',
                path: '/company_benefits/{company_benefit_uuid}/summary',
                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_company_benefit_summary',
                method: 'GET',
                path: '/company_benefits/{company_benefit_uuid}/summary',
                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_company_benefit_summary: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async createTimeOffPolicy(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'create_time_off_policy',
            method: 'POST',
            path: '/companies/{company_uuid}/time_off_policies',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/time_off_policies'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            if (!params.name) {
                throw new Error(`Missing required parameter: name`);
            }
            if (!params.policy_type) {
                throw new Error(`Missing required parameter: policy_type`);
            }
            const path = this.buildPath('/companies/{company_uuid}/time_off_policies', 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_time_off_policy',
                method: 'POST',
                path: '/companies/{company_uuid}/time_off_policies',
                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_time_off_policy',
                method: 'POST',
                path: '/companies/{company_uuid}/time_off_policies',
                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_time_off_policy: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async listTimeOffPolicies(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'list_time_off_policies',
            method: 'GET',
            path: '/companies/{company_uuid}/time_off_policies',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/companies/{company_uuid}/time_off_policies'.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.company_uuid) {
                throw new Error(`Missing required parameter: company_uuid`);
            }
            const path = this.buildPath('/companies/{company_uuid}/time_off_policies', 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_time_off_policies',
                method: 'GET',
                path: '/companies/{company_uuid}/time_off_policies',
                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_time_off_policies',
                method: 'GET',
                path: '/companies/{company_uuid}/time_off_policies',
                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_time_off_policies: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
    async getCurrentUser(params) {
        const startTime = Date.now();
        this.logger.info('ENDPOINT_START', 'Endpoint execution started', {
            endpoint: 'get_current_user',
            method: 'GET',
            path: '/me',
            paramCount: Object.keys(params || {}).length,
            paramKeys: Object.keys(params || {})
        });
        try {
            // Extract path parameters from URL template and separate from query/body params
            const pathParamNames = '/me'.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];
                }
            });
            const path = this.buildPath('/me', 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_user',
                method: 'GET',
                path: '/me',
                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_user',
                method: 'GET',
                path: '/me',
                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_user: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
}
//# sourceMappingURL=gusto-client.js.map