import { z } from 'zod';
import { type OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
import {
	DebtReminderPolicyCreateBodySchema,
	DebtReminderPolicyUpdateBodySchema,
	DebtReminderPolicyResponseSchema,
	DebtReminderPolicyListResponseSchema,
} from '#contracts/debt-reminder-policy/schema';
import { ApiResponseSchema, QueryParamsSchema } from '#contracts/shared';

export function registerDebtReminderPolicyPaths(registry: OpenAPIRegistry): void {
	registry.registerPath({
		method: 'get',
		path: '/api/v1/debt-reminder-policies',
		operationId: 'getDebtReminderPolicies',
		tags: ['Debt Reminder Policies'],
		summary: 'Get debt reminder policies',
		security: [{ BearerAuth: [] }],
		request: { query: QueryParamsSchema },
		responses: {
			200: { description: 'OK', content: { 'application/json': { schema: DebtReminderPolicyListResponseSchema } } },
			401: { description: 'Unauthorized' },
			403: { description: 'Forbidden' },
		},
	});

	registry.registerPath({
		method: 'post',
		path: '/api/v1/debt-reminder-policies',
		operationId: 'createDebtReminderPolicy',
		tags: ['Debt Reminder Policies'],
		summary: 'Create a debt reminder policy',
		security: [{ BearerAuth: [] }],
		request: {
			body: { required: true, content: { 'application/json': { schema: DebtReminderPolicyCreateBodySchema } } },
		},
		responses: {
			200: { description: 'Created', content: { 'application/json': { schema: DebtReminderPolicyResponseSchema } } },
			400: { description: 'Bad Request' },
			401: { description: 'Unauthorized' },
			403: { description: 'Forbidden' },
		},
	});

	registry.registerPath({
		method: 'get',
		path: '/api/v1/debt-reminder-policies/{id}',
		operationId: 'getDebtReminderPolicyById',
		tags: ['Debt Reminder Policies'],
		summary: 'Get debt reminder policy detail',
		security: [{ BearerAuth: [] }],
		request: { params: z.object({ id: z.string().uuid() }) },
		responses: {
			200: { description: 'OK', content: { 'application/json': { schema: DebtReminderPolicyResponseSchema } } },
			401: { description: 'Unauthorized' },
			403: { description: 'Forbidden' },
			404: { description: 'Not Found' },
		},
	});

	registry.registerPath({
		method: 'put',
		path: '/api/v1/debt-reminder-policies/{id}',
		operationId: 'updateDebtReminderPolicy',
		tags: ['Debt Reminder Policies'],
		summary: 'Update a debt reminder policy',
		security: [{ BearerAuth: [] }],
		request: {
			params: z.object({ id: z.string().uuid() }),
			body: { content: { 'application/json': { schema: DebtReminderPolicyUpdateBodySchema } } },
		},
		responses: {
			200: { description: 'Updated', content: { 'application/json': { schema: DebtReminderPolicyResponseSchema } } },
			400: { description: 'Bad Request' },
			401: { description: 'Unauthorized' },
			403: { description: 'Forbidden' },
			404: { description: 'Not Found' },
		},
	});

	registry.registerPath({
		method: 'delete',
		path: '/api/v1/debt-reminder-policies/{id}',
		operationId: 'deleteDebtReminderPolicy',
		tags: ['Debt Reminder Policies'],
		summary: 'Delete a debt reminder policy',
		security: [{ BearerAuth: [] }],
		request: { params: z.object({ id: z.string().uuid() }) },
		responses: {
			200: {
				description: 'Deleted',
				content: { 'application/json': { schema: ApiResponseSchema(z.null()) } },
			},
			401: { description: 'Unauthorized' },
			403: { description: 'Forbidden' },
			404: { description: 'Not Found' },
		},
	});
}
