rtm-api: add support for custom webClient#1696
Conversation
- Update constructor to optionally allow for custom webClient
This reverts commit 9a842ee.
|
Thanks for the contribution! Before we can merge this, we need @ishangarg0 to sign the Salesforce Inc. Contributor License Agreement. |
mwbrooks
left a comment
There was a problem hiding this comment.
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 😄
filmaj
left a comment
There was a problem hiding this comment.
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
|
The I'll update the documentation if everything looks good. |
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
|
Updated the docs, let me know if there are any details missing. Thanks! |
filmaj
left a comment
There was a problem hiding this comment.
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
|
|
||
| ### Custom WebClient | ||
|
|
||
| In some cases, you might want flexibility with the WebClient construction beyond the provided RTMClient options |
There was a problem hiding this comment.
| 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}); |
There was a problem hiding this comment.
| const rtm = new RTMClient(token, {webClient}); | |
| const rtm = new RTMClient(token, { webClient }); |
| </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> |
There was a problem hiding this comment.
| <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> |
There was a problem hiding this comment.
| <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
|
@filmaj Thanks for the suggestions, I pushed the changes let me know how it looks! |
filmaj
left a comment
There was a problem hiding this comment.
Looks great, thank you! Gonna let the tests run and then will merge and release 😄
|
This is now live on [email protected] on npm and on GitHub. Thanks again for your contribution, @ishangarg0 ! |
Summary
Requirements (place an
xin each[ ])