mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #28] "from_token" is currently not a valid parameter #8
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hrkfdn on GitHub (Nov 11, 2018).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/28
Hey,
thanks for your work on the library. I'm currently trying to search for tracks using rspotify. According to the documentation,
from_tokencan be passed as amarketparameter to search in the market tied to the token.However, the
search_*functions seem to require an Option parameter. There seems to be no Country enum representingfrom_token, unless I am missing something?@hrkfdn commented on GitHub (Nov 11, 2018):
Mhh, or is passing
Noneequivalent tofrom_token?@ramsayleung commented on GitHub (Nov 12, 2018):
Could you show which
search_*function you are using to search for tracks, I am not sure whichfrom_tokenyou are talking about ?@hrkfdn commented on GitHub (Nov 12, 2018):
For instance,
search_track(https://github.com/samrayleung/rspotify/blob/master/src/spotify/client.rs#L420):The documentation states the following for market:
market - An ISO 3166-1 alpha-2 country code or the string from_token.Maybe I misread it? The way I interpreted it, is that
marketeither gets an alpha-2 country code or the literal "from_token", but in the signature the type is declared asOption<Country>. So for me, it was unclear how to set the parameter to derive the market from the token.@ramsayleung commented on GitHub (Nov 13, 2018):
Perhaps you could check this example search_track, every function should have a relative example to demonstrate how to use them. If you have time to check
senum.rs, you could find each country are define as a enum fieldgithub.com/samrayleung/rspotify@f8463a302f/src/spotify/senum.rs (L126), and they all have a relative representation(you call them asAn ISO 3166-1 alpha-2 country code)github.com/samrayleung/rspotify@f8463a302f/src/spotify/senum.rs (L615)@hrkfdn commented on GitHub (Nov 15, 2018):
Yes, I know how to pass a Country enum, but it's not clear how to pass "from_token". The way it is described in the function documentation is not possible, as the "from_token" literal is not a valid parameter for Option.
@Qluxzz commented on GitHub (Jan 8, 2021):
What would be the best course of action if we want to enable using the user tokens country instead of having to supply a country ourselves?
A solution would be a type of Country | FromToken using an enum maybe?
And then using it like this?
As @hrkfdn mentioned, country defaults to US if no country was supplied and country is required, would not "from_token" be a better default here?
@Qluxzz commented on GitHub (Jan 24, 2021):
Any thoughts on this? I'm willing to implement this myself and send a PR but I would need to know which way you would prefer.
@marioortizmanero commented on GitHub (Jan 24, 2021):
Sorry about that. Yes, I think that's the best solution to keep it type-safe. Go ahead and make a PR if you want :)
The API doesn't specify a default value so I'm not sure what you're referring to with defaulting to US. If anything I would just not send that parameter.
@Qluxzz commented on GitHub (Jan 24, 2021):
Sorry, seems like it was only one function that defaulted it to the US while it is optional everywhere else.
github.com/ramsayleung/rspotify@18f2396026/src/client.rs (L329-L332)I feel like defaulting to "from_token" is the better option here.
@marioortizmanero commented on GitHub (Jan 24, 2021):
Yes, I would consider that code snippet wrong; it shouldn't default to the US.
In that case it is a required field for the endpoint, so I just wouldn't use an
Optionat all. Why not just keep it as close as possible to the real API?