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

Remove Rspotify default parameters and add parameter macros #202

Merged
merged 39 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5e21000
lots of unwrap_or removed
marioortizmanero Apr 19, 2021
3d183c6
initial macro
marioortizmanero Apr 19, 2021
eee8ceb
macros
marioortizmanero Apr 19, 2021
8a3fccf
json macro
marioortizmanero Apr 19, 2021
6eacf77
small simplification
marioortizmanero Apr 19, 2021
251e80b
add support for simple parameters
marioortizmanero Apr 19, 2021
60e8628
added docs and tests to macros
marioortizmanero Apr 19, 2021
9311555
fix tests
marioortizmanero Apr 20, 2021
fd4866a
fixed some examples
marioortizmanero Apr 20, 2021
b603d54
cleanup test
marioortizmanero Apr 20, 2021
1f1b609
update changelog
marioortizmanero Apr 20, 2021
fdc6e11
update changelog, test for json
marioortizmanero Apr 20, 2021
1f955b4
update changelog
marioortizmanero Apr 20, 2021
28bc52d
rename to build_*
marioortizmanero Apr 20, 2021
5c8c05f
format
marioortizmanero Apr 20, 2021
f94fbf4
fix clippy
marioortizmanero Apr 20, 2021
b64e085
some fixes and small improvements
marioortizmanero Apr 20, 2021
da41642
some more simplifications
marioortizmanero Apr 20, 2021
3e35987
vec! can be []
marioortizmanero Apr 20, 2021
a0b2d8b
fix incorrect market -> country changes
marioortizmanero Apr 20, 2021
d79ea89
consistent brackets in macros
marioortizmanero Apr 20, 2021
d73239e
now using with_capacity! done :)
marioortizmanero Apr 20, 2021
6c4a9c5
update tests
marioortizmanero Apr 20, 2021
0975391
fix in docs
marioortizmanero Apr 20, 2021
1eef166
rename opt/req to optional/required
marioortizmanero Apr 20, 2021
61d67f3
clarify ident_str
marioortizmanero Apr 20, 2021
657495b
fix syntax notation
marioortizmanero Apr 20, 2021
059343d
at least one parameter is required for the macros
marioortizmanero Apr 20, 2021
53ff617
new macro syntax
marioortizmanero Apr 24, 2021
fd03c3f
update docs
marioortizmanero Apr 24, 2021
439abde
fix lifetimes
marioortizmanero Apr 24, 2021
50bec4c
fix tests
marioortizmanero Apr 24, 2021
65ddd08
apply review suggestions
marioortizmanero Apr 24, 2021
307c946
remove unnecessary type
marioortizmanero Apr 24, 2021
d48b41e
use IntoIterator
marioortizmanero Apr 24, 2021
87eb49c
fix some tests
marioortizmanero Apr 24, 2021
89f3250
somewhat prettier syntax
marioortizmanero Apr 24, 2021
0502157
as_deref is clearer than as_ref
marioortizmanero Apr 24, 2021
0e6173b
fix optional
marioortizmanero Apr 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ If we missed any change or there's something you'd like to discuss about this ve

