tidalv2 0.3.0

Rust client library for TIDAL's v2 JSON:API - type-safe access to TIDAL's music catalog and streaming services
Documentation
/*
 * TIDAL API - Beta
 *
 * TIDAL API is a [JSON:API](https://jsonapi.org/) Web API that gives access to TIDAL functionality and data.
 *
 * The version of the OpenAPI document: 0.1.76
 *
 * Generated by: https://openapi-generator.tech
 */

use super::{Error, client};
use crate::models::*;

use reqwest;

impl client::TidalClient {
    /// Retrieves multiple artistRoles by available filters, or without if applicable.
    ///
    /// # Parameters
    /// * `filter_id` - Allows to filter the collection of resources based on id attribute value (e.g. "1")
    pub async fn artist_role_list(
        &self,
        filter_id: Option<Vec<String>>,
    ) -> Result<MultiResource<artist_role::ArtistRole>, Error> {
        // add a prefix to parameters to efficiently prevent name collisions
        let p_filter_id = filter_id;

        let uri_str = format!("{}/artistRoles", self.base_path_api);
        let mut req_builder = self.client.request(reqwest::Method::GET, &uri_str);

        if let Some(ref param_value) = p_filter_id {
            req_builder = req_builder.query(
                &param_value
                    .iter()
                    .map(|p| ("filter[id]".to_owned(), p.to_string()))
                    .collect::<Vec<(std::string::String, std::string::String)>>(),
            );
        }

        self.execute_request(req_builder).await
    }

    /// Retrieves single artistRole by id.
    ///
    /// # Parameters
    /// * `id` - Artist role id (e.g. "1")
    pub async fn artist_role_get(
        &self,
        id: &str,
    ) -> Result<Resource<artist_role::ArtistRole>, Error> {
        // add a prefix to parameters to efficiently prevent name collisions
        let p_id = id;

        let uri_str = format!(
            "{}/artistRoles/{id}",
            self.base_path_api,
            id = crate::apis::urlencode(p_id)
        );
        let req_builder = self.client.request(reqwest::Method::GET, &uri_str);

        self.execute_request(req_builder).await
    }
}