connect-sdk-js
connect-sdk-js copied to clipboard
Add functionality to get File by ID
Summary
Starting with Connect 1.3.0, the users can get files that are stored in an Item. Connect Node SDK should enable the users to do that.
In this issue, we will get a file based on its ID.
Tasks to be done
- [ ] Implement
getFilefunction in theItemsclass insrc/lib/resources.ts. The API endpoint that this function needs to call isv1/vaults/vaultId/items/itemId/files/fileId.
Note: Feel free to place this functionality in a separate class (e.g. Files) if you feel it's more suitable. This is just a suggested approach./** * Get an Item's specific File with a matching ID value. * * @param {string} vaultId * @param {string} itemQuery * @param {string} fileId * @returns {Promise<ItemFile>} * @private */ private async getFile( vaultId: string, itemQuery: string, fileId: string, ): Promise<ItemFile> { // functionality } - [ ] Implement
getFilefunction in OPConnect class insrc/lib/op-connect.ts:/** * Get an Item's specific File with a matching ID value. * * @param {string} vaultId * @param {string} itemQuery * @param {string} fileId * @returns {Promise<ItemFile>} */ public async getFile(vaultId: string, itemQuery: string, fileId: string): Promise<ItemFile> { return await this.items.getFile(vaultId, itemQuery); } - [ ] Add a test for the new function in
__test__/op-connect.test.ts:test("get file", async () => { // actual test here }
This issue is blocked by #62