connect-sdk-js icon indicating copy to clipboard operation
connect-sdk-js copied to clipboard

Add functionality to get a File's content

Open edif2008 opened this issue 3 years ago • 1 comments

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's content.

Tasks to be done

  • [ ] Implement getFileContent function in the Items class in src/lib/resources.ts. The API endpoint that this function needs to call is v1/vaults/vaultId/items/itemId/files/fileId/content. You'll have to figure out the object type the promise expects.
    /**
     * Get an Item File's content.
     *
     * @param {string} vaultId
     * @param {string} itemQuery
     * @param {string} fileId
     * @returns {Promise<>}
     * @private
     */
    private async getFileContent(
             vaultId: string,
             itemQuery: string,
             fileId: string,
         ): Promise<> {
         // functionality
    }
    
    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.
  • [ ] Implement getFileContent function in OPConnect class in src/lib/op-connect.ts:
    /**
     * Get an Item File's content.
     *
     * @param {string} vaultId
     * @param {string} itemQuery
     * @param {string} fileId
     * @returns {Promise<>}
     */
    public async getFileContent(vaultId: string, itemQuery: string, fileId: string): Promise<> {
          return await this.items.getFileContent(vaultId, itemQuery, fileId);
    }
    
  • [ ] Add a test for the new function in __test__/op-connect.test.ts:
    test("get file content", async () => {
        // actual test here
    }
    

edif2008 avatar Jul 15 '22 12:07 edif2008

This issue is blocked by #62

edif2008 avatar Jul 15 '22 12:07 edif2008