/** * 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 { StorageDeleteFileTranscriptResponse, StorageListPhrases, StoragePutFileTranscriptResponse, StorageStartFileTranscriptResponse, } from '../_models'; export const getDeleteFileTranscriptResponseMock = ( overrideResponse: Partial< Extract > = {}, ): StorageDeleteFileTranscriptResponse => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => faker.string.alpha({ length: { min: 10, max: 20, }, }), ), undefined, ]), ...overrideResponse, }); export const getCreateFileTranscriptResponseMock = ( overrideResponse: Partial< Extract > = {}, ): StorageStartFileTranscriptResponse => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => ({ action: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), fileId: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), state: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), })), undefined, ]), ...overrideResponse, }); export const getPutFileTranscriptResponseMock = ( overrideResponse: Partial< Extract > = {}, ): StoragePutFileTranscriptResponse => ({ id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), ...overrideResponse, }); export const getGetFileTranscriptPhrasesResponseMock = ( overrideResponse: Partial> = {}, ): StorageListPhrases => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => ({ channel: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), endSec: faker.helpers.arrayElement([ faker.number.float({ fractionDigits: 2, }), undefined, ]), phrase: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), startSec: faker.helpers.arrayElement([ faker.number.float({ fractionDigits: 2, }), undefined, ]), })), undefined, ]), next: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), ...overrideResponse, }); export const getDeleteFileTranscriptMockHandler = ( overrideResponse?: | StorageDeleteFileTranscriptResponse | (( info: Parameters[1]>[0], ) => | Promise | StorageDeleteFileTranscriptResponse), options?: RequestHandlerOptions, ) => { return http.delete( '*/storage/transcript_file', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getDeleteFileTranscriptResponseMock(), { status: 200, }, ); }, options, ); }; export const getCreateFileTranscriptMockHandler = ( overrideResponse?: | StorageStartFileTranscriptResponse | (( info: Parameters[1]>[0], ) => | Promise | StorageStartFileTranscriptResponse), options?: RequestHandlerOptions, ) => { return http.post( '*/storage/transcript_file', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getCreateFileTranscriptResponseMock(), { status: 200, }, ); }, options, ); }; export const getPutFileTranscriptMockHandler = ( overrideResponse?: | StoragePutFileTranscriptResponse | (( info: Parameters[1]>[0], ) => | Promise | StoragePutFileTranscriptResponse), options?: RequestHandlerOptions, ) => { return http.put( '*/storage/transcript_file', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getPutFileTranscriptResponseMock(), { status: 200, }, ); }, options, ); }; export const getGetFileTranscriptPhrasesMockHandler = ( overrideResponse?: | StorageListPhrases | (( info: Parameters[1]>[0], ) => Promise | StorageListPhrases), options?: RequestHandlerOptions, ) => { return http.get( '*/storage/transcript_file/:id/phrases', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getGetFileTranscriptPhrasesResponseMock(), { status: 200, }, ); }, options, ); }; export const getFileTranscriptServiceMock = () => [ getDeleteFileTranscriptMockHandler(), getCreateFileTranscriptMockHandler(), getPutFileTranscriptMockHandler(), getGetFileTranscriptPhrasesMockHandler(), ];