File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,39 @@ describe('DataClient tests', () => {
217217
218218 expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
219219 } ) ;
220+
221+ // Test for additional params
222+ const additionalParams = {
223+ key : 'value1' ,
224+ } ;
225+
226+ it ( 'gets tabular data for an interval with additional params' , async ( ) => {
227+ await subject ( ) . exportTabularData (
228+ 'partId1' ,
229+ 'resource1' ,
230+ 'resource1:subtype' ,
231+ 'Readings' ,
232+ timeCaptured1 ,
233+ timeCaptured2 ,
234+ additionalParams
235+ ) ;
236+
237+ const expectedRequest = new ExportTabularDataRequest ( {
238+ partId : 'partId1' ,
239+ resourceName : 'resource1' ,
240+ resourceSubtype : 'resource1:subtype' ,
241+ methodName : 'Readings' ,
242+ interval : {
243+ start : Timestamp . fromDate ( timeCaptured1 ) ,
244+ end : Timestamp . fromDate ( timeCaptured2 ) ,
245+ } ,
246+ additionalParameters : Struct . fromJson ( {
247+ key : 'value1' ,
248+ } ) ,
249+ } ) ;
250+
251+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
252+ } ) ;
220253 } ) ;
221254
222255 describe ( 'tabularDataBySQL tests' , ( ) => {
Original file line number Diff line number Diff line change @@ -125,7 +125,8 @@ export class DataClient {
125125 resourceSubtype : string ,
126126 methodName : string ,
127127 startTime ?: Date ,
128- endTime ?: Date
128+ endTime ?: Date ,
129+ additionalParams ?: Record < string , JsonValue >
129130 ) {
130131 const interval = new CaptureInterval ( ) ;
131132 if ( startTime ) {
@@ -135,12 +136,18 @@ export class DataClient {
135136 interval . end = Timestamp . fromDate ( endTime ) ;
136137 }
137138
139+ let additionalParameters : Struct | undefined ;
140+ if ( additionalParams ) {
141+ additionalParameters = Struct . fromJson ( additionalParams ) ;
142+ }
143+
138144 const req = {
139145 partId,
140146 resourceName,
141147 resourceSubtype,
142148 methodName,
143149 interval,
150+ additionalParameters,
144151 } ;
145152
146153 const responses = this . dataClient . exportTabularData ( req ) ;
@@ -1317,13 +1324,20 @@ export class DataClient {
13171324 partId : string ,
13181325 resourceName : string ,
13191326 resourceSubtype : string ,
1320- methodName : string
1327+ methodName : string ,
1328+ additionalParams ?: Record < string , JsonValue >
13211329 ) : Promise < [ Date , Date , Record < string , JsonValue > ] | null > {
1330+ let additionalParameters : Struct | undefined ;
1331+ if ( additionalParams ) {
1332+ additionalParameters = Struct . fromJson ( additionalParams ) ;
1333+ }
1334+
13221335 const resp = await this . dataClient . getLatestTabularData ( {
13231336 partId,
13241337 resourceName,
13251338 resourceSubtype,
13261339 methodName,
1340+ additionalParameters,
13271341 } ) ;
13281342
13291343 if ( ! resp . payload || ! resp . timeCaptured || ! resp . timeSynced ) {
You can’t perform that action at this time.
0 commit comments