synergy_wholesale 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +19 -0
  5. data/CHANGELOG.md +2 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.md +59 -0
  9. data/Rakefile +19 -0
  10. data/lib/synergy_wholesale.rb +17 -0
  11. data/lib/synergy_wholesale/adapter.rb +41 -0
  12. data/lib/synergy_wholesale/api.rb +29 -0
  13. data/lib/synergy_wholesale/base_response.rb +55 -0
  14. data/lib/synergy_wholesale/configuration.rb +22 -0
  15. data/lib/synergy_wholesale/errors.rb +3 -0
  16. data/lib/synergy_wholesale/errors/bad_data_error.rb +6 -0
  17. data/lib/synergy_wholesale/errors/error.rb +15 -0
  18. data/lib/synergy_wholesale/errors/response_error.rb +16 -0
  19. data/lib/synergy_wholesale/inflector.rb +67 -0
  20. data/lib/synergy_wholesale/operation.rb +21 -0
  21. data/lib/synergy_wholesale/operations/check_domain.rb +34 -0
  22. data/lib/synergy_wholesale/operations/disable_auto_renewal.rb +27 -0
  23. data/lib/synergy_wholesale/operations/domain_register.rb +51 -0
  24. data/lib/synergy_wholesale/operations/domain_register_au.rb +46 -0
  25. data/lib/synergy_wholesale/operations/enable_auto_renewal.rb +27 -0
  26. data/lib/synergy_wholesale/response_generator.rb +18 -0
  27. data/lib/synergy_wholesale/types.rb +22 -0
  28. data/lib/synergy_wholesale/types/au_contact.rb +61 -0
  29. data/lib/synergy_wholesale/types/au_domain.rb +17 -0
  30. data/lib/synergy_wholesale/types/au_id_type.rb +28 -0
  31. data/lib/synergy_wholesale/types/au_organisation_type.rb +33 -0
  32. data/lib/synergy_wholesale/types/au_postcode.rb +13 -0
  33. data/lib/synergy_wholesale/types/au_registrant.rb +41 -0
  34. data/lib/synergy_wholesale/types/au_state.rb +15 -0
  35. data/lib/synergy_wholesale/types/contact.rb +61 -0
  36. data/lib/synergy_wholesale/types/country.rb +263 -0
  37. data/lib/synergy_wholesale/types/domain.rb +17 -0
  38. data/lib/synergy_wholesale/types/domain_list.rb +21 -0
  39. data/lib/synergy_wholesale/types/email.rb +31 -0
  40. data/lib/synergy_wholesale/types/phone.rb +13 -0
  41. data/lib/synergy_wholesale/types/registration_years.rb +12 -0
  42. data/lib/synergy_wholesale/version.rb +3 -0
  43. data/spec/fixtures/synergy/domain/autorenew/disable/failure.xml +14 -0
  44. data/spec/fixtures/synergy/domain/autorenew/disable/success.xml +14 -0
  45. data/spec/fixtures/synergy/domain/autorenew/enable/failure.xml +14 -0
  46. data/spec/fixtures/synergy/domain/autorenew/enable/success.xml +14 -0
  47. data/spec/fixtures/synergy/domain/available/example.com.xml +14 -0
  48. data/spec/fixtures/synergy/domain/available/ljsdlksdlfkmsldlskmlskmdlfkjlskjdlmlknlks.com.xml +1 -0
  49. data/spec/fixtures/synergy/domain/register/au/failure.xml +14 -0
  50. data/spec/fixtures/synergy/domain/register/au/success.xml +15 -0
  51. data/spec/fixtures/synergy/domain/register/failure.xml +14 -0
  52. data/spec/fixtures/synergy/domain/register/success.xml +15 -0
  53. data/spec/integration/check_domain_spec.rb +50 -0
  54. data/spec/integration/disable_auto_renewal_spec.rb +52 -0
  55. data/spec/integration/domain_register_au_spec.rb +225 -0
  56. data/spec/integration/domain_register_spec.rb +215 -0
  57. data/spec/integration/enable_auto_renewal_spec.rb +52 -0
  58. data/spec/spec_helper.rb +37 -0
  59. data/spec/unit/adapter_spec.rb +97 -0
  60. data/spec/unit/api_spec.rb +42 -0
  61. data/spec/unit/configuration_spec.rb +44 -0
  62. data/spec/unit/response_generator_spec.rb +35 -0
  63. data/synergy_wholesale.gemspec +26 -0
  64. metadata +210 -0
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:enableAutoRenewalResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:enableAutoRenewalResponse">
9
+ <status xsi:type="xsd:string">ERR_RESELLER_NOT_AUTHORISED</status>
10
+ <errorMessage xsi:type="xsd:string">Reseller is not authorized to perform any functions on this domain</errorMessage>
11
+ </return>
12
+ </ns1:enableAutoRenewalResponse>
13
+ </SOAP-ENV:Body>
14
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:enableAutoRenewalResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:enableAutoRenewalResponse">
9
+ <status xsi:type="xsd:string">OK</status>
10
+ <errorMessage xsi:type="xsd:string">Auto Renewal Has Been Activated Successfully</errorMessage>
11
+ </return>
12
+ </ns1:enableAutoRenewalResponse>
13
+ </SOAP-ENV:Body>
14
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:checkDomainResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:checkDomainResponse">
9
+ <available xsi:type="xsd:int">0</available>
10
+ <status xsi:type="xsd:string">UNAVAILABLE</status>
11
+ </return>
12
+ </ns1:checkDomainResponse>
13
+ </SOAP-ENV:Body>
14
+ </SOAP-ENV:Envelope>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem"><SOAP-ENV:Body><ns1:checkDomainResponse xmlns:ns1="urn:WholesaleSystem"><return xsi:type="tns:checkDomainResponse"><available xsi:type="xsd:int">1</available><status xsi:type="xsd:string">AVAILABLE</status><costPrice xsi:type="xsd:decimal">14.75</costPrice></return></ns1:checkDomainResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:domainRegisterAUResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:domainRegisterAU">
9
+ <errorMessage xsi:type="xsd:string">Domain Register AU Failed - Domain Not Available To Register</errorMessage>
10
+ <status xsi:type="xsd:string">ERR_DOMAINREGISTERAU_FAILED</status>
11
+ </return>
12
+ </ns1:domainRegisterAUResponse>
13
+ </SOAP-ENV:Body>
14
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:domainRegisterAUResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:domainRegisterAU">
9
+ <errorMessage xsi:type="xsd:string">Domain Register AU - Domain Has Been Submitted For Registration</errorMessage>
10
+ <status xsi:type="xsd:string">OK</status>
11
+ <costPrice xsi:type="xsd:string">0.00</costPrice>
12
+ </return>
13
+ </ns1:domainRegisterAUResponse>
14
+ </SOAP-ENV:Body>
15
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:domainRegisterResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:domainRegister">
9
+ <errorMessage xsi:type="xsd:string">Domain Register Failed - Domain Not Available To Register</errorMessage>
10
+ <status xsi:type="xsd:string">ERR_DOMAINREGISTER_FAILED</status>
11
+ </return>
12
+ </ns1:domainRegisterResponse>
13
+ </SOAP-ENV:Body>
14
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
3
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:WholesaleSystem">
6
+ <SOAP-ENV:Body>
7
+ <ns1:domainRegisterResponse xmlns:ns1="urn:WholesaleSystem">
8
+ <return xsi:type="tns:domainRegister">
9
+ <errorMessage xsi:type="xsd:string">Domain Register Successful - Domain Has Been Submitted For Registration</errorMessage>
10
+ <status xsi:type="xsd:string">OK</status>
11
+ <costPrice xsi:type="xsd:string">0.00</costPrice>
12
+ </return>
13
+ </ns1:domainRegisterResponse>
14
+ </SOAP-ENV:Body>
15
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,50 @@
1
+ require 'savon/mock/spec_helper'
2
+
3
+ module SynergyWholesale
4
+ RSpec.describe CheckDomain do
5
+ include Savon::SpecHelper
6
+
7
+ # set Savon in and out of mock mode
8
+ before(:all) { savon.mock! }
9
+ after(:all) { savon.unmock! }
10
+
11
+ def message(params)
12
+ core_params = API.new.adapter.params
13
+ { request: core_params.merge(params) }
14
+ end
15
+
16
+ describe 'CheckDomain' do
17
+ context 'when domain is not available' do
18
+
19
+ it 'is falsey' do
20
+ fixture = File.read('spec/fixtures/synergy/domain/available/example.com.xml')
21
+
22
+ savon
23
+ .expects(:check_domain)
24
+ .with(message: message({ domain_name: 'example.com' }))
25
+ .returns(fixture)
26
+
27
+ expect(CheckDomain.call(domain: { name: 'example.com'}).is_available?).to be_falsey
28
+ end
29
+
30
+ end
31
+
32
+ context 'when domain is available' do
33
+
34
+ it 'is truthy' do
35
+ fixture = File.read('spec/fixtures/synergy/domain/available/ljsdlksdlfkmsldlskmlskmdlfkjlskjdlmlknlks.com.xml')
36
+
37
+ savon
38
+ .expects(:check_domain)
39
+ .with(message: message({ domain_name: 'ljsdlksdlfkmsldlskmlskmdlfkjlskjdlmlknlks.com' }))
40
+ .returns(fixture)
41
+
42
+ expect(CheckDomain.call(domain: { name: 'ljsdlksdlfkmsldlskmlskmdlfkjlskjdlmlknlks.com'}).is_available?).to be_truthy
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,52 @@
1
+ require 'savon/mock/spec_helper'
2
+
3
+ module SynergyWholesale
4
+ RSpec.describe DisableAutoRenewal do
5
+ include Savon::SpecHelper
6
+
7
+ # set Savon in and out of mock mode
8
+ before(:all) { savon.mock! }
9
+ after(:all) { savon.unmock! }
10
+
11
+ def message(params)
12
+ core_params = API.new.adapter.params
13
+ { request: core_params.merge(params) }
14
+ end
15
+
16
+ describe 'EnableAutoRenewal' do
17
+ context 'when disabling succeeds' do
18
+
19
+ it 'is enabled' do
20
+ fixture = File.read('spec/fixtures/synergy/domain/autorenew/disable/success.xml')
21
+
22
+ savon
23
+ .expects(:disable_auto_renewal)
24
+ .with(message: message({ domain_name: 'bobsburgers.com.au' }))
25
+ .returns(fixture)
26
+
27
+ expect(DisableAutoRenewal.call(domain: { name: 'bobsburgers.com.au' }).is_enabled?).to be_falsey
28
+ end
29
+
30
+ end
31
+
32
+ context 'when disabling is not allowed' do
33
+
34
+ it 'raises a response error' do
35
+ fixture = File.read('spec/fixtures/synergy/domain/autorenew/disable/failure.xml')
36
+
37
+ savon
38
+ .expects(:disable_auto_renewal)
39
+ .with(message: message({ domain_name: 'google.com' }))
40
+ .returns(fixture)
41
+
42
+ expect {
43
+ DisableAutoRenewal.call(domain: { name: 'google.com' })
44
+ }.to raise_error(Errors::ResponseError, 'Reseller is not authorized to perform any functions on this domain')
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,225 @@
1
+ require 'savon/mock/spec_helper'
2
+
3
+ module SynergyWholesale
4
+
5
+ RSpec.describe DomainRegisterAu do
6
+ include Savon::SpecHelper
7
+
8
+ # set Savon in and out of mock mode
9
+ before(:all) { savon.mock! }
10
+ after(:all) { savon.unmock! }
11
+
12
+ def message(params)
13
+ core_params = API.new.adapter.params
14
+ { request: core_params.merge(params) }
15
+ end
16
+
17
+ describe 'DomainRegisterAu' do
18
+ context 'with valid parameters' do
19
+
20
+ it 'registers the domain' do
21
+ fixture = File.read('spec/fixtures/synergy/domain/register/au/success.xml')
22
+
23
+ domain = { name: 'bobsburgers.com.au' }
24
+ years = { years: 2 }
25
+ name_servers = { domain_list: %w(ns1.example.com ns2.example.com) }
26
+ registrant_contact = {
27
+ firstname: 'Bob',
28
+ lastname: 'Belcher',
29
+ organisation: "Bob's Burgers",
30
+ address: ['123 Ocean Avenue'],
31
+ suburb: "Seymour's Bay",
32
+ state: 'QLD',
33
+ country: 'AU',
34
+ postcode: '4123',
35
+ phone: '+61.0751234567',
36
+ email: 'bob@bobsburgers.com.au',
37
+ type: :registrant
38
+ }
39
+ technical_contact = {
40
+ firstname: 'Bob',
41
+ lastname: 'Belcher',
42
+ organisation: "Bob's Burgers",
43
+ address: ['123 Ocean Avenue'],
44
+ suburb: "Seymour's Bay",
45
+ state: 'QLD',
46
+ country: 'AU',
47
+ postcode: '4123',
48
+ phone: '+61.0751234567',
49
+ email: 'bob@bobsburgers.com.au',
50
+ type: :technical
51
+ }
52
+ registrant = {
53
+ registrant_name: "Bob's Burgers Pty Ltd",
54
+ registrant_id: '12345678912',
55
+ registrant_id_type: 'ABN',
56
+ eligibility_type: 'Company',
57
+ eligibility_name: "Bob's Burgers Pty Ltd",
58
+ eligibility_id_type: 'ABN',
59
+ eligibility_id: '12345678912'
60
+ }
61
+
62
+ attributes = {
63
+ domain: domain,
64
+ years: years,
65
+ name_servers: Types::DomainList.build(name_servers),
66
+ registrant_contact: Types::AuContact.build(registrant_contact),
67
+ technical_contact: Types::AuContact.build(technical_contact),
68
+ registrant: Types::AuRegistrant.build(registrant)
69
+ }
70
+
71
+ savon
72
+ .expects(:domain_register_au)
73
+ .with(
74
+ message: message(
75
+ {
76
+ domain_name: 'bobsburgers.com.au',
77
+ years: '2',
78
+ name_servers: { item: %w(ns1.example.com ns2.example.com), '@xsi:type' => 'enc:Array' },
79
+ 'registrant_lastname' => 'Belcher',
80
+ 'registrant_firstname' => 'Bob',
81
+ 'registrant_organisation' => "Bob's Burgers",
82
+ 'registrant_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
83
+ 'registrant_suburb' => "Seymour's Bay",
84
+ 'registrant_state' => 'QLD',
85
+ 'registrant_country' => 'AU',
86
+ 'registrant_postcode' => '4123',
87
+ 'registrant_phone' => '+61.0751234567',
88
+ 'registrant_fax' => '',
89
+ 'registrant_email' => 'bob@bobsburgers.com.au',
90
+ 'technical_lastname' => 'Belcher',
91
+ 'technical_firstname' => 'Bob',
92
+ 'technical_organisation' => "Bob's Burgers",
93
+ 'technical_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
94
+ 'technical_suburb' => "Seymour's Bay",
95
+ 'technical_state' => 'QLD',
96
+ 'technical_country' => 'AU',
97
+ 'technical_postcode' => '4123',
98
+ 'technical_phone' => '+61.0751234567',
99
+ 'technical_fax' => '',
100
+ 'technical_email' => 'bob@bobsburgers.com.au',
101
+ 'registrantName' => "Bob's Burgers Pty Ltd",
102
+ 'registrantID' => '12345678912',
103
+ 'registrantIDType' => 'ABN',
104
+ 'eligibilityID' => '12345678912',
105
+ 'eligibilityIDType' => 'ABN',
106
+ 'eligibilityName' => "Bob's Burgers Pty Ltd",
107
+ 'eligibilityType' => 'Company'
108
+ }
109
+ )
110
+ )
111
+ .returns(fixture)
112
+
113
+
114
+ expect(DomainRegisterAu.call(attributes)).to be_successful
115
+ end
116
+
117
+ end
118
+
119
+ context 'with invalid parameters' do
120
+
121
+ it 'returns an error' do
122
+ fixture = File.read('spec/fixtures/synergy/domain/register/au/failure.xml')
123
+
124
+ domain = { name: 'google.com.au' }
125
+ years = { years: 2 }
126
+ name_servers = { domain_list: %w(ns1.example.com ns2.example.com) }
127
+ registrant_contact = {
128
+ firstname: 'Bob',
129
+ lastname: 'Belcher',
130
+ organisation: "Bob's Burgers",
131
+ address: ['123 Ocean Avenue'],
132
+ suburb: "Seymour's Bay",
133
+ state: 'QLD',
134
+ country: 'AU',
135
+ postcode: '4123',
136
+ phone: '+61.0751234567',
137
+ email: 'bob@bobsburgers.com.au',
138
+ type: :registrant
139
+ }
140
+ technical_contact = {
141
+ firstname: 'Bob',
142
+ lastname: 'Belcher',
143
+ organisation: "Bob's Burgers",
144
+ address: ['123 Ocean Avenue'],
145
+ suburb: "Seymour's Bay",
146
+ state: 'QLD',
147
+ country: 'AU',
148
+ postcode: '4123',
149
+ phone: '+61.0751234567',
150
+ email: 'bob@bobsburgers.com.au',
151
+ type: :technical
152
+ }
153
+ registrant = {
154
+ registrant_name: "Bob's Burgers Pty Ltd",
155
+ registrant_id: '12345678912',
156
+ registrant_id_type: 'ABN',
157
+ eligibility_type: 'Company',
158
+ eligibility_name: "Bob's Burgers Pty Ltd",
159
+ eligibility_id_type: 'ABN',
160
+ eligibility_id: '12345678912'
161
+ }
162
+
163
+ attributes = {
164
+ domain: domain,
165
+ years: years,
166
+ name_servers: Types::DomainList.build(name_servers),
167
+ registrant_contact: Types::AuContact.build(registrant_contact),
168
+ technical_contact: Types::AuContact.build(technical_contact),
169
+ registrant: Types::AuRegistrant.build(registrant)
170
+ }
171
+
172
+ savon
173
+ .expects(:domain_register_au)
174
+ .with(
175
+ message: message(
176
+ {
177
+ domain_name: 'google.com.au',
178
+ years: '2',
179
+ name_servers: { item: %w(ns1.example.com ns2.example.com), '@xsi:type' => 'enc:Array' },
180
+ 'registrant_lastname' => 'Belcher',
181
+ 'registrant_firstname' => 'Bob',
182
+ 'registrant_organisation' => "Bob's Burgers",
183
+ 'registrant_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
184
+ 'registrant_suburb' => "Seymour's Bay",
185
+ 'registrant_state' => 'QLD',
186
+ 'registrant_country' => 'AU',
187
+ 'registrant_postcode' => '4123',
188
+ 'registrant_phone' => '+61.0751234567',
189
+ 'registrant_fax' => '',
190
+ 'registrant_email' => 'bob@bobsburgers.com.au',
191
+ 'technical_lastname' => 'Belcher',
192
+ 'technical_firstname' => 'Bob',
193
+ 'technical_organisation' => "Bob's Burgers",
194
+ 'technical_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
195
+ 'technical_suburb' => "Seymour's Bay",
196
+ 'technical_state' => 'QLD',
197
+ 'technical_country' => 'AU',
198
+ 'technical_postcode' => '4123',
199
+ 'technical_phone' => '+61.0751234567',
200
+ 'technical_fax' => '',
201
+ 'technical_email' => 'bob@bobsburgers.com.au',
202
+ 'registrantName' => "Bob's Burgers Pty Ltd",
203
+ 'registrantID' => '12345678912',
204
+ 'registrantIDType' => 'ABN',
205
+ 'eligibilityID' => '12345678912',
206
+ 'eligibilityIDType' => 'ABN',
207
+ 'eligibilityName' => "Bob's Burgers Pty Ltd",
208
+ 'eligibilityType' => 'Company'
209
+ }
210
+ )
211
+ )
212
+ .returns(fixture)
213
+
214
+ expect {
215
+ DomainRegisterAu.call(attributes)
216
+ }.to raise_exception(
217
+ SynergyWholesale::Errors::ResponseError,
218
+ 'Domain Register AU Failed - Domain Not Available To Register'
219
+ )
220
+ end
221
+
222
+ end
223
+ end
224
+ end
225
+ end
@@ -0,0 +1,215 @@
1
+ require 'savon/mock/spec_helper'
2
+
3
+ module SynergyWholesale
4
+
5
+ RSpec.describe DomainRegister do
6
+ include Savon::SpecHelper
7
+
8
+ # set Savon in and out of mock mode
9
+ before(:all) { savon.mock! }
10
+ after(:all) { savon.unmock! }
11
+
12
+ def message(params)
13
+ core_params = API.new.adapter.params
14
+ { request: core_params.merge(params) }
15
+ end
16
+
17
+ describe 'DomainRegister' do
18
+ context 'with valid parameters' do
19
+
20
+ it 'registers the domain' do
21
+ fixture = File.read('spec/fixtures/synergy/domain/register/success.xml')
22
+
23
+ domain = { name: 'bobsburgers.com' }
24
+ years = { years: 2 }
25
+ name_servers = { domain_list: %w(ns1.example.com ns2.example.com) }
26
+ contact = {
27
+ firstname: 'Bob',
28
+ lastname: 'Belcher',
29
+ organisation: "Bob's Burgers",
30
+ address: ['123 Ocean Avenue'],
31
+ suburb: "Seymour's Bay",
32
+ state: 'QLD',
33
+ country: 'AU',
34
+ postcode: '4123',
35
+ phone: '+61.0751234567',
36
+ email: 'bob@bobsburgers.com.au'
37
+ }
38
+
39
+ attributes = {
40
+ domain: domain,
41
+ years: years,
42
+ name_servers: Types::DomainList.build(name_servers),
43
+ registrant_contact: Types::Contact.build(contact.merge(type: :registrant)),
44
+ technical_contact: Types::Contact.build(contact.merge(type: :technical)),
45
+ billing_contact: Types::Contact.build(contact.merge(type: :billing)),
46
+ admin_contact: Types::Contact.build(contact.merge(type: :admin)),
47
+ id_protect: false
48
+ }
49
+
50
+ savon
51
+ .expects(:domain_register)
52
+ .with(
53
+ message: message(
54
+ {
55
+ id_protect: '',
56
+ domain_name: 'bobsburgers.com',
57
+ years: '2',
58
+ name_servers: { item: %w(ns1.example.com ns2.example.com), '@xsi:type' => 'enc:Array' },
59
+ 'registrant_lastname' => 'Belcher',
60
+ 'registrant_firstname' => 'Bob',
61
+ 'registrant_organisation' => "Bob's Burgers",
62
+ 'registrant_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
63
+ 'registrant_suburb' => "Seymour's Bay",
64
+ 'registrant_state' => 'QLD',
65
+ 'registrant_country' => 'AU',
66
+ 'registrant_postcode' => '4123',
67
+ 'registrant_phone' => '+61.0751234567',
68
+ 'registrant_fax' => '',
69
+ 'registrant_email' => 'bob@bobsburgers.com.au',
70
+ 'technical_lastname' => 'Belcher',
71
+ 'technical_firstname' => 'Bob',
72
+ 'technical_organisation' => "Bob's Burgers",
73
+ 'technical_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
74
+ 'technical_suburb' => "Seymour's Bay",
75
+ 'technical_state' => 'QLD',
76
+ 'technical_country' => 'AU',
77
+ 'technical_postcode' => '4123',
78
+ 'technical_phone' => '+61.0751234567',
79
+ 'technical_fax' => '',
80
+ 'technical_email' => 'bob@bobsburgers.com.au',
81
+ 'billing_lastname' => 'Belcher',
82
+ 'billing_firstname' => 'Bob',
83
+ 'billing_organisation' => "Bob's Burgers",
84
+ 'billing_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
85
+ 'billing_suburb' => "Seymour's Bay",
86
+ 'billing_state' => 'QLD',
87
+ 'billing_country' => 'AU',
88
+ 'billing_postcode' => '4123',
89
+ 'billing_phone' => '+61.0751234567',
90
+ 'billing_fax' => '',
91
+ 'billing_email' => 'bob@bobsburgers.com.au',
92
+ 'admin_lastname' => 'Belcher',
93
+ 'admin_firstname' => 'Bob',
94
+ 'admin_organisation' => "Bob's Burgers",
95
+ 'admin_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
96
+ 'admin_suburb' => "Seymour's Bay",
97
+ 'admin_state' => 'QLD',
98
+ 'admin_country' => 'AU',
99
+ 'admin_postcode' => '4123',
100
+ 'admin_phone' => '+61.0751234567',
101
+ 'admin_fax' => '',
102
+ 'admin_email' => 'bob@bobsburgers.com.au'
103
+ }
104
+ )
105
+ )
106
+ .returns(fixture)
107
+
108
+
109
+ expect(DomainRegister.call(attributes)).to be_successful
110
+ end
111
+
112
+ end
113
+
114
+ context 'with invalid parameters' do
115
+
116
+ it 'returns an error' do
117
+ fixture = File.read('spec/fixtures/synergy/domain/register/failure.xml')
118
+
119
+ domain = { name: 'google.com' }
120
+ years = { years: 2 }
121
+ name_servers = { domain_list: %w(ns1.example.com ns2.example.com) }
122
+ contact = {
123
+ firstname: 'Bob',
124
+ lastname: 'Belcher',
125
+ organisation: "Bob's Burgers",
126
+ address: ['123 Ocean Avenue'],
127
+ suburb: "Seymour's Bay",
128
+ state: 'QLD',
129
+ country: 'AU',
130
+ postcode: '4123',
131
+ phone: '+61.0751234567',
132
+ email: 'bob@bobsburgers.com.au'
133
+ }
134
+
135
+ attributes = {
136
+ domain: domain,
137
+ years: years,
138
+ name_servers: Types::DomainList.build(name_servers),
139
+ registrant_contact: Types::Contact.build(contact.merge(type: :registrant)),
140
+ technical_contact: Types::Contact.build(contact.merge(type: :technical)),
141
+ billing_contact: Types::Contact.build(contact.merge(type: :billing)),
142
+ admin_contact: Types::Contact.build(contact.merge(type: :admin)),
143
+ id_protect: false
144
+ }
145
+
146
+ savon
147
+ .expects(:domain_register)
148
+ .with(
149
+ message: message(
150
+ {
151
+ id_protect: '',
152
+ domain_name: 'google.com',
153
+ years: '2',
154
+ name_servers: { item: %w(ns1.example.com ns2.example.com), '@xsi:type' => 'enc:Array' },
155
+ 'registrant_lastname' => 'Belcher',
156
+ 'registrant_firstname' => 'Bob',
157
+ 'registrant_organisation' => "Bob's Burgers",
158
+ 'registrant_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
159
+ 'registrant_suburb' => "Seymour's Bay",
160
+ 'registrant_state' => 'QLD',
161
+ 'registrant_country' => 'AU',
162
+ 'registrant_postcode' => '4123',
163
+ 'registrant_phone' => '+61.0751234567',
164
+ 'registrant_fax' => '',
165
+ 'registrant_email' => 'bob@bobsburgers.com.au',
166
+ 'technical_lastname' => 'Belcher',
167
+ 'technical_firstname' => 'Bob',
168
+ 'technical_organisation' => "Bob's Burgers",
169
+ 'technical_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
170
+ 'technical_suburb' => "Seymour's Bay",
171
+ 'technical_state' => 'QLD',
172
+ 'technical_country' => 'AU',
173
+ 'technical_postcode' => '4123',
174
+ 'technical_phone' => '+61.0751234567',
175
+ 'technical_fax' => '',
176
+ 'technical_email' => 'bob@bobsburgers.com.au',
177
+ 'billing_lastname' => 'Belcher',
178
+ 'billing_firstname' => 'Bob',
179
+ 'billing_organisation' => "Bob's Burgers",
180
+ 'billing_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
181
+ 'billing_suburb' => "Seymour's Bay",
182
+ 'billing_state' => 'QLD',
183
+ 'billing_country' => 'AU',
184
+ 'billing_postcode' => '4123',
185
+ 'billing_phone' => '+61.0751234567',
186
+ 'billing_fax' => '',
187
+ 'billing_email' => 'bob@bobsburgers.com.au',
188
+ 'admin_lastname' => 'Belcher',
189
+ 'admin_firstname' => 'Bob',
190
+ 'admin_organisation' => "Bob's Burgers",
191
+ 'admin_address' => { item: ['123 Ocean Avenue'], '@xsi:type' => 'enc:Array' },
192
+ 'admin_suburb' => "Seymour's Bay",
193
+ 'admin_state' => 'QLD',
194
+ 'admin_country' => 'AU',
195
+ 'admin_postcode' => '4123',
196
+ 'admin_phone' => '+61.0751234567',
197
+ 'admin_fax' => '',
198
+ 'admin_email' => 'bob@bobsburgers.com.au'
199
+ }
200
+ )
201
+ )
202
+ .returns(fixture)
203
+
204
+ expect {
205
+ DomainRegister.call(attributes)
206
+ }.to raise_exception(
207
+ SynergyWholesale::Errors::ResponseError,
208
+ 'Domain Register Failed - Domain Not Available To Register'
209
+ )
210
+ end
211
+
212
+ end
213
+ end
214
+ end
215
+ end