synergy_wholesale 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +59 -0
- data/Rakefile +19 -0
- data/lib/synergy_wholesale.rb +17 -0
- data/lib/synergy_wholesale/adapter.rb +41 -0
- data/lib/synergy_wholesale/api.rb +29 -0
- data/lib/synergy_wholesale/base_response.rb +55 -0
- data/lib/synergy_wholesale/configuration.rb +22 -0
- data/lib/synergy_wholesale/errors.rb +3 -0
- data/lib/synergy_wholesale/errors/bad_data_error.rb +6 -0
- data/lib/synergy_wholesale/errors/error.rb +15 -0
- data/lib/synergy_wholesale/errors/response_error.rb +16 -0
- data/lib/synergy_wholesale/inflector.rb +67 -0
- data/lib/synergy_wholesale/operation.rb +21 -0
- data/lib/synergy_wholesale/operations/check_domain.rb +34 -0
- data/lib/synergy_wholesale/operations/disable_auto_renewal.rb +27 -0
- data/lib/synergy_wholesale/operations/domain_register.rb +51 -0
- data/lib/synergy_wholesale/operations/domain_register_au.rb +46 -0
- data/lib/synergy_wholesale/operations/enable_auto_renewal.rb +27 -0
- data/lib/synergy_wholesale/response_generator.rb +18 -0
- data/lib/synergy_wholesale/types.rb +22 -0
- data/lib/synergy_wholesale/types/au_contact.rb +61 -0
- data/lib/synergy_wholesale/types/au_domain.rb +17 -0
- data/lib/synergy_wholesale/types/au_id_type.rb +28 -0
- data/lib/synergy_wholesale/types/au_organisation_type.rb +33 -0
- data/lib/synergy_wholesale/types/au_postcode.rb +13 -0
- data/lib/synergy_wholesale/types/au_registrant.rb +41 -0
- data/lib/synergy_wholesale/types/au_state.rb +15 -0
- data/lib/synergy_wholesale/types/contact.rb +61 -0
- data/lib/synergy_wholesale/types/country.rb +263 -0
- data/lib/synergy_wholesale/types/domain.rb +17 -0
- data/lib/synergy_wholesale/types/domain_list.rb +21 -0
- data/lib/synergy_wholesale/types/email.rb +31 -0
- data/lib/synergy_wholesale/types/phone.rb +13 -0
- data/lib/synergy_wholesale/types/registration_years.rb +12 -0
- data/lib/synergy_wholesale/version.rb +3 -0
- data/spec/fixtures/synergy/domain/autorenew/disable/failure.xml +14 -0
- data/spec/fixtures/synergy/domain/autorenew/disable/success.xml +14 -0
- data/spec/fixtures/synergy/domain/autorenew/enable/failure.xml +14 -0
- data/spec/fixtures/synergy/domain/autorenew/enable/success.xml +14 -0
- data/spec/fixtures/synergy/domain/available/example.com.xml +14 -0
- data/spec/fixtures/synergy/domain/available/ljsdlksdlfkmsldlskmlskmdlfkjlskjdlmlknlks.com.xml +1 -0
- data/spec/fixtures/synergy/domain/register/au/failure.xml +14 -0
- data/spec/fixtures/synergy/domain/register/au/success.xml +15 -0
- data/spec/fixtures/synergy/domain/register/failure.xml +14 -0
- data/spec/fixtures/synergy/domain/register/success.xml +15 -0
- data/spec/integration/check_domain_spec.rb +50 -0
- data/spec/integration/disable_auto_renewal_spec.rb +52 -0
- data/spec/integration/domain_register_au_spec.rb +225 -0
- data/spec/integration/domain_register_spec.rb +215 -0
- data/spec/integration/enable_auto_renewal_spec.rb +52 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/unit/adapter_spec.rb +97 -0
- data/spec/unit/api_spec.rb +42 -0
- data/spec/unit/configuration_spec.rb +44 -0
- data/spec/unit/response_generator_spec.rb +35 -0
- data/synergy_wholesale.gemspec +26 -0
- metadata +210 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
class CheckDomain < Operation
|
3
|
+
class Command < ::Dry::Struct
|
4
|
+
attribute :domain, Types::Domain
|
5
|
+
|
6
|
+
def to_param
|
7
|
+
domain.to_param
|
8
|
+
end
|
9
|
+
|
10
|
+
def operation
|
11
|
+
:check_domain
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Response < BaseResponse
|
16
|
+
def is_available?
|
17
|
+
response[:status] == 'AVAILABLE'
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def success_statuses
|
23
|
+
%w(AVAILABLE UNAVAILABLE)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def call(domain)
|
29
|
+
command = Command.new(domain)
|
30
|
+
api.call(command)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
class DisableAutoRenewal < Operation
|
3
|
+
class Command < ::Dry::Struct
|
4
|
+
attribute :domain, Types::Domain
|
5
|
+
|
6
|
+
def to_param
|
7
|
+
domain.to_param
|
8
|
+
end
|
9
|
+
|
10
|
+
def operation
|
11
|
+
:disable_auto_renewal
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Response < BaseResponse
|
16
|
+
def is_enabled?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(domain)
|
22
|
+
command = Command.new(domain)
|
23
|
+
api.call(command)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
class DomainRegister < Operation
|
3
|
+
class Command < Dry::Struct
|
4
|
+
attribute :domain, Types::Domain
|
5
|
+
attribute :years, Types::RegistrationYears
|
6
|
+
attribute :name_servers, Types::DomainList
|
7
|
+
attribute :registrant_contact, Types::Contact
|
8
|
+
attribute :technical_contact, Types::Contact
|
9
|
+
attribute :billing_contact, Types::Contact
|
10
|
+
attribute :admin_contact, Types::Contact
|
11
|
+
attribute :id_protect, Types::Bool.optional
|
12
|
+
|
13
|
+
def to_param
|
14
|
+
params = {
|
15
|
+
id_protect: id_protect ? 'Y' : ''
|
16
|
+
}
|
17
|
+
params.merge!(domain.to_param)
|
18
|
+
params.merge!(years.to_param)
|
19
|
+
params.merge!(name_servers.to_param)
|
20
|
+
params.merge!(registrant_contact.to_param)
|
21
|
+
params.merge!(technical_contact.to_param)
|
22
|
+
params.merge!(billing_contact.to_param)
|
23
|
+
params.merge!(admin_contact.to_param)
|
24
|
+
|
25
|
+
params
|
26
|
+
end
|
27
|
+
|
28
|
+
def operation
|
29
|
+
:domain_register
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Response < BaseResponse
|
34
|
+
def validate_data
|
35
|
+
raise Errors::BadDataError.new('Expected a numeric cost price', command, response) unless Inflector.is_numeric?(response[:cost_price])
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def expected_fields
|
41
|
+
%w(cost_price)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def call(attributes)
|
46
|
+
command = Command.new(attributes)
|
47
|
+
api.call(command)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
class DomainRegisterAu < Operation
|
3
|
+
class Command < Dry::Struct
|
4
|
+
attribute :domain, Types::Domain
|
5
|
+
attribute :years, Types::RegistrationYears
|
6
|
+
attribute :name_servers, Types::DomainList
|
7
|
+
attribute :registrant_contact, Types::AuContact
|
8
|
+
attribute :technical_contact, Types::AuContact
|
9
|
+
attribute :registrant, Types::AuRegistrant
|
10
|
+
|
11
|
+
def to_param
|
12
|
+
params = {}
|
13
|
+
params.merge!(domain.to_param)
|
14
|
+
params.merge!(years.to_param)
|
15
|
+
params.merge!(name_servers.to_param)
|
16
|
+
params.merge!(registrant_contact.to_param)
|
17
|
+
params.merge!(technical_contact.to_param)
|
18
|
+
params.merge!(registrant.to_param)
|
19
|
+
|
20
|
+
params
|
21
|
+
end
|
22
|
+
|
23
|
+
def operation
|
24
|
+
:domain_register_au
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Response < BaseResponse
|
29
|
+
def validate_data
|
30
|
+
raise Errors::BadDataError.new('Expected a numeric cost price', command, response) unless Inflector.is_numeric?(response[:cost_price])
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def expected_fields
|
36
|
+
%w(cost_price)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def call(attributes)
|
41
|
+
command = Command.new(attributes)
|
42
|
+
api.call(command)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
class EnableAutoRenewal < Operation
|
3
|
+
class Command < ::Dry::Struct
|
4
|
+
attribute :domain, Types::Domain
|
5
|
+
|
6
|
+
def to_param
|
7
|
+
domain.to_param
|
8
|
+
end
|
9
|
+
|
10
|
+
def operation
|
11
|
+
:enable_auto_renewal
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Response < BaseResponse
|
16
|
+
def is_enabled?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call(domain)
|
22
|
+
command = Command.new(domain)
|
23
|
+
api.call(command)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'inflector'
|
2
|
+
|
3
|
+
module SynergyWholesale
|
4
|
+
class ResponseGenerator
|
5
|
+
|
6
|
+
def build_response(command_name, response, soap_command)
|
7
|
+
get_response_class(command_name).new(response, soap_command)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def get_response_class(command_name)
|
13
|
+
response_class = command_name.gsub('Command', 'Response')
|
14
|
+
Inflector.constantize(response_class)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dry-types'
|
2
|
+
|
3
|
+
module SynergyWholesale
|
4
|
+
module Types
|
5
|
+
include Dry::Types.module
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'synergy_wholesale/types/domain'
|
10
|
+
require 'synergy_wholesale/types/au_domain'
|
11
|
+
require 'synergy_wholesale/types/au_id_type'
|
12
|
+
require 'synergy_wholesale/types/au_organisation_type'
|
13
|
+
require 'synergy_wholesale/types/au_postcode'
|
14
|
+
require 'synergy_wholesale/types/au_state'
|
15
|
+
require 'synergy_wholesale/types/country'
|
16
|
+
require 'synergy_wholesale/types/domain_list'
|
17
|
+
require 'synergy_wholesale/types/email'
|
18
|
+
require 'synergy_wholesale/types/phone'
|
19
|
+
require 'synergy_wholesale/types/registration_years'
|
20
|
+
require 'synergy_wholesale/types/contact'
|
21
|
+
require 'synergy_wholesale/types/au_contact'
|
22
|
+
require 'synergy_wholesale/types/au_registrant'
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
module Types
|
3
|
+
class AuContact < Dry::Struct
|
4
|
+
attribute :organisation, Types::Strict::String.optional
|
5
|
+
attribute :firstname, Types::Strict::String
|
6
|
+
attribute :lastname, Types::Strict::String
|
7
|
+
attribute :address, Types::Strict::Array.constrained(filled: true)
|
8
|
+
attribute :suburb, Types::Strict::String
|
9
|
+
|
10
|
+
attribute :state, Types::AuState
|
11
|
+
attribute :postcode, Types::AuPostcode
|
12
|
+
attribute :country, Types::Country
|
13
|
+
attribute :phone, Types::Phone
|
14
|
+
attribute :fax, Types::Phone.optional
|
15
|
+
attribute :email, Types::Email
|
16
|
+
attribute :type, Types::Strict::Symbol.constrained(included_in: %i(billing admin technical registrant))
|
17
|
+
|
18
|
+
def self.build(attributes)
|
19
|
+
new(
|
20
|
+
{
|
21
|
+
firstname: attributes[:firstname],
|
22
|
+
lastname: attributes[:lastname],
|
23
|
+
organisation: attributes[:organisation],
|
24
|
+
address: attributes[:address],
|
25
|
+
suburb: attributes[:suburb],
|
26
|
+
state: { state: attributes[:state] },
|
27
|
+
country: { country_code: attributes[:country] },
|
28
|
+
postcode: { postcode: attributes[:postcode] },
|
29
|
+
phone: { phone: attributes[:phone] },
|
30
|
+
fax: attributes[:fax] ? { phone: attributes[:fax] } : nil,
|
31
|
+
email: { email: attributes[:email] },
|
32
|
+
type: attributes[:type]
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_param
|
38
|
+
{
|
39
|
+
prefixed(:lastname) => lastname,
|
40
|
+
prefixed(:firstname) => firstname,
|
41
|
+
prefixed(:organisation) => organisation,
|
42
|
+
prefixed(:address) => { item: address, '@xsi:type' => 'enc:Array' },
|
43
|
+
prefixed(:suburb) => suburb,
|
44
|
+
prefixed(:state) => state.to_s,
|
45
|
+
prefixed(:country) => country.to_s,
|
46
|
+
prefixed(:postcode) => postcode.to_s,
|
47
|
+
prefixed(:phone) => phone.to_s,
|
48
|
+
prefixed(:fax) => fax.to_s,
|
49
|
+
prefixed(:email) => email.to_s
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def prefixed(attr)
|
56
|
+
"#{type}_#{attr}"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
module Types
|
3
|
+
class AuIDType < Dry::Struct
|
4
|
+
|
5
|
+
ID_TYPES = [
|
6
|
+
'ABN',
|
7
|
+
'ACN',
|
8
|
+
'ACT BN',
|
9
|
+
'NSW BN',
|
10
|
+
'NT BN',
|
11
|
+
'OTHER',
|
12
|
+
'QLD BN',
|
13
|
+
'SA BN',
|
14
|
+
'TAS BN',
|
15
|
+
'TM',
|
16
|
+
'VIC BN',
|
17
|
+
'WA BN'
|
18
|
+
]
|
19
|
+
|
20
|
+
attribute :id_type, Types::Strict::String.constrained(included_in: ID_TYPES)
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
id_type
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
module Types
|
3
|
+
class AuOrganisationType < Dry::Struct
|
4
|
+
|
5
|
+
ORGANISATION_TYPES = [
|
6
|
+
'Charity',
|
7
|
+
'Citizen/Resident',
|
8
|
+
'Club',
|
9
|
+
'Commercial Statutory Body',
|
10
|
+
'Company',
|
11
|
+
'Incorporated Association',
|
12
|
+
'Industry Body',
|
13
|
+
'Non-profit Organisation',
|
14
|
+
'Other',
|
15
|
+
'Partnership',
|
16
|
+
'Pending TM Owner',
|
17
|
+
'Political Party',
|
18
|
+
'Registered Business',
|
19
|
+
'Religious/Church Group',
|
20
|
+
'Sole Trader',
|
21
|
+
'Trade Union',
|
22
|
+
'Trademark'
|
23
|
+
]
|
24
|
+
|
25
|
+
attribute :organisation_type, Types::Strict::String.constrained(included_in: ORGANISATION_TYPES)
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
organisation_type
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module SynergyWholesale
|
2
|
+
module Types
|
3
|
+
class AuRegistrant < Dry::Struct
|
4
|
+
|
5
|
+
attribute :registrant_name, Types::Strict::String
|
6
|
+
attribute :registrant_id, Types::Strict::String.constrained(size: 9) | Types::Strict::String.constrained(size: 11)
|
7
|
+
attribute :registrant_id_type, Types::AuIDType.optional
|
8
|
+
attribute :eligibility_name, Types::Strict::String.optional
|
9
|
+
attribute :eligibility_id, Types::Strict::String.constrained(size: 9) | Types::Strict::String.constrained(size: 11)
|
10
|
+
attribute :eligibility_type, Types::AuOrganisationType
|
11
|
+
attribute :eligibility_id_type, Types::AuIDType.optional
|
12
|
+
|
13
|
+
def self.build(attributes)
|
14
|
+
new(
|
15
|
+
{
|
16
|
+
registrant_name: attributes[:registrant_name],
|
17
|
+
registrant_id: attributes[:registrant_id],
|
18
|
+
registrant_id_type: { id_type: attributes[:registrant_id_type] },
|
19
|
+
eligibility_type: { organisation_type: attributes[:eligibility_type] },
|
20
|
+
eligibility_name: attributes[:eligibility_name],
|
21
|
+
eligibility_id_type: { id_type: attributes[:eligibility_id_type] },
|
22
|
+
eligibility_id: attributes[:eligibility_id]
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_param
|
28
|
+
{
|
29
|
+
'registrantName' => registrant_name,
|
30
|
+
'registrantID' => registrant_id,
|
31
|
+
'registrantIDType' => registrant_id_type.to_s,
|
32
|
+
'eligibilityID' => eligibility_id,
|
33
|
+
'eligibilityIDType' => eligibility_id_type.to_s,
|
34
|
+
'eligibilityName' => eligibility_name,
|
35
|
+
'eligibilityType' => eligibility_type.to_s
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|