- Rewritten documentation in hopes that it's easier to get started with Rspotify.
- Reduced the number of examples. Instead of having an example for each endpoint, which is repetitive and unhelpful for newcomers, some real-life examples are now included. If you'd like to add your own example, please do! ([#113](https://github.com/ramsayleung/rspotify/pull/113))
- Rspotify now uses macros internally to make the endpoints as concise as possible and nice to read.
- Add `add_item_to_queue` endpoint.
- Add `category_playlists` endpoint ([#153](https://github.com/ramsayleung/rspotify/pull/153)).
- Fix race condition when using a single client from multiple threads ([#114](https://github.com/ramsayleung/rspotify/pull/114)).
Expand Down Expand Up @@ -84,6 +85,7 @@ If we missed any change or there's something you'd like to discuss about this ve
- ([#189](https://github.com/ramsayleung/rspotify/pull/189)) Add `scopes!` macro to generate scope for `Token` from string literal

**Breaking changes:**
- ([#202](https://github.com/ramsayleung/rspotify/pull/202)) Rspotify now consistently uses `Option<T>` for optional parameters. Those generic over `Into<Option<T>>` have been changed, which makes calling endpoints a bit ugiler but more consistent and simpler.
- `SpotifyClientCredentials` has been renamed to `Credentials` ([#129](https://github.com/ramsayleung/rspotify/pull/129)), and its members `client_id` and `client_secret` to `id` and `secret`, respectively.
- `TokenInfo` has been renamed to `Token`. It no longer has the `token_type` member, as it's always `Bearer` for now ([#129](https://github.com/ramsayleung/rspotify/pull/129)).
- `SpotifyOAuth` has been renamed to `OAuth`. It only contains the necessary parameters for OAuth authorization instead of repeating the items from `Credentials` and `Spotify`, so `client_id`, `client_secret` and `cache_path` are no longer in `OAuth` ([#129](https://github.com/ramsayleung/rspotify/pull/129)).
Expand Down Expand Up @@ -205,11 +207,14 @@ If we missed any change or there's something you'd like to discuss about this ve
+ Rename `ClientError::IO` to `ClientError::Io`
+ Rename `ClientError::CLI` to `ClientError::Cli`
+ Rename `BaseHTTPClient` to `BaseHttpClient`
- [#166](https://github.com/ramsayleung/rspotify/pull/166) [#201](https://github.com/ramsayleung/rspotify/pull/201) Add automatic pagination, which is now enabled by default. You can still use the methods with the `_manual` suffix to have access to manual pagination. There are three new examples for this, check out `examples/pagination*` to learn more!
- ([#166](https://github.com/ramsayleung/rspotify/pull/166) [#201](https://github.com/ramsayleung/rspotify/pull/201)) Add automatic pagination, which is now enabled by default. You can still use the methods with the `_manual` suffix to have access to manual pagination. There are three new examples for this, check out `examples/pagination*` to learn more!

As a side effect, some methods now take references instead of values (so that they can be used multiple times when querying), and the parameters have been reordered so that the `limit` and `offset` are consistently the last two.

The pagination chunk size can be configured with the `Spotify::pagination_chunks` field, which is set to 50 items by default.
- No default values are set from Rspotify now, they will be left to the Spotify API.
- ([#202](https://github.com/ramsayleung/rspotify/pull/202)) Add a `collaborative` parameter to `user_playlist_create`.
- ([#202](https://github.com/ramsayleung/rspotify/pull/202)) Add a `uris` parameter to `playlist_reorder_tracks`.

## 0.10 (2020/07/01)

Expand Down
2 changes: 1 addition & 1 deletion examples/current_user_recently_played.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() {
spotify.prompt_for_user_token().await.unwrap();

// Running the requests
let history = spotify.current_user_recently_played(10).await;
let history = spotify.current_user_recently_played(Some(10)).await;

println!("Response: {:?}", history);
}
2 changes: 1 addition & 1 deletion examples/pagination_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() {
println!("Items:");
loop {
let page = spotify
.current_user_saved_tracks_manual(limit, offset)
.current_user_saved_tracks_manual(Some(limit), Some(offset))
.await
.unwrap();
for item in page.items {
Expand Down
4 changes: 1 addition & 3 deletions examples/ureq/device.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use rspotify::client::SpotifyBuilder;
use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
use rspotify::scope;

use std::collections::HashSet;
use rspotify::scopes;

fn main() {
// You can use any logger for debugging.
Expand Down
4 changes: 1 addition & 3 deletions examples/ureq/me.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use rspotify::client::SpotifyBuilder;
use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
use rspotify::scope;

use std::collections::HashSet;
use rspotify::scopes;

fn main() {
// You can use any logger for debugging.
Expand Down
29 changes: 17 additions & 12 deletions examples/ureq/search.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use rspotify::client::SpotifyBuilder;
use rspotify::model::{Country, Market, SearchType};
use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
use rspotify::scope;

use std::collections::HashSet;
use rspotify::scopes;

fn main() {
// You can use any logger for debugging.
Expand Down Expand Up @@ -47,7 +45,7 @@ fn main() {
spotify.request_client_token().unwrap();

let album_query = "album:arrival artist:abba";
let result = spotify.search(album_query, SearchType::Album, 10, 0, None, None);
let result = spotify.search(album_query, SearchType::Album, None, None, Some(10), None);
match result {
Ok(album) => println!("searched album:{:?}", album),
Err(err) => println!("search error!{:?}", err),
Expand All @@ -57,10 +55,10 @@ fn main() {
let result = spotify.search(
artist_query,
SearchType::Artist,
10,
0,
Some(Market::Country(Country::UnitedStates)),
None,
Some(10),
None,
);
match result {
Ok(album) => println!("searched artist:{:?}", album),
Expand All @@ -71,10 +69,10 @@ fn main() {
let result = spotify.search(
playlist_query,
SearchType::Playlist,
10,
0,
Some(Market::Country(Country::UnitedStates)),
None,
Some(10),
None,
);
match result {
Ok(album) => println!("searched playlist:{:?}", album),
Expand All @@ -85,25 +83,32 @@ fn main() {
let result = spotify.search(
track_query,
SearchType::Track,
10,
0,
Some(Market::Country(Country::UnitedStates)),
None,
Some(10),
None,
);
match result {
Ok(album) => println!("searched track:{:?}", album),
Err(err) => println!("search error!{:?}", err),
}

let show_query = "love";
let result = spotify.search(show_query, SearchType::Show, 10, 0, None, None);
let result = spotify.search(show_query, SearchType::Show, None, None, Some(10), None);
match result {
Ok(show) => println!("searched show:{:?}", show),
Err(err) => println!("search error!{:?}", err),
}

let episode_query = "love";
let result = spotify.search(episode_query, SearchType::Episode, 10, 0, None, None);
let result = spotify.search(
episode_query,
SearchType::Episode,
None,
None,
Some(10),
None,
);
match result {
Ok(episode) => println!("searched episode:{:?}", episode),
Err(err) => println!("search error!{:?}", err),
Expand Down
Loading