/** * Generated by orval v8.19.0 🍺 * Do not edit manually. * Webitel API * OpenAPI spec version: 24.04.0 */ import { faker } from '@faker-js/faker'; import type { RequestHandlerOptions } from 'msw'; import { HttpResponse, http } from 'msw'; import type { EngineChatPlan, EngineListChatPlan } from '../_models'; export const getSearchChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineListChatPlan => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), })), undefined, ]), next: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), ...overrideResponse, }); export const getCreateChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineChatPlan => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getDeleteChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineChatPlan => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getReadChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineChatPlan => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getPatchChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineChatPlan => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getUpdateChatPlanResponseMock = ( overrideResponse: Partial> = {}, ): EngineChatPlan => ({ description: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), enabled: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), id: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), schema: faker.helpers.arrayElement([ { id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), name: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getSearchChatPlanMockHandler = ( overrideResponse?: | EngineListChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineListChatPlan), options?: RequestHandlerOptions, ) => { return http.get( '*/routing/outbound/chat', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getSearchChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getCreateChatPlanMockHandler = ( overrideResponse?: | EngineChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineChatPlan), options?: RequestHandlerOptions, ) => { return http.post( '*/routing/outbound/chat', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getCreateChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getDeleteChatPlanMockHandler = ( overrideResponse?: | EngineChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineChatPlan), options?: RequestHandlerOptions, ) => { return http.delete( '*/routing/outbound/chat/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getDeleteChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getReadChatPlanMockHandler = ( overrideResponse?: | EngineChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineChatPlan), options?: RequestHandlerOptions, ) => { return http.get( '*/routing/outbound/chat/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getReadChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getPatchChatPlanMockHandler = ( overrideResponse?: | EngineChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineChatPlan), options?: RequestHandlerOptions, ) => { return http.patch( '*/routing/outbound/chat/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getPatchChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getUpdateChatPlanMockHandler = ( overrideResponse?: | EngineChatPlan | (( info: Parameters[1]>[0], ) => Promise | EngineChatPlan), options?: RequestHandlerOptions, ) => { return http.put( '*/routing/outbound/chat/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getUpdateChatPlanResponseMock(), { status: 200, }, ); }, options, ); }; export const getRoutingChatPlanServiceMock = () => [ getSearchChatPlanMockHandler(), getCreateChatPlanMockHandler(), getDeleteChatPlanMockHandler(), getReadChatPlanMockHandler(), getPatchChatPlanMockHandler(), getUpdateChatPlanMockHandler(), ];