/** * Do not edit this file it is auto-generated by io-utils / gen-api-models. * See https://github.com/pagopa/io-utils */ /* tslint:disable */ import { RequestParams, TypeofApiCall, TypeofApiParams, createFetchRequestForApi, ReplaceRequestParams } from "italia-ts-commons/lib/requests"; import { identity } from "fp-ts/lib/function"; import { SubmitMessageforUserWithFiscalCodeInBodyT, submitMessageforUserWithFiscalCodeInBodyDefaultDecoder, SubmitMessageforUserT, submitMessageforUserDefaultDecoder, GetMessageT, getMessageDefaultDecoder, GetProfileByPOSTT, getProfileByPOSTDefaultDecoder, GetProfileT, getProfileDefaultDecoder, GetSubscriptionsFeedForDateT, getSubscriptionsFeedForDateDefaultDecoder, CreateServiceT, createServiceDefaultDecoder, GetUserServicesT, getUserServicesDefaultDecoder, GetServiceT, getServiceDefaultDecoder, UpdateServiceT, updateServiceDefaultDecoder, UploadServiceLogoT, uploadServiceLogoDefaultDecoder, RegenerateServiceKeyT, regenerateServiceKeyDefaultDecoder, UploadOrganizationLogoT, uploadOrganizationLogoDefaultDecoder } from "./requestTypes"; // This is a placeholder for undefined when dealing with object keys // Typescript doesn't perform well when narrowing a union type which includes string and undefined // (example: "foo" | "bar" | undefined) // We use this as a placeholder for type parameters indicating "no key" type __UNDEFINED_KEY = "_____"; export type ApiOperation = TypeofApiCall< SubmitMessageforUserWithFiscalCodeInBodyT > & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall; export type ParamKeys = keyof (TypeofApiParams< SubmitMessageforUserWithFiscalCodeInBodyT > & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams & TypeofApiParams); /** * Defines an adapter for TypeofApiCall which omit one or more parameters in the signature * @param ApiT the type which defines the operation to expose * @param K the parameter to omit. undefined means no parameters will be omitted */ export type OmitApiCallParams< ApiT, K extends ParamKeys | __UNDEFINED_KEY = __UNDEFINED_KEY > = ( op: TypeofApiCall ) => K extends __UNDEFINED_KEY ? TypeofApiCall : TypeofApiCall, K>>>; /** * Defines an adapter for TypeofApiCall which omit one or more parameters in the signature * @param ApiT the type which defines the operation to expose * @param K the parameter to omit. undefined means no parameters will be omitted */ export type WithDefaultsT< K extends ParamKeys | __UNDEFINED_KEY = __UNDEFINED_KEY > = OmitApiCallParams< | SubmitMessageforUserWithFiscalCodeInBodyT | SubmitMessageforUserT | GetMessageT | GetProfileByPOSTT | GetProfileT | GetSubscriptionsFeedForDateT | CreateServiceT | GetUserServicesT | GetServiceT | UpdateServiceT | UploadServiceLogoT | RegenerateServiceKeyT | UploadOrganizationLogoT, K >; /** * Defines a collection of api operations * @param K name of the parameters that the Clients masks from the operations */ export type Client< K extends ParamKeys | __UNDEFINED_KEY = __UNDEFINED_KEY > = K extends __UNDEFINED_KEY ? { readonly submitMessageforUserWithFiscalCodeInBody: TypeofApiCall< SubmitMessageforUserWithFiscalCodeInBodyT >; readonly submitMessageforUser: TypeofApiCall; readonly getMessage: TypeofApiCall; readonly getProfileByPOST: TypeofApiCall; readonly getProfile: TypeofApiCall; readonly getSubscriptionsFeedForDate: TypeofApiCall< GetSubscriptionsFeedForDateT >; readonly createService: TypeofApiCall; readonly getUserServices: TypeofApiCall; readonly getService: TypeofApiCall; readonly updateService: TypeofApiCall; readonly uploadServiceLogo: TypeofApiCall; readonly regenerateServiceKey: TypeofApiCall; readonly uploadOrganizationLogo: TypeofApiCall; } : { readonly submitMessageforUserWithFiscalCodeInBody: TypeofApiCall< ReplaceRequestParams< SubmitMessageforUserWithFiscalCodeInBodyT, Omit, K> > >; readonly submitMessageforUser: TypeofApiCall< ReplaceRequestParams< SubmitMessageforUserT, Omit, K> > >; readonly getMessage: TypeofApiCall< ReplaceRequestParams, K>> >; readonly getProfileByPOST: TypeofApiCall< ReplaceRequestParams< GetProfileByPOSTT, Omit, K> > >; readonly getProfile: TypeofApiCall< ReplaceRequestParams, K>> >; readonly getSubscriptionsFeedForDate: TypeofApiCall< ReplaceRequestParams< GetSubscriptionsFeedForDateT, Omit, K> > >; readonly createService: TypeofApiCall< ReplaceRequestParams< CreateServiceT, Omit, K> > >; readonly getUserServices: TypeofApiCall< ReplaceRequestParams< GetUserServicesT, Omit, K> > >; readonly getService: TypeofApiCall< ReplaceRequestParams, K>> >; readonly updateService: TypeofApiCall< ReplaceRequestParams< UpdateServiceT, Omit, K> > >; readonly uploadServiceLogo: TypeofApiCall< ReplaceRequestParams< UploadServiceLogoT, Omit, K> > >; readonly regenerateServiceKey: TypeofApiCall< ReplaceRequestParams< RegenerateServiceKeyT, Omit, K> > >; readonly uploadOrganizationLogo: TypeofApiCall< ReplaceRequestParams< UploadOrganizationLogoT, Omit, K> > >; }; /** * Create an instance of a client * @param params hash map of parameters thata define the client: * - baseUrl: the base url for every api call (required) * - fetchApi: an implementation of the fetch() web API, depending on the platform (required) * - basePath: optional path to be appended to the baseUrl * - withDefaults: optional adapter to be applied to every operation, to omit some paramenters * @returns a collection of api operations */ export function createClient(params: { baseUrl: string; // tslint:disable-next-line:no-any fetchApi: typeof fetch; withDefaults: WithDefaultsT; basePath?: string; }): Client; export function createClient(params: { baseUrl: string; // tslint:disable-next-line:no-any fetchApi: typeof fetch; withDefaults?: undefined; basePath?: string; }): Client; export function createClient({ baseUrl, // tslint:disable-next-line:no-any fetchApi, withDefaults, basePath = "/api/v1" }: { baseUrl: string; // tslint:disable-next-line:no-any fetchApi: typeof fetch; withDefaults?: WithDefaultsT; basePath?: string; }) { const options = { baseUrl, fetchApi }; const submitMessageforUserWithFiscalCodeInBodyT: ReplaceRequestParams< SubmitMessageforUserWithFiscalCodeInBodyT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: submitMessageforUserWithFiscalCodeInBodyDefaultDecoder(), url: ({}) => `${basePath}/messages`, body: ({ ["message"]: message }) => JSON.stringify(message), query: () => ({}) }; const submitMessageforUserWithFiscalCodeInBody: TypeofApiCall = createFetchRequestForApi( submitMessageforUserWithFiscalCodeInBodyT, options ); const submitMessageforUserT: ReplaceRequestParams< SubmitMessageforUserT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: submitMessageforUserDefaultDecoder(), url: ({ ["fiscal_code"]: fiscalCode }) => `${basePath}/messages/${fiscalCode}`, body: ({ ["message"]: message }) => JSON.stringify(message), query: () => ({}) }; const submitMessageforUser: TypeofApiCall = createFetchRequestForApi( submitMessageforUserT, options ); const getMessageT: ReplaceRequestParams< GetMessageT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getMessageDefaultDecoder(), url: ({ ["fiscal_code"]: fiscalCode, ["id"]: id }) => `${basePath}/messages/${fiscalCode}/${id}`, query: () => ({}) }; const getMessage: TypeofApiCall = createFetchRequestForApi( getMessageT, options ); const getProfileByPOSTT: ReplaceRequestParams< GetProfileByPOSTT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: getProfileByPOSTDefaultDecoder(), url: ({}) => `${basePath}/profiles`, body: ({ ["payload"]: payload }) => JSON.stringify(payload), query: () => ({}) }; const getProfileByPOST: TypeofApiCall = createFetchRequestForApi( getProfileByPOSTT, options ); const getProfileT: ReplaceRequestParams< GetProfileT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getProfileDefaultDecoder(), url: ({ ["fiscal_code"]: fiscalCode }) => `${basePath}/profiles/${fiscalCode}`, query: () => ({}) }; const getProfile: TypeofApiCall = createFetchRequestForApi( getProfileT, options ); const getSubscriptionsFeedForDateT: ReplaceRequestParams< GetSubscriptionsFeedForDateT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getSubscriptionsFeedForDateDefaultDecoder(), url: ({ ["date"]: date }) => `${basePath}/subscriptions-feed/${date}`, query: () => ({}) }; const getSubscriptionsFeedForDate: TypeofApiCall = createFetchRequestForApi( getSubscriptionsFeedForDateT, options ); const createServiceT: ReplaceRequestParams< CreateServiceT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: createServiceDefaultDecoder(), url: ({}) => `${basePath}/services`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const createService: TypeofApiCall = createFetchRequestForApi( createServiceT, options ); const getUserServicesT: ReplaceRequestParams< GetUserServicesT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getUserServicesDefaultDecoder(), url: ({}) => `${basePath}/services`, query: () => ({}) }; const getUserServices: TypeofApiCall = createFetchRequestForApi( getUserServicesT, options ); const getServiceT: ReplaceRequestParams< GetServiceT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getServiceDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}`, query: () => ({}) }; const getService: TypeofApiCall = createFetchRequestForApi( getServiceT, options ); const updateServiceT: ReplaceRequestParams< UpdateServiceT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: updateServiceDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const updateService: TypeofApiCall = createFetchRequestForApi( updateServiceT, options ); const uploadServiceLogoT: ReplaceRequestParams< UploadServiceLogoT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: uploadServiceLogoDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}/logo`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const uploadServiceLogo: TypeofApiCall = createFetchRequestForApi( uploadServiceLogoT, options ); const regenerateServiceKeyT: ReplaceRequestParams< RegenerateServiceKeyT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: regenerateServiceKeyDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}/keys`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const regenerateServiceKey: TypeofApiCall = createFetchRequestForApi( regenerateServiceKeyT, options ); const uploadOrganizationLogoT: ReplaceRequestParams< UploadOrganizationLogoT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: uploadOrganizationLogoDefaultDecoder(), url: ({}) => `${basePath}/organizations/{organization_fiscal_code}/logo`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const uploadOrganizationLogo: TypeofApiCall = createFetchRequestForApi( uploadOrganizationLogoT, options ); return { submitMessageforUserWithFiscalCodeInBody: (withDefaults || identity)( submitMessageforUserWithFiscalCodeInBody ), submitMessageforUser: (withDefaults || identity)(submitMessageforUser), getMessage: (withDefaults || identity)(getMessage), getProfileByPOST: (withDefaults || identity)(getProfileByPOST), getProfile: (withDefaults || identity)(getProfile), getSubscriptionsFeedForDate: (withDefaults || identity)( getSubscriptionsFeedForDate ), createService: (withDefaults || identity)(createService), getUserServices: (withDefaults || identity)(getUserServices), getService: (withDefaults || identity)(getService), updateService: (withDefaults || identity)(updateService), uploadServiceLogo: (withDefaults || identity)(uploadServiceLogo), regenerateServiceKey: (withDefaults || identity)(regenerateServiceKey), uploadOrganizationLogo: (withDefaults || identity)(uploadOrganizationLogo) }; }