import { checkAssetId , toQueryString } from "../../utils" ; import { SdkClient } from "../common/sdk-client" ; import { TimeSeriesBulkModels } from "./iot-timeseries-bulk-models" ; export class extends SdkClient export class TimeSeriesBulkClient extends SdkClient { private _baseUrl : string = "/api/iottsbulk/v3" ; param { TimeSeriesBulkModels . BulkImportInput } job returns { Promise < TimeSeriesBulkModels . JobStatus > } memberOf public async PostImportJob ( job ) { const result = ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/importJobs` , body : job , message : "PostImportJob" } ) ) as TimeSeriesBulkModels . JobStatus ; this . fixResultsFor3_3_0 ( result ) ; return result ; } param { string } jobId returns { Promise < TimeSeriesBulkModels . JobStatus > } memberOf public async GetJobStatus ( jobId ) { const result = ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/importJobs/${ jobId }` , message : "GetJobStatus" } ) ) as any ; this . fixResultsFor3_3_0 ( result ) ; return result as TimeSeriesBulkModels . JobStatus ; } private fixResultsFor3_3_0 ( result ) { result . id = result . id || result . jobId ; result . startTime = result . startTime || result . jobStartTime ; result . lastModifed = result . lastModifed || result . jobLastModified ; } param { string } entity param { string } propertysetname param { Date } from param { Date } to param { { limit ? : number ; select ? : string ; sort ? : string } } optional returns { Promise < TimeSeriesBulkModels . Timeseries [ ] > } memberOf public async GetTimeSeries ( entity , propertysetname , from , to , optional ? ) { checkAssetId ( entity ) ; const fromto = toQueryString ( { from : from , to : to } ) ; let qs = toQueryString ( optional ) ; if ( qs !== "" ) qs = `&${ qs }` ; return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeseries/${ entity }/${ propertysetname }?${ fromto }${ qs }` , message : "GetTimeSeries" } ) ) as TimeSeriesBulkModels . Timeseries [ ] ; } }