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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
//! EPP commands relating to domain objects

use chrono::prelude::*;

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

#[derive(Debug)]
pub struct CheckRequest {
    pub(super) name: String,
    pub(super) fee_check: Option<fee::FeeCheck>,
    pub(super) launch_check: Option<launch::LaunchAvailabilityCheck>,
    pub return_path: Sender<CheckResponse>,
}

#[derive(Debug)]
pub struct ClaimsCheckRequest {
    pub(super) name: String,
    pub(super) launch_check: launch::LaunchClaimsCheck,
    pub return_path: Sender<ClaimsCheckResponse>,
}

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

/// Response to a domain check query
#[derive(Debug)]
pub struct CheckResponse {
    /// Is the domain available for registration
    pub avail: bool,
    /// An optional reason for the domain's status
    pub reason: Option<String>,
    /// Fee information (if supplied by the registry)
    pub fee_check: Option<fee::FeeCheckData>,
    pub donuts_fee_check: Option<fee::DonutsFeeData>,
    pub eurid_check: Option<super::eurid::DomainCheck>,
    pub eurid_idn: Option<super::eurid::Idn>,
}

/// Response to a domain claims check query
#[derive(Debug)]
pub struct ClaimsCheckResponse {
    /// Does a trademark claim exist
    pub exists: bool,
    /// Claims key for this domain
    pub claims_key: Vec<launch::LaunchClaimKey>,
}

#[derive(Debug)]
pub enum InfoHost {
    All,
    Delegated,
    Subordinate,
    None,
}

#[derive(Debug)]
pub struct InfoRequest {
    pub(super) name: String,
    pub(super) auth_info: Option<String>,
    pub(super) launch_info: Option<launch::LaunchInfo>,
    pub(super) hosts: Option<InfoHost>,
    pub(super) eurid_data: Option<super::eurid::DomainInfoRequest>,
    pub return_path: Sender<InfoResponse>,
}

/// Response to a domain info query
#[derive(Debug)]
pub struct InfoResponse {
    /// Domain name in question
    pub name: String,
    /// Internal registry ID
    pub registry_id: String,
    /// Statuses attached to the domain
    pub statuses: Vec<Status>,
    /// Contact ID of the registrant
    pub registrant: String,
    /// Additional contacts on the domain
    pub contacts: Vec<InfoContact>,
    /// Nameservers for the domain
    pub nameservers: Vec<InfoNameserver>,
    /// Host names attached to the domain
    pub hosts: Vec<String>,
    /// Sponsoring client ID
    pub client_id: String,
    /// ID of the client that originally registered the domain
    pub client_created_id: Option<String>,
    /// Date of initial registration
    pub creation_date: Option<DateTime<Utc>>,
    /// Date of registration expiration
    pub expiry_date: Option<DateTime<Utc>>,
    /// ID of the client that last updated the domain
    pub last_updated_client: Option<String>,
    /// Date of last update
    pub last_updated_date: Option<DateTime<Utc>>,
    /// Date of last transfer
    pub last_transfer_date: Option<DateTime<Utc>>,
    /// Redemption grace period state of the domain
    pub rgp_state: Vec<super::rgp::RGPState>,
    pub auth_info: Option<String>,
    /// DNSSEC data
    pub sec_dns: Option<SecDNSData>,
    pub launch_info: Option<launch::LaunchInfoData>,
    pub donuts_fee_data: Option<fee::DonutsFeeData>,
    pub whois_info: Option<super::verisign::InfoWhois>,
    pub isnic_info: Option<super::isnic::DomainInfo>,
    pub eurid_data: Option<super::eurid::DomainInfo>,
    pub eurid_idn: Option<super::eurid::Idn>,
    pub personal_registration: Option<super::personal_registration::PersonalRegistrationInfo>,
}

/// Additional contact associated with a domain
#[derive(Debug)]
pub struct InfoContact {
    /// Type of contact
    pub contact_type: String,
    /// Contact ID of the contact
    pub contact_id: String,
}

/// Nameserver associated with a domain
#[derive(Debug)]
pub enum InfoNameserver {
    /// Host only type
    HostOnly(String),
    /// Host name with glue records
    HostAndAddress {
        host: String,
        addresses: Vec<super::host::Address>,
        eurid_idn: Option<super::eurid::Idn>,
    },
}

