80 lines
2.4 KiB
JavaScript
80 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Base Partner Service Class
|
|
* Defines the common interface and shared functionality for all partner integrations
|
|
*/
|
|
class BasePartnerService {
|
|
constructor(partnerCode) {
|
|
this.partnerCode = partnerCode;
|
|
}
|
|
|
|
/**
|
|
* Generate job ID for partner system (override in subclass)
|
|
* @param {object} job - Job object
|
|
* @param {string} systemType - System type (optional)
|
|
* @returns {string} Generated job ID
|
|
*/
|
|
generateJobId(job, systemType = null) {
|
|
// Default implementation: use job._id
|
|
return job._id.toString();
|
|
}
|
|
|
|
/**
|
|
* Upload job data to aircraft (must be implemented by subclass)
|
|
* @param {object} assignment - Job assignment with populated job and user data
|
|
* @returns {Promise<object>} Upload result
|
|
*/
|
|
async uploadJobDataToAircraft(assignment) {
|
|
throw new Error('uploadJobDataToAircraft must be implemented by subclass');
|
|
}
|
|
|
|
/**
|
|
* Health check for partner API (must be implemented by subclass)
|
|
* @returns {Promise<object>} Health status
|
|
*/
|
|
async healthCheck() {
|
|
throw new Error('healthCheck must be implemented by subclass');
|
|
}
|
|
|
|
/**
|
|
* Get aircraft list (must be implemented by subclass)
|
|
* @param {string} customerId - Customer ID
|
|
* @returns {Promise<object>} Aircraft list response
|
|
*/
|
|
async getAircraftList(customerId) {
|
|
throw new Error('getAircraftList must be implemented by subclass');
|
|
}
|
|
|
|
/**
|
|
* Get aircraft logs (must be implemented by subclass)
|
|
* @param {string} customerId - Customer ID
|
|
* @param {string} aircraftId - Aircraft ID
|
|
* @returns {Promise<array>} Available logs
|
|
*/
|
|
async getAircraftLogs(customerId, aircraftId) {
|
|
throw new Error('getAircraftLogs must be implemented by subclass');
|
|
}
|
|
|
|
/**
|
|
* Get the storage path for partner log files (must be implemented by subclass)
|
|
* Centralized method for path-agnostic storage management
|
|
* @returns {string} Storage directory path
|
|
*/
|
|
getStoragePath() {
|
|
throw new Error('getStoragePath must be implemented by subclass');
|
|
}
|
|
|
|
/**
|
|
* Resolve full file path from filename (must be implemented by subclass)
|
|
* Used for reconstructing paths from savedLocalFile (filename only)
|
|
* @param {string} filename - Log filename
|
|
* @returns {string} Full file path
|
|
*/
|
|
resolveLogFilePath(filename) {
|
|
throw new Error('resolveLogFilePath must be implemented by subclass');
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = BasePartnerService; |