MB API requests as references
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 2m1s
Cargo CI / Lint (pull_request) Successful in 1m9s

This commit is contained in:
Wojciech Kozlowski 2024-09-29 16:50:24 +02:00
parent 70e510a1de
commit 2d88e45d25
7 changed files with 17 additions and 17 deletions

View File

@ -62,7 +62,7 @@ fn main() {
}
let response = client
.lookup_artist(request)
.lookup_artist(&request)
.expect("failed to make API call");
println!("{response:#?}");
@ -72,7 +72,7 @@ fn main() {
let request = LookupReleaseGroupRequest::new(&mbid);
let response = client
.lookup_release_group(request)
.lookup_release_group(&request)
.expect("failed to make API call");
println!("{response:#?}");

View File

@ -107,7 +107,7 @@ fn main() {
println!("Query: {query}");
let matches = client
.search_artist(query)
.search_artist(&query)
.expect("failed to make API call");
println!("{matches:#?}");
@ -139,7 +139,7 @@ fn main() {
println!("Query: {query}");
let matches = client
.search_release_group(query)
.search_release_group(&query)
.expect("failed to make API call");
println!("{matches:#?}");

View File

@ -14,7 +14,7 @@ use super::{MbArtistMeta, MbReleaseGroupMeta, SerdeMbArtistMeta, SerdeMbReleaseG
impl<Http: IMusicBrainzHttp> MusicBrainzClient<Http> {
pub fn lookup_artist(
&mut self,
request: LookupArtistRequest,
request: &LookupArtistRequest,
) -> Result<LookupArtistResponse, Error> {
let mut include: Vec<String> = vec![];
@ -35,7 +35,7 @@ impl<Http: IMusicBrainzHttp> MusicBrainzClient<Http> {
pub fn lookup_release_group(
&mut self,
request: LookupReleaseGroupRequest,
request: &LookupReleaseGroupRequest,
) -> Result<LookupReleaseGroupResponse, Error> {
let url = format!(
"{MB_BASE_URL}/release-group/{mbid}",
@ -177,7 +177,7 @@ mod tests {
let mbid: Mbid = "00000000-0000-0000-0000-000000000000".try_into().unwrap();
let mut request = LookupArtistRequest::new(&mbid);
request.include_release_groups();
let result = client.lookup_artist(request).unwrap();
let result = client.lookup_artist(&request).unwrap();
assert_eq!(result, response);
}
@ -214,7 +214,7 @@ mod tests {
let mbid: Mbid = "00000000-0000-0000-0000-000000000000".try_into().unwrap();
let request = LookupReleaseGroupRequest::new(&mbid);
let result = client.lookup_release_group(request).unwrap();
let result = client.lookup_release_group(&request).unwrap();
assert_eq!(result, response);
}

View File

@ -128,7 +128,7 @@ mod tests {
let query = SearchArtistRequest::new().string(name);
let matches = client.search_artist(query).unwrap();
let matches = client.search_artist(&query).unwrap();
assert_eq!(matches, response);
}
}

View File

@ -27,7 +27,7 @@ macro_rules! impl_search_entity {
paste! {
pub fn [<search_ $name:snake>](
&mut self,
query: [<Search $name Request>]
query: &[<Search $name Request>]
) -> Result<[<Search $name Response>], Error> {
let query: String =
form_urlencoded::byte_serialize(format!("{query}").as_bytes()).collect();

View File

@ -161,7 +161,7 @@ mod tests {
let query = SearchReleaseGroupRequest::new().string(title);
let matches = client.search_release_group(query).unwrap();
let matches = client.search_release_group(&query).unwrap();
assert_eq!(matches, response);
}
@ -198,7 +198,7 @@ mod tests {
.and()
.first_release_date(&date);
let matches = client.search_release_group(query).unwrap();
let matches = client.search_release_group(&query).unwrap();
assert_eq!(matches, response);
}
@ -226,7 +226,7 @@ mod tests {
let query = SearchReleaseGroupRequest::new().rgid(&rgid);
let matches = client.search_release_group(query).unwrap();
let matches = client.search_release_group(&query).unwrap();
assert_eq!(matches, response);
}
}

View File

@ -41,7 +41,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
fn lookup_artist(&mut self, mbid: &Mbid) -> Result<Lookup<ArtistMeta>, Error> {
let request = LookupArtistRequest::new(mbid);
let mb_response = self.client.lookup_artist(request)?;
let mb_response = self.client.lookup_artist(&request)?;
Ok(from_lookup_artist_response(mb_response))
}
@ -49,7 +49,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
fn lookup_release_group(&mut self, mbid: &Mbid) -> Result<Lookup<AlbumMeta>, Error> {
let request = LookupReleaseGroupRequest::new(mbid);
let mb_response = self.client.lookup_release_group(request)?;
let mb_response = self.client.lookup_release_group(&request)?;
Ok(from_lookup_release_group_response(mb_response))
}
@ -57,7 +57,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
fn search_artist(&mut self, artist: &ArtistMeta) -> Result<Vec<Match<ArtistMeta>>, Error> {
let query = SearchArtistRequest::new().string(&artist.id.name);
let mb_response = self.client.search_artist(query)?;
let mb_response = self.client.search_artist(&query)?;
Ok(mb_response
.artists
@ -82,7 +82,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
.and()
.release_group(&album.id.title);
let mb_response = self.client.search_release_group(query)?;
let mb_response = self.client.search_release_group(&query)?;
Ok(mb_response
.release_groups