import { type CreateAxiosDefaults } from 'axios'; import { DataFormat } from '../enums/DataFormat.js'; import { ReportDataType } from '../enums/ReportDataType.js'; import { type ApiResponse } from './ApiResponse.js'; import { type App } from './App.js'; import { type CollectionResponse } from './CollectionResponse.js'; import { type CreatedWithIdResponse } from './CreatedWithIdResponse.js'; import { type Field } from './Field.js'; import { type File } from './File.js'; import { type FileInfo } from './FileInfo.js'; import { type GetPagedAppsResponse } from './GetPagedAppsResponse.js'; import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse.js'; import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse.js'; import { type GetPagedReportsResponse } from './GetPagedReportsResponse.js'; import { type GetRecordRequest } from './GetRecordRequest.js'; import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest.js'; import { type GetRecordsRequest } from './GetRecordsRequest.js'; import { type ListItemRequest } from './ListItemRequest.js'; import { type ListItemResponse } from './ListItemResponse.js'; import { PagingRequest } from './PagingRequest.js'; import { type QueryRecordsRequest } from './QueryRecordsRequest.js'; import { Record } from './Record.js'; import { type ReportData } from './ReportData.js'; import { type SaveFileRequest } from './SaveFileRequest.js'; import { type SaveRecordRequest } from './SaveRecordRequest.js'; import { type SaveRecordResponse } from './SaveRecordResponse.js'; /** * @class OnspringClient - A client that can communicate with the Onspring API. */ export declare class OnspringClient { /** * @readonly {AxiosInstance} client - The axios instance that will be used to make requests to the Onspring API. */ private readonly _client; /** * @constructor - Creates a new instance of the OnspringClient class. * @param {string} baseUrl - The base url that will be used to make requests to the Onspring API. * @param {string} apiKey - The api key that will be used to authorize requests made by this client. * @throws {Error} - Thrown when the baseUrl is not a valid url. * @throws {Error} - Thrown when the apiKey is null/undefined/empty/whitespace. * @returns {OnspringClient} - A new instance of the OnspringClient class. */ constructor(baseUrl: string | undefined | null, apiKey: string | undefined | null, config?: CreateAxiosDefaults); /** * @method canConnect - Determines if the client can connect to the Onspring API. * @returns {Promise} - A promise that resolves to a boolean indicating if the client can connect to the Onspring API. */ canConnect(): Promise; /** * @method getApps - Gets a paged list of apps. * @param {PagingRequest} pagingRequest - The paging request that will be used to get the apps. * @returns {Promise>} - A promise that resolves to an ApiResponse of type GetPagedAppsResponse. */ getApps(pagingRequest?: PagingRequest): Promise>; /** * @method getAppById - Gets an app by its id. * @param {number} appId - The id of the app to get. * @returns {Promise>} - A promise that resolves to an ApiResponse of type App. */ getAppById(appId: number): Promise>; /** * @method getAppsByIds - Gets a list of apps by their ids. * @param {number[]} appIds - The ids of the apps to get. * @returns {Promise>>} - A promise that resolves to an ApiResponse of type CollectionResponse. */ getAppsByIds(appIds: number[]): Promise>>; /** * @method getFieldById - Gets a field by its id. * @param {number} fieldId - The id of the field to get. * @returns {Promise>} - A promise that resolves to an ApiResponse of type Field. */ getFieldById(fieldId: number): Promise>; /** * @method getFieldsByIds - Gets a list of fields by their ids. * @param {number[]} fieldIds - The ids of the fields to get. * @returns {Promise>>} - A promise that resolves to an ApiResponse of type CollectionResponse. */ getFieldsByIds(fieldIds: number[]): Promise>>; /** * @method getFieldsByAppId - Gets a paged list of fields by an app id. * @param {number} appId - The id of the app to get the fields for. * @param {PagingRequest} pagingRequest - The paging request that will be used to get the fields. * @returns {Promise>} - A promise that resolves to an ApiResponse of type GetPagedFieldsResponse. */ getFieldsByAppId(appId: number, pagingRequest?: PagingRequest): Promise>; /** * @method getFileInfoById - Gets a file's information by its id. * @param {number} recordId - The id of the record that the file is attached to. * @param {number} fieldId - The id of the field that the file is attached to. * @param {number} fileId - The id of the file to get the information for. * @returns {Promise>} - A promise that resolves to an ApiResponse of type FileInfo. */ getFileInfoById(recordId: number, fieldId: number, fileId: number): Promise>; /** * @method getFileById - Gets a file by its id. * @param {number} recordId - The id of the record that the file is attached to. * @param {number} fieldId - The id of the field that the file is attached to. * @param {number} fileId - The id of the file to get. * @returns {Promise>} - A promise that resolves to an ApiResponse of type File. */ getFileById(recordId: number, fieldId: number, fileId: number): Promise>; /** * @method saveFile - Saves a file to a record in Onspring. * @param {SaveFileRequest} request - The request that will be used to save the file. * @returns {Promise>>} - A promise that resolves to an ApiResponse of type CreatedWithIdResponse. */ saveFile(request: SaveFileRequest): Promise>>; /** * @method deleteFileById - Deletes a file by its id. * @param {number} recordId - The id of the record that the file is held on. * @param {number} fieldId - The id of the field that the file is held in. * @param {number} fileId - The id of the file to delete. * @returns {Promise>} - A promise that resolves to an ApiResponse of type any. */ deleteFileById(recordId: number, fieldId: number, fileId: number): Promise>; /** * @method addOrUpdateListItem - Adds or updates a list item depending on if an id is provided or not. * @param {ListItemRequest} listItemRequest - The request that will be used to add or update the list item. * @returns {Promise>} - A promise that resolves to an ApiResponse of type ListItemResponse. */ addOrUpdateListItem(listItemRequest: ListItemRequest): Promise>; /** * @method deleteListItemById - Deletes a list item by its id. * @param {number} listId - The id of the list that the list item belongs to. * @param {string} itemId - The id of the list item to delete. * @returns {Promise>} - A promise that resolves to an ApiResponse of type any. */ deleteListItemById(listId: number, itemId: string): Promise>; /** * @method getRecordsByAppId - Gets records by an app id. * @param {GetRecordsByAppIdRequest} request - The request that will be used to get the records. * @returns {Promise>} - A promise that resolves to an ApiResponse of type GetPagedRecordsResponse. */ getRecordsByAppId(request: GetRecordsByAppIdRequest): Promise>; /** * @method getRecordById - Gets a record by its id. * @param {GetRecordRequest} request - The request that will be used to get the record. * @returns {Promise>} - A promise that resolves to an ApiResponse of type Record. */ getRecordById(request: GetRecordRequest): Promise>; /** * @method getRecordsByIds - Gets records by their ids. * @param {GetRecordsRequest} request - The request that will be used to get the records. * @returns {Promise>>} - A promise that resolves to an ApiResponse of type CollectionResponse of type Record. */ getRecordsByIds(request: GetRecordsRequest): Promise>>; /** * @method getRecordsByQuery - Gets records by a query. * @param {GetRecordsByQueryRequest} request - The request that will be used to query for records. * @returns {Promise>} - A promise that resolves to an ApiResponse of type GetPagedRecordsResponse. */ queryRecords(request: QueryRecordsRequest): Promise>; /** * @method saveRecord - Saves a record. * @param {Record | SaveRecordRequest} request - The record or request that will be used to save the record. * @returns {Promise>} - A promise that resolves to an ApiResponse of type SaveRecordResponse. */ saveRecord(request: Record | SaveRecordRequest): Promise>; /** * @method deleteRecordById - Deletes a record by its id. * @param {number} appId - The id of the app that the record belongs to. * @param {number} recordId - The id of the record to delete. * @returns {Promise>} - A promise that resolves to an ApiResponse of type any. */ deleteRecordById(appId: number, recordId: number): Promise>; /** * @method deleteRecordsByIds - Deletes records by their ids. * @param {number} appId - The id of the app that the records belong to. * @param {number[]} recordIds - The ids of the records to delete. * @returns {Promise>} - A promise that resolves to an ApiResponse of type any. */ deleteRecordsByIds(appId: number, recordIds: number[]): Promise>; /** * @method getReportsByAppId - Gets a paged list of reports by the app id. * @param {number} appId - The id of the app to get the reports for. * @param {PagingRequest} pagingRequest - The paging request that will be used to get the reports. * @returns {Promise>} - A promise that resolves to an ApiResponse of type GetPagedReportsResponse. */ getReportsByAppId(appId: number, pagingRequest?: PagingRequest): Promise>; /** * @method getReportById - Gets a report by its id. * @param {number} reportId - The id of the report to get. * @param {DataFormat} apiDataFormat - The data format that the report data will be returned in. * @param {ReportDataType} dataType - The type of data that will be returned. * @returns {Promise>} - A promise that resolves to an ApiResponse of type ReportData. */ getReportById(reportId: number, apiDataFormat?: DataFormat, dataType?: ReportDataType): Promise>; /** * @method get - Makes a GET request to the specified endpoint. * @param {string} endpoint - The endpoint that will be used to make the request. * @param {AxiosRequestConfig} config - The configuration that will be used to make the request. * @returns {Promise>} - A promise that resolves to an ApiResponse of type T. */ private get; /** * @method post - Makes a POST request to the specified endpoint. * @param {string} endpoint - The endpoint that will be used to make the request. * @param {any} data - The data that will be sent with the request. * @param {AxiosRequestConfig} config - The configuration that will be used to make the request. * @returns {Promise>} - A promise that resolves to an ApiResponse of type T. */ private post; /** * @method put - Makes a PUT request to the specified endpoint. * @param {string} endpoint - The endpoint that will be used to make the request. * @param {any} data - The data that will be sent with the request. * @param {AxiosRequestConfig} config - The configuration that will be used to make the request. * @returns {Promise>} - A promise that resolves to an ApiResponse of type T. */ private put; /** * @method delete - Makes a DELETE request to the specified endpoint. * @param {string} endpoint - The endpoint that will be used to make the request. * @param {AxiosRequestConfig} config - The configuration that will be used to make the request. * @returns {Promise>} - A promise that resolves to an ApiResponse of type T. */ private delete; }