import { RouterOSAPI , RosException } from "node-routeros" ; import { RouterOSAPICrud } from "./RosApiCrud" ; import * as Types from "./Types" ; export class RosApiModel extends RouterOSAPICrud { /**
     * The original item before applying the properties in the object
     */ private originalItem : any ; param rosApi param item param snakeCase constructor ( rosApi , item , snakeCase ) { super ( rosApi , item . $$path , snakeCase ) ; this . originalItem = item ; this . dissolveProperties ( ) ; } /**
     * Alias to remove
     */ public delete ( ) { return this . remove ( ) ; } /**
     * Disable itself
     */ public disable ( ) { return super . disable ( this . originalItem . id ) . then ( ( response ) => { return this . refreshData ( response ) ; } ) . catch ( ( err ) => { return Promise . reject ( err ) ; } ) ; } /**
     * Enable itself
     */ public enable ( ) { return super . enable ( this . originalItem . id ) . then ( ( response ) => { return this . refreshData ( response ) ; } ) . catch ( ( err ) => { return Promise . reject ( err ) ; } ) ; } param to public move ( to ? ) { return super . moveEntry ( this . originalItem . id , to ) . then ( ( response ) => { return this . refreshData ( response ) ; } ) . catch ( ( err ) => { return Promise . reject ( err ) ; } ) ; } param properties public unset ( properties ) { return super . unset ( properties , this . originalItem . id ) . then ( ( response ) => { return this . refreshData ( response ) ; } ) . catch ( ( err ) => { return Promise . reject ( err ) ; } ) ; } param data public update ( data ) { return super . update ( data , this . originalItem . id ) . then ( ( response ) => { return this . refreshData ( response ) ; } ) . catch ( ( err ) => { return Promise . reject ( err ) ; } ) ; } /**
     * Removes itself
     */ public remove ( ) { return super . remove ( this . originalItem . id ) ; } param data public set ( data ) { return this . update ( data ) ; } /**
     * Removes all dissolved item properties assigned to
     * this object
     */ private cleanDissolvedProperties ( ) { for ( const property in this . originalItem ) { if ( this . originalItem . hasOwnProperty ( property ) ) { delete this [ property ] ; } } } /**
     * Dissolves all properties of the item into this
     * object
     */ private dissolveProperties ( ) { for ( const property in this . originalItem ) { if ( this . originalItem . hasOwnProperty ( property ) ) { this [ property ] = this . originalItem [ property ] ; } } } /**
     * Refresh this object with new data of the item
     * after printing it again
     */ private refreshData ( response ) { this . cleanDissolvedProperties ( ) ; this . originalItem = response ; this . dissolveProperties ( ) ; return Promise . resolve ( this ) ; } }