internetbs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE +19 -0
  5. data/README.md +758 -0
  6. data/internetbs.gemspec +18 -0
  7. data/lib/internetbs.rb +64 -0
  8. data/lib/internetbs/account_balance.rb +8 -0
  9. data/lib/internetbs/account_balances.rb +40 -0
  10. data/lib/internetbs/account_domain.rb +11 -0
  11. data/lib/internetbs/account_domains.rb +100 -0
  12. data/lib/internetbs/account_price.rb +19 -0
  13. data/lib/internetbs/account_prices.rb +70 -0
  14. data/lib/internetbs/account_transaction.rb +9 -0
  15. data/lib/internetbs/account_transactions.rb +54 -0
  16. data/lib/internetbs/additional_attributes.rb +41 -0
  17. data/lib/internetbs/base.rb +33 -0
  18. data/lib/internetbs/client.rb +49 -0
  19. data/lib/internetbs/configuration.rb +61 -0
  20. data/lib/internetbs/country_codes.rb +288 -0
  21. data/lib/internetbs/domain_availability.rb +37 -0
  22. data/lib/internetbs/domain_contact.rb +109 -0
  23. data/lib/internetbs/domain_host.rb +46 -0
  24. data/lib/internetbs/domain_hosts.rb +101 -0
  25. data/lib/internetbs/domain_information.rb +128 -0
  26. data/lib/internetbs/domain_push.rb +33 -0
  27. data/lib/internetbs/domain_record.rb +31 -0
  28. data/lib/internetbs/domain_records.rb +172 -0
  29. data/lib/internetbs/domain_total.rb +8 -0
  30. data/lib/internetbs/dot_asia_attributes.rb +56 -0
  31. data/lib/internetbs/dot_de_attributes.rb +64 -0
  32. data/lib/internetbs/dot_eu_attributes.rb +20 -0
  33. data/lib/internetbs/dot_fr_attributes.rb +138 -0
  34. data/lib/internetbs/dot_it_attributes.rb +182 -0
  35. data/lib/internetbs/dot_nl_attributes.rb +47 -0
  36. data/lib/internetbs/dot_uk_attributes.rb +60 -0
  37. data/lib/internetbs/dot_us_attributes.rb +54 -0
  38. data/lib/internetbs/error.rb +38 -0
  39. data/lib/internetbs/language_codes.rb +27 -0
  40. data/lib/internetbs/order_domain.rb +78 -0
  41. data/lib/internetbs/private_whois.rb +81 -0
  42. data/lib/internetbs/registrar_lock.rb +73 -0
  43. data/lib/internetbs/registry_status.rb +39 -0
  44. data/lib/internetbs/renew_domain.rb +43 -0
  45. data/lib/internetbs/update_domain.rb +71 -0
  46. data/lib/internetbs/version.rb +10 -0
  47. metadata +104 -0
