diff --git a/src/models/GetRecordsByAppIdRequest.ts b/src/models/GetRecordsByAppIdRequest.ts new file mode 100644 index 0000000..9b142f7 --- /dev/null +++ b/src/models/GetRecordsByAppIdRequest.ts @@ -0,0 +1,44 @@ +import { DataFormat } from '../enums/DataFormat'; +import { PagingRequest } from './PagingRequest'; + +export class GetRecordsByAppIdRequest { + /** + * @property {number} appId - The id of the app that the records belong to. + */ + public appId: number; + + /** + * @property {number[]} fieldIds - The ids of the fields to include in the response. + */ + public fieldIds: number[]; + + /** + * @property {DataFormat} dataFormat - The format of the data in the response. + */ + public dataFormat: DataFormat; + + /** + * @property {PagingRequest} pagingRequest - The paging request. + */ + public pagingRequest: PagingRequest; + + /** + *@constructor - Creates a new instance of GetRecordsByAppIdRequest. + * @param {number} appId - The id of the app that the records belong to. + * @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. + * @returns {GetRecordsByAppIdRequest} - A new instance of GetRecordsByAppIdRequest. + */ + constructor( + appId: number, + fieldIds: number[] = [], + dataFormat: DataFormat = DataFormat.Raw, + pagingRequest: PagingRequest = new PagingRequest(1, 50) + ) { + this.appId = appId; + this.fieldIds = fieldIds; + this.dataFormat = dataFormat; + this.pagingRequest = pagingRequest; + } +} diff --git a/tests/GetRecordsByAppIdRequest.spec.ts b/tests/GetRecordsByAppIdRequest.spec.ts new file mode 100644 index 0000000..b8aab25 --- /dev/null +++ b/tests/GetRecordsByAppIdRequest.spec.ts @@ -0,0 +1,52 @@ +import { GetRecordsByAppIdRequest } from '../src/models/GetRecordsByAppIdRequest'; +import { expect } from 'chai'; +import { DataFormat } from '../src/enums/DataFormat'; + +describe('GetRecordsByAppIdRequest', function () { + it('should be defined', function () { + expect(GetRecordsByAppIdRequest).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(GetRecordsByAppIdRequest).to.have.property('constructor'); + }); + + it('should have a constructor that takes 1 parameter', function () { + expect(GetRecordsByAppIdRequest).to.have.a.lengthOf(1); + }); + + it('should have an appId property', function () { + expect(new GetRecordsByAppIdRequest(1)).to.have.property('appId'); + }); + + it('should have a fieldIds property', function () { + expect(new GetRecordsByAppIdRequest(1)).to.have.property('fieldIds'); + }); + + it('should have a dataFormat property', function () { + expect(new GetRecordsByAppIdRequest(1)).to.have.property('dataFormat'); + }); + + it('should have a pagingRequest property', function () { + expect(new GetRecordsByAppIdRequest(1)).to.have.property('pagingRequest'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const appId = 1; + const fieldIds = [1, 2, 3]; + const dataFormat = DataFormat.Raw; + const pagingRequest = { pageNumber: 1, pageSize: 50 }; + + const request = new GetRecordsByAppIdRequest( + appId, + fieldIds, + dataFormat, + pagingRequest + ); + + expect(request).to.have.property('appId', appId); + expect(request).to.have.property('fieldIds', fieldIds); + expect(request).to.have.property('dataFormat', dataFormat); + expect(request).to.have.property('pagingRequest', pagingRequest); + }); +});