seven_client/
validate_for_voice.rs

1use crate::client::Client;
2use ureq::{Error};
3use serde::{Deserialize};
4
5#[derive(Deserialize)]
6pub struct ValidateForVoiceResponse {
7    pub code: Option<String>,
8    pub error: Option<String>,
9    pub formatted_output: Option<String>,
10    pub id: Option<u64>,
11    pub sender: Option<String>,
12    pub success: bool,
13    pub voice: Option<bool>,
14}
15
16#[derive(Default)]
17pub struct ValidateForVoiceParams {
18    pub callback: Option<String>,
19    pub number: String,
20}
21
22pub struct ValidateForVoice {
23    client: Client
24}
25
26impl ValidateForVoice {
27    pub fn new(client: Client) -> Self {
28        ValidateForVoice {
29            client,
30        }
31    }
32
33    pub fn post(&self, params: ValidateForVoiceParams) -> Result<ValidateForVoiceResponse, Error> {
34        Ok(self.client.request("POST", "validate_for_voice")
35            .send_form(&[
36                ("callback", &*params.callback.unwrap_or_default()),
37                ("number", &*params.number),
38            ])?
39            .into_json::<ValidateForVoiceResponse>()?
40        )
41    }
42}