/// DNSSEC key data
#[derive(Debug)]
pub struct SecDNSData {
    pub max_sig_life: Option<i64>,
    pub data: SecDNSDataType,
}

#[derive(Debug)]
pub enum SecDNSDataType {
    DSData(Vec<SecDNSDSData>),
    KeyData(Vec<SecDNSKeyData>),
}

#[derive(Debug)]
pub struct SecDNSDSData {
    pub key_tag: u16,
    pub algorithm: u8,
    pub digest_type: u8,
    pub digest: String,
    pub key_data: Option<SecDNSKeyData>,
}

#[derive(Debug)]
pub struct SecDNSKeyData {
    pub flags: u16,
    pub protocol: u8,
    pub algorithm: u8,
    pub public_key: String,
}

#[derive(Debug)]
pub struct CreateRequest {
    pub(super) name: String,
    pub(super) period: Option<super::Period>,
    pub(super) registrant: String,
    pub(super) contacts: Vec<InfoContact>,
    pub(super) nameservers: Vec<InfoNameserver>,
    pub(super) auth_info: String,
    pub(super) sec_dns: Option<SecDNSData>,
    pub(super) launch_create: Option<launch::LaunchCreate>,
    pub(super) fee_agreement: Option<fee::FeeAgreement>,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub(super) eurid_data: Option<super::eurid::DomainCreate>,
    pub(super) isnic_payment: Option<super::isnic::PaymentInfo>,
    pub(super) personal_registration:
        Option<super::personal_registration::PersonalRegistrationInfo>,
    pub return_path: Sender<CreateResponse>,
}

#[derive(Debug)]
pub struct CreateResponse {
    /// Was the request completed instantly or not
    pub pending: bool,
    pub data: CreateData,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
    pub donuts_fee_data: Option<fee::DonutsFeeData>,
    pub launch_create: Option<launch::LaunchCreateData>,
}

#[derive(Debug)]
pub struct CreateData {
    /// The actual domain name created
    pub name: String,
    /// What date did the server log as the date of creation
    pub creation_date: Option<DateTime<Utc>>,
    /// When will the domain expire
    pub expiration_date: Option<DateTime<Utc>>,
    pub eurid_idn: Option<super::eurid::Idn>,
    pub personal_registration: Option<super::personal_registration::PersonalRegistrationCreate>,
}

#[derive(Debug)]
pub struct DeleteRequest {
    pub(super) name: String,
    pub(super) launch_info: Option<launch::LaunchUpdate>,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub(super) eurid_data: Option<super::eurid::DomainDelete>,
    pub return_path: Sender<DeleteResponse>,
}

#[derive(Debug)]
pub struct DeleteResponse {
    /// Was the request completed instantly or not
    pub pending: bool,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
    pub eurid_idn: Option<super::eurid::Idn>,
}

#[derive(Debug)]
pub struct UpdateRequest {
    pub(super) name: String,
    pub(super) add: Vec<UpdateObject>,
    pub(super) remove: Vec<UpdateObject>,
    pub(super) new_registrant: Option<String>,
    pub(super) new_auth_info: Option<String>,
    pub(super) sec_dns: Option<UpdateSecDNS>,
    pub(super) launch_info: Option<launch::LaunchUpdate>,
    pub(super) fee_agreement: Option<fee::FeeAgreement>,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub(super) eurid_data: Option<super::eurid::DomainUpdate>,
    pub(super) isnic_info: Option<super::isnic::DomainUpdate>,
    pub return_path: Sender<UpdateResponse>,
}

#[derive(Debug)]
pub enum UpdateObject {
    Status(Status),
    Contact(InfoContact),
    Nameserver(InfoNameserver),
}

#[derive(Debug)]
pub struct UpdateSecDNS {
    pub urgent: Option<bool>,
    pub remove: Option<UpdateSecDNSRemove>,
    pub add: Option<SecDNSDataType>,
    pub new_max_sig_life: Option<i64>,
}

#[derive(Debug)]
pub enum UpdateSecDNSRemove {
    All(bool),
    Data(SecDNSDataType),
}

#[derive(Debug)]
pub struct UpdateResponse {
    /// Was the request completed instantly or not
    pub pending: bool,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
    pub donuts_fee_data: Option<fee::DonutsFeeData>,
}

#[derive(Debug)]
pub struct VerisignSyncRequest {
    pub(super) name: String,
    pub(super) month: u32,
    pub(super) day: u32,
    pub return_path: Sender<UpdateResponse>,
}