@@ -0,0 +1,172 @@
1
+ module InternetBS
2
+ class DomainRecords < Base
3
+ attribute :domain, String # Only used by #fetch method
4
+ attribute :filter_type, String # One of DomainRecord::TYPES, only used by #fetch method
5
+ attribute :list, Array[DomainRecord]
6
+
7
+ def add(dns_record)
8
+ set_record :add, dns_record
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!({'filtertype' => @filter_type}) if @filter_type
17
+
18
+ response = Client.get('/domain/dnsrecord/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
+ hash['records'].each do |record|
30
+ @list << DomainRecord.new(
31
+ :name => record['name'],
32
+ :value => record['value'],
33
+ :ttl => record['ttl'],
34
+ :type => record['type']
35
+ )
36
+ end
37
+ else
38
+ set_errors(response)
39
+ return false
40
+ end
41
+
42
+ return true
43
+ else
44
+ set_errors(response)
45
+ return false
46
+ end
47
+ end
48
+
49
+ def remove(dns_record)
50
+ set_record :remove, dns_record
51
+ end
52
+
53
+ def update(current_dns_record, new_dns_record)
54
+ @errors.clear
55
+
56
+ unless current_dns_record.valid? && new_dns_record.valid?
57
+ current_dns_record.each do |err|
58
+ @errors << "current: #{err}"
59
+ end
60
+
61
+ new_dns_record.each do |err|
62
+ @errors << "new: #{err}"
63
+ end
64
+
65
+ return false
66
+ end
67
+
68
+ params = {
69
+ 'fullrecordname' => current_dns_record.full_record_name,
70
+ 'type' => current_dns_record.type
71
+ }
72
+
73
+ if current_dns_record.value && dns_record.value
74
+ params.merge!({
75
+ 'currentvalue' => current_dns_record.value,
76
+ 'newvalue' => new_dns_record.value
77
+ })
78
+ end
79
+
80
+ if current_dns_record.ttl && \
81
+ new_dns_record.ttl && \
82
+ current_dns_record.ttl == new_dns_record.ttl
83
+ params.merge!({
84
+ 'currentttl' => current_dns_record.ttl,
85
+ 'newttl' => new_dns_record.ttl
86
+ })
87
+ end
88
+
89
+ if current_dns_record.type == 'MX' && \
90
+ current_dns_record.priority && \
91
+ new_dns_record.priority &&
92
+ current_dns_record.priority == new_dns_record.priority
93
+ params.merge!({
94
+ 'currentpriority' => current_dns_record.priority,
95
+ 'newpriority' => new_dns_record.priority
96
+ })
97
+ end
98
+
99
+ response = Client.post("/domain/dnsrecord/update", params)
100
+ code = response.code rescue ""
101
+
102
+ case code
103
+ when '200'
104
+ hash = JSON.parse(response.body)
105
+
106
+ @status = hash['status']
107
+ @transaction_id = hash['transactid']
108
+
109
+ unless @status == 'SUCCESS'
110
+ set_errors(response)
111
+ return false
112
+ end
113
+
114
+ return true
115
+ else
116
+ set_errors(response)
117
+ return false
118
+ end
119
+ end
120
+
121
+ private
122
+
123
+ # Expects an action parameter of either :add or :remove.
124
+ def set_record(action, dns_record)
125
+ @errors.clear
126
+
127
+ unless dns_record.valid?
128
+ @errors = dns_record.errors
129
+ return false
130
+ end
131
+
132
+ params = {
133
+ 'fullrecordname' => dns_record.full_record_name,
134
+ 'type' => dns_record.type
135
+ }
136
+
137
+ if dns_record.value
138
+ params.merge!({'value' => dns_record.value})
139
+ end
140
+
141
+ if action == :add
142
+ if dns_record.ttl
143
+ params.merge!({'ttl' => dns_record.ttl})
144
+ end
145
+ if dns_record.priority && dns_record.type == 'MX'
146
+ params.merge!({'priority' => dns_record.priority})
147
+ end
148
+ end
149
+
150
+ response = Client.post("/domain/dnsrecord/#{action.to_s}", params)
151
+ code = response.code rescue ""
152
+
153
+ case code
154
+ when '200'
155
+ hash = JSON.parse(response.body)
156
+
157
+ @status = hash['status']
158
+ @transaction_id = hash['transactid']
159
+
160
+ unless @status == 'SUCCESS'
161
+ set_errors(response)
162
+ return false
163
+ end
164
+
165
+ return true
166
+ else
167
+ set_errors(response)
168
+ return false
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,8 @@
1
+ module InternetBS
2
+ class DomainTotal
3
+ include Virtus.model
4
+
5
+ attribute :tld, String
6
+ attribute :total, Integer
7
+ end
8
+ end
@@ -0,0 +1,56 @@
1
+ module InternetBS
2
+ class DotAsiaAttributes < AdditionalAttributes
3
+ CED_ENTITY_TYPES = \
4
+ %w[naturalperson corporation cooperative partnership government politicalparty society institution other]
5
+
6
+ CED_ID_FORM_TYPES = \
7
+ %w[passport certificate legislation societiesregistry policalpartyregistry other]
8
+
9
+ # Additional attributes are for Charter Eligibility Declaration (CED)
10
+ attribute :ced_locality, String # Required
11
+ attribute :ced_entity, String # Required - must be one of CED_ENTITY_TYPES
12
+ attribute :ced_entity_other, String # Required if ced_entity is 'other'
13
+ attribute :ced_id_form, String # Required - must be one of CED_ID_FORM_TYPES
14
+ attribute :ced_id_form_other, String # Required if ced_id_form is 'other'
15
+ attribute :ced_city, String # Optional
16
+ attribute :ced_id_number, String # Optional
17
+ attribute :ced_state_province, String # Optional
18
+
19
+ def is_sunrise?
20
+ false # Sunrise and landrush periods ended March, 26 2008 when .asia transitioned to GoLive
21
+ end
22
+
23
+ def mandatory_params
24
+ params = {
25
+ 'dotasiacedlocality' => @ced_locality,
26
+ 'dotasiacedentity' => @ced_entity,
27
+ 'dotasiacedidform' => @ced_id_form
28
+ }
29
+ params.merge!({'dotasiacedentityother' => @ced_entity_other}) if @ced_entity == 'other'
30
+ params.merge!({'dotasiacedidformother' => @ced_id_form_other}) if @ced_id_form == 'other'
31
+ return params
32
+ end
33
+
34
+ def optional_params
35
+ params = {}
36
+ params.merge!({'dotasiacedcity' => @ced_city}) if @ced_city
37
+ params.merge!({'dotasiacedidnumber' => @ced_id_number}) if @ced_id_number
38
+ params.merge!({'dotasiacedstateprovince' => @ced_state_province}) if @ced_state_province
39
+ return params
40
+ end
41
+
42
+ def valid?(inputs = {})
43
+ ensure_attribute_has_value :ced_locality, :ced_entity, :ced_id_form
44
+ unless CED_ENTITY_TYPES.include?(@ced_entity)
45
+ @errors << "ced_entity must be one of CED_ENTITY_TYPES"
46
+ end
47
+ unless CED_ID_FORM_TYPES.include?(@ced_id_form)
48
+ @errors << "ced_id_form must be one of CED_ID_FORM_TYPES"
49
+ end
50
+ ensure_attribute_has_value :ced_entity_other if @ced_entity == 'other'
51
+ ensure_attribute_has_value :ced_id_form_other if @ced_id_form == 'other'
52
+ ensure_attribute_has_value :cd_id_number if is_sunrise?
53
+ super
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,64 @@
1
+ require_relative 'country_codes'
2
+
3
+ module InternetBS
4
+ class DotDEAttributes < AdditionalAttributes
5
+ ROLES = {
6
+ 'PERSON' => 'Natural person',
7
+ 'ROLE' => 'An abstract name for a group of persons (so-called role account, e.g. Business Services)',
8
+ 'ORG' => 'A legal person (company, association, grouping of holders, organization etc.)'
9
+ }
10
+
11
+ attribute :role, String # Required - one in ROLES
12
+ attribute :ip_address, String # Required
13
+ attribute :disclose_name, Boolean, :default => false # Required
14
+ attribute :disclose_contact, Boolean, :default => false # Required
15
+ attribute :disclose_address, Boolean, :default => false # Required
16
+ attribute :remark, String # Optional
17
+ attribute :sip_uri, String # Optional
18
+ attribute :terms_accepted, Boolean, :default => false # Required
19
+
20
+ def mandatory_params
21
+ params = {"#{@contact_type.to_s}_role" => @role, "#{@contact_type.to_s}_clientip" => @ip_address}
22
+ params.merge!({"#{@contact_type.to_s}_disclosename" => @disclose_name ? 'YES' : 'NO'})
23
+ params.merge!({"#{@contact_type.to_s}_disclosecontact" => @disclose_contact ? 'YES' : 'NO'})
24
+ params.merge!({"#{@contact_type.to_s}_discloseaddress" => @disclose_address ? 'YES' : 'NO'})
25
+ params.merge!({"#{@contact_type.to_s}_tosagree" => @terms_accepted ? 'YES' : 'NO'})
26
+ return params
27
+ end
28
+
29
+ def optional_params
30
+ params = {}
31
+ params.merge!({"#{@contact_type.to_s}_sip" => @sip_uri}) if @sip_uri
32
+ params.merge!({"#{@contact_type.to_s}_remark" => @remark}) if @remark
33
+ return params
34
+ end
35
+
36
+ def valid?(inputs = {})
37
+ ensure_attribute_has_value :role, :disclose_name, :disclose_contact,
38
+ :disclose_address, :terms_accepted, :ip_address
39
+ unless ROLES.has_key?(@role)
40
+ @errors << "role must be one in ROLES"
41
+ else
42
+ case @contact_type
43
+ when :registrant
44
+ unless ['PERSON', 'ORG'].include?(@role)
45
+ @errors << 'role must be either PERSON or ORG for registrant contact'
46
+ end
47
+ when :admin
48
+ unless ['PERSON'].include?(@role)
49
+ @errors << 'role must be PERSON for admin contact'
50
+ end
51
+ when :tech
52
+ unless ['PERSON', 'ORG'].include?(@role)
53
+ @errors << 'role must be either PERSON or ORG for tech contact'
54
+ end
55
+ when :zone
56
+ unless ['PERSON', 'ORG'].include?(@role)
57
+ @errors << 'role must be either PERSON or ORG for zone contact'
58
+ end
59
+ end
60
+ end
61
+ super
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'language_codes'
2
+
3
+ module InternetBS
4
+ class DotEUAttributes < AdditionalAttributes
5
+ attribute :language, String # Required - must be one of LANGUAGE_CODES
6
+
7
+ def registrant_params
8
+ params = {'registrant_language' => @language}
9
+ return params
10
+ end
11
+
12
+ def valid?(inputs = {})
13
+ ensure_attribute_has_value :language
14
+ unless @language && LANGUAGE_CODES.include?(@language)
15
+ @errors << "language must be one of LANGUAGE_CODES"
16
+ end
17
+ super
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,138 @@
1
+ require_relative 'country_codes'
2
+
3
+ module InternetBS
4
+ class DotFRAttributes < AdditionalAttributes
5
+ CONTACT_ENTITY_TYPES = %w[INDIVIDUAL COMPANY TRADEMARK ASSOCIATION OTHER]
6
+
7
+ attribute :entity_type, String # Must be one of CONTACT_ENTITY_TYPES
8
+ attribute :entity_name, String
9
+ attribute :entity_vat, String # Optional
10
+ attribute :entity_siren, String # Optional
11
+ attribute :entity_duns, String # Optional
12
+ attribute :entity_trade_mark, String
13
+ attribute :entity_waldec, String
14
+ attribute :entity_date_of_association, Date # YYYY-MM-DD
15
+ attribute :entity_date_of_publication, Date # YYYY-MM-DD
16
+ attribute :entity_gazette_announcement_number, String
17
+ attribute :entity_gazette_page_number, String
18
+ attribute :entity_birth_date, Date # YYYY-MM-DD
19
+ attribute :entity_birth_place_country_code, String # Must be one in COUNTRY_CODES
20
+ attribute :entity_birth_city, String
21
+ attribute :entity_birth_place_postal_code, String
22
+ attribute :entity_restricted_publication, Boolean # 1 = true, 0 = false
23
+ attribute :other_contact_entity, String
24
+
25
+ def registrant_params
26
+ params = {"registrant_dot#{@domain_extension}contactentitytype" => @entity_type}
27
+ case @entity_type
28
+ when 'INDIVIDUAL'
29
+ params.merge!({"registrant_dot#{@domain_extension}contactentitybirthdate" => @entity_birth_date.strftime('%Y-%m-%d')})
30
+ params.merge!({"registrant_dot#{@domain_extension}contactentitybirthplacecountrycode" => @entity_birth_place_country_code})
31
+ if @entity_birth_place_country_code == 'FR'
32
+ params.merge!({"registrant_dot#{@domain_extension}contactentitybirthcity" => @entity_birth_city})
33
+ params.merge!({"registrant_dot#{@domain_extension}contactentitybirthplacepostalcode" => @entity_birth_place_postal_code})
34
+ end
35
+ when 'COMPANY'
36
+ params.merge!({"registrant_dot#{@domain_extension}contactentityname" => @entity_name})
37
+ params.merge!({"registrant_dot#{@domain_extension}contactentitysiren" => @entity_siren})
38
+ when 'TRADEMARK'
39
+ params.merge!({"registrant_dot#{@domain_extension}contactentityname" => @entity_name})
40
+ params.merge!({"registrant_dot#{@domain_extension}contactentitytrademark" => @entity_trade_mark})
41
+ when 'ASSOCIATION'
42
+ params.merge!({"registrant_dot#{@domain_extension}contactentityname" => @entity_name})
43
+ params.merge!({"registrant_dot#{@domain_extension}contactentitywaldec" => @entity_waldec})
44
+ params.merge!({"registrant_dot#{@domain_extension}contactentitydateofassocation" => @entity_date_of_association.strftime('%Y-%m-%d')})
45
+ params.merge!({"registrant_dot#{@domain_extension}contactentityannounceno" => @entity_gazette_announcement_number})
46
+ params.merge!({"registrant_dot#{@domain_extension}contactentitydateofpublication" => @entity_date_of_publication.strftime('%Y-%m-%d')})
47
+ params.merge!({"registrant_dot#{@domain_extension}contactentitypageno" => @entity_gazette_page_number})
48
+ when 'OTHER'
49
+ params.merge!({"registrant_dot#{@domain_extension}contactentityname" => @entity_name})
50
+ params.merge!({"registrant_dot#{@domain_extension}othercontactentity" => @other_contact_entity})
51
+ end
52
+ return params
53
+ end
54
+
55
+ def admin_params
56
+ params = {"admin_dot#{@domain_extension}contactentitytype" => @entity_type}
57
+ case @entity_type
58
+ when 'INDIVIDUAL'
59
+ params.merge!({"admin_dot#{@domain_extension}contactentitybirthdate" => @entity_birth_date.strftime('%Y-%m-%d')})
60
+ params.merge!({"admin_dot#{@domain_extension}contactentitybirthplacecountrycode" => @entity_birth_place_country_code})
61
+ if @entity_birth_place_country_code == 'FR'
62
+ params.merge!({"admin_dot#{@domain_extension}contactentitybirthcity" => @entity_birth_city})
63
+ params.merge!({"admin_dot#{@domain_extension}contactentitybirthplacepostalcode" => @entity_birth_place_postal_code})
64
+ end
65
+ when 'COMPANY'
66
+ params.merge!({"admin_dot#{@domain_extension}contactentityname" => @entity_name})
67
+ params.merge!({"admin_dot#{@domain_extension}contactentitysiren" => @entity_siren})
68
+ when 'TRADEMARK'
69
+ params.merge!({"admin_dot#{@domain_extension}contactentityname" => @entity_name})
70
+ params.merge!({"admin_dot#{@domain_extension}contactentitytrademark" => @entity_trade_mark})
71
+ when 'ASSOCIATION'
72
+ params.merge!({"admin_dot#{@domain_extension}contactentityname" => @entity_name})
73
+ params.merge!({"admin_dot#{@domain_extension}contactentitywaldec" => @entity_waldec})
74
+ params.merge!({"admin_dot#{@domain_extension}contactentitydateofassocation" => @entity_date_of_association.strftime('%Y-%m-%d')})
75
+ params.merge!({"admin_dot#{@domain_extension}contactentityannounceno" => @entity_gazette_announcement_number})
76
+ params.merge!({"admin_dot#{@domain_extension}contactentitydateofpublication" => @entity_date_of_publication.strftime('%Y-%m-%d')})
77
+ params.merge!({"admin_dot#{@domain_extension}contactentitypageno" => @entity_gazette_page_number})
78
+ when 'OTHER'
79
+ params.merge!({"admin_dot#{@domain_extension}contactentityname" => @entity_name})
80
+ params.merge!({"admin_dot#{@domain_extension}othercontactentity" => @other_contact_entity})
81
+ end
82
+ return params
83
+ end
84
+
85
+ def optional_params
86
+ params = {}
87
+ if @entity_type == 'INDIVIDUAL'
88
+ if @entity_birth_date
89
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentitybirthdate" => @entity_birth_date})
90
+ end
91
+ if @entity_birth_place_country_code
92
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentitybirthplacecountrycode" => @entity_birth_place_country_code})
93
+ end
94
+ if @entity_birth_city
95
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentitybirthcity" => @entity_birth_city})
96
+ end
97
+ if @entity_birth_place_postal_code
98
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentitybirthplacepostalcode" => @entity_birth_place_postal_code})
99
+ end
100
+ if @entity_restricted_publication
101
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentityrestrictedpublication" => @entity_restricted_publication == true ? 1 : 0})
102
+ end
103
+ end
104
+ if @entity_vat
105
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentityvat" => @entity_vat})
106
+ end
107
+ if @entity_duns
108
+ params.merge!({"#{@contact_type.to_s}_dot#{@domain_extension}contactentityduns" => @entity_duns})
109
+ end
110
+ return params
111
+ end
112
+
113
+ def valid?(inputs = {})
114
+ ensure_attribute_has_value :entity_type
115
+ case @entity_type
116
+ when 'INDIVIDUAL'
117
+ unless COUNTRY_CODES.has_key?(@entity_birth_place_country_code)
118
+ @errors << "entity_birth_place_country_code must be one in COUNTRY_CODES"
119
+ end
120
+ if @entity_birth_place_country_code == 'FR'
121
+ ensure_attribute_has_value :entity_birth_city, :entity_birth_place_postal_code
122
+ end
123
+ case 'COMPANY'
124
+ ensure_attribute_has_value :entity_name
125
+ case 'TRADEMARK'
126
+ ensure_attribute_has_value :entity_name, :entity_trade_mark
127
+ case 'ASSOCIATION'
128
+ ensure_attribute_has_value :entity_name
129
+ unless @entity_waldec
130
+ ensure_attribute_has_value :entity_date_of_association, :entity_date_of_publication, :entity_announce_no, :entity_page_no
131
+ end
132
+ case 'ENTITY'
133
+ ensure_attribute_has_value :entity_name
134
+ end
135
+ super
136
+ end
137
+ end
138
+ end