/** * 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 { EngineListSchemaVariable, EngineSchemaVariable, } from '../_models'; export const getSearchSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineListSchemaVariable => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => ({ encrypt: 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, ]), })), undefined, ]), next: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), ...overrideResponse, }); export const getCreateSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineSchemaVariable => ({ encrypt: 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, ]), ...overrideResponse, }); export const getDeleteSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineSchemaVariable => ({ encrypt: 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, ]), ...overrideResponse, }); export const getReadSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineSchemaVariable => ({ encrypt: 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, ]), ...overrideResponse, }); export const getPatchSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineSchemaVariable => ({ encrypt: 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, ]), ...overrideResponse, }); export const getUpdateSchemaVariableResponseMock = ( overrideResponse: Partial> = {}, ): EngineSchemaVariable => ({ encrypt: 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, ]), ...overrideResponse, }); export const getSearchSchemaVariableMockHandler = ( overrideResponse?: | EngineListSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineListSchemaVariable), options?: RequestHandlerOptions, ) => { return http.get( '*/routing/schema/variables', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getSearchSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getCreateSchemaVariableMockHandler = ( overrideResponse?: | EngineSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineSchemaVariable), options?: RequestHandlerOptions, ) => { return http.post( '*/routing/schema/variables', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getCreateSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getDeleteSchemaVariableMockHandler = ( overrideResponse?: | EngineSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineSchemaVariable), options?: RequestHandlerOptions, ) => { return http.delete( '*/routing/schema/variables/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getDeleteSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getReadSchemaVariableMockHandler = ( overrideResponse?: | EngineSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineSchemaVariable), options?: RequestHandlerOptions, ) => { return http.get( '*/routing/schema/variables/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getReadSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getPatchSchemaVariableMockHandler = ( overrideResponse?: | EngineSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineSchemaVariable), options?: RequestHandlerOptions, ) => { return http.patch( '*/routing/schema/variables/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getPatchSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getUpdateSchemaVariableMockHandler = ( overrideResponse?: | EngineSchemaVariable | (( info: Parameters[1]>[0], ) => Promise | EngineSchemaVariable), options?: RequestHandlerOptions, ) => { return http.put( '*/routing/schema/variables/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getUpdateSchemaVariableResponseMock(), { status: 200, }, ); }, options, ); }; export const getSchemaVariablesServiceMock = () => [ getSearchSchemaVariableMockHandler(), getCreateSchemaVariableMockHandler(), getDeleteSchemaVariableMockHandler(), getReadSchemaVariableMockHandler(), getPatchSchemaVariableMockHandler(), getUpdateSchemaVariableMockHandler(), ];