/*
 * Isilon SDK
 *
 * Isilon SDK - Language bindings for the OneFS API
 *
 * OpenAPI spec version: 5
 * Contact: sdk@isilon.com
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

use std::borrow::Borrow;
use std::rc::Rc;

use futures;
use futures::Future;
use hyper;

use super::{configuration, query, Error};

pub struct IdResolutionApiClient<C: hyper::client::connect::Connect> {
    configuration: Rc<configuration::Configuration<C>>,
}

impl<C: hyper::client::connect::Connect> IdResolutionApiClient<C> {
    pub fn new(configuration: Rc<configuration::Configuration<C>>) -> IdResolutionApiClient<C> {
        IdResolutionApiClient {
            configuration: configuration,
        }
    }
}

pub trait IdResolutionApi {
    fn get_id_resolution_path(
        &self,
        id_resolution_path_id: i32,
    ) -> Box<dyn Future<Item = crate::models::IdResolutionPaths, Error = Error>>;
    fn get_id_resolution_paths(
        &self,
        sort: &str,
        lins: &str,
        limit: i32,
        dir: &str,
        resume: &str,
    ) -> Box<dyn Future<Item = crate::models::IdResolutionPathsExtended, Error = Error>>;
}

impl<C: hyper::client::connect::Connect + 'static> IdResolutionApi for IdResolutionApiClient<C> {
    fn get_id_resolution_path(
        &self,
        id_resolution_path_id: i32,
    ) -> Box<dyn Future<Item = crate::models::IdResolutionPaths, Error = Error>> {
        let uri_str = format!(
            "{}/platform/4/id-resolution/paths/{IdResolutionPathId}",
            self.configuration.base_path,
            IdResolutionPathId = id_resolution_path_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_id_resolution_paths(
        &self,
        sort: &str,
        lins: &str,
        limit: i32,
        dir: &str,
        resume: &str,
    ) -> Box<dyn Future<Item = crate::models::IdResolutionPathsExtended, Error = Error>> {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("sort", &sort.to_string())
            .append_pair("lins", &lins.to_string())
            .append_pair("limit", &limit.to_string())
            .append_pair("dir", &dir.to_string())
            .append_pair("resume", &resume.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/4/id-resolution/paths?{}",
            self.configuration.base_path, q
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }
}
