epp-xml 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a333e53de98c51025b92438d94662959c5f5626
4
- data.tar.gz: 6343090f33e1fa9dd2752c02ad5d035696b8deec
3
+ metadata.gz: e2b66da8a11f78ef522acebe121774e0aef3a800
4
+ data.tar.gz: 09d4df0f4bfc832d43fc9871666c66cd6e390bae
5
5
  SHA512:
6
- metadata.gz: 28b3189db593290ed87b157b9e8504b6607ef5b37752d81cb4bb30a2d60a27c837ffd2d9f34abb085ca8ca482d864d47055079bfd255fed2a5ce99523f85d78d
7
- data.tar.gz: 90d3dcd3685a80c3b4192cc52dbb423da7061ee6452b8a541bc00f64581b1928a8f2e9936e84f3764cb1bbb53429ede775bf4d9873b32e345309e4ee9f7d9f56
6
+ metadata.gz: f67ad49770d6f0780eb79dcb5980a52c4229a29cefbcec55820944680442da8ff96cc4412578ddd5fbc01d0c1528554e57c9ba05e7c98ee50ac2b4bdc09b757f
7
+ data.tar.gz: c08a10f363d819d8e35e28ff5216a00821be7430518e5410a3073bddea995713756100657f66212b4b447d5980349fdd217c86d9c7aa53614f81de0b2313764b
@@ -24,8 +24,10 @@ module EppXml
24
24
  xml.tag!("#{ns}#{k}", v[:value], v[:attrs])
25
25
  # Value is a hash which is nested
26
26
  elsif v.is_a?(Hash)
27
- xml.tag!("#{ns}#{k}") do
28
- generate_xml_from_hash(v, xml, ns)
27
+ attrs = v.delete(:attrs)
28
+ value = v.delete(:value) || v
29
+ xml.tag!("#{ns}#{k}", attrs) do
30
+ generate_xml_from_hash(value, xml, ns)
29
31
  end
30
32
  # Value is an array
31
33
  elsif v.is_a?(Array)
@@ -1,3 +1,57 @@
1
- module EppXmlCore::Contact
1
+ module EppXmlCore
2
+ module Contact
3
+ def create(xml_params = {})
4
+ build('create', xml_params)
5
+ end
2
6
 
