internetbs 1.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 +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
data/internetbs.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require './lib/internetbs/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'internetbs'
|
5
|
+
gem.version = InternetBS::VERSION::STRING
|
6
|
+
gem.authors = 'Jurgen Jocubeit'
|
7
|
+
gem.email = 'support@brightcommerce.com'
|
8
|
+
gem.homepage = 'https://github.com/brightcommerce/internetbs'
|
9
|
+
gem.summary = InternetBS::VERSION::SUMMARY
|
10
|
+
gem.description = 'A Ruby API client for InternetBS resellers.'
|
11
|
+
gem.license = 'MIT'
|
12
|
+
gem.metadata = { 'copyright' => 'Copyright 2015 Brightcommerce, Inc.' }
|
13
|
+
gem.files = `git ls-files`.split($/)
|
14
|
+
# gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.require_path = 'lib'
|
16
|
+
gem.required_ruby_version = '>= 2.0.0'
|
17
|
+
gem.add_dependency 'virtus', '~> 1.0.3'
|
18
|
+
end
|
data/lib/internetbs.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
module InternetBS
|
2
|
+
autoload :AccountBalance, 'internetbs/account_balance'
|
3
|
+
autoload :AccountBalances, 'internetbs/account_balances'
|
4
|
+
autoload :AccountDomain, 'internetbs/account_domain'
|
5
|
+
autoload :AccountDomains, 'internetbs/account_domains'
|
6
|
+
autoload :AccountPrice, 'internetbs/account_price'
|
7
|
+
autoload :AccountPrices, 'internetbs/account_prices'
|
8
|
+
autoload :AccountTransaction, 'internetbs/account_transaction'
|
9
|
+
autoload :AccountTransactions, 'internetbs/account_transactions'
|
10
|
+
autoload :Base, 'internetbs/base'
|
11
|
+
autoload :Client, 'internetbs/client'
|
12
|
+
autoload :Configuration, 'internetbs/configuration'
|
13
|
+
autoload :DomainAvailability, 'internetbs/domain_availability'
|
14
|
+
autoload :DomainContact, 'internetbs/domain_contact'
|
15
|
+
autoload :DomainHost, 'internetbs/domain_host'
|
16
|
+
autoload :DomainHosts, 'internetbs/domain_hosts'
|
17
|
+
autoload :DomainInformation, 'internetbs/domain_information'
|
18
|
+
autoload :DomainPush, 'internetbs/domain_push'
|
19
|
+
autoload :DomainRecord, 'internetbs/domain_record'
|
20
|
+
autoload :DomainRecords, 'internetbs/domain_records'
|
21
|
+
autoload :DomainTotal, 'internetbs/domain_total'
|
22
|
+
autoload :DotAsiaAttributes, 'internetbs/dot_asia_attributes'
|
23
|
+
autoload :DotDEAttributes, 'internetbs/dot_de_attributes'
|
24
|
+
autoload :DotEUAttributes, 'internetbs/dot_eu_attributes'
|
25
|
+
autoload :DotFRAttributes, 'internetbs/dot_fr_attributes'
|
26
|
+
autoload :DotITAttributes, 'internetbs/dot_it_attributes'
|
27
|
+
autoload :DotNLAttributes, 'internetbs/dot_nl_attributes'
|
28
|
+
autoload :DotUKAttributes, 'internetbs/dot_uk_attributes'
|
29
|
+
autoload :DotUSAttributes, 'internetbs/dot_us_attributes'
|
30
|
+
autoload :OrderDomain, 'internetbs/order_domain'
|
31
|
+
autoload :PrivateWhois, 'internetbs/private_whois'
|
32
|
+
autoload :RegistrarLock, 'internetbs/registrar_lock'
|
33
|
+
autoload :RegistryStatus, 'internetbs/registry_status'
|
34
|
+
autoload :RenewDomain, 'internetbs/renew_domain'
|
35
|
+
autoload :UpdateDomain, 'internetbs/update_domain'
|
36
|
+
|
37
|
+
@@configuration = nil
|
38
|
+
|
39
|
+
def self.configure
|
40
|
+
@@configuration = Configuration.new
|
41
|
+
yield(configuration) if block_given?
|
42
|
+
configuration
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.configuration
|
46
|
+
@@configuration || configure
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.method_missing(method_sym, *arguments, &block)
|
50
|
+
if configuration.respond_to?(method_sym)
|
51
|
+
configuration.send(method_sym)
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.respond_to?(method_sym, include_private = false)
|
58
|
+
if configuration.respond_to?(method_sym, include_private)
|
59
|
+
true
|
60
|
+
else
|
61
|
+
super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountBalances < Base
|
3
|
+
attribute :list, Array[AccountBalance]
|
4
|
+
attribute :currency, String
|
5
|
+
|
6
|
+
def fetch
|
7
|
+
@errors.clear
|
8
|
+
|
9
|
+
params = {}
|
10
|
+
params.merge!({'currency' => @currency}) if @currency
|
11
|
+
response = Client.get('/account/balance/get', 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
|
+
if @status == 'SUCCESS'
|
22
|
+
hash['balance'].each do |balance|
|
23
|
+
@list << AccountBalance.new(
|
24
|
+
:amount => balance['amount'],
|
25
|
+
:currency => balance['currency']
|
26
|
+
)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
set_errors(response)
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
return true
|
34
|
+
else
|
35
|
+
set_errors(response)
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountDomain
|
3
|
+
include Virtus.model
|
4
|
+
|
5
|
+
attribute :name, String
|
6
|
+
attribute :expiration_date, Date
|
7
|
+
attribute :registrar_lock, String # ENABLED or DISABLED or NOTADMITTED
|
8
|
+
attribute :status, String
|
9
|
+
attribute :transfer_auth_info, String
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountDomains < Base
|
3
|
+
attribute :compact_list, Boolean, :default => true # YES or NO
|
4
|
+
attribute :expiring_only, Integer # Number of days
|
5
|
+
attribute :extension_filter, String
|
6
|
+
attribute :pending_transfer_only, Boolean, :default => false # YES or NO
|
7
|
+
attribute :range_from, Integer
|
8
|
+
attribute :range_to, Integer
|
9
|
+
attribute :search_term_filter, String
|
10
|
+
attribute :list, Array[AccountDomain]
|
11
|
+
attribute :sort_by, String, :default => 'DOMAIN_NAME' # DOMAIN_NAME, DOMAIN_NAME_DESC, EXPIRATION, EXPIRATION_DESC
|
12
|
+
attribute :total_domains, Integer
|
13
|
+
attribute :total_domains_by_tld, Array[DomainTotal]
|
14
|
+
|
15
|
+
def fetch
|
16
|
+
@errors.clear
|
17
|
+
@list.clear
|
18
|
+
@total_domains = 0
|
19
|
+
@total_domains_by_tld = 0
|
20
|
+
|
21
|
+
params = {'compactlist' => @compact_list ? 'YES' : 'NO', 'sortby' => @sort_by}
|
22
|
+
params.merge!({'expiringonly' => @expiring_only}) if @expiring_only
|
23
|
+
params.merge!({'extensionfilter' => @extension_filter}) if @extension_filter
|
24
|
+
params.merge!({'pendingtransferonly' => 'YES'}) if @pending_transfer_only
|
25
|
+
params.merge!({'rangefrom' => @range_from, 'rangeto' => @range_to}) if @range_from && @range_to
|
26
|
+
params.merge!({'searchtermfilter' => @search_term_filter}) if @search_term_filter
|
27
|
+
|
28
|
+
response = Client.get('/domain/list', params)
|
29
|
+
code = response.code rescue ""
|
30
|
+
|
31
|
+
case code
|
32
|
+
when '200'
|
33
|
+
hash = JSON.parse(response.body)
|
34
|
+
|
35
|
+
@status = hash.delete('status')
|
36
|
+
@transaction_id = hash.delete('transactid')
|
37
|
+
|
38
|
+
if @status == 'SUCCESS'
|
39
|
+
@total_domains = hash['domaincount']
|
40
|
+
|
41
|
+
if @compact_list
|
42
|
+
hash['domain'].each do |domain|
|
43
|
+
@list << AccountDomain.new(:name => domain)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
hash['domain'].each do |domain|
|
47
|
+
@list << AccountDomain.new(
|
48
|
+
:name => domain['name'],
|
49
|
+
:expiration_date => domain['expiration'],
|
50
|
+
:registrar_lock => domain['registrarlock'],
|
51
|
+
:status => domain['status'],
|
52
|
+
:transfer_auth_info => domain['transferauthinfo']
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
set_errors(response)
|
58
|
+
return false
|
59
|
+
end
|
60
|
+
|
61
|
+
return true
|
62
|
+
else
|
63
|
+
set_errors(response)
|
64
|
+
return false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def totals
|
69
|
+
@errors.clear
|
70
|
+
|
71
|
+
response = Client.get('/domain/count')
|
72
|
+
code = response.code rescue ""
|
73
|
+
|
74
|
+
case code
|
75
|
+
when '200'
|
76
|
+
hash = JSON.parse(response.body)
|
77
|
+
|
78
|
+
@status = hash.delete('status')
|
79
|
+
@transaction_id = hash.delete('transactid')
|
80
|
+
|
81
|
+
if @status == 'SUCCESS'
|
82
|
+
@total_domains = hash.delete('totaldomains')
|
83
|
+
@total_domains_by_tld.clear
|
84
|
+
|
85
|
+
hash.each do |tld, total|
|
86
|
+
@total_domains_by_tld << DomainTotal.new(:tld => tld, :total => total)
|
87
|
+
end
|
88
|
+
else
|
89
|
+
set_errors(response)
|
90
|
+
return false
|
91
|
+
end
|
92
|
+
|
93
|
+
return true
|
94
|
+
else
|
95
|
+
set_errors(response)
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountPrice
|
3
|
+
include Virtus.model
|
4
|
+
|
5
|
+
attribute :currency, String
|
6
|
+
attribute :name, String
|
7
|
+
attribute :operation, String
|
8
|
+
attribute :price_1_year, Float
|
9
|
+
attribute :price_2_years, Float
|
10
|
+
attribute :price_3_years, Float
|
11
|
+
attribute :price_4_years, Float
|
12
|
+
attribute :price_5_years, Float
|
13
|
+
attribute :price_6_years, Float
|
14
|
+
attribute :price_7_years, Float
|
15
|
+
attribute :price_8_years, Float
|
16
|
+
attribute :price_9_years, Float
|
17
|
+
attribute :price_10_years, Float
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountPrices < Base
|
3
|
+
attribute :currency, String, :default => 'USD'
|
4
|
+
attribute :discount_code, String
|
5
|
+
attribute :level, String
|
6
|
+
attribute :list, Array[AccountPrice]
|
7
|
+
attribute :version, Integer, :default => 1 # 1 or 2
|
8
|
+
|
9
|
+
def fetch
|
10
|
+
@errors.clear
|
11
|
+
|
12
|
+
params = {'currency' => @currency, 'version' => @version}
|
13
|
+
optional_params = {'discountcode' => @discount_code}
|
14
|
+
params.merge!(optional_params) if @discount_code
|
15
|
+
|
16
|
+
response = Client.get('/account/pricelist/get', params)
|
17
|
+
code = response.code rescue ""
|
18
|
+
|
19
|
+
case code
|
20
|
+
when '200'
|
21
|
+
hash = JSON.parse(response.body)
|
22
|
+
|
23
|
+
@status = hash["status"]
|
24
|
+
@transaction_id = hash["transactid"]
|
25
|
+
|
26
|
+
if @status == 'SUCCESS'
|
27
|
+
case @version
|
28
|
+
when 1
|
29
|
+
hash['product'].each do |product|
|
30
|
+
@list << AccountPrice.new(
|
31
|
+
:currency => @currency,
|
32
|
+
:name => product['name'],
|
33
|
+
:price_1_year => product['price']
|
34
|
+
)
|
35
|
+
end
|
36
|
+
when 2
|
37
|
+
@level = hash['pricelevel']
|
38
|
+
@currency = hash['currency']
|
39
|
+
|
40
|
+
hash['product'].each do |product|
|
41
|
+
@list << AccountPrice.new(
|
42
|
+
:currency => @currency,
|
43
|
+
:name => product['type'],
|
44
|
+
:operation => product['operation'],
|
45
|
+
:price_1_year => product['period']['1'],
|
46
|
+
:price_2_years => product['period']['2'],
|
47
|
+
:price_3_years => product['period']['3'],
|
48
|
+
:price_4_years => product['period']['4'],
|
49
|
+
:price_5_years => product['period']['5'],
|
50
|
+
:price_6_years => product['period']['6'],
|
51
|
+
:price_7_years => product['period']['7'],
|
52
|
+
:price_8_years => product['period']['8'],
|
53
|
+
:price_9_years => product['period']['9'],
|
54
|
+
:price_10_years => product['period']['10']
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
else
|
59
|
+
set_errors(response)
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
|
63
|
+
return true
|
64
|
+
else
|
65
|
+
set_errors(response)
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AccountTransactions < Base
|
3
|
+
attribute :client_transaction_id, String
|
4
|
+
attribute :currency, String, :default => 'USD'
|
5
|
+
attribute :list, Array[AccountTransaction]
|
6
|
+
attribute :response_type, String, :default => 'EXACT_RESPONSE' # EXACT_RESPONSE, RESPONSE_DATA or REQUEST_DATA
|
7
|
+
|
8
|
+
def fetch
|
9
|
+
@errors.clear
|
10
|
+
|
11
|
+
params = {}
|
12
|
+
params.merge!({'transaction_id' => @transaction_id}) if @transaction_id
|
13
|
+
params.merge!({'client_transaction_id' => @client_transaction_id}) if @client_transaction_id
|
14
|
+
|
15
|
+
response = Client.get('/account/transactioninfo/get', params)
|
16
|
+
code = response.code rescue ""
|
17
|
+
|
18
|
+
case code
|
19
|
+
when '200'
|
20
|
+
hash = JSON.parse(response.body)
|
21
|
+
|
22
|
+
@status = hash["status"]
|
23
|
+
@transaction_id = hash["transactid"]
|
24
|
+
|
25
|
+
# Receiving: "FAILURE", "Permission Denied %1%"
|
26
|
+
# This endpoint may require activation by InternetBS themselves?
|
27
|
+
# Documentation exists in PDF only. May be an artifact, but would
|
28
|
+
# expect to receive an error stating the endpoint doesn't exist.
|
29
|
+
debugger
|
30
|
+
puts hash
|
31
|
+
|
32
|
+
if @status == 'SUCCESS'
|
33
|
+
@currency = hash['currency']
|
34
|
+
|
35
|
+
hash['product'].each do |product|
|
36
|
+
@list << AccountTransaction.new(
|
37
|
+
:currency => @currency ,
|
38
|
+
:name => product['name'],
|
39
|
+
:price => product['price']
|
40
|
+
)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
set_errors(response)
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
47
|
+
return true
|
48
|
+
else
|
49
|
+
set_errors(response)
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module InternetBS
|
2
|
+
class AdditionalAttributes < Base
|
3
|
+
attribute :contact_type, String # Internal - symbol: one of :registrant, :admin, :billing, :tech, :zone
|
4
|
+
attribute :domain_extension, String
|
5
|
+
|
6
|
+
def admin_params
|
7
|
+
return {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def billing_params
|
11
|
+
return {}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Mandatory attributes for all contact types
|
15
|
+
def mandatory_params
|
16
|
+
return {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Optional attributes for all contact types
|
20
|
+
def optional_params
|
21
|
+
return {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def registrant_params
|
25
|
+
return {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def valid?(inputs = {})
|
29
|
+
if @errors.any?
|
30
|
+
return false
|
31
|
+
else
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# .de domains only - substituted with billing contact
|
37
|
+
def zone_params
|
38
|
+
return {}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|