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

rtm-api: add support for custom webClient #1696

Merged
merged 5 commits into from Nov 27, 2023

Conversation

ishangarg0
Copy link
Contributor

Summary

  • Adding optional parameter to get more flexibility with webClient construction

Requirements (place an x in each [ ])

- Update constructor to optionally allow for custom webClient
Copy link

Thanks for the contribution! Before we can merge this, we need @ishangarg0 to sign the Salesforce Inc. Contributor License Agreement.

@mwbrooks mwbrooks added semver:minor enhancement M-T: A feature request for new functionality labels Nov 23, 2023
@mwbrooks mwbrooks added this to the rtm-api@6.2.0 milestone Nov 23, 2023
Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @ishangarg0 🙇🏻

The addition of webClient looks good to me and since rtm-api doesn't have any tests, I don't think we need to add a test.

I'm going to loop in another maintainer to give the PR a second pair of 👀 eyes, in case there was a historical reason to not support custom webClients!

Thanks for the signing the CLA btw 😄

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

How does this new webClient option interact with the slackApiUrl that can be passed into the constructor, which sets the URL that the web client will interact with? If both webClient and slackApiUrl are set, what should this package do?

Assuming we can resolve that question, we should also expand the documentation/reference to describe this. In particular:

  • the reference documentation in the file docs/_reference/rtm-api.md
  • the main package description in the file docs/_packages/rtm_api.md, which maps to what is seen on https://slack.dev/node-slack-sdk/rtm-api

@ishangarg0
Copy link
Contributor Author

The webClient option will take precedence over any of the other arguments passed into the constructor. If the webClient option is not set, then the constructor will use the passed in value for slackApiUrl.

I'll update the documentation if everything looks good.

@filmaj
Copy link
Contributor

filmaj commented Nov 24, 2023

The webClient option will take precedence over any of the other arguments passed into the constructor. If the webClient option is not set, then the constructor will use the passed in value for slackApiUrl.

Sounds good to me, let's just update the docs to reflect this fact. Thank you!

- updated docs to reflect new custom webClient parameter for RTMClient constructor
@ishangarg0
Copy link
Contributor Author

Updated the docs, let me know if there are any details missing. Thanks!

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

LGTM, left some minor formatting / linking / phrasing suggestions. Please ping me once updated and I can review once more and merge if ready.

Thanks a lot for doing this! <3

@@ -644,6 +644,30 @@ const rtm = new RTMClient(token, options);

---

### Custom WebClient

In some cases, you might want flexibility with the WebClient construction beyond the provided RTMClient options
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In some cases, you might want flexibility with the WebClient construction beyond the provided RTMClient options
In some cases, you might want to customize the underlying component making HTTP requests to the Slack API, the [`WebClient`](reference/web-api#webclient), beyond the provided [`RTMClientOptions`](reference/rtm-api#rtmclientoptions). Note that overriding the [`WebClient`](reference/web-api#webclient) instance takes precedence over any other [`RTMClientOptions`](reference/rtm-api#rtmclientoptions) specified.

const webClient = new WebClient(token, options);

// Initialize a client using the configuration
const rtm = new RTMClient(token, {webClient});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const rtm = new RTMClient(token, {webClient});
const rtm = new RTMClient(token, { webClient });

@@ -31,6 +32,13 @@ slug: rtm-api
<td align="center">✗</td>
<td></td>
</tr>
<tr>
<td align="center">webClient</td>
<td align="center"><code><a href="https://github.com/slackapi/node-slack-sdk/blob/main/docs/_reference/web-api.md#webclient" title="">WebClient</a></code></td>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<td align="center"><code><a href="https://github.com/slackapi/node-slack-sdk/blob/main/docs/_reference/web-api.md#webclient" title="">WebClient</a></code></td>
<td align="center"><code><a href="web-api#webclient" title="">WebClient</a></code></td>

Link to hosted docs instead of github

<td align="center">webClient</td>
<td align="center"><code><a href="https://github.com/slackapi/node-slack-sdk/blob/main/docs/_reference/web-api.md#webclient" title="">WebClient</a></code></td>
<td align="center">✗</td>
<td align="center">An optional parameter to provide a customized <a href="https://github.com/slackapi/node-slack-sdk/blob/main/docs/_reference/web-api.md#webclient">WebClient</a>. Any desired options for the custom client must be set in this parameter (<code>webClient</code>) as they will take precedence over other arguments passed into <code>RTMClient</code>.</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<td align="center">An optional parameter to provide a customized <a href="https://github.com/slackapi/node-slack-sdk/blob/main/docs/_reference/web-api.md#webclient">WebClient</a>. Any desired options for the custom client must be set in this parameter (<code>webClient</code>) as they will take precedence over other arguments passed into <code>RTMClient</code>.</td>
<td align="center">An optional parameter to provide a customized <a href="web-api#webclient">WebClient</a>. Any desired options for the custom client must be set in this parameter (<code>webClient</code>) as they will take precedence over other arguments passed into <code>RTMClient</code>.</td>

Link to hosted docs instead of github

- minor formatting, linking, and phrasing updates to rtm-api docs
@ishangarg0
Copy link
Contributor Author

@filmaj Thanks for the suggestions, I pushed the changes let me know how it looks!

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

Looks great, thank you! Gonna let the tests run and then will merge and release 😄

@filmaj filmaj merged commit 62e4570 into slackapi:main Nov 27, 2023
15 checks passed
@ishangarg0 ishangarg0 deleted the rtm-api-patch branch November 27, 2023 18:27
@filmaj
Copy link
Contributor

filmaj commented Nov 27, 2023

This is now live on rtm-api@6.2.0 on npm and on GitHub. Thanks again for your contribution, @ishangarg0 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed enhancement M-T: A feature request for new functionality semver:minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants