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
//! EPP commands relating to nominet specific features

use super::{fee, CommandResponse, RequestMessage, Sender};

#[derive(Debug)]
pub struct RestoreRequest {
    pub(super) name: String,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub return_path: Sender<RestoreResponse>,
}

/// Response to a RGP query
#[derive(Debug)]
pub struct RestoreResponse {
    pub pending: bool,
    pub transaction_id: String,
    pub state: Vec<RGPState>,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
}

#[derive(Debug, PartialEq, Eq)]
pub enum RGPState {
    Unknown,
    AddPeriod,
    AutoRenewPeriod,
    RenewPeriod,
    TransferPeriod,
    RedemptionPeriod,
    PendingRestore,
    PendingDelete,
}

/// Checks if a domain name
///
/// # Arguments
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn request(
    domain: &str,
    donuts_fee_agreement: Option<fee::DonutsFeeData>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<RestoreResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::RestoreRequest(Box::new(RestoreRequest {
            name: domain.to_string(),
            donuts_fee_agreement,
            return_path: sender,
        })),
        receiver,
    )
    .await
}