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,182 @@
1
+ require_relative 'country_codes'
2
+
3
+ module InternetBS
4
+ class DotITAttributes < AdditionalAttributes
5
+ ENTITY_TYPES = {
6
+ '1' => 'Italian and foreign natural persons',
7
+ '2' => 'Companies/one man companies',
8
+ '3' => 'Freelance workers/professionals',
9
+ '4' => 'Non-profit organizations',
10
+ '5' => 'Public organizations',
11
+ '6' => 'Other subjects',
12
+ '7' => 'Foreigners who match 2-6'
13
+ }
14
+
15
+ # From ISO 3166-2:IT @ https://en.wikipedia.org/wiki/ISO_3166-2:IT
16
+ PROVINCIAL_CODES = {
17
+ "AG" => "Agrigento",
18
+ "AL" => "Alessandria",
19
+ "AN" => "Ancona",
20
+ "AO" => "Aosta, Aoste (fr)",
21
+ "AR" => "Arezzo",
22
+ "AP" => "Ascoli Piceno",
23
+ "AT" => "Asti",
24
+ "AV" => "Avellino",
25
+ "BA" => "Bari",
26
+ "BT" => "Barletta-Andria-Trani",
27
+ "BL" => "Belluno",
28
+ "BN" => "Benevento",
29
+ "BG" => "Bergamo",
30
+ "BI" => "Biella",
31
+ "BO" => "Bologna",
32
+ "BZ" => "Bolzano, Bozen (de)",
33
+ "BS" => "Brescia",
34
+ "BR" => "Brindisi",
35
+ "CA" => "Cagliari",
36
+ "CL" => "Caltanissetta",
37
+ "CB" => "Campobasso",
38
+ "CI" => "Carbonia-Iglesias",
39
+ "CE" => "Caserta",
40
+ "CT" => "Catania",
41
+ "CZ" => "Catanzaro",
42
+ "CH" => "Chieti",
43
+ "CO" => "Como",
44
+ "CS" => "Cosenza",
45
+ "CR" => "Cremona",
46
+ "KR" => "Crotone",
47
+ "CN" => "Cuneo",
48
+ "EN" => "Enna",
49
+ "FM" => "Fermo",
50
+ "FE" => "Ferrara",
51
+ "FI" => "Firenze",
52
+ "FG" => "Foggia",
53
+ "FC" => "Forlì-Cesena",
54
+ "FR" => "Frosinone",
55
+ "GE" => "Genova",
56
+ "GO" => "Gorizia",
57
+ "GR" => "Grosseto",
58
+ "IM" => "Imperia",
59
+ "IS" => "Isernia",
60
+ "SP" => "La Spezia",
61
+ "AQ" => "L'Aquila",
62
+ "LT" => "Latina",
63
+ "LE" => "Lecce",
64
+ "LC" => "Lecco",
65
+ "LI" => "Livorno",
66
+ "LO" => "Lodi",
67
+ "LU" => "Lucca",
68
+ "MC" => "Macerata",
69
+ "MN" => "Mantova",
70
+ "MS" => "Massa-Carrara",
71
+ "MT" => "Matera",
72
+ "VS" => "Medio Campidano",
73
+ "ME" => "Messina",
74
+ "MI" => "Milano",
75
+ "MO" => "Modena",
76
+ "MB" => "Monza e Brianza",
77
+ "NA" => "Napoli",
78
+ "NO" => "Novara",
79
+ "NU" => "Nuoro",
80
+ "OG" => "Ogliastra",
81
+ "OT" => "Olbia-Tempio",
82
+ "OR" => "Oristano",
83
+ "PD" => "Padova",
84
+ "PA" => "Palermo",
85
+ "PR" => "Parma",
86
+ "PV" => "Pavia",
87
+ "PG" => "Perugia",
88
+ "PU" => "Pesaro e Urbino",
89
+ "PE" => "Pescara",
90
+ "PC" => "Piacenza",
91
+ "PI" => "Pisa",
92
+ "PT" => "Pistoia",
93
+ "PN" => "Pordenone",
94
+ "PZ" => "Potenza",
95
+ "PO" => "Prato",
96
+ "RG" => "Ragusa",
97
+ "RA" => "Ravenna",
98
+ "RC" => "Reggio Calabria",
99
+ "RE" => "Reggio Emilia",
100
+ "RI" => "Rieti",
101
+ "RN" => "Rimini",
102
+ "RM" => "Roma",
103
+ "RO" => "Rovigo",
104
+ "SA" => "Salerno",
105
+ "SS" => "Sassari",
106
+ "SV" => "Savona",
107
+ "SI" => "Siena",
108
+ "SR" => "Siracusa",
109
+ "SO" => "Sondrio",
110
+ "TA" => "Taranto",
111
+ "TE" => "Teramo",
112
+ "TR" => "Terni",
113
+ "TO" => "Torino",
114
+ "TP" => "Trapani",
115
+ "TN" => "Trento",
116
+ "TV" => "Treviso",
117
+ "TS" => "Trieste",
118
+ "UD" => "Udine",
119
+ "VA" => "Varese",
120
+ "VE" => "Venezia",
121
+ "VB" => "Verbano-Cusio-Ossola",
122
+ "VC" => "Vercelli",
123
+ "VR" => "Verona",
124
+ "VV" => "Vibo Valentia",
125
+ "VI" => "Vicenza",
126
+ "VT" => "Viterbo"
127
+ }
128
+
129
+ attribute :entity_type, String # Required - one in ENTITY_TYPES
130
+ attribute :nationality, String # Required - one in COUNTRY_CODES
131
+ attribute :reg_code, String
132
+ attribute :hide_whois, Boolean, :default => false
133
+ attribute :province, String # One in PROVINCIAL_CODES if nationality = IT
134
+ attribute :terms_1_accepted, Boolean, :default => false
135
+ attribute :terms_2_accepted, Boolean, :default => false
136
+ attribute :terms_3_accepted, Boolean, :default => false
137
+ attribute :terms_4_accepted, Boolean, :default => false
138
+ attribute :ip_address, String
139
+
140
+ def registrant_params
141
+ params = {
142
+ 'registrant_dotitentitytype' => @entity_type,
143
+ 'registrant_dotitnationality' => @nationality,
144
+ 'registrant_dotitregcode' => @reg_code,
145
+ 'registrant_dotithidewhois' => @hide_whois ? 'YES' : 'NO',
146
+ 'registrant_dotitprovince' => @province,
147
+ 'registrant_dotitterm1' => @term_1 ? 'YES' : 'NO',
148
+ 'registrant_dotitterm2' => @term_2 ? 'YES' : 'NO',
149
+ 'registrant_dotitterm3' => @term_3 ? 'YES' : 'NO',
150
+ 'registrant_dotitterm4' => @term_4 ? 'YES' : 'NO',
151
+ 'registrant_clientip' => @ip_address
152
+ }
153
+ return params
154
+ end
155
+
156
+ def valid?(inputs = {})
157
+ ensure_attribute_has_value :entity_type, :nationality, :reg_code, :province, :ip_address
158
+
159
+ unless COUNTRY_CODES.has_key?(@nationality)
160
+ @errors << "nationality must be one in COUNTRY_CODES"
161
+ end
162
+
163
+ if @nationality == 'IT'
164
+ unless PROVINCIAL_CODES.include?(@province)
165
+ @errors << "province must be one in PROVINCIAL_CODES when nationality is IT"
166
+ end
167
+ end
168
+
169
+ case @entity_type
170
+ when '1'
171
+ unless COUNTRY_CODES_EU.include?(@nationality) || COUNTRY_CODES_EU.include?(inputs['registrant_country_code'])
172
+ @errors << "either nationality or registrant country_code must be member of EU"
173
+ end
174
+ else
175
+ unless @nationality != inputs['registrant_country_code']
176
+ @errors << "nationality must be the same as registrant country_code"
177
+ end
178
+ end
179
+ super
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,47 @@
1
+ module InternetBS
2
+ class DotNLAttributes < AdditionalAttributes
3
+ LEGAL_FORMS = {
4
+ 'BGG' => 'Non-Dutch EC company',
5
+ 'BRO' => 'Non-Dutch legal form/enterprise/subsidiary',
6
+ 'BV' => 'Limited company',
7
+ 'BVI/O' => 'Limited company in formation',
8
+ 'COOP' => 'Cooperative',
9
+ 'CV' => 'Limited Partnership',
10
+ 'EENMANSZAAK' => 'Sole trader',
11
+ 'EESV' => 'European Economic Interest Group',
12
+ 'KERK' => 'Religious society',
13
+ 'MAATSCHAP' => 'Partnership',
14
+ 'NV' => 'Public Company',
15
+ 'OWM' => 'Mutual benefit company',
16
+ 'PERSOON' => 'Natural person',
17
+ 'REDR' => 'Shipping company',
18
+ 'STICHTING' => 'Foundation',
19
+ 'VERENIGING' => 'Association',
20
+ 'VOF Trading' => 'partnership',
21
+ 'ANDERS' => 'Other'
22
+ }
23
+
24
+ attribute :ip_address, String # Required
25
+ attribute :legal_form, String # Required - one of LEGAL_FORMS
26
+ attribute :registration_number, String # Optional
27
+ attribute :terms_accepted, Boolean, :default => false # Required - YES = true, NO = false
28
+
29
+ def registrant_params
30
+ params = {
31
+ 'registrant_nllegalform' => @legal_form,
32
+ 'registrant_nlterm' => @terms_accepted ? 'YES' : 'NO',
33
+ 'registrant_clientip' => @ip_address
34
+ }
35
+ params.merge!({'registrant_nlregnumber' => @registration_number}) if @registration_number
36
+ return params
37
+ end
38
+
39
+ def valid?(inputs = {})
40
+ ensure_attribute_has_value :ip_address, :legal_form, :terms_accepted
41
+ unless LEGAL_FORMS.include?(@legal_form)
42
+ @errors << "legal_form must be one in LEGAL_FORMS"
43
+ end
44
+ super
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,60 @@
1
+ module InternetBS
2
+ class DotUKAttributes < AdditionalAttributes
3
+ ORGANIZATION_TYPES = {
4
+ 'LTD' => 'UK Limited Company',
5
+ 'PLC' => 'UK Public Limited Company',
6
+ 'PTNR' => 'UK Partnership',
7
+ 'STRA' => 'UK Sole Trader',
8
+ 'LLP' => 'UK Limited Liability Partnership',
9
+ 'IP' => 'UK Industrial/Provident Registered Company',
10
+ 'IND' => 'UK Individual (self representing)',
11
+ 'SCH' => 'UK School',
12
+ 'RCHAR' => 'UK Registered Charity',
13
+ 'GOV' => 'UK Government Body',
14
+ 'CRO' => 'UK Corporation by Royal Charter',
15
+ 'STAT' => 'UK Statutory Body',
16
+ 'OTHER' => 'UK Entity that does not fit into any of the above',
17
+ 'FIND' => 'Non-UK Individual (self representing)',
18
+ 'FCORP' => 'Non-UK Corporation',
19
+ 'FOTHER' => 'Non-UK Entity that does not fit into any of the above'
20
+ }
21
+
22
+ attribute :county, String
23
+ # attribute :locality, String # DEPRECATED
24
+ # attribute :mobile, String # DEPRECATED
25
+ attribute :opt_out, Boolean, :default => false # Y = hide, N = no hide, only for FIND or IND
26
+ attribute :organization_type, String # Required, must be one of ORGANIZATION_TYPES
27
+ attribute :organization_number, String # Required if LTD, PLC, LLP, IP, SCH, RCHAR
28
+ attribute :registration_number, String # Required for LTD, PLC, LLP, IP, SCH, RCHAR
29
+
30
+ def registrant_params
31
+ params = {'registrant_county' => @county, 'registrant_dotukorgtype' => @organization_type}
32
+ if %w[LTD PLC LLP IP SCH RCHAR].include?(@organization_type)
33
+ params.merge!({
34
+ 'registrant_dotukorgno' => @organization_number,
35
+ 'registrant_dotukregistrationnumber' => @registration_number
36
+ })
37
+ end
38
+ returns params
39
+ end
40
+
41
+ def optional_params
42
+ params = {}
43
+ if %w[IND FIND].include?(@organization_type)
44
+ params.merge!({"#{@contact_type.to_s}_dotukoptout" => @opt_out ? 'Y' : 'N'})
45
+ end
46
+ return params
47
+ end
48
+
49
+ def valid?(inputs = {})
50
+ ensure_attribute_has_value :county, :organization_type
51
+ unless ORGANIZATION_TYPES.has_key?(@organization_type)
52
+ @errors << "organization_type must be one in ORGANIZATION_TYPES"
53
+ end
54
+ if %w[LTD PLC LLP IP SCH RCHAR].include?(@organization_type)
55
+ ensure_attribute_has_value :organization_number, :registration_number
56
+ end
57
+ super
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,54 @@
1
+ require_relative 'country_codes'
2
+
3
+ module InternetBS
4
+ class DotUSAttributes < AdditionalAttributes
5
+ PURPOSES = {
6
+ 'P1' => 'Business use for profit',
7
+ 'P2' => 'Non-profit business, club, association, religious organization, etc.',
8
+ 'P3' => 'Personal use',
9
+ 'P4' => 'Educational purposes',
10
+ 'P5' => 'Government purposes'
11
+ }
12
+
13
+ NEXUS_CATEGORIES = {
14
+ 'C11' => 'A natural person who is a US Citizen',
15
+ 'C12' => 'A natural person who is a Permanent Resident',
16
+ 'C21' => 'An entity or organization that is (i) incorporated within one of the fifty US states, the District of Columbia, or any of the US possessions or territories, or (ii) organized or otherwise constituted under the laws of a state of the US, the District of Columbia or any of its possessions and territories (including federal, state, or local government of the US, or a political subdivision thereof, and non-commercial organizations based in the US.)',
17
+ 'C31' => 'A foreign organization that regularly engages in lawful activities (sales of goods or services or other business, commercial, or non-commercial, including not for profit relations) in the United States.',
18
+ 'C32' => 'Organization has an office or other facility in the US'
19
+ }
20
+
21
+ attribute :purpose, String # Required - one of PURPOSES
22
+ attribute :nexus_category, String # Required - one of NEXUS_CATEGORIES
23
+ attribute :nexus_country, String # Required if nexus_category is C31 or C32 - one of COUNTRY_CODES
24
+
25
+ def registrant_params
26
+ params = {'registrant_uspurpose' => @purpose, 'registrant_usnexuscategory' => @nexus_category}
27
+ if ['C31', 'C32'].include?(@nexus_category)
28
+ params.merge!({'registrant_usnexuscountry' => @nexus_country})
29
+ end
30
+ return params
31
+ end
32
+
33
+ def valid?(inputs = {})
34
+ ensure_attribute_has_value :purpose, :nexus_category
35
+ unless PURPOSES.include?(@purpose)
36
+ @errors << "purpose must be one in PURPOSES"
37
+ end
38
+ unless NEXUS_CATEGORIES.inlcude?(@nexus_category)
39
+ @errors << "nexus_category must be one in NEXUS_CATEGORIES"
40
+ end
41
+ case @nexus_category
42
+ when 'C31', 'C32'
43
+ unless @nexus_country
44
+ @errors << "nexus_country is required"
45
+ else
46
+ unless COUNTRY_CODES.has_key?(@nexus_country)
47
+ @errors << "nexus_country must be one in COUNTRY_CODES"
48
+ end
49
+ end
50
+ end
51
+ super
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,38 @@
1
+ module InternetBS
2
+ class Error
3
+
4
+ # 100001 Unexpected error occurred!
5
+ # 100002 Invalid value "{wrong_value}" for parameter "{parameter_name}"!
6
+ # 100003 Required parameter "{parameter_name}" missing!
7
+ # 100004 The domain {domain_name} has a not supported extension!
8
+ # 100005 The domain "{domain_name}" is not accessible. Permission denied!
9
+ # 100008 Invalid operation!
10
+ # 100010 The current domain status prohibits this operation!
11
+ # 100013 Registry not available
12
+ # 100014 Feature not supported for {entity_name}
13
+ # 100015 Value "{value_example}" is out of range for parameter {parameter_name}
14
+ # 100021 Invallid integer value "{value_example}"!
15
+ # 100026 Parameter {parameter_name} and {parameter_name} cannot be used both at the same time. They are mutually exclusive
16
+ # 100028 Maximum length exceeded for {entity_name}, given {given_value}, maximum allowed {limit}
17
+ # 100029 Parameter(s) {parameter_name} not recognized by the command
18
+ # 100033 Value "{value_example}" is out of range
19
+ # 107001 Account locked
20
+ # 107002 Invalid API key and/or Password
21
+ # 107003 Daily limit exceeded for command
22
+ # 107004 Hourly limit exceeded for command
23
+ # 107005 Minute limit exceeded for command
24
+ # 107006 Monthly limit exceeded for command
25
+ # 107007 Weekly limit exceeded for command
26
+ # 107008 Daily global API usage limit exceeded
27
+ # 107009 Hourly global API usage limit exceeded
28
+ # 107010 Minute global API usage limit exceeded
29
+ # 107011 Monthly global API usage limit exceeded
30
+ # 107012 Weekly global API usage limit exceeded
31
+ # 107013 API command does not exist!
32
+ # 107015 Unexpected ERROR: Tech department has been notified!
33
+ # 107016 API temporary blocked, please contact us at {support_email}
34
+ # 107017 Connection refused from unauthorized host. IP {ip_address} is NOT allowed to access your account
35
+ # 107018 Authentication error
36
+
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ module InternetBS
2
+ LANGUAGE_CODES = {
3
+ "cs" => "Čeština",
4
+ "da" => "Dansk",
5
+ "de" => "Deutsch",
6
+ "el" => "Ελληνικά",
7
+ "en" = "English",
8
+ "es" => "Espanol",
9
+ "et" => "Eesti",
10
+ "fi" => "Suomi",
11
+ "fr" => "Francais",
12
+ "hu" => "Magyar",
13
+ "it" => "Italiano",
14
+ "lt" => "Lithuanian",
15
+ "lv" => "Latviešu",
16
+ "mt" => "Malti",
17
+ "nl" => "Nederlands",
18
+ "pl" => "Polski",
19
+ "pt" => "Português",
20
+ "sk" => "Slovenčina",
21
+ "sl" => "Slovenščina",
22
+ "sv" => "Svenska",
23
+ "ro" => "Romana",
24
+ "bg" => "Bulgarian",
25
+ "ga" => "Irish"
26
+ }
27
+ end
@@ -0,0 +1,78 @@
1
+ module InternetBS
2
+ class OrderDomain < Base
3
+ attribute :auto_renew, Boolean # YES or NO
4
+ attribute :contacts, Array[DomainContact]
5
+ attribute :currency, String, :default => 'USD'
6
+ attribute :discount_code, String
7
+ attribute :domain, String
8
+ attribute :domain_extension, String
9
+ attribute :nameservers, Array[String]
10
+ attribute :period, String # 1Y, 2Y up to 10Y
11
+ attribute :private_whois, String # DISABLED or FULL or PARTIAL
12
+ attribute :registrar_lock, String # ENABLED or DISABLED or NOTADMITTED
13
+ attribute :tel_hosting_account, String # .tel domains only
14
+ attribute :tel_hosting_password, String # .tel domains only
15
+ attribute :tel_hide_whois_data, Boolean # .tel domains only, either YES or NO
16
+ attribute :total_price, Float
17
+ attribute :transfer_auth_info, String
18
+
19
+ def purchase!
20
+ ensure_attribute_has_value :domain
21
+ return false if @errors.any?
22
+
23
+ @domain_extension = @domain.split('.').last
24
+
25
+ params = {
26
+ 'domain' => @domain,
27
+ 'currency' => @currency,
28
+ 'period' => @period,
29
+ 'ns_list' => @nameservers.join(',')
30
+ }
31
+
32
+ params.merge!({'transferauthinfo' => @transfer_auth_info}) if @transfer_auth_info
33
+ parmas.merge!({'registrarlock' => @registrar_lock}) if @registrar_lock
34
+ params.merge!({'privatewhois' => @private_whois}) if @private_whois
35
+ params.merge!({'discountcode' => @discount_code}) if @discount_code
36
+ params.merge!({'autorenew' => @auto_renew ? 'YES' : 'NO'}) if @auto_renew
37
+
38
+ @contacts.each do |contact|
39
+ params.merge!(contact.params)
40
+ end
41
+
42
+ if @domain_extension == "tel"
43
+ params.merge!({
44
+ 'telhostingaccount' => @tel_hosting_account,
45
+ 'telhostingpassword' => @tel_hosting_password
46
+ })
47
+ if @tel_hide_whois_data
48
+ params.merge!({'telhidewhoisdata' => @tel_hide_whois_data ? 'YES' : 'NO'})
49
+ end
50
+ end
51
+
52
+ response = Client.post('/domain/create', params)
53
+ code = response.code rescue ""
54
+
55
+ case code
56
+ when '200'
57
+ hash = JSON.parse(response.body)
58
+
59
+ @status = hash['status']
60
+ @transaction_id = hash['transactid']
61
+
62
+ if @status == 'SUCCESS'
63
+ @currency = hash['currency']
64
+ @total_price = hash['price']
65
+ else
66
+ set_errors(response)
67
+ return false
68
+ end
69
+
70
+ return true
71
+ else
72
+ set_errors(response)
73
+ return false
74
+ end
75
+ end
76
+
77
+ end
78
+ end