UNPKG

@signiant/media-shuttle-sdk

Version:

The SDK for supporting file transfer to and from Media Shuttle

167 lines 7.58 kB
import { RemoteFile, signiant_private } from '@signiant/media-shuttle-sdk-base'; import Credentials from '../../external/common/Credentials'; import { GetFolderContentRequest, Portal, PortalBasicRequest, PortalFile, PortalPermissions } from '../../external'; import { BasicRequestOptions } from '../../external/common/BasicRequestOptions'; export interface GetTransferConfigOptions extends BasicRequestOptions { files: RemoteFile[]; destinationPath?: string; portalId: string; transferDirection?: string; appVersion?: string; clientId?: string; } export interface PlatformServiceConstructorOptions { baseUrl: string; credentials: Credentials; } interface CreateTransferFileResponse { filePath: string; fileSize: number; fileId: string; fileName: string; } export interface CreateTransferResponse { portalId: string; packageId: string; transferId: string; transferConfig: signiant_private.TransferConfig; files: CreateTransferFileResponse[]; } export interface UpdateTransferBody { fileIds: string[]; portalId: string; status?: string; protocol?: string; userAgent?: string; bytesTransferred?: number; bytesRemaining?: number; etaMillis?: number; rateInBytesPerSecond?: number; } export interface UpdateTransferOptions extends BasicRequestOptions { body: UpdateTransferBody; transferId: string; } export interface GetPortalsRequestOptions extends BasicRequestOptions { cursor?: string; pageSize?: number; limitPortalsToMemberRole?: boolean; } interface PlatformArrayResponse<T> { items: T[]; } interface Account { accountId: string; accountName: string; authenticationConfig: { mfaEnabled: boolean; }; } interface Service { serviceInfo: string; accountId: string; serviceId: string; serviceType: string; startsOn: string; effectiveContractDetails: { isExpired: boolean; startsOn: string; }; } interface Role { accountId: string; serviceId: string; role: string; msAccountId?: string; } interface ProfileResponse { accounts: PlatformArrayResponse<Account>; services: PlatformArrayResponse<Service>; roles: PlatformArrayResponse<Role>; } interface ListResponse<T> { items: T[]; nextCursor?: string; } /** * All messages to the platform API service should be filtered through the PlatformService. */ declare class PlatformService { private readonly _baseUrl; private readonly _credentials; constructor({ baseUrl, credentials }: PlatformServiceConstructorOptions); /** * This function creates a transfer in Media Shuttle * @param {GetTransferConfigOptions} - **files** - An array of file objects. Each file object must * have a **path** property and a **size** property. * @returns The response from the API call. */ createTransfer({ files, portalId, transferDirection, accountId, destinationPath, serviceId, appVersion, clientId, }: GetTransferConfigOptions): Promise<CreateTransferResponse>; /** * Fetches the profile information for a given user * @returns {Promise<ProfileResponse>} List of accounts and service basic information */ getProfile(): Promise<ProfileResponse>; /** * Fetch a list of portals. * * @param {GetPortalsRequestOptions} options - GetPortalsRequestOptions * @param {string} options.cursor - Opaque string used to fetch the next page of results * @returns {Promise<ListResponse<Portal>>} A promise that resolves to a ListResponse<Portal> object. */ getPortals({ serviceId, accountId, cursor, pageSize, limitPortalsToMemberRole, }: GetPortalsRequestOptions): Promise<ListResponse<Portal>>; /** * @ignore * It updates a transfer. * @param {UpdateTransferOptions} UpdateTransferOptions the required parameters to update a transfer * @param {string} UpdateTransferOptions.serviceId - **serviceId**: The ID of the Media Shuttle service. * @param {UpdateTransferOptions} UpdateTransferOptions.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {UpdateTransferOptions} UpdateTransferOptions.transferId - **transferId**: The ID of transfer. * @param {UpdateTransferOptions} UpdateTransferOptions.body - **body**: Update transfer REST request body. * @returns The update transfer response. */ updateTransfer({ serviceId, body, transferId, accountId, }: UpdateTransferOptions): Promise<UpdateTransferBody>; /** * @ignore * It gets the contents of a portal folder. * @param {GetFolderContentRequest} - Request Object | Includes all the required parameters in order to perform te getFolderContent request * @param {GetFolderContentRequest} GetFolderContentRequest.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {GetFolderContentRequest} GetFolderContentRequest.portalId - **portalId**: The ID of portal. * @param {GetFolderContentRequest} GetFolderContentRequest.serviceId - **serviceId**: The ID of the MS Service. * @param {GetFolderContentRequest} GetFolderContentRequest.folderId - **folderId**: Folder Identifier. * @param {GetFolderContentRequest} GetFolderContentRequest.browsePath - **browsePath**: path of the subfolder to look for relative to the provided folderId * @returns A list of files/folders in the folder. */ getFolderContent({ accountId, portalId, serviceId, folderId, browsePath, }: GetFolderContentRequest): Promise<ListResponse<PortalFile>>; /** * @ignore * It gets the permissions for a member of a portal. * @param {PortalBasicRequest} requestObject - Request Object | Includes all the required parameters in order to perform te getPortalMemberPermissions request * @param {string} requestObject.accountId - **accountId**: The ID of the Account Containing the MS Service. * @param {string} requestObject.serviceId - **serviceId**: The ID of the MS Service. * @param {string} requestObject.portalId - **portalId**: The ID of portal. * @returns The permissions for the portal member. */ getPortalMemberPermissions({ accountId, serviceId, portalId, }: PortalBasicRequest): Promise<PortalPermissions>; /** * It takes an object with two properties, `accountId` and `serviceId`, and returns a promise that * resolves to an object with four properties, `Authorization`, `Date`, `Signiant-Account-Id`, and * `Signiant-Service-Id`, which are the required headers for most of the Platform requests * @param {Object} headerOptions * @param {string} headerOptions.accountId - `accountId` - The account ID of the account you want to use. * @param {string} headerOptions.serviceId - `serviceId` - The Media Shuttle service ID. * @param {string} headerOptions.appVersion - `appVersion` - Signiant application version * @param {string} headerOptions.clientId - `clientId` - Signiant App Machine identifier * @param {string} headerOptions.apiClientType - `apiClientType` - Indicates the initiator of the API Request * @returns {Promise<PlatformRequestHeaders} a PlatformRequestHeaders object. */ private generateHeaders; /** * Returns the basic required headers to make a Platform request * @param {string} token auth token used for the Authorization header * @returns {object} basic headers */ private getBasicHeaders; } export default PlatformService; //# sourceMappingURL=PlatformService.d.ts.map