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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//! EPP commands relating to EURid extensions

use super::{CommandResponse, RequestMessage, Sender};
use chrono::prelude::*;

#[derive(Debug)]
pub struct HitPointsRequest {
    pub return_path: Sender<HitPointsResponse>,
}

#[derive(Debug)]
pub struct HitPointsResponse {
    pub hit_points: u64,
    pub max_hit_points: u64,
    pub blocked_until: Option<DateTime<Utc>>,
}

#[derive(Debug)]
pub struct RegistrationLimitRequest {
    pub return_path: Sender<RegistrationLimitResponse>,
}

#[derive(Debug)]
pub struct RegistrationLimitResponse {
    pub monthly_registrations: u64,
    pub max_monthly_registrations: Option<u64>,
    pub limited_until: Option<DateTime<Utc>>,
}

#[derive(Debug)]
pub struct DNSSECEligibilityRequest {
    pub(super) name: String,
    pub return_path: Sender<DNSSECEligibilityResponse>,
}

#[derive(Debug)]
pub struct DNSSECEligibilityResponse {
    pub eligible: bool,
    pub message: String,
    pub code: u32,
    pub idn: Option<Idn>,
}

#[derive(Debug)]
pub struct DNSQualityRequest {
    pub(super) name: String,
    pub return_path: Sender<DNSQualityResponse>,
}

#[derive(Debug)]
pub struct DNSQualityResponse {
    pub check_time: Option<DateTime<Utc>>,
    pub score: String,
    pub idn: Option<Idn>,
}

#[derive(Debug)]
pub struct PollResponse {
    pub context: String,
    pub object_type: String,
    pub object: String,
    pub object_unicode: Option<String>,
    pub action: String,
    pub code: u32,
    pub detail: Option<String>,
    pub registrar: Option<String>,
}

#[derive(Debug)]
pub struct ContactExtension {
    pub contact_type: ContactType,
    pub whois_email: Option<String>,
    pub vat: Option<String>,
    pub citizenship_country: Option<String>,
    pub language: String,
}

#[derive(Debug)]
pub struct ContactExtensionUpdate {
    pub whois_email: Option<String>,
    pub vat: Option<String>,
    pub citizenship_country: Option<String>,
    pub language: Option<String>,
}

pub fn is_entity_natural_person(entity: Option<&super::contact::EntityType>) -> bool {
    match entity {
        Some(e) => matches!(
            e,
            super::contact::EntityType::UkIndividual
                | super::contact::EntityType::FinnishIndividual
                | super::contact::EntityType::OtherIndividual
        ),
        None => true,
    }
}

#[derive(Debug, PartialEq, Eq)]
pub enum ContactType {
    Billing,
    Tech,
    Registrant,
    OnSite,
    Reseller,
}

#[derive(Debug)]
pub struct Idn {
    pub ace: String,
    pub unicode: String,
}

#[derive(Debug)]
pub struct DomainCheck {
    pub available_date: Option<DateTime<Utc>>,
    pub status: Vec<super::domain::Status>,
}

#[derive(Debug)]
pub struct DomainCreate {
    pub on_site: Option<String>,
    pub reseller: Option<String>,
}

#[derive(Debug)]
pub struct DomainUpdate {
    pub add_on_site: Option<String>,
    pub add_reseller: Option<String>,
    pub remove_on_site: Option<String>,
    pub remove_reseller: Option<String>,
}

#[derive(Debug)]
pub enum DomainDelete {
    Schedule(DateTime<Utc>),
    Cancel,
}

#[derive(Debug)]
pub struct DomainTransfer {
    pub on_site: Option<String>,
    pub reseller: Option<String>,
    pub technical: Option<String>,
    pub billing: String,
    pub registrant: String,
}

#[derive(Debug)]
pub struct DomainInfoRequest {
    pub auth_info: Option<DomainAuthInfo>,
}

#[derive(Debug)]
pub enum DomainAuthInfo {
    Request,
    Cancel,
}

#[derive(Debug)]
pub struct DomainInfo {
    pub on_hold: bool,
    pub quarantined: bool,
    pub suspended: bool,
    pub delayed: bool,
    pub seized: bool,
    pub deletion_date: Option<DateTime<Utc>>,
    pub on_site: Option<String>,
    pub reseller: Option<String>,
    pub max_extension_period: u32,
    pub registrant_country: String,
    pub registrant_country_of_citizenship: Option<String>,
    pub auth_info_valid_until: Option<DateTime<Utc>>,
}

#[derive(Debug)]
pub struct DomainTransferInfo {
    pub on_hold: bool,
    pub quarantined: bool,
    pub delayed: bool,
    pub reason: String,
    pub registrant: String,
    pub billing: String,
    pub on_site: Option<String>,
    pub technical: Option<String>,
    pub reseller: Option<String>,
}

#[derive(Debug)]
pub struct DomainRenewInfo {
    pub removed_deletion: bool,
}

/// Makes a hit points enquiry to the registry
///
/// # Arguments
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn hit_points_info(
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<HitPointsResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::EURIDHitPoints(Box::new(HitPointsRequest {
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Makes a registration limits enquiry to the registry
///
/// # Arguments
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn registration_limit_info(
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<RegistrationLimitResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::EURIDRegistrationLimit(Box::new(RegistrationLimitRequest {
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Makes a DNSSEC discount eligibility enquiry to the registry
///
/// # Arguments
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn dnssec_eligibility_info(
    name: &str,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<DNSSECEligibilityResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::EURIDDNSSECEligibility(Box::new(DNSSECEligibilityRequest {
            name: name.to_string(),
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Makes a DNS quality enquiry to the registry
///
/// # Arguments
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn dns_quality_info(
    name: &str,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<DNSQualityResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::EURIDDNSQuality(Box::new(DNSQualityRequest {
            name: name.to_string(),
            return_path: sender,
        })),
        receiver,
    )
    .await
}