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

import { z as zod } from "zod"
import {
	Long,
	MediaInformationsDeltaWrite,
	UserMediaAdvancement,
	ZodUserMediaAdvancement,
	isUserMediaAdvancement,
} from "../model";

export namespace UserMediaAdvancementResource {

	/**
	 * Get a specific user advancement with his ID
	 */
	export function get({
			restConfig,
			params,
		}: {
		restConfig: RESTConfig,
		params: {
			id: Long,
		},
	}): Promise<UserMediaAdvancement> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/advancement/{id}",
				requestType: HTTPRequestModel.GET,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
			params,
		}, isUserMediaAdvancement);
	};

	export const ZodGetsTypeReturn = zod.array(ZodUserMediaAdvancement);
	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;
		}
	}

	/**
	 * Get all user advancement
	 */
	export function gets({
			restConfig,
		}: {
		restConfig: RESTConfig,
	}): Promise<GetsTypeReturn> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/advancement/",
				requestType: HTTPRequestModel.GET,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
		}, isGetsTypeReturn);
	};
	/**
	 * Modify a user advancement
	 */
	export function patch({
			restConfig,
			params,
			data,
		}: {
		restConfig: RESTConfig,
		params: {
			id: Long,
		},
		data: MediaInformationsDeltaWrite,
	}): Promise<UserMediaAdvancement> {
		return RESTRequestJson({
			restModel: {
				endPoint: "/advancement/{id}",
				requestType: HTTPRequestModel.PATCH,
				contentType: HTTPMimeType.JSON,
				accept: HTTPMimeType.JSON,
			},
			restConfig,
			params,
			data,
		}, isUserMediaAdvancement);
	};
	/**
	 * Remove a specific user advancement
	 */
	export function remove({
			restConfig,
			params,
		}: {
		restConfig: RESTConfig,
		params: {
			id: Long,
		},
	}): Promise<void> {
		return RESTRequestVoid({
			restModel: {
				endPoint: "/advancement/{id}",
				requestType: HTTPRequestModel.DELETE,
				contentType: HTTPMimeType.TEXT_PLAIN,
			},
			restConfig,
			params,
		});
	};
}
