/** * 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 { ContactsCondition, ContactsConditionList, ContactsLocateConditionResponse, } from '../_models'; export const getDeleteConditionResponseMock = ( overrideResponse: Partial> = {}, ): ContactsCondition => ({ assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getLocateConditionResponseMock = ( overrideResponse: Partial< Extract > = {}, ): ContactsLocateConditionResponse => ({ condition: faker.helpers.arrayElement([ { assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getUpdateCondition2ResponseMock = ( overrideResponse: Partial> = {}, ): ContactsCondition => ({ assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getUpdateConditionResponseMock = ( overrideResponse: Partial> = {}, ): ContactsCondition => ({ assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getListConditionsResponseMock = ( overrideResponse: Partial> = {}, ): ContactsConditionList => ({ items: faker.helpers.arrayElement([ Array.from( { length: faker.number.int({ min: 1, max: 10, }), }, (_, i) => i + 1, ).map(() => ({ assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), })), undefined, ]), next: faker.helpers.arrayElement([ faker.datatype.boolean(), undefined, ]), page: faker.helpers.arrayElement([ faker.number.int(), undefined, ]), ...overrideResponse, }); export const getCreateConditionResponseMock = ( overrideResponse: Partial> = {}, ): ContactsCondition => ({ assignee: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), createdAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), createdBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), expression: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), group: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), id: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedAt: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), updatedBy: 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, ]), type: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20, }, }), undefined, ]), }, undefined, ]), ...overrideResponse, }); export const getDeleteConditionMockHandler = ( overrideResponse?: | ContactsCondition | (( info: Parameters[1]>[0], ) => Promise | ContactsCondition), options?: RequestHandlerOptions, ) => { return http.delete( '*/contacts/groups/conditions/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getDeleteConditionResponseMock(), { status: 200, }, ); }, options, ); }; export const getLocateConditionMockHandler = ( overrideResponse?: | ContactsLocateConditionResponse | (( info: Parameters[1]>[0], ) => | Promise | ContactsLocateConditionResponse), options?: RequestHandlerOptions, ) => { return http.get( '*/contacts/groups/conditions/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getLocateConditionResponseMock(), { status: 200, }, ); }, options, ); }; export const getUpdateCondition2MockHandler = ( overrideResponse?: | ContactsCondition | (( info: Parameters[1]>[0], ) => Promise | ContactsCondition), options?: RequestHandlerOptions, ) => { return http.patch( '*/contacts/groups/conditions/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getUpdateCondition2ResponseMock(), { status: 200, }, ); }, options, ); }; export const getUpdateConditionMockHandler = ( overrideResponse?: | ContactsCondition | (( info: Parameters[1]>[0], ) => Promise | ContactsCondition), options?: RequestHandlerOptions, ) => { return http.put( '*/contacts/groups/conditions/:id', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getUpdateConditionResponseMock(), { status: 200, }, ); }, options, ); }; export const getListConditionsMockHandler = ( overrideResponse?: | ContactsConditionList | (( info: Parameters[1]>[0], ) => Promise | ContactsConditionList), options?: RequestHandlerOptions, ) => { return http.get( '*/contacts/groups/:groupId/conditions', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getListConditionsResponseMock(), { status: 200, }, ); }, options, ); }; export const getCreateConditionMockHandler = ( overrideResponse?: | ContactsCondition | (( info: Parameters[1]>[0], ) => Promise | ContactsCondition), options?: RequestHandlerOptions, ) => { return http.post( '*/contacts/groups/:groupId/conditions', async (info: Parameters[1]>[0]) => { return HttpResponse.json( overrideResponse !== undefined ? typeof overrideResponse === 'function' ? await overrideResponse(info) : overrideResponse : getCreateConditionResponseMock(), { status: 200, }, ); }, options, ); }; export const getDynamicConditionsMock = () => [ getDeleteConditionMockHandler(), getLocateConditionMockHandler(), getUpdateCondition2MockHandler(), getUpdateConditionMockHandler(), getListConditionsMockHandler(), getCreateConditionMockHandler(), ];