UNPKG

fsm-sdk

Version:

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

127 lines (126 loc) 5.18 kB
import { ClientConfig } from './core/client-config.model'; import { OAuthTokenResponse } from './core/oauth/oauth-token-response.model'; import { AccountAPIService } from './core/account/account-api.service'; import { TranslationApiService } from './core/translations/translations-api.service'; import { ServiceManagementAPIService } from './core/service-management/service-management.service'; import { DataServiceAPIService } from './core/data-service/data-service.service'; import { RulesAPIService } from './core/rules/rules-api.service'; export declare class CoreAPIClient { private _auth; private _serviceManagementApi; private _accountApi; private _translationApi; private _rulesApi; private _dataServiceAPI; private _config_default; private _config; /** * The CoreAPIClient * * ```typescript *{ * // [mandatory] your client configuration * clientIdentifier: '<your-clientIdentifier>', * clientSecret: '<your-clientSecret>', * clientVersion: '<your-clientVersion>', * * // [optional] oauth grant type, default=password * authGrantType: 'password' | 'client_credentials' | undefined * * // [optional] | [mandatory] if oauth grant type password * authAccountName: '<your-authAccountName>', * * // [optional] | [mandatory] if oauth grant type password * authUserName: '<your-authUserName>', * * // [optional] | [mandatory] if oauth grant type password * authPassword: '<your-authPassword>', * * // [optional] or default=FIRST * authCompany: '<your-authCompany>', * * // [optional] provide verbose logs * debug: false, * * // [optional] enable using custom oauth endpoints see https://api.sap.com/api/cloud_authentication_service_ext/overview * oauthEndpoint: 'https://eu.fsm.cloud.sap/api/oauth2/v2', * * // [optional] client will cache token (helpful for writing integration tests) * tokenCacheFilePath: './.myToken.json' * *} * ``` * @param _config ClientConfig * @returns CoreAPIClient */ constructor(config: Partial<ClientConfig>); /** * @param o { legacyFormat: boolean } * @description Creates a UUID string. * If `legacyFormat` is true, it returns the UUID without dashes and in uppercase. used by FSM legacy data-cloud APIs APIs. * If `legacyFormat` is false, it returns the UUID in its standard format. * @returns string */ static createUUID(o?: { legacyFormat: boolean; } | undefined): string; /** * Provides access to the Service Management API for managing service calls and activities. * * @returns {ServiceManagementAPIService} Service management API instance with activity, service call, and composite operations. */ get serviceManagementAPI(): ServiceManagementAPIService; /** * Provides access to the legacy Data Service API (Data Cloud). * * @returns {DataServiceAPIService} Data service API instance for legacy data cloud operations. */ get dataServiceAPI(): DataServiceAPIService; /** * Provides access to the Account API for retrieving account and company information. * * @returns {AccountAPIService} Account API instance for account and company operations. */ get accountAPI(): AccountAPIService; /** * Provides access to the Translation API for managing labels and translations. * * @returns {TranslationApiService} Translation API instance for label and value operations. */ get translationAPI(): TranslationApiService; /** * Provides access to the Rules API for managing business rules. * * @returns {RulesAPIService} Rules API instance for business rule operations. */ get rulesAPI(): RulesAPIService; /** * Executes a login using the current client configuration and retrieves an OAuth token. * * Note: Explicit login is not required before other actions; the client will auto-login and refresh tokens as needed. * * @returns {Promise<OAuthTokenResponse>} Resolves with the OAuth token response. */ login(): Promise<OAuthTokenResponse>; /** * Retrieves the current OAuth token, if available. * * @returns {Readonly<OAuthTokenResponse> | undefined} The current OAuth token or undefined if not logged in. */ getToken(): Readonly<OAuthTokenResponse> | undefined; /** * Sets the OAuth token to be used by the client. * * @param {OAuthTokenResponse} token - The OAuth token to set. * @returns {CoreAPIClient} The current client instance for chaining. */ setToken(token: OAuthTokenResponse): CoreAPIClient; /** * Sets the company to use for authentication, if the token contains multiple companies. * * @param {string} companyName - The name of the company to set for authentication. * @throws {Error} If no token is found, or if the company is not available in the token. * @returns {CoreAPIClient} The current client instance for chaining. */ setAuthCompany(companyName: string): CoreAPIClient; }