/** * 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 { GetServiceT, getServiceDefaultDecoder, UpdateServiceT, updateServiceDefaultDecoder, UploadServiceLogoT, uploadServiceLogoDefaultDecoder, GetServicesT, getServicesDefaultDecoder, CreateServiceT, createServiceDefaultDecoder, UploadOrganizationLogoT, uploadOrganizationLogoDefaultDecoder, CreateDevelopmentProfileT, createDevelopmentProfileDefaultDecoder, GetSubscriptionKeysT, getSubscriptionKeysDefaultDecoder, RegenerateSubscriptionKeysT, RegenerateSubscriptionKeysDefaultDecoder, GetUsersT, getUsersDefaultDecoder, CreateUserT, createUserDefaultDecoder, GetUserT, getUserDefaultDecoder, UpdateUserT, updateUserDefaultDecoder, UpdateGroupsT, updateGroupsDefaultDecoder, CreateSubscriptionT, createSubscriptionDefaultDecoder } 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 & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall & TypeofApiCall; export type ParamKeys = keyof (TypeofApiParams & TypeofApiParams & TypeofApiParams & 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< | GetServiceT | UpdateServiceT | UploadServiceLogoT | GetServicesT | CreateServiceT | UploadOrganizationLogoT | CreateDevelopmentProfileT | GetSubscriptionKeysT | RegenerateSubscriptionKeysT | GetUsersT | CreateUserT | GetUserT | UpdateUserT | UpdateGroupsT | CreateSubscriptionT, 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 getService: TypeofApiCall; readonly updateService: TypeofApiCall; readonly uploadServiceLogo: TypeofApiCall; readonly getServices: TypeofApiCall; readonly createService: TypeofApiCall; readonly uploadOrganizationLogo: TypeofApiCall; readonly createDevelopmentProfile: TypeofApiCall< CreateDevelopmentProfileT >; readonly getSubscriptionKeys: TypeofApiCall; readonly RegenerateSubscriptionKeys: TypeofApiCall< RegenerateSubscriptionKeysT >; readonly getUsers: TypeofApiCall; readonly createUser: TypeofApiCall; readonly getUser: TypeofApiCall; readonly updateUser: TypeofApiCall; readonly updateGroups: TypeofApiCall; readonly createSubscription: TypeofApiCall; } : { readonly getService: TypeofApiCall< ReplaceRequestParams, K>> >; readonly updateService: TypeofApiCall< ReplaceRequestParams< UpdateServiceT, Omit, K> > >; readonly uploadServiceLogo: TypeofApiCall< ReplaceRequestParams< UploadServiceLogoT, Omit, K> > >; readonly getServices: TypeofApiCall< ReplaceRequestParams, K>> >; readonly createService: TypeofApiCall< ReplaceRequestParams< CreateServiceT, Omit, K> > >; readonly uploadOrganizationLogo: TypeofApiCall< ReplaceRequestParams< UploadOrganizationLogoT, Omit, K> > >; readonly createDevelopmentProfile: TypeofApiCall< ReplaceRequestParams< CreateDevelopmentProfileT, Omit, K> > >; readonly getSubscriptionKeys: TypeofApiCall< ReplaceRequestParams< GetSubscriptionKeysT, Omit, K> > >; readonly RegenerateSubscriptionKeys: TypeofApiCall< ReplaceRequestParams< RegenerateSubscriptionKeysT, Omit, K> > >; readonly getUsers: TypeofApiCall< ReplaceRequestParams, K>> >; readonly createUser: TypeofApiCall< ReplaceRequestParams, K>> >; readonly getUser: TypeofApiCall< ReplaceRequestParams, K>> >; readonly updateUser: TypeofApiCall< ReplaceRequestParams, K>> >; readonly updateGroups: TypeofApiCall< ReplaceRequestParams< UpdateGroupsT, Omit, K> > >; readonly createSubscription: TypeofApiCall< ReplaceRequestParams< CreateSubscriptionT, 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 = "/adm" }: { baseUrl: string; // tslint:disable-next-line:no-any fetchApi: typeof fetch; withDefaults?: WithDefaultsT; basePath?: string; }) { const options = { baseUrl, fetchApi }; 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 getServicesT: ReplaceRequestParams< GetServicesT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getServicesDefaultDecoder(), url: ({}) => `${basePath}/services`, query: () => ({}) }; const getServices: TypeofApiCall = createFetchRequestForApi( getServicesT, 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 uploadOrganizationLogoT: ReplaceRequestParams< UploadOrganizationLogoT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: uploadOrganizationLogoDefaultDecoder(), url: ({ ["organization_fiscal_code"]: organizationFiscalCode }) => `${basePath}/organizations/${organizationFiscalCode}/logo`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const uploadOrganizationLogo: TypeofApiCall = createFetchRequestForApi( uploadOrganizationLogoT, options ); const createDevelopmentProfileT: ReplaceRequestParams< CreateDevelopmentProfileT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: createDevelopmentProfileDefaultDecoder(), url: ({ ["fiscal_code"]: fiscalCode }) => `${basePath}/development-profiles/${fiscalCode}`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const createDevelopmentProfile: TypeofApiCall = createFetchRequestForApi( createDevelopmentProfileT, options ); const getSubscriptionKeysT: ReplaceRequestParams< GetSubscriptionKeysT, RequestParams > = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getSubscriptionKeysDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}/keys`, query: () => ({}) }; const getSubscriptionKeys: TypeofApiCall = createFetchRequestForApi( getSubscriptionKeysT, options ); const RegenerateSubscriptionKeysT: ReplaceRequestParams< RegenerateSubscriptionKeysT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: RegenerateSubscriptionKeysDefaultDecoder(), url: ({ ["service_id"]: serviceId }) => `${basePath}/services/${serviceId}/keys`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const RegenerateSubscriptionKeys: TypeofApiCall = createFetchRequestForApi( RegenerateSubscriptionKeysT, options ); const getUsersT: ReplaceRequestParams> = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getUsersDefaultDecoder(), url: ({}) => `${basePath}/users`, query: ({ ["cursor"]: cursor }) => ({ cursor }) }; const getUsers: TypeofApiCall = createFetchRequestForApi( getUsersT, options ); const createUserT: ReplaceRequestParams< CreateUserT, RequestParams > = { method: "post", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: createUserDefaultDecoder(), url: ({}) => `${basePath}/users`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const createUser: TypeofApiCall = createFetchRequestForApi( createUserT, options ); const getUserT: ReplaceRequestParams> = { method: "get", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey }), response_decoder: getUserDefaultDecoder(), url: ({ ["email"]: email }) => `${basePath}/users/${email}`, query: () => ({}) }; const getUser: TypeofApiCall = createFetchRequestForApi( getUserT, options ); const updateUserT: ReplaceRequestParams< UpdateUserT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: updateUserDefaultDecoder(), url: ({ ["email"]: email }) => `${basePath}/users/${email}`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const updateUser: TypeofApiCall = createFetchRequestForApi( updateUserT, options ); const updateGroupsT: ReplaceRequestParams< UpdateGroupsT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: updateGroupsDefaultDecoder(), url: ({ ["email"]: email }) => `${basePath}/users/${email}/groups`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const updateGroups: TypeofApiCall = createFetchRequestForApi( updateGroupsT, options ); const createSubscriptionT: ReplaceRequestParams< CreateSubscriptionT, RequestParams > = { method: "put", headers: ({ ["SubscriptionKey"]: SubscriptionKey }: { SubscriptionKey: string; }) => ({ "Ocp-Apim-Subscription-Key": SubscriptionKey, "Content-Type": "application/json" }), response_decoder: createSubscriptionDefaultDecoder(), url: ({ ["email"]: email, ["subscription_id"]: subscriptionId }) => `${basePath}/users/${email}/subscriptions/${subscriptionId}`, body: ({ ["body"]: body }) => JSON.stringify(body), query: () => ({}) }; const createSubscription: TypeofApiCall = createFetchRequestForApi( createSubscriptionT, options ); return { getService: (withDefaults || identity)(getService), updateService: (withDefaults || identity)(updateService), uploadServiceLogo: (withDefaults || identity)(uploadServiceLogo), getServices: (withDefaults || identity)(getServices), createService: (withDefaults || identity)(createService), uploadOrganizationLogo: (withDefaults || identity)(uploadOrganizationLogo), createDevelopmentProfile: (withDefaults || identity)( createDevelopmentProfile ), getSubscriptionKeys: (withDefaults || identity)(getSubscriptionKeys), RegenerateSubscriptionKeys: (withDefaults || identity)( RegenerateSubscriptionKeys ), getUsers: (withDefaults || identity)(getUsers), createUser: (withDefaults || identity)(createUser), getUser: (withDefaults || identity)(getUser), updateUser: (withDefaults || identity)(updateUser), updateGroups: (withDefaults || identity)(updateGroups), createSubscription: (withDefaults || identity)(createSubscription) }; }