/**
 * 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 { KhovtMasterNhom, KhovtMasterNhomWithRelations, LoopbackCount } from '../../models';

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

export const getKhovtNhomControllerFindByIdResponseMock = (
  overrideResponse: Partial<KhovtMasterNhomWithRelations> = {},
): KhovtMasterNhomWithRelations => ({
  ghiChu: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
  id: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
  maNhom: faker.word.sample(),
  tenNhom: faker.word.sample(),
  ...overrideResponse,
});

export const getKhovtNhomControllerCreateResponseMock = (
  overrideResponse: Partial<KhovtMasterNhom> = {},
): KhovtMasterNhom => ({
  ghiChu: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined]),
  id: faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined }), undefined]),
  maNhom: faker.word.sample(),
  tenNhom: faker.word.sample(),
  ...overrideResponse,
});

export const getKhovtNhomControllerFindResponseMock = (): KhovtMasterNhomWithRelations[] =>
  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]),
    maNhom: faker.word.sample(),
    tenNhom: faker.word.sample(),
  }));

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

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

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

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

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

export const getKhovtNhomControllerFindMockHandler = (
  overrideResponse?:
    | KhovtMasterNhomWithRelations[]
    | ((
        info: Parameters<Parameters<typeof http.get>[1]>[0],
      ) => Promise<KhovtMasterNhomWithRelations[]> | KhovtMasterNhomWithRelations[]),
) => {
  return http.get('*/khovt-master-nhoms', async (info) => {
    await delay(1000);
    return new HttpResponse(
      JSON.stringify(
        overrideResponse !== undefined
          ? typeof overrideResponse === 'function'
            ? await overrideResponse(info)
            : overrideResponse
          : getKhovtNhomControllerFindResponseMock(),
      ),
      {
        status: 200,
        headers: {
          'Content-Type': 'application/json',
        },
      },
    );
  });
};
export const getKhovtNhomControllerMock = () => [
  getKhovtNhomControllerCountMockHandler(),
  getKhovtNhomControllerUpdateByIdMockHandler(),
  getKhovtNhomControllerFindByIdMockHandler(),
  getKhovtNhomControllerDeleteByIdMockHandler(),
  getKhovtNhomControllerCreateMockHandler(),
  getKhovtNhomControllerFindMockHandler(),
];