#[derive(Debug)]
pub struct RenewRequest {
    pub(super) name: String,
    pub(super) add_period: Option<super::Period>,
    pub(super) cur_expiry_date: DateTime<Utc>,
    pub(super) fee_agreement: Option<fee::FeeAgreement>,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub(super) isnic_payment: Option<super::isnic::PaymentInfo>,
    pub return_path: Sender<RenewResponse>,
}

#[derive(Debug)]
pub struct RenewResponse {
    /// Was the request completed instantly or not
    pub pending: bool,
    pub data: RenewData,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
    pub donuts_fee_data: Option<fee::DonutsFeeData>,
}

#[derive(Debug)]
pub struct RenewData {
    pub name: String,
    pub new_expiry_date: Option<DateTime<Utc>>,
    pub eurid_idn: Option<super::eurid::Idn>,
    pub eurid_data: Option<super::eurid::DomainRenewInfo>,
    pub personal_registration: Option<super::personal_registration::PersonalRegistrationCreate>,
}

#[derive(Debug)]
pub struct TransferQueryRequest {
    pub(super) name: String,
    pub(super) auth_info: Option<String>,
    pub return_path: Sender<TransferResponse>,
}

#[derive(Debug)]
pub struct TransferRequestRequest {
    pub(super) name: String,
    pub(super) auth_info: String,
    pub(super) add_period: Option<super::Period>,
    pub(super) fee_agreement: Option<fee::FeeAgreement>,
    pub(super) donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub(super) eurid_data: Option<super::eurid::DomainTransfer>,
    pub return_path: Sender<TransferResponse>,
}

#[derive(Debug)]
pub struct TransferAcceptRejectRequest {
    pub(super) name: String,
    pub(super) auth_info: Option<String>,
    pub return_path: Sender<TransferResponse>,
}

#[derive(Debug)]
pub struct TransferResponse {
    /// Was the request completed instantly or not
    pub pending: bool,
    pub data: TransferData,
    /// Fee information (if supplied by the registry)
    pub fee_data: Option<fee::FeeData>,
    pub donuts_fee_data: Option<fee::DonutsFeeData>,
}

#[derive(Debug)]
pub struct TransferData {
    pub name: String,
    pub status: super::TransferStatus,
    /// Which client requested the transfer
    pub requested_client_id: String,
    /// The date of the transfer request
    pub requested_date: DateTime<Utc>,
    /// Whcich client last acted / needs to act
    pub act_client_id: String,
    /// Date on which a client acted / must act by
    pub act_date: DateTime<Utc>,
    /// New domain expiry date if amended by the transfer
    pub expiry_date: Option<DateTime<Utc>>,
    pub eurid_idn: Option<super::eurid::Idn>,
    pub eurid_data: Option<super::eurid::DomainTransferInfo>,
    pub personal_registration: Option<super::personal_registration::PersonalRegistrationCreate>,
}

#[derive(Debug, PartialEq, Eq)]
pub enum Status {
    ClientDeleteProhibited,
    ClientHold,
    ClientRenewProhibited,
    ClientTransferProhibited,
    ClientUpdateProhibited,
    Inactive,
    Ok,
    PendingCreate,
    PendingDelete,
    PendingRenew,
    PendingTransfer,
    PendingUpdate,
    ServerDeleteProhibited,
    ServerHold,
    ServerRenewProhibited,
    ServerTransferProhibited,
    ServerUpdateProhibited,
}

#[derive(Debug)]
pub struct PanData {
    pub name: String,
    pub result: bool,
    pub server_transaction_id: Option<String>,
    pub client_transaction_id: Option<String>,
    pub date: DateTime<Utc>,
}

