1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * ApproveAPISwagger
 *
 * The simple API to request a user's approval on anything via email + sms.
 *
 * OpenAPI spec version: 1.0.1
 * Contact: dev@approveapi.com
 * Generated by: https://openapi-generator.tech
 */

use std::sync::Arc;
use std::borrow::Borrow;

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

use super::{Error, configuration};
use super::request as __internal_request;

pub struct ApproveApiClient<C: hyper::client::connect::Connect + 'static> {
    configuration: Arc<configuration::Configuration<C>>,
}

impl<C: hyper::client::connect::Connect + 'static> ApproveApiClient<C> {
    pub fn new(configuration: Arc<configuration::Configuration<C>>) -> ApproveApiClient<C> {
        ApproveApiClient {
            configuration: configuration,
        }
    }
}

pub trait ApproveApi {
    fn create_prompt(&self, create_prompt_request: ::models::CreatePromptRequest) -> Box<Future<Item = ::models::Prompt, Error = Error<serde_json::Value>> + Send>;
    fn get_prompt(&self, id: &str, long_poll: bool) -> Box<Future<Item = ::models::Prompt, Error = Error<serde_json::Value>> + Send>;
    fn get_prompt_status(&self, id: &str) -> Box<Future<Item = ::models::PromptStatus, Error = Error<serde_json::Value>> + Send>;
}


impl<C: hyper::client::connect::Connect + 'static>ApproveApi for ApproveApiClient<C> {
    fn create_prompt(&self, create_prompt_request: ::models::CreatePromptRequest) -> Box<Future<Item = ::models::Prompt, Error = Error<serde_json::Value>> + Send> {
        __internal_request::Request::new(hyper::Method::POST, "/prompt".to_string())
            .with_auth(__internal_request::Auth::Basic)
            .with_body_param(create_prompt_request)
            .execute(self.configuration.borrow())
    }

    fn get_prompt(&self, id: &str, long_poll: bool) -> Box<Future<Item = ::models::Prompt, Error = Error<serde_json::Value>> + Send> {
        __internal_request::Request::new(hyper::Method::GET, "/prompt/{id}".to_string())
            .with_auth(__internal_request::Auth::Basic)
            .with_query_param("long_poll".to_string(), long_poll.to_string())
            .with_path_param("id".to_string(), id.to_string())
            .execute(self.configuration.borrow())
    }

    fn get_prompt_status(&self, id: &str) -> Box<Future<Item = ::models::PromptStatus, Error = Error<serde_json::Value>> + Send> {
        __internal_request::Request::new(hyper::Method::GET, "/prompt/{id}/status".to_string())
            .with_path_param("id".to_string(), id.to_string())
            .execute(self.configuration.borrow())
    }

}