UNPKG

trade360-nodejs-sdk

Version:
37 lines (36 loc) 1.74 kB
import { ClassConstructor } from 'class-transformer'; import { BaseEntity } from '../entities/message-types'; export declare class TransformerUtil { /** * Deserialize a plain object to an instance of the * specified class. * @param plainObject The plain object to deserialize * @param targetClass The class to instantiate with the * properties set according to the plain object provided * @returns An instance of the specified class, TEntity, * with the properties set according to the plain object * provided */ static transform<TEntity extends BaseEntity>(plainObject: BaseEntity, targetClass: ClassConstructor<TEntity>): TEntity; /** * Deserialize an array of plain objects to an array of * instances of the specified class. * @param plainArray The array of plain objects to * deserialize * @param targetClass The class to instantiate with the * properties set according to the plain objects provided * @returns An array of instances of the specified class, * TEntity, with the properties set according to the plain * objects provided */ static transformArray<TEntity extends BaseEntity>(plainArray: Record<string, unknown>[], targetClass: new () => TEntity): TEntity[]; /** * Serialize an instance to a plain object using the @Expose * decorator names (PascalCase) for API compatibility. * This converts TypeScript objects back to the API format. * @param instance The instance to serialize * @returns A plain object with PascalCase field names as * defined by @Expose decorators */ static serializeToApiFormat<TEntity extends BaseEntity>(instance: TEntity): Record<string, unknown>; }