/**
 * Generated by orval v6.31.0 🍺
 * Do not edit manually.
 * pkh-api
 * pkh api
 * OpenAPI spec version: 0.0.1
 */
import { faker } from '@faker-js/faker';
import { HttpResponse, delay, http } from 'msw';
import type { KhovtMasterKho, KhovtMasterKhoWithRelations, LoopbackCount } from '../../models';

export const getKhovtMasterKhoControllerCountResponseMock = (
  overrideResponse: Partial<LoopbackCount> = {},
): LoopbackCount => ({
  count: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
  ...overrideResponse,
});

export const getKhovtMasterKhoControllerFindByIdResponseMock = (
  overrideResponse: Partial<KhovtMasterKhoWithRelations> = {},
): KhovtMasterKhoWithRelations => ({
  ghiChu: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
  id: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
  maKho: faker.word.sample(),
  tenKho: faker.word.sample(),
  ...overrideResponse,
});

export const getKhovtMasterKhoControllerCreateResponseMock = (
  overrideResponse: Partial<KhovtMasterKho> = {},
): KhovtMasterKho => ({
  ghiChu: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
  id: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
  maKho: faker.word.sample(),
  tenKho: faker.word.sample(),
  ...overrideResponse,
});

export const getKhovtMasterKhoControllerFindResponseMock = (): KhovtMasterKhoWithRelations[] =>
  Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
    ghiChu: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
    id: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
    maKho: faker.word.sample(),
    tenKho: faker.word.sample(),
  }));

export const getKhovtMasterKhoControllerCountMockHandler = (
  overrideResponse?:
    | LoopbackCount
    | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<LoopbackCount> | LoopbackCount),
) => {
  return http.get('*/khovt-master-khos/count', async (info) => {
    await delay(1000);
    return new HttpResponse(
      JSON.stringify(
        overrideResponse !== undefined
          ? typeof overrideResponse === 'function'
            ? await overrideResponse(info)
            : overrideResponse
          : getKhovtMasterKhoControllerCountResponseMock(),
      ),
      {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      },
    );
  });
};

export const getKhovtMasterKhoControllerUpdateByIdMockHandler = () => {
  return http.patch('*/khovt-master-khos/:id', async () => {
    await delay(1000);
    return new HttpResponse(null, {
      status: 204,
      headers: {
        'Content-Type': 'application/json',
      },
    });
  });
};

export const getKhovtMasterKhoControllerFindByIdMockHandler = (
  overrideResponse?:
    | KhovtMasterKhoWithRelations
    | ((
        info: Parameters<Parameters<typeof http.get>[1]>[0],
      ) => Promise<KhovtMasterKhoWithRelations> | KhovtMasterKhoWithRelations),
) => {
  return http.get('*/khovt-master-khos/:id', async (info) => {
    await delay(1000);
    return new HttpResponse(
      JSON.stringify(
        overrideResponse !== undefined
          ? typeof overrideResponse === 'function'
            ? await overrideResponse(info)
            : overrideResponse
          : getKhovtMasterKhoControllerFindByIdResponseMock(),
      ),
      {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      },
    );
  });
};

export const getKhovtMasterKhoControllerDeleteByIdMockHandler = () => {
  return http.delete('*/khovt-master-khos/:id', async () => {
    await delay(1000);
    return new HttpResponse(null, {
      status: 204,
      headers: {
        'Content-Type': 'application/json',
      },
    });
  });
};

export const getKhovtMasterKhoControllerCreateMockHandler = (
  overrideResponse?:
    | KhovtMasterKho
    | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<KhovtMasterKho> | KhovtMasterKho),
) => {
  return http.post('*/khovt-master-khos', async (info) => {
    await delay(1000);
    return new HttpResponse(
      JSON.stringify(
        overrideResponse !== undefined
          ? typeof overrideResponse === 'function'
            ? await overrideResponse(info)
            : overrideResponse
          : getKhovtMasterKhoControllerCreateResponseMock(),
      ),
      {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      },
    );
  });
};

export const getKhovtMasterKhoControllerFindMockHandler = (
  overrideResponse?:
    | KhovtMasterKhoWithRelations[]
    | ((
        info: Parameters<Parameters<typeof http.get>[1]>[0],
      ) => Promise<KhovtMasterKhoWithRelations[]> | KhovtMasterKhoWithRelations[]),
) => {
  return http.get('*/khovt-master-khos', async (info) => {
    await delay(1000);
    return new HttpResponse(
      JSON.stringify(
        overrideResponse !== undefined
          ? typeof overrideResponse === 'function'
            ? await overrideResponse(info)
            : overrideResponse
          : getKhovtMasterKhoControllerFindResponseMock(),
      ),
      {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      },
    );
  });
};
export const getKhovtMasterKhoControllerMock = () => [
  getKhovtMasterKhoControllerCountMockHandler(),
  getKhovtMasterKhoControllerUpdateByIdMockHandler(),
  getKhovtMasterKhoControllerFindByIdMockHandler(),
  getKhovtMasterKhoControllerDeleteByIdMockHandler(),
  getKhovtMasterKhoControllerCreateMockHandler(),
  getKhovtMasterKhoControllerFindMockHandler(),
];
