enom-ruby 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32fc7f2467d71ec7fb9ab6f83a8487bb69b9d3a1
4
- data.tar.gz: 0f3886445535f8f62fd6f804f34c7784e3a35e42
3
+ metadata.gz: 7cbf91eee2532ca4c366d39155de084f98b3cc68
4
+ data.tar.gz: 0220d62b02d1a363ff6c313866ee27417f8cf376
5
5
  SHA512:
6
- metadata.gz: 04237b6ac092643eeb69ea7f160dec44de06532ff466e92592ca9973806155637da8d1ad2610638e1eb17af3438acb924085e38d7ae3bbc9dc24277fffdc995c
7
- data.tar.gz: 19c2edad06f2c06a31102986e010cdba2762b2a1a66628181d67e08eef430912ac6c0038c790fd4fc02f4b4fc051b7a2c1a60b4d2a55a13d84c48b61a24775d2
6
+ metadata.gz: 43427f178d127ed944d2e84620cbc7db7f1438435bae1093381f7f38df246b25bb36e5cf20a67ffe44a38757ac092fa02ef96323e7aeecb75cc60e895915709f
7
+ data.tar.gz: c26f24eeff26a187c75208e594d48d84a3fcab18edcdd5b7db7248633b36db9a47b52df02961e78d7de6a6978f6ef10afa14cd6c1296592c025967f0551a81c8
data/README.md CHANGED
@@ -36,6 +36,9 @@ domains = EnomRuby::Domain.check('google')
36
36
  domains = EnomRuby::Domain.check('google', ['co', 'org', 'net'])
37
37
 
38
38
  domains.first.unavailable? #=> true
39
+
40
+ # adds google.co and google.org to your cart
41
+ EnomRuby::Domain.bulk_register('google', ['co', 'org'])
39
42
  ```
40
43
 
41
44
  ## Development
@@ -34,7 +34,7 @@ module EnomRuby
34
34
  if Integer(response["interface_response"]["ErrCount"]).zero?
35
35
  return response["interface_response"]
36
36
  else
37
- raise InterfaceError, response["interface_response"]["errors"].values.join(", ")
37
+ raise response["interface_response"]["errors"].values.join(", ")
38
38
  end
39
39
  end
40
40
  end
@@ -5,14 +5,38 @@ module EnomRuby
5
5
  class Domain
6
6
  DEFAULT_TLDS = ['com']
7
7
 
8
+ # Check a particular domain (sld) with an array of tlds (tld_list)
8
9
  def self.check(sld, tld_list = DEFAULT_TLDS)
9
- response = Client.request(command: 'Check', sld: sld, tldlist: tld_list.join(','))
10
+ response = Client.request(command: 'Check', sld: sld, tldlist: Array(tld_list).join(','))
10
11
  domains = Hash[*Array(response['Domain']).zip(Array(response['RRPText'])).flatten]
11
12
  [].tap do |results|
12
13
  domains.each_pair { |domain, text| results << new(domain, text) }
13
14
  end
14
15
  end
15
16
 
17
+ # Return an array of all the available TLDs to check against
18
+ def self.tld_list
19
+ response = Client.request(command: 'GetTLDList')
20
+ tld_list = response['tldlist']['tld'].collect(&:values).flatten
21
+ tld_list.compact.reject {|d| d.include?('--') || d.match(/\d+/) }
22
+ end
23
+
24
+ def self.bulk_register(sld, tld_list = DEFAULT_TLDS)
25
+ responses = []
26
+ tld_list.each_slice(4) do |group|
27
+ query = {}
28
+ group.each_with_index do |tld, idx|
29
+ query["tld#{idx+1}"] = tld
30
+ query["sld#{idx+1}"] = sld
31
+ end
32
+ query[:command] = 'AddBulkDomains'
33
+ query[:producttype] = 'register'
34
+ query[:listcount] = group.size
35
+ responses << Client.request(query)
36
+ end
37
+ responses
38
+ end
39
+
16
40
  def initialize(domain, availability_text)
17
41
  @domain = domain
18
42
  @availability_text = availability_text
@@ -1,3 +1,3 @@
1
1
  module EnomRuby
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -14,4 +14,18 @@ RSpec.describe EnomRuby::Domain do
14
14
  end
15
15
  end
16
16
 
17
+ describe '.tld_list', vcr: true do
18
+ subject { EnomRuby::Domain.tld_list }
19
+
20
+ it 'returns an array including normal tld "com" and fancy tld "ninja"' do
21
+ expect(subject).to include 'com'
22
+ expect(subject).to include 'ninja'
23
+ end
24
+
25
+ it 'returns an array excluding foreign tlds like xn--mgbh0fb or 5earlyaccess' do
26
+ test_results = subject.collect {|d| d.include?('--') || d.match(/\d+/)}.compact
27
+ expect(test_results).to be_empty
28
+ end
29
+ end
30
+
17
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enom-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Woertink
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty