/**
 * Interface of the server (auto-generated code)
 */
import {
	HTTPMimeType,
	HTTPRequestModel,
	RESTConfig,
	RESTRequestJson,
} from "../rest-tools";

import { z as zod } from "zod"
import {
	Long,
	UserKarusic,
	UserMe,
	ZodUserKarusic,
	isUserKarusic,
	isUserMe,
} from "../model";

export namespace UserResource {

	export function get({
			restConfig,
			params,
		}: {
		restConfig: RESTConfig,
		params: {
			id: Long,
		},
	}): Promise<UserKarusic> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/users/{id}",
				requestType: HTTPRequestModel.GET,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
			params,
		}, isUserKarusic);
	};
	export function getMe({
			restConfig,
		}: {
		restConfig: RESTConfig,
	}): Promise<UserMe> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/users/me",
				requestType: HTTPRequestModel.GET,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
		}, isUserMe);
	};

	export const ZodGetsTypeReturn = zod.array(ZodUserKarusic);
	export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
	
	export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
		try {
			ZodGetsTypeReturn.parse(data);
			return true;
		} catch (e: any) {
			console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
			return false;
		}
	}

	export function gets({
			restConfig,
		}: {
		restConfig: RESTConfig,
	}): Promise<GetsTypeReturn> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/users/",
				requestType: HTTPRequestModel.GET,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
		}, isGetsTypeReturn);
	};
}
