export class WebApiMock implements Xrm . WebApi { public online : Xrm . WebApiOnline ; public offline : Xrm . WebApiOffline ; private clientContext : Xrm . ClientContext ; private isOffline : boolean ; constructor ( clientContext , online , offline ) { this . online = online ; this . offline = offline ; this . clientContext = clientContext ; this . isOffline = clientContext . getClientState ( ) === "Offline" ; } public createRecord ( entityLogicalName , record ) { if ( this . isOffline ) { return this . offline . createRecord ( entityLogicalName , record ) ; } else { return this . online . createRecord ( entityLogicalName , record ) ; } } public deleteRecord ( entityLogicalName , id ) { if ( this . isOffline ) { return this . offline . deleteRecord ( entityLogicalName , id ) ; } else { return this . online . deleteRecord ( entityLogicalName , id ) ; } } public retrieveRecord ( entityLogicalName , id , options ) { if ( this . isOffline ) { return this . offline . retrieveRecord ( entityLogicalName , id , options ) ; } else { return this . online . retrieveRecord ( entityLogicalName , id , options ) ; } } public retrieveMultipleRecords ( entityLogicalName , options ? , maxPageSize ? ) { if ( this . isOffline ) { return this . offline . retrieveMultipleRecords ( entityLogicalName , options , maxPageSize ) ; } else { return this . online . retrieveMultipleRecords ( entityLogicalName , options , maxPageSize ) ; } } public updateRecord ( entityLogicalName , id , data ) { if ( this . isOffline ) { return this . offline . updateRecord ( entityLogicalName , id , data ) ; } else { return this . online . updateRecord ( entityLogicalName , id , data ) ; } } public isAvailableOffline ( entityLogicalName ) { throw new Error ( "xrm-mock doesn\'t yet implement metadata features." ) ; } }