feat: add filter operator enum, add models for getting records by ids and querying records
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
export enum FilterOperators {
|
||||
Equal = 'eq',
|
||||
NotEqual = 'ne',
|
||||
Contains = 'contains',
|
||||
IsNull = 'isnull',
|
||||
NotNull = 'notnull',
|
||||
GreaterThan = 'gt',
|
||||
LessThan = 'lt',
|
||||
And = 'and',
|
||||
Or = 'or',
|
||||
Not = 'not',
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
|
||||
/**
|
||||
* @class GetRecordsRequest - Request to get records by their ids
|
||||
*/
|
||||
export class GetRecordsRequest {
|
||||
/**
|
||||
* @property {number} appId - The id of the app the records belong to.
|
||||
*/
|
||||
appId: number;
|
||||
|
||||
/**
|
||||
* @property {number[]} recordIds - The ids of the records to get.
|
||||
*/
|
||||
recordIds: number[];
|
||||
|
||||
/**
|
||||
* @property {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
*/
|
||||
fieldIds: number[];
|
||||
|
||||
/**
|
||||
* @property {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
dataFormat: DataFormat;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of GetRecordsRequest
|
||||
* @param {number} appId - The id of the app the records belong to.
|
||||
* @param {number[]} recordIds - The ids of the records to get.
|
||||
* @param {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
* @param {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
constructor(
|
||||
appId: number,
|
||||
recordIds: number[],
|
||||
fieldIds: number[] = [],
|
||||
dataFormat: DataFormat = DataFormat.Raw
|
||||
) {
|
||||
this.appId = appId;
|
||||
this.recordIds = recordIds;
|
||||
this.fieldIds = fieldIds;
|
||||
this.dataFormat = dataFormat;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import { type Record } from './Record';
|
||||
import { type GetRecordRequest } from './GetRecordRequest';
|
||||
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest';
|
||||
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse';
|
||||
import { type GetRecordsRequest } from './GetRecordsRequest';
|
||||
|
||||
/**
|
||||
* @class OnspringClient - A client that can communicate with the Onspring API.
|
||||
@@ -356,6 +357,12 @@ export class OnspringClient {
|
||||
return apiResponse.asRecordType();
|
||||
}
|
||||
|
||||
public async getRecordsByIds(
|
||||
request: GetRecordsRequest
|
||||
): Promise<ApiResponse<CollectionResponse<Record>>> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
import { PagingRequest } from './PagingRequest';
|
||||
|
||||
/**
|
||||
* @class QueryRecordsRequest - Request to query for records.
|
||||
*/
|
||||
export class QueryRecordsRequest {
|
||||
/**
|
||||
* @property {number} appId - The id of the app the records belong to.
|
||||
*/
|
||||
appId: number;
|
||||
|
||||
/**
|
||||
* @property {string} filter - The filter to use to query for records.
|
||||
*/
|
||||
filter: string;
|
||||
|
||||
/**
|
||||
* @property {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
*/
|
||||
fieldIds: number[];
|
||||
|
||||
/**
|
||||
* @property {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
dataFormat: DataFormat;
|
||||
|
||||
/**
|
||||
* @property {PagingRequest} pagingRequest - The paging request to use to query for records.
|
||||
*/
|
||||
pagingRequest: PagingRequest;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of QueryRecordsRequest
|
||||
* @param {number} appId - The id of the app the records belong to.
|
||||
* @param {string} filter - The filter to use to query for records.
|
||||
* @param {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
* @param {DataFormat} dataFormat - The format of the data in the response.
|
||||
* @param {PagingRequest} pagingRequest - The paging request to use to query for records.
|
||||
* @returns {QueryRecordsRequest} - A new instance of QueryRecordsRequest
|
||||
*/
|
||||
constructor(
|
||||
appId: number,
|
||||
filter: string,
|
||||
fieldIds: number[] = [],
|
||||
dataFormat: DataFormat = DataFormat.Raw,
|
||||
pagingRequest: PagingRequest = new PagingRequest(1, 50)
|
||||
) {
|
||||
this.appId = appId;
|
||||
this.filter = filter;
|
||||
this.fieldIds = fieldIds;
|
||||
this.dataFormat = dataFormat;
|
||||
this.pagingRequest = pagingRequest;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user