Add functionality to get an item's files
edif2008 opened this issue · 0 comments
edif2008 commented
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 the list of files that are in an Item.
Since the File object doesn't exist in this SDK yet, we will also create the File object in this issue, according to the API spec.
Tasks to be done
- Create a new file named
itemFile.ts
and implement theItemFile
class. As an inspiration, you can take a look at howItemURLs
is implemented. - Implement
listFiles
function in theItems
class insrc/lib/resources.ts
. The API endpoint that this function needs to call isv1/vaults/vaultId/items/itemId/files
.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./** * Lists all files an Item contains. * * @param {string} vaultId * @param {string} itemQuery * @returns {Promise<ItemFile[]>} * @private */ private async listFiles( vaultId: string, itemQuery: string, ): Promise<ItemFile[]> { // functionality }
- Implement
listFiles
function in OPConnect class insrc/lib/op-connect.ts
:/** * Get a list of files an Item contains. * * @param {string} vaultId * @param {string} itemQuery * @returns {Promise<ItemFile[]>} */ public async listFiles(vaultId: string, itemQuery: string): Promise<ItemFile[]> { return await this.items.listFiles(vaultId, itemQuery); }
- Add a test for the new function in
__test__/op-connect.test.ts
:test("list files", async () => { // actual test here }