Skip to content

Update query parameters and add documentation #11

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

Merged
merged 7 commits into from
Jan 17, 2025

Conversation

brandoncharnesky
Copy link
Contributor

@brandoncharnesky brandoncharnesky commented Jan 11, 2025

Overview

Add a query parameter example
Update the way query parameters are handled in getFromApi
Add documentation directly to the dotenv.sample

Security

REMINDER: All file contents are public.

  • I have ensured no secure credentials or sensitive information remain in code, metadata, comments, etc.
  • There are no temporary testing changes committed such as API base URLs, access tokens, print/log statements, etc.
  • These changes do not introduce any security risks, or any such risks have been properly mitigated.

Describe briefly what security risks you considered, why they don't apply, or how they've been mitigated.

  • Used made up GUIDs for example

Consider "Squash and merge" as needed to keep the commit history reasonable on main.

Reviewers

Assign to the appropriate reviewer(s). Minimally, a second set of eyes is needed ensure no non-public information is published. Consider also including:

  • Subject-matter experts
  • Style/editing reviewers
  • Others requested by the content owner

@brandoncharnesky brandoncharnesky requested review from explunit and lynnfaraday and removed request for explunit January 11, 2025 00:04
@github-actions github-actions bot added the cc/publicinfo/mdh Public content changes for MDH and Designer label Jan 11, 2025
dotenv.sample Outdated
RKS_SERVICE_ACCOUNT=
# The Project GUID
#
# Found in MyDataHelpsDesigner via Projects -> About Settings -> Project ID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general note at the top, but these specific instructions may change, and nobody's going to remember to update them here. I think it's better to just point them at the readme.

We could improve the readme though if you think it's unclear. Maybe link each line item in the bullet points to the specific sections rather than having the note underneath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all of this in favor of one line to remind about the readme

dotenv.sample Outdated
#
# Found in MyDataHelpsDesigner via Projects -> About Settings -> Project ID
#
RKS_PROJECT_ID="361e1234-8c15-78ae-1234-3b70d33023d6"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better not to have concrete examples here since someone might think they're real. If you want to make it something generic like "YOUR_PROJECT_ID" or "YOUR_ACCOUNT_NAME" that's fine, or just leave them blank.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

quickstart.js Outdated
@@ -54,14 +54,15 @@ async function getServiceAccessToken() {

async function getFromApi(serviceAccessToken, resourceUrl, queryParams = {}, raiseError = true) {

const url = `${baseUrl}${resourceUrl}`
const url = new URL(`${baseUrl}${resourceUrl}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. I think there's a slightly more straightforward way to do this:

async function getFromApi(serviceAccessToken, resourceUrl, queryParams = null, raiseError = true) {

  const queryString = queryParams ? `?${new URLSearchParams(queryParams)}` : '';
  const url = `${baseUrl}${resourceUrl}${queryString}`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

quickstart.js Outdated
@@ -104,6 +105,7 @@ function logResponse(response) {
async function quickstart() {
var url;
var response;
var queryParams = {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing example was to illustrate getting all participants, so we don't want to add the query param to that one.

I think now that you've fixed it, it'll be pretty obvious how to do a call with a query param and we don't need a specific example. But if you want to include one, you should add a new example at the end, after the existing ones. (maybe a participant search by name or something)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the queryParams var is no longer used now and can also be removed.

@lynnfaraday
Copy link
Collaborator

@brandoncharnesky Please tick off the security checklist boxes in the PR description if they're completed.

@brandoncharnesky
Copy link
Contributor Author

Thank you for the feedback!

quickstart.js Outdated
const url = `${baseUrl}${resourceUrl}`
const queryString = queryParams ? `?${new URLSearchParams(queryParams)}` : '';
const url = `${baseUrl}${resourceUrl}${queryString}`;
console.log(url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either remove this log or add some clarity text if you feel it's important for debugging. Like: "Calling ${url}"

@brandoncharnesky brandoncharnesky merged commit 857947b into main Jan 17, 2025
1 check passed
@brandoncharnesky brandoncharnesky deleted the bmc/query-parameters branch January 17, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc/publicinfo/mdh Public content changes for MDH and Designer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants