epp-client-hostmaster 0.2.0 → 0.2.1

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.
@@ -2,7 +2,8 @@ module EPPClient
2
2
  module HostmasterConnection
3
3
  def send_frame(xml)
4
4
  @sent_frame = xml
5
- @socket.write([xml.bytesize + 4].pack("N") + xml)
5
+ @socket.write [xml.bytesize + 4].pack("N")
6
+ @socket.write xml
6
7
  sent_frame_to_xml
7
8
  end
8
9
  end
@@ -25,6 +25,21 @@ module EPPClient
25
25
  end
26
26
  end
27
27
 
28
+ def contact_disclose_xml(xml, disclose)
29
+ [:show, :hide].each do |operation|
30
+ next unless disclose.key? operation
31
+ xml.contact :disclose, flag: operation == :show ? '1' : '0' do
32
+ disclose[operation].each do |element|
33
+ if element.key? :type
34
+ xml.contact element[:name].to_sym, type: element[:type]
35
+ else
36
+ xml.contact element[:name].to_sym
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
28
43
  def contact_create_xml(contact)
29
44
  command do |xml|
30
45
  xml.create do
@@ -39,8 +54,10 @@ module EPPClient
39
54
  xml.contact :name, infos[:name]
40
55
  xml.contact :org, infos[:org] if infos.key?(:org)
41
56
  xml.contact :addr do
42
- infos[:addr][:street].each do |street|
43
- xml.contact :street, street
57
+ if infos[:addr].key? :street
58
+ infos[:addr][:street].each do |street|
59
+ xml.contact :street, street
60
+ end
44
61
  end
45
62
  xml.contact :city, infos[:addr][:city]
46
63
  xml.contact :sp, infos[:addr][:sp] if infos[:addr].key? :sp
@@ -55,17 +72,7 @@ module EPPClient
55
72
  xml.contact :authInfo do
56
73
  xml.contact :pw, contact[:authInfo]
57
74
  end
58
- if contact.key?(:disclose)
59
- xml.contact :disclose, flag: '1' do # TODO: parameter for flag need
60
- contact[:disclose].each do |disc|
61
- if disc.key?(:type)
62
- xml.contact disc[:name], type: disc[:type]
63
- else
64
- xml.contact disc[:name]
65
- end
66
- end
67
- end
68
- end
75
+ contact_disclose_xml(xml, contact[:disclose]) if contact.key?(:disclose)
69
76
  end
70
77
  end
71
78
  end
@@ -128,17 +135,7 @@ module EPPClient
128
135
  xml.contact :pw, contact[:authInfo]
129
136
  end
130
137
  end
131
- if contact.key?(:disclose)
132
- xml.contact :disclose, flag: '1' do # TODO: parameter for flag need
133
- contact[:disclose].each do |disc|
134
- if disc.key?(:type)
135
- xml.contact disc[:name], type: disc[:type]
136
- else
137
- xml.contact disc[:name]
138
- end
139
- end
140
- end
141
- end
138
+ contact_disclose_xml(xml, contact[:disclose]) if contact.key?(:disclose)
142
139
  end
143
140
  end
144
141
  end
@@ -71,7 +71,7 @@ module EPPClient
71
71
  domain_period_xml(xml, args[:period]) if args.key?(:period)
72
72
  domain_nss_xml(xml, args[:ns]) if args.key? :ns
73
73
  xml.domain :registrant, args[:registrant]
74
- domain_contacts_xml(xml, args[:contacts])
74
+ domain_contacts_xml(xml, args[:contacts]) if args.key? :contacts
75
75
  xml.domain :license, args[:license] if args.key? :license
76
76
  end
77
77
  end
@@ -122,9 +122,11 @@ module EPPClient
122
122
  xml.create do
123
123
  xml.host :create, 'xmlns:host' => EPPClient::SCHEMAS_URL['host-1.1'] do
124
124
  xml.host :name, host[:name]
125
- %w(addrv4 addrv6).each do |type|
126
- next unless host.key? type
127
- host[type].each {|ip| xml.host :addr, ip}
125
+ if host.key? :addrv4
126
+ host[:addrv4].each { |ip| xml.host :addr, { ip: 'v4' }, ip }
127
+ end
128
+ if host.key? :addrv6
129
+ host[:addrv6].each { |ip| xml.host :addr, { ip: 'v6' }, ip }
128
130
  end
129
131
  end
130
132
  end
@@ -183,9 +185,11 @@ module EPPClient
183
185
  if args.key? operation
184
186
  xml.host operation do
185
187
  args[operation][:status].each {|s| xml.host :status, s: s} if args[operation].key? :status
186
- %w(addrv4 addrv6).each do |type|
187
- next unless args[operation].key? type
188
- args[operation][type].each {|a| xml.host type, a}
188
+ if args[operation].key? :addrv4
189
+ args[operation][:addrv4].each { |ip| xml.host :addr, { ip: 'v4' }, ip }
190
+ end
191
+ if args[operation].key? :addrv6
192
+ args[operation][:addrv6].each { |ip| xml.host :addr, { ip: 'v6' }, ip }
189
193
  end
190
194
  end
191
195
  end
@@ -9,7 +9,7 @@ require "epp-client/hostmaster-transfer"
9
9
 
10
10
  module EPPClient
11
11
  class Hostmaster < Base
12
- VERSION = '0.2.0'
12
+ VERSION = '0.2.1'
13
13
 
14
14
  SCHEMAS = %w(domain-1.1 host-1.1 contact-1.1 rgp-1.1)
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epp-client-hostmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000 Z
12
+ date: 2012-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler