import { IODataQuery } from "gd-sprest-def" ; /**
 * OData
 */ export class OData { /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ private _custom ? : string ; private _expand ? : Array < string > ; private _filter ? : string ; private _getAllItems ? : boolean ; private _orderBy ? : Array < string > ; private _select ? : Array < string > ; private _skip ? : number ; private _top ? : number ; /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ constructor ( oData ) { this . _custom = oData && oData . Custom ? oData . Custom : null ; this . _expand = oData && oData . Expand ? oData . Expand : [ ] ; this . _filter = oData && oData . Filter ? oData . Filter : null ; this . _getAllItems = oData && oData . GetAllItems ? oData . GetAllItems : false ; this . _orderBy = oData && oData . OrderBy ? oData . OrderBy : [ ] ; this . _select = oData && oData . Select ? oData . Select : [ ] ; this . _skip = oData && oData . Skip ? oData . Skip : null ; this . _top = oData && oData . Top ? oData . Top : null ; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ get Custom ( ) : string { return this . _custom ; } set Custom ( value ) { this . _custom = value ; } get Expand ( ) : Array < string > { return this . _expand ; } set Expand ( value ) { this . _expand = value ; } get Filter ( ) : string { return this . _filter ; } set Filter ( value ) { this . _filter = value ; } get GetAllItems ( ) : boolean { return this . _getAllItems ; } set GetAllItems ( value ) { this . _getAllItems = value ; } get OrderBy ( ) : Array < string > { return this . _orderBy ; } set OrderBy ( value ) { this . _orderBy = value ; } get QueryString ( ) { let qs = "" ; let values = [ ] ; values . push ( this . getQSValue ( "$select" , this . _select ) ) ; values . push ( this . getQSValue ( "$orderby" , this . _orderBy ) ) ; this . _top ? values . push ( "$top=" + this . _top ) : null ; this . _skip ? values . push ( "$skip=" + this . _skip ) : null ; this . _filter ? values . push ( "$filter=" + this . _filter ) : null ; values . push ( this . getQSValue ( "$expand" , this . _expand ) ) ; this . _custom ? values . push ( this . _custom ) : null ; for ( let value of values ) { if ( value && value != "" ) { qs += ( qs == "" ? "" : "&" ) + value ; } } return qs ; } get Select ( ) : Array < string > { return this . _select ; } set Select ( value ) { this . _select = value ; } get Skip ( ) : number { return this . _skip ; } set Skip ( value ) { this . _skip = value ; } get Top ( ) : number { return this . _top ; } set Top ( value ) { this . _top = value ; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ private getQSValue ( qsKey , keys ? ) { return keys . length > 0 ? qsKey + "=" + keys . join ( "," ) : "" ; } }