Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to get multiple items by a title #58

Closed
3 tasks done
edif2008 opened this issue Jul 15, 2022 · 0 comments · Fixed by #70
Closed
3 tasks done

Add functionality to get multiple items by a title #58

edif2008 opened this issue Jul 15, 2022 · 0 comments · Fixed by #70

Comments

@edif2008
Copy link
Member

edif2008 commented Jul 15, 2022

Summary

We want to enhance the way users can get items when using the Connect Node SDK. In this issue, we want to enable users to get a list of items that have the given title.

Tasks to be done

  • Implement listItemsByTitle function in the Items class in src/lib/resources.ts. Important note: The API response returns an Item summary, not the full item, therefore once you get the list of item summaries, for each item you have to call getItemById.
    /**
     * Search for all Items with an exact match on title.
     *
     * @param {string} title
     * @returns {Promise<FullItem[]>}
     * @private
     */
    private async listItemssByTitle(
             vaultId: string,
             title: string,
         ): Promise<Response> {
         // functionality
    }
    Tip: You can move this snippet from get to listItemsByTitle and then call listItemsByTitle in get. In this way, you avoid duplicate code in the two function.
  • Implement listItemsByTitle function in OPConnect class in src/lib/op-connect.ts:
    /**
     * Returns a list of Items with a matching Title value.
     *
     * @param {string} vaultId
     * @param {string} itemTitle
     * @returns {Promise<FullItem[]>}
     */
    public async listItemsByTitle(vaultId: string, itemTitle: string): Promise<FullItem[]> {
          return await this.items.listItemsByTitle(vaultId, itemTitle);
    }
  • Add a test for the new function in __test__/op-connect.test.ts below get item test case:
    test("list items by titte", async () => {
        // actual test here
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant