// DO NOT EDIT THIS FILE // This file has been generated by gen-api-models // eslint-disable sonar/max-union-size // eslint-disable sonarjs/no-identical-functions import * as t from "io-ts"; import * as r from "@pagopa/ts-commons/lib/requests"; import { Notification } from "./Notification"; import { SuccessResponse } from "./SuccessResponse"; import { ProblemJson } from "./ProblemJson"; /**************************************************************** * notify */ // Request type definition export type NotifyT = r.IPostApiRequestType< { readonly body: Notification }, "Content-Type", never, | r.IResponseType<200, SuccessResponse, never> | r.IResponseType<400, ProblemJson, never> | r.IResponseType<401, undefined, never> | r.IResponseType<500, ProblemJson, never> >; export const notifyDefaultResponses = { 200: SuccessResponse, 400: ProblemJson, 401: t.undefined, 500: ProblemJson }; export type NotifyResponsesT< A0 = SuccessResponse, C0 = SuccessResponse, A1 = ProblemJson, C1 = ProblemJson, A2 = undefined, C2 = undefined, A3 = ProblemJson, C3 = ProblemJson > = { 200: t.Type; 400: t.Type; 401: t.Type; 500: t.Type; }; export function notifyDecoder< A0 = SuccessResponse, C0 = SuccessResponse, A1 = ProblemJson, C1 = ProblemJson, A2 = undefined, C2 = undefined, A3 = ProblemJson, C3 = ProblemJson >( overrideTypes: | Partial> | t.Type | undefined = {} ): r.ResponseDecoder< | r.IResponseType<200, A0, never> | r.IResponseType<400, A1, never> | r.IResponseType<401, A2, never> | r.IResponseType<500, A3, never> > { const isDecoder = (d: any): d is t.Type => typeof d["_A"] !== "undefined"; const type = { ...((notifyDefaultResponses as unknown) as NotifyResponsesT< A0, C0, A1, C1, A2, C2, A3, C3 >), ...(isDecoder(overrideTypes) ? { 200: overrideTypes } : overrideTypes) }; const d200 = (type[200].name === "undefined" ? r.constantResponseDecoder(200, undefined) : r.ioResponseDecoder< 200, typeof type[200]["_A"], typeof type[200]["_O"], never >(200, type[200])) as r.ResponseDecoder>; const d400 = (type[400].name === "undefined" ? r.constantResponseDecoder(400, undefined) : r.ioResponseDecoder< 400, typeof type[400]["_A"], typeof type[400]["_O"], never >(400, type[400])) as r.ResponseDecoder>; const d401 = (type[401].name === "undefined" ? r.constantResponseDecoder(401, undefined) : r.ioResponseDecoder< 401, typeof type[401]["_A"], typeof type[401]["_O"], never >(401, type[401])) as r.ResponseDecoder>; const d500 = (type[500].name === "undefined" ? r.constantResponseDecoder(500, undefined) : r.ioResponseDecoder< 500, typeof type[500]["_A"], typeof type[500]["_O"], never >(500, type[500])) as r.ResponseDecoder>; return r.composeResponseDecoders( r.composeResponseDecoders(r.composeResponseDecoders(d200, d400), d401), d500 ); } // Decodes the success response with the type defined in the specs export const notifyDefaultDecoder = () => notifyDecoder();