Skip to content

Latest commit

 

History

History
303 lines (224 loc) · 9.82 KB

transformation.md

File metadata and controls

303 lines (224 loc) · 9.82 KB

Transformation

const transformationController = new TransformationController(client);

Class Name

TransformationController

Methods

Transform Via File

Transform an API into any of the supported API specification formats by uploading the API specification file.

This endpoint transforms and then uploads the transformed API specification to APIMatic's cloud storage. An ID for the transformation performed is returned as part of the response.

async transformViaFile(
  file: FileWrapper,
  exportFormat: ExportFormats,
  requestOptions?: RequestOptions
): Promise<ApiResponse<Transformation>>

Parameters

Parameter Type Tags Description
file FileWrapper Form, Required The API specification file.
The type of the specification file should be any of the supported formats.
exportFormat ExportFormats Form, Required The structure contains API specification formats that Transformer can convert to.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

Transformation

Example Usage

const contentType = null;
const file = new FileWrapper(fs.createReadStream('dummy_file'));
const exportFormat = 'WSDL';
try {
  const { result, ...httpResponse } = await transformationController.transformViaFile(file, exportFormat);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Transform Via URL

Transform an API into any of the supported API specification formats by providing the URL of the API specification file.

This endpoint transforms and then uploads the transformed API specification to APIMatic's cloud storage. An ID for the transformation performed is returned as part of the response.

async transformViaURL(
  body: TransformViaUrlRequest,
  requestOptions?: RequestOptions
): Promise<ApiResponse<Transformation>>

Parameters

Parameter Type Tags Description
body TransformViaUrlRequest Body, Required Request Body
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

Transformation

Example Usage

const contentType = null;
const body: TransformViaUrlRequest = {
  url: 'https://petstore.swagger.io/v2/swagger.json',
  exportFormat: 'APIMATIC',
};

try {
  const { result, ...httpResponse } = await transformationController.transformViaURL(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Download Transformed File

Download the transformed API specification file transformed via the Transformation endpoints.

async downloadTransformedFile(
  transformationId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<NodeJS.ReadableStream | Blob>>

Parameters

Parameter Type Tags Description
transformationId string Template, Required The ID of transformation received in the response of the Transform Via File or Transform Via URL calls.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

NodeJS.ReadableStream | Blob

Example Usage

const transformationId = 'transformation_id6';
try {
  const { result, ...httpResponse } = await transformationController.downloadTransformedFile(transformationId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Download Input File

Download the API Specification file used as input for a particular Transformation performed via the Transformation endpoints.

async downloadInputFile(
  transformationId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<NodeJS.ReadableStream | Blob>>

Parameters

Parameter Type Tags Description
transformationId string Template, Required The ID of the transformation to download the API specification for. The transformation ID is received in the response of the Transform Via File or Transform Via URL calls.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

NodeJS.ReadableStream | Blob

Example Usage

const transformationId = 'transformation_id6';
try {
  const { result, ...httpResponse } = await transformationController.downloadInputFile(transformationId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

List All Transformations

Get a list of all API transformations performed.

async listAllTransformations(
  requestOptions?: RequestOptions
): Promise<ApiResponse<Transformation[]>>

Parameters

Parameter Type Tags Description
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

Transformation[]

Example Usage

try {
  const { result, ...httpResponse } = await transformationController.listAllTransformations();
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get a Transformation

Get details on a particular Transformation performed via the Transformation endpoints.

async getATransformation(
  transformationId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<Transformation>>

Parameters

Parameter Type Tags Description
transformationId string Template, Required The ID of the transformation to fetch. The transformation ID is received in the response of the Transform Via File or Transform Via URL calls.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

Transformation

Example Usage

const transformationId = 'transformation_id6';
try {
  const { result, ...httpResponse } = await transformationController.getATransformation(transformationId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Delete Transformation

Delete a particular Transformation performed for an API via the Transformation endpoints.

async deleteTransformation(
  transformationId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<void>>

Parameters

Parameter Type Tags Description
transformationId string Template, Required The ID of the transformation to delete. The transformation ID is received in the response of the Transform Via File or Transform Via URL calls.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

void

Example Usage

const transformationId = 'transformation_id6';
try {
  const { result, ...httpResponse } = await transformationController.deleteTransformation(transformationId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}