UNPKG

fsm-sdk

Version:

Node.JS sdk to interface with SAP Field Service Management APIs.

227 lines (226 loc) 10.9 kB
import { ClientConfig } from '../client-config.model'; import { HttpService } from '../http/http-service'; import { OAuthService } from '../oauth/oauth.service'; import { ActivityBulkAPI } from './activity-bulk-api.service'; import { Activity, UdfValue, UnifiedIdentifier } from './service-management.model'; export declare class ActivityAPI { private _config; private _http; private _auth; bulk: ActivityBulkAPI; constructor(_config: Readonly<ClientConfig>, _http: Readonly<HttpService>, _auth: Readonly<OAuthService>); /** * Constructs the API URL for activity bulk operations. * * @param {string} path - Path to append to the base URL. * @returns {string} The complete API URL. * @see https://api.sap.com/api/service_management_ext/resource/Activity_Business_Actions */ getApiUrl(path?: string): string; /** * Cancels an activity by its ID. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional cancellation parameters. * @param {boolean} options.cancelServiceCallConfirmed - Whether service call cancellation is confirmed. * @param {string} options.cancellationReason - Reason for cancellation. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the cancelled activity. */ cancel(id: string, // also support code=$ or externalId=$, options?: Partial<{ cancelServiceCallConfirmed: boolean; cancellationReason: string; udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Closes an activity by its ID. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional closing parameters. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the closed activity. */ close(id: string, // also support code=$ or externalId=$, options?: Partial<{ udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Duplicates an activity by its ID. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional duplication parameters. * @param {string} options.crew - Crew identifier. * @param {string[]} options.responsibles - Array of responsible person identifiers. * @param {string} options.startDateTime - Start date and time in ISO 8601 format. * @param {string} options.unit - Unit identifier. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the duplicated activity. */ duplicate(id: string, // also support code=$ or externalId=$, options?: Partial<{ crew: string; responsibles: string[]; startDateTime: string; unit: string; udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Plans an activity by its ID. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional planning parameters. * @param {string} options.crew - Crew identifier. * @param {UnifiedIdentifier} options.technician - Technician identifier. * @param {string} options.startDateTime - Start date and time in ISO 8601 format. * @param {boolean} options.startDateTimeFixed - Whether start date/time is fixed. * @param {number} options.plannedDurationInMinutes - Planned duration in minutes. * @param {number} options.travelTimeFromInMinutes - Travel time from in minutes. * @param {number} options.travelTimeToInMinutes - Travel time to in minutes. * @param {string} options.endDateTime - End date and time in ISO 8601 format. * @param {boolean} options.endDateTimeFixed - Whether end date/time is fixed. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the planned activity. */ plan(id: string, // also support code=$ or externalId=$, options?: Partial<{ crew: string; technician: UnifiedIdentifier; startDateTime: string; startDateTimeFixed: boolean; plannedDurationInMinutes: number; travelTimeFromInMinutes: number; travelTimeToInMinutes: number; endDateTime: string; endDateTimeFixed: boolean; udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Releases an activity by its ID. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional release parameters. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the released activity. */ release(id: string, // also support code=$ or externalId=$, options?: Partial<{ udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Replans an activity to a different technician. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional replanning parameters. * @param {string} options.crew - Crew identifier. * @param {UnifiedIdentifier} options.technician - New technician identifier. * @param {string} options.startDateTime - New start date and time in ISO 8601 format. * @param {boolean} options.startDateTimeFixed - Whether start date/time is fixed. * @param {number} options.plannedDurationInMinutes - Planned duration in minutes. * @param {number} options.travelTimeFromInMinutes - Travel time from in minutes. * @param {number} options.travelTimeToInMinutes - Travel time to in minutes. * @param {string} options.endDateTime - End date and time in ISO 8601 format. * @param {boolean} options.endDateTimeFixed - Whether end date/time is fixed. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the replanned activity. */ replan(id: string, // also support code=$ or externalId=$, options?: Partial<{ crew: string; technician: UnifiedIdentifier; startDateTime: string; startDateTimeFixed: boolean; plannedDurationInMinutes: number; travelTimeFromInMinutes: number; travelTimeToInMinutes: number; endDateTime: string; endDateTimeFixed: boolean; udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; /** * Reschedules an activity to a different time slot and/or technician. * * @param {string} id - Activity ID (also supports code=$ or externalId=$ format). * @param {object} options - Optional rescheduling parameters. * @param {string} options.crew - Crew identifier. * @param {UnifiedIdentifier} options.technician - New technician identifier. * @param {string} options.startDateTime - New start date and time in ISO 8601 format. * @param {boolean} options.startDateTimeFixed - Whether start date/time is fixed. * @param {number} options.plannedDurationInMinutes - Planned duration in minutes. * @param {number} options.travelTimeFromInMinutes - Travel time from in minutes. * @param {number} options.travelTimeToInMinutes - Travel time to in minutes. * @param {string} options.endDateTime - End date and time in ISO 8601 format. * @param {boolean} options.endDateTimeFixed - Whether end date/time is fixed. * @param {UdfValue[]} options.udfValues - User-defined field values. * @param {object} params - Optional query parameters. * @param {string} params.fieldsMode - Fields mode: 'INCLUDE', 'EXCLUDE', or 'ADD'. * @param {string[]} params.fields - Fields to include/exclude/add. * @returns {Promise<{ activity: Activity }>} A promise resolving to the rescheduled activity. */ reschedule(id: string, // also support code=$ or externalId=$, options?: Partial<{ crew: string; technician: UnifiedIdentifier; startDateTime: string; startDateTimeFixed: boolean; plannedDurationInMinutes: number; travelTimeFromInMinutes: number; travelTimeToInMinutes: number; endDateTime: string; endDateTimeFixed: boolean; udfValues: UdfValue[]; }>, params?: Partial<{ fieldsMode: 'INCLUDE' | 'EXCLUDE' | 'ADD'; fields: string[]; }>): Promise<{ activity: Activity; }>; }