UNPKG

@microsoft/microsoft-graph-client

Version:
41 lines 1.8 kB
/** * ------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. * See License in the project root for license information. * ------------------------------------------------------------------------------------------- */ /** * @module ChaosHandlerOptions */ import { ChaosStrategy } from "./ChaosStrategy"; /** * Class representing ChaosHandlerOptions * @class * Class * @implements MiddlewareOptions */ export class ChaosHandlerOptions { /** * @public * @constructor * To create an instance of Testing Handler Options * @param {ChaosStrategy} chaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL * @param {string} statusMessage - The Message to be returned in the response * @param {number?} statusCode - The statusCode to be returned in the response * @param {number?} chaosPercentage - The percentage of randomness/chaos in the handler * @param {any?} responseBody - The response body to be returned in the response * @returns An instance of ChaosHandlerOptions */ constructor(chaosStrategy = ChaosStrategy.RANDOM, statusMessage = "Some error Happened", statusCode, chaosPercentage, responseBody, headers) { this.chaosStrategy = chaosStrategy; this.statusCode = statusCode; this.statusMessage = statusMessage; this.chaosPercentage = chaosPercentage !== undefined ? chaosPercentage : 10; this.responseBody = responseBody; this.headers = headers; if (this.chaosPercentage > 100) { throw new Error("Error Pecentage can not be more than 100"); } } } //# sourceMappingURL=ChaosHandlerOptions.js.map