fn authenticate<'a>(client: &'a Client,
                    http_method: &HttpMethod,
                    endpoint: Endpoint,
                    method: Method,
                    credentials: Option<&Credentials>)
                    -> RequestBuilder<'a> {

    let url = format!("{}?method={}", endpoint.to_string(), method.to_string());
    let mut url = Url::parse(&url).unwrap();

    if let Some(credentials) = credentials {
        use std::collections::BTreeMap;
        let mut query_pairs: BTreeMap<&str, &str> = BTreeMap::new();
        if let Some(partner_auth_token) = credentials.partner_auth_token() {
            query_pairs.insert("auth_token", partner_auth_token);
        }
        if let Some(user_auth_token) = credentials.user_auth_token() {
            query_pairs.insert("auth_token", user_auth_token);
        }
        if let Some(partner_id) = credentials.partner_id() {
            query_pairs.insert("partner_id", partner_id);
        }
        if let Some(user_id) = credentials.user_id() {
            query_pairs.insert("user_id", user_id);
        }
        url.query_pairs_mut().extend_pairs(query_pairs);
    }

    debug!("== URL ==\n{:?}", url);
    client.request(http_method.clone(), url)
}
/// Returns a RequestBuilder with the HTTP method and URL set. The URL query string
/// will include the auth information if credentials were provided.
Returns a RequestBuilder with the HTTP method and URL set. The URL query string
will include the auth information if credentials were provided.
Returns a RequestBuilder with the HTTP method and URL set . The URL query string will include the auth information if credentials were provided .
fn authenticate<'a>(client: &'a Client,
                    http_method: &HttpMethod,
                    endpoint: Endpoint,
                    method: Method,
                    credentials: Option<&Credentials>)
                    -> RequestBuilder<'a> {
    let url = format!("{}?method={}", endpoint.to_string(), method.to_string());
    let mut url = Url::parse(&url).unwrap();
    if let Some(credentials) = credentials {
        use std::collections::BTreeMap;
        let mut query_pairs: BTreeMap<&str, &str> = BTreeMap::new();
        if let Some(partner_auth_token) = credentials.partner_auth_token() {
            query_pairs.insert("auth_token", partner_auth_token);
        }
        if let Some(user_auth_token) = credentials.user_auth_token() {
            query_pairs.insert("auth_token", user_auth_token);
        }
        if let Some(partner_id) = credentials.partner_id() {
            query_pairs.insert("partner_id", partner_id);
        }
        if let Some(user_id) = credentials.user_id() {
            query_pairs.insert("user_id", user_id);
        }
        url.query_pairs_mut().extend_pairs(query_pairs);
    }
    debug!("== URL ==\n{:?}", url);
    client.request(http_method.clone(), url)
}
fn authenticate < ' a > ( client : & ' a Client , http_method : & HttpMethod , endpoint : Endpoint , method : Method , credentials : Option < & Credentials > ) -> RequestBuilder < ' a > { let url = format ! ( " " endpoint to_string ( ) method to_string ( ) ) ; let mut url = Url :: parse ( & url ) . unwrap ( ) ; if let Some ( credentials ) = credentials { use std :: collections :: BTreeMap ; let mut query_pairs : BTreeMap < & str , & str > = BTreeMap :: new ( ) ; if let Some ( partner_auth_token ) = credentials . partner_auth_token ( ) { query_pairs . insert ( " " , partner_auth_token ) ; } if let Some ( user_auth_token ) = credentials . user_auth_token ( ) { query_pairs . insert ( " " , user_auth_token ) ; } if let Some ( partner_id ) = credentials . partner_id ( ) { query_pairs . insert ( " " , partner_id ) ; } if let Some ( user_id ) = credentials . user_id ( ) { query_pairs . insert ( " " , user_id ) ; } url . query_pairs_mut ( ) . extend_pairs ( query_pairs ) ; } debug ! ( " \n " url ) ; client . request ( http_method . clone ( ) , url ) }
Returns a RequestBuilder with the HTTP method and URL set.
Returns a RequestBuilder with the HTTP method and URL set .
client
&'a Client
http_method
&HttpMethod
endpoint
Endpoint
method
Method
credentials
Option<&Credentials>
client
&'a Client
http_method
&HttpMethod
endpoint
Endpoint
method
Method
credentials
Option<&Credentials>