import { toQueryString } from "../../utils" ; import { SdkClient } from "../common/sdk-client" ; import { DataExchangeModels } from "./data-exchange-models" ; import { dataExchangeTemplate , putFileTemplate } from "./data-exchange-template" ; export class extends SdkClient export class DataExchangeClient extends SdkClient { private _baseUrl : string = "/api/dataexchange/v3" ; param { DataExchangeModels . ResourcePatch } metadata param { Buffer } file returns { Promise < DataExchangeModels . File > } memberOf public async PostFile ( metadata , file ) { const body = dataExchangeTemplate ( metadata , file ) ; const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files` , body : body , multiPartFormData : true , additionalHeaders : { enctype : "multipart/form-data" } , } ) ; return result as DataExchangeModels . File ; } param { string } id returns { Promise < Response > } memberOf public async GetFile ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files/${ id }` , additionalHeaders : { "Content-Type" : "application/octet-stream" } , rawResponse : true , } ) ; return result as Response ; } param { string } id param { Buffer } file returns { Promise < DataExchangeModels . File > } memberOf public async PutFile ( id , file ) { const body = putFileTemplate ( file ) ; const result = await this . HttpAction ( { verb : "PUT" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files/${ id }` , body : body , multiPartFormData : true , additionalHeaders : { enctype : "multipart/form-data" } , } ) ; return result as DataExchangeModels . File ; } param { string } id memberOf public async DeleteFile ( id ) { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files/${ id }` , noResponse : true , } ) ; } param { string } id returns { Promise < DataExchangeModels . File > } memberOf public async GetFileProperties ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files/${ id }/properties` , additionalHeaders : { "Content-Type" : "application/json" } , } ) ; return result as DataExchangeModels . File ; } param { string } id param { DataExchangeModels . ResourcePatch } options returns { Promise < DataExchangeModels . File > } memberOf public async PatchFileProperties ( id , options ) { const result = await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/files/${ id }/properties` , body : options , } ) ; return result as DataExchangeModels . File ; } param { DataExchangeModels . ResourcePatch } metadata returns { Promise < DataExchangeModels . Directory > } memberOf public async PostDirectory ( metadata ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/directories` , body : metadata , } ) ; return result as DataExchangeModels . Directory ; } param { string } id returns { Promise < DataExchangeModels . Directory > } memberOf public async GetDirectoryProperties ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/directories/${ id }/properties` , additionalHeaders : { "Content-Type" : "application/json" } , } ) ; return result as DataExchangeModels . Directory ; } param { string } id param { DataExchangeModels . ResourcePatch } options returns { Promise < DataExchangeModels . Directory > } memberOf public async PatchDirectoryProperties ( id , options ) { const result = await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/directories/${ id }/properties` , body : options , } ) ; return result as DataExchangeModels . Directory ; } param { string } id param { { pageNumber ? : number ; pageSize ? : number ; filter : string } } params returns { Promise < DataExchangeModels . DirectoriesFilesArray > } memberOf public async GetDirectory ( id , params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/directories/${ id }?${ toQueryString ( parameters ) }` , } ) ; return result as DataExchangeModels . DirectoriesFilesArray ; } param { string } id param { { recursive ? : boolean } } params param params . recursive memberOf public async DeleteDirectory ( id , params ? ) { const parameters = params || { } ; await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/directories/${ id }?${ toQueryString ( parameters ) }` , noResponse : true , } ) ; } }