/// Checks if a domain name is available
///
/// # Arguments
/// * `domain` - The domain in question
/// * `launch_check` - Launch availability info
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn check(
    domain: &str,
    fee_check: Option<fee::FeeCheck>,
    launch_check: Option<launch::LaunchAvailabilityCheck>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<CheckResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainCheck(Box::new(CheckRequest {
            name: domain.to_string(),
            fee_check,
            launch_check,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Checks if a domain name has claims registered for a launch phase
///
/// # Arguments
/// * `domain` - The domain in question
/// * `launch_check` - Launch claims info
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn launch_claims_check(
    domain: &str,
    launch_check: launch::LaunchClaimsCheck,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<ClaimsCheckResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainClaimsCheck(Box::new(ClaimsCheckRequest {
            name: domain.to_string(),
            launch_check,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Checks if a domain name has trademarks registered for it
///
/// # Arguments
/// * `domain` - The domain in question
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn launch_trademark_check(
    domain: &str,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<ClaimsCheckResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTrademarkCheck(Box::new(TrademarkCheckRequest {
            name: domain.to_string(),
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Fetches information about a domain name
///
/// # Arguments
/// * `domain` - The domain in question
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn info(
    domain: &str,
    auth_info: Option<&str>,
    hosts: Option<InfoHost>,
    launch_info: Option<launch::LaunchInfo>,
    eurid_data: Option<super::eurid::DomainInfoRequest>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<InfoResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainInfo(Box::new(InfoRequest {
            name: domain.to_string(),
            auth_info: auth_info.map(|s| s.into()),
            hosts,
            launch_info,
            eurid_data,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

pub struct CreateInfo<'a> {
    pub domain: &'a str,
    pub period: Option<super::Period>,
    pub registrant: &'a str,
    pub contacts: Vec<InfoContact>,
    pub nameservers: Vec<InfoNameserver>,
    pub auth_info: &'a str,
    pub sec_dns: Option<SecDNSData>,
    pub launch_create: Option<launch::LaunchCreate>,
    pub fee_agreement: Option<fee::FeeAgreement>,
    pub donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub eurid_data: Option<super::eurid::DomainCreate>,
    pub isnic_payment: Option<super::isnic::PaymentInfo>,
    pub personal_registration: Option<super::personal_registration::PersonalRegistrationInfo>,
}

/// Registers a new domain
///
/// # Arguments
/// * `domain` - The domain to be registered
/// * `period` - How long to register for
/// * `registrant` - Registrant contact ID,
/// * `contacts` - Other contact types for the domain
/// * `nameservers` - Domain nameservers
/// * `auth_info` - Auth info password for future transfers
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn create(
    info: CreateInfo<'_>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<CreateResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainCreate(Box::new(CreateRequest {
            name: info.domain.to_string(),
            period: info.period,
            registrant: info.registrant.to_string(),
            contacts: info.contacts,
            nameservers: info.nameservers,
            auth_info: info.auth_info.to_string(),
            sec_dns: info.sec_dns,
            launch_create: info.launch_create,
            fee_agreement: info.fee_agreement,
            donuts_fee_agreement: info.donuts_fee_agreement,
            eurid_data: info.eurid_data,
            isnic_payment: info.isnic_payment,
            personal_registration: info.personal_registration,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Deletes a domain name
///
/// # Arguments
/// * `domain` - The domain in question
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn delete(
    domain: &str,
    launch_info: Option<launch::LaunchUpdate>,
    donuts_fee_agreement: Option<fee::DonutsFeeData>,
    eurid_data: Option<super::eurid::DomainDelete>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<DeleteResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainDelete(Box::new(DeleteRequest {
            name: domain.to_string(),
            launch_info,
            donuts_fee_agreement,
            eurid_data,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

#[derive(Default)]
pub struct UpdateInfo<'a> {
    pub domain: &'a str,
    pub add: Vec<UpdateObject>,
    pub remove: Vec<UpdateObject>,
    pub new_registrant: Option<&'a str>,
    pub new_auth_info: Option<&'a str>,
    pub sec_dns: Option<UpdateSecDNS>,
    pub launch_info: Option<launch::LaunchUpdate>,
    pub fee_agreement: Option<fee::FeeAgreement>,
    pub donuts_fee_agreement: Option<fee::DonutsFeeData>,
    pub eurid_data: Option<super::eurid::DomainUpdate>,
    pub isnic_info: Option<super::isnic::DomainUpdate>,
}

/// Updates properties of a domain name
///
/// # Arguments
/// * `domain` - The domain to be updated
/// * `add` - Attributes to be added
/// * `remove` - Attributes to be removed
/// * `new_registrant` - New registrant ID
/// * `new_auth_info` - New auth info password for future transfers
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn update(
    info: UpdateInfo<'_>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<UpdateResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainUpdate(Box::new(UpdateRequest {
            name: info.domain.to_string(),
            add: info.add,
            remove: info.remove,
            new_registrant: info.new_registrant.map(|s| s.into()),
            new_auth_info: info.new_auth_info.map(|s| s.into()),
            sec_dns: info.sec_dns,
            launch_info: info.launch_info,
            fee_agreement: info.fee_agreement,
            donuts_fee_agreement: info.donuts_fee_agreement,
            eurid_data: info.eurid_data,
            isnic_info: info.isnic_info,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Performs a Verisign ConsoliDate
///
/// # Arguments
/// * `domain` - The domain to be updated
/// * `month` - Month to move renewal to
/// * `day` - Day of month to move renewal to
pub async fn verisign_sync(
    domain: &str,
    month: u32,
    day: u32,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<UpdateResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::VerisignSync(Box::new(VerisignSyncRequest {
            name: domain.to_string(),
            month,
            day,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Renews a domain name
///
/// # Arguments
/// * `domain` - The domain in question
/// * `add_period` - How much time to add to the domain
/// * `cur_expiry_date` - The current expiry date
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn renew(
    domain: &str,
    add_period: Option<super::Period>,
    cur_expiry_date: DateTime<Utc>,
    fee_agreement: Option<fee::FeeAgreement>,
    donuts_fee_agreement: Option<fee::DonutsFeeData>,
    isnic_payment: Option<super::isnic::PaymentInfo>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<RenewResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainRenew(Box::new(RenewRequest {
            name: domain.to_string(),
            add_period,
            cur_expiry_date,
            fee_agreement,
            donuts_fee_agreement,
            isnic_payment,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Queries the current transfer status of a domain name
///
/// # Arguments
/// * `domain` - The domain to be queried
/// * `auth_info` - Auth info for the domain (not always required)
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn transfer_query(
    domain: &str,
    auth_info: Option<&str>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<TransferResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTransferQuery(Box::new(TransferQueryRequest {
            name: domain.to_string(),
            auth_info: auth_info.map(|s| s.into()),
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Requests the transfer of a domain name
///
/// # Arguments
/// * `domain` - The domain to be transferred
/// * `add_period` - How much time to add to the domain's expiry on transfer
/// * `auth_info` - Auth info for the domain
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn transfer_request(
    domain: &str,
    add_period: Option<super::Period>,
    auth_info: &str,
    fee_agreement: Option<fee::FeeAgreement>,
    donuts_fee_agreement: Option<fee::DonutsFeeData>,
    eurid_data: Option<super::eurid::DomainTransfer>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<TransferResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTransferRequest(Box::new(TransferRequestRequest {
            name: domain.to_string(),
            add_period,
            auth_info: auth_info.to_string(),
            fee_agreement,
            donuts_fee_agreement,
            eurid_data,
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Cancels the pending transfer of a domain name
///
/// # Arguments
/// * `domain` - The domain to be cancelled
/// * `auth_info` - Auth info for the domain
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn transfer_cancel(
    domain: &str,
    auth_info: Option<&str>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<TransferResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTransferCancel(Box::new(TransferAcceptRejectRequest {
            name: domain.to_string(),
            auth_info: auth_info.map(|s| s.into()),
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Accepts the transfer of a domain name
///
/// # Arguments
/// * `domain` - The domain to be approved
/// * `auth_info` - Auth info for the domain
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn transfer_accept(
    domain: &str,
    auth_info: Option<&str>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<TransferResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTransferAccept(Box::new(TransferAcceptRejectRequest {
            name: domain.to_string(),
            auth_info: auth_info.map(|s| s.into()),
            return_path: sender,
        })),
        receiver,
    )
    .await
}

/// Rejects the transfer of a domain name
///
/// # Arguments
/// * `domain` - The domain to be rejected
/// * `auth_info` - Auth info for the domain
/// * `client_sender` - Reference to the tokio channel into the client
pub async fn transfer_reject(
    domain: &str,
    auth_info: Option<&str>,
    client_sender: &mut futures::channel::mpsc::Sender<RequestMessage>,
) -> Result<CommandResponse<TransferResponse>, super::Error> {
    let (sender, receiver) = futures::channel::oneshot::channel();
    super::send_epp_client_request(
        client_sender,
        RequestMessage::DomainTransferReject(Box::new(TransferAcceptRejectRequest {
            name: domain.to_string(),
            auth_info: auth_info.map(|s| s.into()),
            return_path: sender,
        })),
        receiver,
    )
    .await
}