instant_epp/extensions/frnic/
mod.rs1use instant_xml::{FromXml, ToXml};
4
5pub mod contact;
6
7pub use contact::ContactCreate;
8
9pub const XMLNS: &str = "http://www.afnic.fr/xml/epp/frnic-2.0";
10
11#[derive(Debug, FromXml, ToXml)]
12#[xml(rename = "ext", ns(XMLNS))]
13pub struct Ext<T> {
14 pub data: T,
15}
16
17#[derive(Debug, FromXml, ToXml)]
18#[xml(rename = "create", ns(XMLNS))]
19pub struct Create<T> {
20 pub data: T,
21}
22
23#[cfg(test)]
24mod tests {
25 use crate::contact::ContactCreate;
26 use crate::contact::{Address, PostalInfo, Voice};
27 use crate::extensions::frnic;
28 use crate::tests::assert_serialized;
29 use frnic::{contact, Ext};
30
31 #[test]
32 fn test_contact_create_natural_person() {
33 let frnic_contact = Ext::from(frnic::ContactCreate::new_natural_person("Michel"));
35 let object = ContactCreate::new(
36 "XXX000",
37 "test@test.fr",
38 PostalInfo::new(
39 "loc",
40 "Dupont",
41 None,
42 Address::new(
43 &["1 Rue des fleurs"],
44 "Paris",
45 None,
46 Some("75000"),
47 "FR".parse().unwrap(),
48 ),
49 ),
50 Some(Voice::new("+33.1234567890")),
51 "Afn-12345678",
52 );
53 assert_serialized(
54 "request/extensions/frnic_create_contact_natural_person.xml",
55 (&object, &frnic_contact),
56 );
57 }
58
59 #[test]
60 fn test_contact_create_company() {
61 let frnic_contact = Ext::from(frnic::ContactCreate::new_company(
63 None, None, None, None, None,
64 ));
65 let object = ContactCreate::new(
66 "XXXXXXX",
67 "test@test.fr",
68 PostalInfo::new(
69 "loc",
70 "SARL DUPONT",
71 None,
72 Address::new(
73 &["1 Rue des coquelicots"],
74 "Paris",
75 None,
76 Some("75000"),
77 "FR".parse().unwrap(),
78 ),
79 ),
80 Some(Voice::new("+33.1234567890")),
81 "Afn-123456",
82 );
83 assert_serialized(
84 "request/extensions/frnic_create_contact_company.xml",
85 (&object, &frnic_contact),
86 );
87 }
88
89 #[test]
90 fn test_contact_create_corporation_with_siren() {
91 let frnic_contact = Ext::from(frnic::ContactCreate::new_company(
93 Some("123456789"),
94 None,
95 None,
96 None,
97 None,
98 ));
99 let object = ContactCreate::new(
100 "XXXX0000",
101 "test@test.fr",
102 PostalInfo::new(
103 "loc",
104 "SARL DUPONT SIREN",
105 None,
106 Address::new(
107 &["1 Rue des Sirenes"],
108 "Paris",
109 None,
110 Some("75000"),
111 "FR".parse().unwrap(),
112 ),
113 ),
114 Some(Voice::new("+33.1234567890")),
115 "Afn-123456",
116 );
117 assert_serialized(
118 "request/extensions/frnic_create_contact_siren.xml",
119 (&object, &frnic_contact),
120 );
121 }
122
123 #[test]
124 fn test_contact_create_non_profit() {
125 let frnic_contact = Ext::from(frnic::ContactCreate::new_non_profit(
127 None,
128 Some("2011-05-02"),
129 Some(contact::Publication {
130 announce: 123456,
131 page: 15,
132 date: "2011-05-07".into(),
133 }),
134 ));
135 let object = ContactCreate::new(
136 "XXXX0000",
137 "test@test.fr",
138 PostalInfo::new(
139 "loc",
140 "Dupont JO",
141 None,
142 Address::new(
143 &["1 Rue des Fleurs"],
144 "Paris",
145 None,
146 Some("75000"),
147 "FR".parse().unwrap(),
148 ),
149 ),
150 Some(Voice::new("+33.1234567890")),
151 "Afn-123456",
152 );
153 assert_serialized(
154 "request/extensions/frnic_create_contact_non_profit.xml",
155 (&object, &frnic_contact),
156 );
157 }
158}