/** * Generated by orval v8.19.0 🍺 * Do not edit manually. * Webitel API * OpenAPI spec version: 24.04.0 */ import axios from '@aliasedDeps/api-services/axios'; import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import type { ContactsContactList, ContactsCreateContactsBulkResponse, ContactsInputContact, CreateContactParams, CreateContactsParams, DeleteContactParams, LocateContactParams, SearchContactsParams, UpdateContactBody, UpdateContactParams, WebitelContactsContact, } from '../_models'; // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B; type WritableKeys = { [P in keyof T]-?: IfEquals< { [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P >; }[keyof T]; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( k: infer I, ) => void ? I : never; type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; type Writable = Pick>; type NonReadonly = [ T, ] extends [ UnionToIntersection, ] ? { [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P]; } : DistributeReadOnlyOverUnions; // --- header start // export const // --- title start getContacts = // --- title end (axiosInstance: AxiosInstance = axios) => { // --- header end /** * | Field | Type * | ----------- | ---- * | **----------- READ-ONLY -----------** | * | `id` | int64 * | `ver` | int32 * | `etag` | string * | **---------- OPERATIONAL ----------** | * | `created_at` | int64(epoch:milli) * | `created_by` | lookup(user) * | `updated_at` | int64(epoch:milli) * | `updated_by` | lookup(user) * | **---------- ATTRIBUTES -----------** | * | `name` | name! * | `about` | string * | `labels` | list[label!] * | `emails` | list[email!] * | `photos` | list[photo!] * | `phones` | list[phone!] * | `managers` | list[manager!] * | `comments` | list[comment!] * | `addresses` | list[address!] * | `timezones` | list[timezone!] * | `variables` | list[variable!] * | `imclients` | list[imClient!] * @summary Search for Contact(s) */ const searchContacts = ( params?: SearchContactsParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.get(`/contacts`, { ...options, params: { ...params, ...options?.params, }, }); }; /** * @summary Create NEW Contact */ const createContact = ( contactsInputContact: NonReadonly, params?: CreateContactParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.post(`/contacts`, contactsInputContact, { ...options, params: { ...params, ...options?.params, }, }); }; /** * @summary Bulk create of Contacts. */ const createContacts = ( contactsInputContact: NonReadonly, params?: CreateContactsParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.post(`/contacts/bulk`, contactsInputContact, { ...options, params: { ...params, ...options?.params, }, }); }; /** * @summary Remove Contact source */ const deleteContact = ( etag: string, params?: DeleteContactParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.delete(`/contacts/${etag}`, { ...options, params: { ...params, ...options?.params, }, }); }; /** * @summary Locate Contact source */ const locateContact = ( etag: string, params?: LocateContactParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.get(`/contacts/${etag}`, { ...options, params: { ...params, ...options?.params, }, }); }; /** * @summary NEW Update of the Contact source */ const updateContact = ( etag: string, updateContactBody: NonReadonly, params?: UpdateContactParams, options?: AxiosRequestConfig, ): Promise> => { return axiosInstance.patch(`/contacts/${etag}`, updateContactBody, { ...options, params: { ...params, ...options?.params, }, }); }; // --- footer start return { searchContacts, createContact, createContacts, deleteContact, locateContact, updateContact, }; }; export type SearchContactsResult = AxiosResponse; export type CreateContactResult = AxiosResponse; export type CreateContactsResult = AxiosResponse; export type DeleteContactResult = AxiosResponse; export type LocateContactResult = AxiosResponse; export type UpdateContactResult = AxiosResponse; // --- footer end