internetbs 1.0.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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +5 -0
- data/LICENSE +19 -0
- data/README.md +758 -0
- data/internetbs.gemspec +18 -0
- data/lib/internetbs.rb +64 -0
- data/lib/internetbs/account_balance.rb +8 -0
- data/lib/internetbs/account_balances.rb +40 -0
- data/lib/internetbs/account_domain.rb +11 -0
- data/lib/internetbs/account_domains.rb +100 -0
- data/lib/internetbs/account_price.rb +19 -0
- data/lib/internetbs/account_prices.rb +70 -0
- data/lib/internetbs/account_transaction.rb +9 -0
- data/lib/internetbs/account_transactions.rb +54 -0
- data/lib/internetbs/additional_attributes.rb +41 -0
- data/lib/internetbs/base.rb +33 -0
- data/lib/internetbs/client.rb +49 -0
- data/lib/internetbs/configuration.rb +61 -0
- data/lib/internetbs/country_codes.rb +288 -0
- data/lib/internetbs/domain_availability.rb +37 -0
- data/lib/internetbs/domain_contact.rb +109 -0
- data/lib/internetbs/domain_host.rb +46 -0
- data/lib/internetbs/domain_hosts.rb +101 -0
- data/lib/internetbs/domain_information.rb +128 -0
- data/lib/internetbs/domain_push.rb +33 -0
- data/lib/internetbs/domain_record.rb +31 -0
- data/lib/internetbs/domain_records.rb +172 -0
- data/lib/internetbs/domain_total.rb +8 -0
- data/lib/internetbs/dot_asia_attributes.rb +56 -0
- data/lib/internetbs/dot_de_attributes.rb +64 -0
- data/lib/internetbs/dot_eu_attributes.rb +20 -0
- data/lib/internetbs/dot_fr_attributes.rb +138 -0
- data/lib/internetbs/dot_it_attributes.rb +182 -0
- data/lib/internetbs/dot_nl_attributes.rb +47 -0
- data/lib/internetbs/dot_uk_attributes.rb +60 -0
- data/lib/internetbs/dot_us_attributes.rb +54 -0
- data/lib/internetbs/error.rb +38 -0
- data/lib/internetbs/language_codes.rb +27 -0
- data/lib/internetbs/order_domain.rb +78 -0
- data/lib/internetbs/private_whois.rb +81 -0
- data/lib/internetbs/registrar_lock.rb +73 -0
- data/lib/internetbs/registry_status.rb +39 -0
- data/lib/internetbs/renew_domain.rb +43 -0
- data/lib/internetbs/update_domain.rb +71 -0
- data/lib/internetbs/version.rb +10 -0
- metadata +104 -0
@@ -0,0 +1,109 @@
|
|
1
|
+
require_relative 'country_codes'
|
2
|
+
|
3
|
+
module InternetBS
|
4
|
+
class DomainContact < Base
|
5
|
+
attribute :additional_attributes, AdditionalAttributes
|
6
|
+
attribute :city, String
|
7
|
+
attribute :contact_type, String # Internal - symbol: one of :registrant, :admin, :billing, :tech, :zone
|
8
|
+
attribute :country, String # Read only - returned by DomainInformation
|
9
|
+
attribute :country_code, String # Must be one in COUNTRY_CODES
|
10
|
+
attribute :email, String
|
11
|
+
attribute :fax, String # Optional - only supported for .uk
|
12
|
+
attribute :first_name, String
|
13
|
+
attribute :last_name, String
|
14
|
+
attribute :obfuscate_email, Boolean, :default => false # Optional - only supported for .com/.net/.tv, 1 = obfuscate, 0 = not
|
15
|
+
attribute :organization, String # Required for .uk, otherwise optional, only effective when private whois is disabled
|
16
|
+
attribute :phone_number, String
|
17
|
+
attribute :postal_code, String
|
18
|
+
attribute :street, String
|
19
|
+
attribute :street_2, String # Optional
|
20
|
+
attribute :street_3, String # Optional
|
21
|
+
|
22
|
+
def initialize(attributes = nil)
|
23
|
+
super(attributes)
|
24
|
+
|
25
|
+
# Add any additional attributes
|
26
|
+
case @domain_extension
|
27
|
+
when 'asia'
|
28
|
+
@additional_attributes = DotAsiaAttributes.new
|
29
|
+
when 'de'
|
30
|
+
@additional_attributes = DotDEAttributes.new
|
31
|
+
when 'eu'
|
32
|
+
@additional_attributes = DotEUAttributes.new
|
33
|
+
when 'fr', 're', 'pm', 'tf', 'wf', 'yt'
|
34
|
+
@additional_attributes = DotFRAttributes.new
|
35
|
+
when 'it'
|
36
|
+
@additional_attributes = DotITAttributes.new
|
37
|
+
when 'nl'
|
38
|
+
@additional_attributes = DotDLAttributes.new
|
39
|
+
when 'uk'
|
40
|
+
@additional_attributes = DotUKAttributes.new
|
41
|
+
when 'us'
|
42
|
+
@additional_attributes = DotUSAttributes.new
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set contact_type and domain_extension for additional attributes
|
46
|
+
@additional_attributes.contact_type = @contact_type
|
47
|
+
@additional_attributes.domain_extension = @domain_extension
|
48
|
+
end
|
49
|
+
|
50
|
+
def params
|
51
|
+
contact = {
|
52
|
+
"#{@contact_type.to_s}_firstname" => @first_name,
|
53
|
+
"#{@contact_type.to_s}_lastname" => @last_name,
|
54
|
+
"#{@contact_type.to_s}_email" => @email,
|
55
|
+
"#{@contact_type.to_s}_phone_number" => @phone_number,
|
56
|
+
"#{@contact_type.to_s}_city" => @city,
|
57
|
+
"#{@contact_type.to_s}_street" => @street,
|
58
|
+
"#{@contact_type.to_s}_postal_code" => @postal_code,
|
59
|
+
"#{@contact_type.to_s}_country_code" => @country_code
|
60
|
+
}
|
61
|
+
|
62
|
+
if @organization || @domain_extension == 'uk'
|
63
|
+
contact.merge!({"#{@contact_type.to_s}_organization" => @organization})
|
64
|
+
end
|
65
|
+
|
66
|
+
if @fax && @domain_extension == 'uk'
|
67
|
+
contact.merge!({"#{@contact_type.to_s}_fax" => @fax})
|
68
|
+
end
|
69
|
+
|
70
|
+
if %w[com net tv].include?(@domain_extension)
|
71
|
+
contact.merge!({"#{@contact_type.to_s}_obfuscateemail" => @obfuscate_email ? 1 : 0})
|
72
|
+
end
|
73
|
+
|
74
|
+
if @street_2
|
75
|
+
contact.merge!({"#{@contact_type.to_s}_street2" => @street_2})
|
76
|
+
end
|
77
|
+
|
78
|
+
if @street_3
|
79
|
+
contact.merge!({"#{@contact_type.to_s}_street3" => @street_3})
|
80
|
+
end
|
81
|
+
|
82
|
+
case @contact_type
|
83
|
+
when :registrant
|
84
|
+
contact.merge!(@additional_attributes.registrant_params)
|
85
|
+
when :admin
|
86
|
+
contact.merge!(@additional_attributes.admin_params)
|
87
|
+
when :billing
|
88
|
+
contact.merge!(@additional_attributes.billing_params)
|
89
|
+
when :tech
|
90
|
+
contact.merge!(@additional_attributes.tech_params)
|
91
|
+
when :zone # .de only
|
92
|
+
contact.merge!(@additional_attributes.zone_params) if @domain_extension == 'de'
|
93
|
+
end
|
94
|
+
|
95
|
+
contact.merge!(@additional_attributes.mandatory_params)
|
96
|
+
contact.merge!(@additional_attributes.optional_params)
|
97
|
+
|
98
|
+
return contact
|
99
|
+
end
|
100
|
+
|
101
|
+
def valid?
|
102
|
+
ensure_attribute_has_value :first_name, :last_name, :email,
|
103
|
+
:phone_number, :city, :street, :postal_code, :country_code
|
104
|
+
unless COUNTRY_CODES.has_key?(@country_code)
|
105
|
+
@errors << "country_code must be one in COUNTRY_CODES"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class DomainHost < Base
|
3
|
+
attribute :host, String
|
4
|
+
attribute :ip_addresses, Array[String]
|
5
|
+
|
6
|
+
def fetch
|
7
|
+
ensure_attribute_has_value :host
|
8
|
+
return false if @errors.any?
|
9
|
+
|
10
|
+
params = {'host' => @host}
|
11
|
+
response = Client.get('/domain/host/info', params)
|
12
|
+
|
13
|
+
case response.code
|
14
|
+
when '200'
|
15
|
+
hash = JSON.parse(response.body)
|
16
|
+
|
17
|
+
@status = hash['status']
|
18
|
+
@transaction_id = hash['transactid']
|
19
|
+
|
20
|
+
unless @status == 'SUCCESS'
|
21
|
+
set_errors(response)
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
return true
|
26
|
+
else
|
27
|
+
set_errors(response)
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid?
|
33
|
+
ensure_attribute_has_value :host
|
34
|
+
|
35
|
+
unless ip_addresses.any?
|
36
|
+
@errors << 'at least one ip address is required'
|
37
|
+
end
|
38
|
+
|
39
|
+
if @errors.any?
|
40
|
+
return false
|
41
|
+
else
|
42
|
+
return true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class DomainHosts < Base
|
3
|
+
attribute :compact, Boolean, :default => true
|
4
|
+
attribute :domain, String
|
5
|
+
attribute :list, Array[DomainHost]
|
6
|
+
|
7
|
+
def add(domain_host)
|
8
|
+
set_record :create, domain_host
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch
|
12
|
+
ensure_attribute_has_value :domain
|
13
|
+
return false if @errors.any?
|
14
|
+
|
15
|
+
params = {'domain' => @domain}
|
16
|
+
params.merge!({'compactlist' => @compact ? 'YES' : 'NO'}) if @compact
|
17
|
+
|
18
|
+
response = Client.get('/domain/host/list', params)
|
19
|
+
code = response.code rescue ""
|
20
|
+
|
21
|
+
case code
|
22
|
+
when '200'
|
23
|
+
hash = JSON.parse(response.body)
|
24
|
+
|
25
|
+
@status = hash['status']
|
26
|
+
@transaction_id = hash['transactid']
|
27
|
+
|
28
|
+
if @status == 'SUCCESS'
|
29
|
+
total_hosts = hash['total_hosts'].to_i
|
30
|
+
if total_hosts > 0
|
31
|
+
hash['host'].each do |key, value|
|
32
|
+
@list << DomainHost.new(:host => value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
set_errors(response)
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
set_errors(response)
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def remove(domain_host)
|
48
|
+
set_record :delete, domain_host
|
49
|
+
end
|
50
|
+
|
51
|
+
def update(domain_host)
|
52
|
+
set_record :update, domain_host
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Expects an action parameter of either :create, :update or :delete.
|
58
|
+
def set_record(action, domain_host)
|
59
|
+
@errors.clear
|
60
|
+
|
61
|
+
case action
|
62
|
+
when :create, :update
|
63
|
+
unless domain_host.valid?
|
64
|
+
@errors = domain_host.errors
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
when :delete
|
68
|
+
unless domain_host.host
|
69
|
+
@errors = 'host is required'
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
params = {'host' => domain.host}
|
75
|
+
|
76
|
+
if [:create, :update].include?(action)
|
77
|
+
params.merge!({:ip_list => @ip_addresses.join(',')})
|
78
|
+
end
|
79
|
+
|
80
|
+
response = Client.post("/domain/host/#{action.to_s}", params)
|
81
|
+
|
82
|
+
case response.code
|
83
|
+
when '200'
|
84
|
+
hash = JSON.parse(response.body)
|
85
|
+
|
86
|
+
@status = hash['status']
|
87
|
+
@transaction_id = hash['transactid']
|
88
|
+
|
89
|
+
unless @status == 'SUCCESS'
|
90
|
+
set_errors(response)
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
|
94
|
+
return true
|
95
|
+
else
|
96
|
+
set_errors(response)
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class DomainInformation < Base
|
3
|
+
attribute :auto_renew, Boolean
|
4
|
+
attribute :contacts, Array[DomainContact]
|
5
|
+
attribute :domain, String
|
6
|
+
attribute :domain_extension, String
|
7
|
+
attribute :domain_status, String # REGISTERED, REGISTRAR LOCKED, PENDING TRANSFER, PENDING TRADE, ON HOLD, EXPIRED, UNKNOWN
|
8
|
+
attribute :expiration_date, Date
|
9
|
+
attribute :private_whois, String # DISABLED or FULL or PARTIAL
|
10
|
+
attribute :registrar_lock, String # ENABLED or DISABLED or NOTADMITTED
|
11
|
+
attribute :transfer_auth_info, String
|
12
|
+
|
13
|
+
def fetch
|
14
|
+
ensure_attribute_has_value :domain
|
15
|
+
return false if @errors.any?
|
16
|
+
|
17
|
+
params = {'domain' => @domain}
|
18
|
+
response = Client.get('/domain/info', params)
|
19
|
+
code = response.code rescue ""
|
20
|
+
|
21
|
+
case code
|
22
|
+
when '200'
|
23
|
+
hash = JSON.parse(response.body)
|
24
|
+
|
25
|
+
@status = hash['status']
|
26
|
+
@transaction_id = hash['transactid']
|
27
|
+
|
28
|
+
if @status == 'SUCCESS'
|
29
|
+
@auto_renew = hash['autorenew'] == 'YES' ? true : false
|
30
|
+
@domain_extension = @domain.split('.').last
|
31
|
+
@domain_status = hash['domainstatus']
|
32
|
+
@expiration_date = hash['expirationdate']
|
33
|
+
@private_whois = hash['privatewhois']
|
34
|
+
@registrar_lock = hash['registrarlock']
|
35
|
+
@transfer_auth_info = hash['transferauthinfo']
|
36
|
+
|
37
|
+
@contacts << DomainContact.new(
|
38
|
+
:contact_type => 'registrant',
|
39
|
+
:first_name => hash['contacts']['registrant']['firstname'],
|
40
|
+
:last_name => hash['contacts']['registrant']['lastname'],
|
41
|
+
:email => hash['contacts']['registrant']['email'],
|
42
|
+
:phone_number => hash['contacts']['registrant']['phonenumber'],
|
43
|
+
:organization => hash['contacts']['registrant']['organization'],
|
44
|
+
:city => hash['contacts']['registrant']['city'],
|
45
|
+
:street => hash['contacts']['registrant']['street'],
|
46
|
+
:street_2 => hash['contacts']['registrant']['street2'],
|
47
|
+
:street_3 => hash['contacts']['registrant']['street3'],
|
48
|
+
:postal_code => hash['contacts']['registrant']['postalcode'],
|
49
|
+
:country_code => hash['contacts']['registrant']['countrycode'],
|
50
|
+
:country => hash['contacts']['registrant']['country']
|
51
|
+
)
|
52
|
+
|
53
|
+
@contacts << DomainContact.new(
|
54
|
+
:contact_type => 'tech',
|
55
|
+
:first_name => hash['contacts']['technical']['firstname'],
|
56
|
+
:last_name => hash['contacts']['technical']['lastname'],
|
57
|
+
:email => hash['contacts']['technical']['email'],
|
58
|
+
:phone_number => hash['contacts']['technical']['phonenumber'],
|
59
|
+
:organization => hash['contacts']['technical']['organization'],
|
60
|
+
:city => hash['contacts']['technical']['city'],
|
61
|
+
:street => hash['contacts']['technical']['street'],
|
62
|
+
:street_2 => hash['contacts']['technical']['street2'],
|
63
|
+
:street_3 => hash['contacts']['technical']['street3'],
|
64
|
+
:postal_code => hash['contacts']['technical']['postalcode'],
|
65
|
+
:country_code => hash['contacts']['technical']['countrycode'],
|
66
|
+
:country => hash['contacts']['technical']['country']
|
67
|
+
)
|
68
|
+
|
69
|
+
@contacts << DomainContact.new(
|
70
|
+
:contact_type => 'admin',
|
71
|
+
:first_name => hash['contacts']['admin']['firstname'],
|
72
|
+
:last_name => hash['contacts']['admin']['lastname'],
|
73
|
+
:email => hash['contacts']['admin']['email'],
|
74
|
+
:phone_number => hash['contacts']['admin']['phonenumber'],
|
75
|
+
:organization => hash['contacts']['admin']['organization'],
|
76
|
+
:city => hash['contacts']['admin']['city'],
|
77
|
+
:street => hash['contacts']['admin']['street'],
|
78
|
+
:street_2 => hash['contacts']['admin']['street2'],
|
79
|
+
:street_3 => hash['contacts']['admin']['street3'],
|
80
|
+
:postal_code => hash['contacts']['admin']['postalcode'],
|
81
|
+
:country_code => hash['contacts']['admin']['countrycode'],
|
82
|
+
:country => hash['contacts']['admin']['country']
|
83
|
+
)
|
84
|
+
|
85
|
+
if @domain_extension == 'de'
|
86
|
+
@contacts << DomainContact.new(
|
87
|
+
:contact_type => 'zone',
|
88
|
+
:first_name => hash['contacts']['billing']['firstname'],
|
89
|
+
:last_name => hash['contacts']['billing']['lastname'],
|
90
|
+
:email => hash['contacts']['billing']['email'],
|
91
|
+
:phone_number => hash['contacts']['billing']['phonenumber'],
|
92
|
+
:organization => hash['contacts']['billing']['organization'],
|
93
|
+
:city => hash['contacts']['billing']['city'],
|
94
|
+
:street => hash['contacts']['billing']['street'],
|
95
|
+
:street_2 => hash['contacts']['billing']['street2'],
|
96
|
+
:street_3 => hash['contacts']['billing']['street3'],
|
97
|
+
:postal_code => hash['contacts']['billing']['postalcode'],
|
98
|
+
:country_code => hash['contacts']['billing']['countrycode'],
|
99
|
+
:country => hash['contacts']['billing']['country']
|
100
|
+
else
|
101
|
+
@contacts << DomainContact.new(
|
102
|
+
:contact_type => 'billing',
|
103
|
+
:first_name => hash['contacts']['billing']['firstname'],
|
104
|
+
:last_name => hash['contacts']['billing']['lastname'],
|
105
|
+
:email => hash['contacts']['billing']['email'],
|
106
|
+
:phone_number => hash['contacts']['billing']['phonenumber'],
|
107
|
+
:organization => hash['contacts']['billing']['organization'],
|
108
|
+
:city => hash['contacts']['billing']['city'],
|
109
|
+
:street => hash['contacts']['billing']['street'],
|
110
|
+
:street_2 => hash['contacts']['billing']['street2'],
|
111
|
+
:street_3 => hash['contacts']['billing']['street3'],
|
112
|
+
:postal_code => hash['contacts']['billing']['postalcode'],
|
113
|
+
:country_code => hash['contacts']['billing']['countrycode'],
|
114
|
+
:country => hash['contacts']['billing']['country']
|
115
|
+
end
|
116
|
+
else
|
117
|
+
set_errors(response)
|
118
|
+
return false
|
119
|
+
end
|
120
|
+
|
121
|
+
return true
|
122
|
+
else
|
123
|
+
set_errors(response)
|
124
|
+
return false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class DomainPush < Base
|
3
|
+
attribute :domain, String # The domain being pushed
|
4
|
+
attribute :email_address, String # The destination account's email address
|
5
|
+
|
6
|
+
def push!
|
7
|
+
ensure_attribute_has_value :domain, :email_address
|
8
|
+
return false if @errors.any?
|
9
|
+
|
10
|
+
params = {'domain' => @domain, 'destination' => @email_address}
|
11
|
+
response = Client.post('/domain/push', params)
|
12
|
+
code = response.code rescue ""
|
13
|
+
|
14
|
+
case code
|
15
|
+
when '200'
|
16
|
+
hash = JSON.parse(response.body)
|
17
|
+
|
18
|
+
@status = hash['status']
|
19
|
+
@transaction_id = hash['transactid']
|
20
|
+
|
21
|
+
unless @status == 'SUCCESS'
|
22
|
+
set_errors(response)
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
|
26
|
+
return true
|
27
|
+
else
|
28
|
+
set_errors(response)
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class DomainRecord < Base
|
3
|
+
TYPES = ['A', 'AAAA', 'DYNAMIC', 'CNAME', 'MX', 'SRV', 'TXT', 'NS'].freeze
|
4
|
+
|
5
|
+
attribute :name, String
|
6
|
+
attribute :priority, Integer, :default => 10 # Used for MX type records (optional)
|
7
|
+
attribute :ttl, Integer, :default => 3600 # 1 hour (optional)
|
8
|
+
attribute :type, String # One of DomainRecord::TYPES
|
9
|
+
attribute :value, String
|
10
|
+
|
11
|
+
# attribute :dyn_dns_login, String # Required for DYNAMIC records, ignored for all others, 1 - 30 chars
|
12
|
+
# attribute :dyn_dns_password, String # Required for DYNAMIC records, ignored for all others, 1 - 30 chars
|
13
|
+
# attribute :at_registry, Boolean # Only valid for .de & will be ignored for all other domains
|
14
|
+
|
15
|
+
def valid?
|
16
|
+
ensure_attribute_has_value :full_record_name, :type, :value
|
17
|
+
|
18
|
+
if @type
|
19
|
+
unless TYPES.include?(@type.upcase!)
|
20
|
+
@errors << "type must be one of: #{TYPES.join(', ')}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if @errors.any?
|
25
|
+
return false
|
26
|
+
else
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|