7
+ def check(xml_params = {})
8
+ build('check', xml_params)
9
+ end
10
+
11
+ def info(xml_params = {})
12
+ build('info', xml_params)
13
+ end
14
+
15
+ def delete(xml_params = {})
16
+ build('delete', xml_params)
17
+ end
18
+
19
+ def update(xml_params = {})
20
+ build('update', xml_params)
21
+ end
22
+
23
+ def transfer(xml_params = {}, op = 'query')
24
+ xml = Builder::XmlMarkup.new
25
+
26
+ xml.instruct!(:xml, standalone: 'no')
27
+ xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
28
+ xml.command do
29
+ xml.transfer('op' => op) do
30
+ xml.tag!('contact:transfer', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
31
+ EppXml.generate_xml_from_hash(xml_params, xml, 'contact:')
32
+ end
33
+ end
34
+ xml.clTRID 'ABC-12345'
35
+ end
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def build(command, xml_params)
42
+ xml = Builder::XmlMarkup.new
43
+
44
+ xml.instruct!(:xml, standalone: 'no')
45
+ xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
46
+ xml.command do
47
+ xml.tag!(command) do
48
+ xml.tag!("contact:#{command}", 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
49
+ EppXml.generate_xml_from_hash(xml_params, xml, 'contact:')
50
+ end
51
+ end
52
+ xml.clTRID 'ABC-12345'
53
+ end
54
+ end
55
+ end
56
+ end
3
57
  end
@@ -1,36 +1,22 @@
1
1
  module EppXmlCore
2
2
  module Domain
3
- def create(xml_params = {}, dnssec_params = {})
4
- defaults = {
5
- name: { value: 'example.ee' },
6
- period: { value: '1', attrs: { unit: 'y' } },
7
- ns: [
8
- { hostObj: { value: 'ns1.example.net' } },
9
- { hostObj: { value: 'ns2.example.net' } }
10
- ],
11
- registrant: { value: 'jd1234' },
12
- _anonymus: [
13
- { contact: { value: 'sh8013', attrs: { type: 'admin' } } },
14
- { contact: { value: 'sh8013', attrs: { type: 'tech' } } },
15
- { contact: { value: 'sh801333', attrs: { type: 'tech' } } }
16
- ]
17
- }
3
+ def info(xml_params = {})
4
+ build('info', xml_params)
5
+ end
18
6
 
19
- xml_params = defaults.deep_merge(xml_params)
7
+ def check(xml_params = {})
8
+ build('check', xml_params)
9
+ end
20
10
 
21
- dnssec_defaults = {
22
- _anonymus: [
23
- { keyData: {
24
- flags: { value: '257' },
25
- protocol: { value: '3' },
26
- alg: { value: '5' },
27
- pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
28
- }
29
- }]
30
- }
11
+ def delete(xml_params = {})
12
+ build('delete', xml_params)
13
+ end
31
14
 
32
- dnssec_params = dnssec_defaults.deep_merge(dnssec_params) if dnssec_params != false
15
+ def renew(xml_params = {})
16
+ build('renew', xml_params)
17
+ end
33
18
 
19
+ def create(xml_params = {}, dnssec_params = {})
34
20
  xml = Builder::XmlMarkup.new
35
21
 
36
22
  xml.instruct!(:xml, standalone: 'no')
@@ -51,62 +37,7 @@ module EppXmlCore
51
37
  end
52
38
  end
53
39
 
54
- def check(xml_params = {})
55
- defaults = {
56
- _anonymus: [
57
- { name: { value: 'example.ee'} }
58
- ]
59
- }
60
-
61
- xml_params = defaults.deep_merge(xml_params)
62
-
63
- xml = Builder::XmlMarkup.new
64
-
65
- xml.instruct!(:xml, standalone: 'no')
66
- xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
67
- xml.command do
68
- xml.check do
69
- xml.tag!('domain:check', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
70
- EppXml.generate_xml_from_hash(xml_params, xml, 'domain:')
71
- end
72
- end
73
- xml.clTRID 'ABC-12345'
74
- end
75
- end
76
- end
77
-
78
- def info(xml_params = {})
79
- defaults = {
80
- name: { value: 'example.ee', attrs: { hosts: 'all' } },
81
- authInfo: {
82
- pw: { value: '2fooBAR' }
83
- }
84
- }
85
-
86
- xml_params = defaults.deep_merge(xml_params)
87
-
88
- xml = Builder::XmlMarkup.new
89
-
90
- xml.instruct!(:xml, standalone: 'no')
91
- xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
92
- xml.command do
93
- xml.info do
94
- xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
95
- EppXml.generate_xml_from_hash(xml_params, xml, 'domain:')
96
- end
97
- end
98
- xml.clTRID 'ABC-12345'
99
- end
100
- end
101
- end
102
-
103
40
  def update(xml_params = {}, dnssec_params = false)
104
- defaults = {
105
- name: { value: 'example.ee' }
106
- }
107
-
108
- xml_params = defaults.deep_merge(xml_params)
109
-
110
41
  xml = Builder::XmlMarkup.new
111
42
 
112
43
  xml.instruct!(:xml, standalone: 'no')
@@ -128,14 +59,14 @@ module EppXmlCore
128
59
  end
129
60
  end
130
61
 
131
- def delete(xml_params = {})
62
+ def transfer(xml_params = {}, op = 'query')
132
63
  xml = Builder::XmlMarkup.new
133
64
 
134
65
  xml.instruct!(:xml, standalone: 'no')
135
66
  xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
136
67
  xml.command do
137
- xml.delete do
138
- xml.tag!('domain:delete', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
68
+ xml.transfer('op' => op) do
69
+ xml.tag!('domain:transfer', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
139
70
  EppXml.generate_xml_from_hash(xml_params, xml, 'domain:')
140
71
  end
141
72
  end
@@ -144,30 +75,16 @@ module EppXmlCore
144
75
  end
145
76
  end
146
77
 
147
- def renew(xml_params = {})
148
- xml = Builder::XmlMarkup.new
149
-
150
- xml.instruct!(:xml, standalone: 'no')
151
- xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
152
- xml.command do
153
- xml.renew do
154
- xml.tag!('domain:renew', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
155
- EppXml.generate_xml_from_hash(xml_params, xml, 'domain:')
156
- end
157
- end
158
- xml.clTRID 'ABC-12345'
159
- end
160
- end
161
- end
78
+ private
162
79
 
163
- def transfer(xml_params = {}, op = 'query')
80
+ def build(command, xml_params)
164
81
  xml = Builder::XmlMarkup.new
165
82
 
166
83
  xml.instruct!(:xml, standalone: 'no')
167
84
  xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
168
85
  xml.command do
169
- xml.transfer('op' => op) do
170
- xml.tag!('domain:transfer', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
86
+ xml.tag!(command) do
87
+ xml.tag!("domain:#{command}", 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
171
88
  EppXml.generate_xml_from_hash(xml_params, xml, 'domain:')
172
89
  end
173
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epp-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GiTLAB LTD