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

Exported API has no available client #81

Open
squidpickles opened this issue May 5, 2017 · 8 comments
Open

Exported API has no available client #81

squidpickles opened this issue May 5, 2017 · 8 comments

Comments

@squidpickles
Copy link
Contributor

I've been refactoring my code with recent changes to the library.

One change is that we no longer get our user's name or ID on on_connect(), so I'm trying to call slack::api::users::list to find that information.

The problem is the API calls all require a client implementing the SlackWebRequestSender trait. No such client is exposed either by slack or slack_api. The authentication token also needs to be passed to any function that might want to make an API call.

Would it make sense to have something analogous to the RtmClient that essentially wraps the reqwest::Client and an API token? It's what I would likely implement, but I guess my question is whether there's some other way to access a SlackWebRequestSender that I'm missing.

@dten
Copy link
Contributor

dten commented May 5, 2017

Once connected you can access the start response which contains a lot of the things previously
on the client
https://docs.rs/slack/0.17.1/slack/struct.RtmClient.html#method.start_response

Using the api is currently kind of standalone. You can use reqwest for the api client or impl your own. It was the same before i thought.

@dten
Copy link
Contributor

dten commented May 5, 2017

Docs.rs isn't linking to the type for some reason but it's here https://docs.rs/slack_api/0.16.1/slack_api/rtm/struct.StartResponse.html

@squidpickles
Copy link
Contributor Author

Ah yes, I did see and then forget about that. Thanks.

That solves my particular issue, but I am still at a bit of a loss as to how to access API functions without rolling my own client. Is that possible?

@bwasty
Copy link

bwasty commented May 5, 2017

@squidpickles
Took me quite a while to figure this out, but it seems that the SlackWebRequestSender impl for reqwest only works if the reqwest version in your Cargo.toml matches the one used by slack_api, so 0.4.0 currently.

@dten
Copy link
Contributor

dten commented May 6, 2017

Oh i did have the same problem with versions. If slack api re-exported its one rather than relying on versions matching it would work better i think

@squidpickles
Copy link
Contributor Author

Oh yeah... version mismatch + traits... I have run into that several times before. I don't know why I still don't think to check that. An exported client would help a ton, yes.

@bwasty
Copy link

bwasty commented May 7, 2017

Made a PR: slack-rs/slack-rs-api#42.

@bwasty
Copy link

bwasty commented May 7, 2017

And another one with an example: #82.

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

No branches or pull requests

3 participants