diff options
Diffstat (limited to 'src/Model/Folder/EnhancedFolder.js')
-rw-r--r-- | src/Model/Folder/EnhancedFolder.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Model/Folder/EnhancedFolder.js b/src/Model/Folder/EnhancedFolder.js new file mode 100644 index 0000000..cbc6d8f --- /dev/null +++ b/src/Model/Folder/EnhancedFolder.js @@ -0,0 +1,70 @@ +import Folder from './Folder'; + +export default class EnhancedFolder extends Folder { + + /** + * + * @param {Object} [data={}] + * @param {BasicPasswordsClient} api + */ + constructor(data = {}, api) { + super(data); + this._api = api; + } + + /** + * + * @returns {Server} + */ + getServer() { + return this._api.getServer(); + } + + /** + * + * @returns {Promise<FolderCollection>} + */ + async fetchRevisions() { + if(this.getProperty('revisions') === undefined) { + await this._api.getFolderRepository().findById(this.getId(), 'revisions'); + } + + return this.getProperty('revisions'); + } + + /** + * + * @returns {Promise<PasswordCollection>} + */ + async fetchPasswords() { + if(this.getProperty('passwords') === undefined) { + await this._api.getFolderRepository().findById(this.getId(), 'passwords'); + } + + return this.getProperty('passwords'); + } + + /** + * + * @returns {Promise<FolderCollection>} + */ + async fetchFolders() { + if(this.getProperty('folders') === undefined) { + await this._api.getFolderRepository().findById(this.getId(), 'folders'); + } + + return this.getProperty('folders'); + } + + /** + * + * @returns {Promise<Folder>} + */ + async fetchParent() { + if(this.getProperty('parent') === undefined) { + await this._api.getFolderRepository().findById(this.getId(), 'parent'); + } + + return this.getProperty('parent'); + } +}
\ No newline at end of file |