nic_ar 0.0.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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/lib/nic_ar/client.rb +86 -0
- data/lib/nic_ar/version.rb +3 -0
- data/lib/nic_ar.rb +24 -0
- data/nic_ar.gemspec +21 -0
- metadata +66 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Cristian R. Arroyo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# NicAr::Client
|
2
|
+
|
3
|
+
The NicAr::Client gem allows to programatically extract information about any ".ar" (Argentina) domain name.
|
4
|
+
|
5
|
+
It uses the public information as is made available at the [Dirección Nacional del Registro de Dominios de Internet](http://www.nic.ar) via the third-party [nic!alert API](http://api.nicalert.com.ar) webservice.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'nic_ar'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install nic_ar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The NicAr::Client class supports lookups for domain names, domain transactions, entities, people, DNS servers.
|
24
|
+
|
25
|
+
All the following lookups will raise a NicAr::NotFound exception if the requested resource could not be found.
|
26
|
+
|
27
|
+
NicAr::Client.domains("vivaserver.com.ar")
|
28
|
+
=> {"available"=>false, "delegated"=>true, "expiring"=>false, "pending"=>false, "registered"=>true, "name"=>"vivaserver", "domain"=>".com.ar", "created_on"=>"2004-11-18", "expires_on"=>"2012-11-18", "contacts"=>{"registrant"=>{"name"=>"Cristian Renato Arroyo", "occupation"=>"Diseno de Paginas Web", "address"=>"Pje. Vucetich 676. Ciudad De Nieva", "city"=>"S. S. de Jujuy", "province"=>"Jujuy", "zip_code"=>"4600", "country"=>"Argentina", "phone"=>"(0388)155827713", "fax"=>"(0388)155827713"}, "responsible"=>{"name"=>"Cristian Renato Arroyo", "address"=>"Pje. Vucetich 676. Ciudad De Nieva.", "city"=>"S. S. de jujuy", "province"=>"Jujuy", "zip_code"=>"4600", "country"=>"Argentina", "phone"=>"(0388)155827713", "fax"=>"(0388)155827713", "work_hours"=>"8am-1pm"}, "administrative"=>{"name"=>"Dynamic DNS Network Services", "address"=>"210 Park Ave. #267", "city"=>"Worcester", "province"=>"", "zip_code"=>"MA 01609", "country"=>"USA", "phone"=>"1-508-798-2145", "fax"=>"1-508-798-5748", "activity"=>"Network Services"}, "technical"=>{"name"=>"Andre Dure", "address"=>"Humahuaca 1303", "city"=>"Capital Federal", "province"=>"Ciudad de Buenos Aires", "zip_code"=>"C1405BIA", "country"=>"Argentina", "phone"=>"49588864", "fax"=>"43335885", "work_hours"=>"10 a 22"}}, "dns_servers"=>{"primary"=>{"host"=>"ns1.mydyndns.org", "ip"=>nil}, "secondary"=>{"host"=>"ns2.mydyndns.org", "ip"=>nil}, "alternate1"=>{"host"=>"ns3.mydyndns.org", "ip"=>nil}, "alternate2"=>{"host"=>"ns4.mydyndns.org", "ip"=>nil}, "alternate3"=>{"host"=>"ns5.mydyndns.org", "ip"=>nil}}}
|
29
|
+
|
30
|
+
NicAr::Client.entities("Dynamic DNS Network Services")
|
31
|
+
=> {"name"=>"Dynamic DNS Network Services", "type"=>"ADMINISTRADORA", "address"=>"210 Park Ave. #267", "city"=>"Worcester", "province"=>nil, "country"=>"USA", "activity"=>"Network Services", "handle"=>"NICAR-E607791"}
|
32
|
+
|
33
|
+
NicAr::Client.people("Andre Dure")
|
34
|
+
=> {"name"=>"Andre Dure", "handle"=>"NICAR-P425476"}
|
35
|
+
|
36
|
+
NicAr::Client.dns_servers("ns1.mydyndns.org")
|
37
|
+
=> {"host"=>"ns1.mydyndns.org", "ip"=>nil, "owner"=>"Andre Dure", "operator"=>"Andre Dure", "handle"=>"NICAR-H12587"}
|
38
|
+
|
39
|
+
If a domain name has no recent transactions, a NicAr::NoContent exception will be raised.
|
40
|
+
|
41
|
+
NicAr::Client.transactions("nazarenorock.com.ar")
|
42
|
+
=> [{"id"=>"REG18127727", "created_at"=>"2012-10-03T15:11:01-03:00", "description"=>"Registro de Nombre", "status"=>"PENDIENTE", "notes"=>"Se envio acuse de recibo al solicitante"}]
|
43
|
+
|
44
|
+
Transactions can also be queried by it's unique identifier:
|
45
|
+
|
46
|
+
NicAr::Client.transactions("REG18127727")
|
47
|
+
=> {"domain"=>"nazarenorock.com.ar", "created_at"=>"2012-10-03T15:11:01-03:00", "description"=>"Registro de Nombre", "status"=>"PENDIENTE", "notes"=>"Se envio acuse de recibo al solicitante"}
|
48
|
+
|
49
|
+
The full documentation of the nic!alert API is available at [api.nicalert.com.ar](http://api.nicalert.com.ar) if you want to write your own client, use any other language, or just use CURL in a RESTful way.
|
50
|
+
|
51
|
+
## Live sample
|
52
|
+
|
53
|
+
A live test application is set up at the [nic!alert](http://www.nicalert.com.ar) website that allows for the automatic renewal of ".ar" domain names within their 30-day expiring period. The application also has the added feature of resolving the CAPTCHA challenge for the submission of the renewal request.
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
62
|
+
|
63
|
+
## Copyright
|
64
|
+
|
65
|
+
Copyright (c)2012 [Cristian R. Arroyo](mailto:cristian.arroyo@vivasserver.com). MIT Licensed.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module NicAr
|
2
|
+
class Client
|
3
|
+
class << self
|
4
|
+
def method_missing(name, *args)
|
5
|
+
unless args.empty?
|
6
|
+
params = args.map { |p| CGI.escape(p) }.join '/'
|
7
|
+
resource = name.to_s
|
8
|
+
# send the bang! trailing the request (upcoming API feat.)
|
9
|
+
if unbanged = resource[/(\w+)!$/,1]
|
10
|
+
resource = unbanged
|
11
|
+
params += '!'
|
12
|
+
end
|
13
|
+
get "/#{resource}/#{params}"
|
14
|
+
else
|
15
|
+
raise ArgumentError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def get(path) #:nodoc:
|
22
|
+
RestClient.get("#{api_host}/#{path}") do |response, request, result, &block|
|
23
|
+
message = message_from(response)
|
24
|
+
|
25
|
+
case response.code
|
26
|
+
#200: Success
|
27
|
+
when 200
|
28
|
+
JSON.parse(response)
|
29
|
+
|
30
|
+
#204: No Content
|
31
|
+
when 204
|
32
|
+
raise NoContent
|
33
|
+
|
34
|
+
#424: Failed Dependency
|
35
|
+
when 424
|
36
|
+
raise CaptchaError, message
|
37
|
+
|
38
|
+
#406: Not Acceptable
|
39
|
+
when 406
|
40
|
+
raise DomainError, message
|
41
|
+
|
42
|
+
#417: Expectation Failed
|
43
|
+
when 417
|
44
|
+
raise ExpectationError, message
|
45
|
+
|
46
|
+
#404: Not Found
|
47
|
+
when 404
|
48
|
+
raise NotFound
|
49
|
+
|
50
|
+
#400: Bad Request
|
51
|
+
when 400
|
52
|
+
raise ParameterError, message
|
53
|
+
|
54
|
+
#412: Precondition Failed
|
55
|
+
when 412
|
56
|
+
raise PreconditionError, message
|
57
|
+
|
58
|
+
#408: Request Timeout
|
59
|
+
#503: Service Unavailable
|
60
|
+
when 408, 503
|
61
|
+
raise TimeoutError, message
|
62
|
+
|
63
|
+
#500: System Error
|
64
|
+
when 500
|
65
|
+
raise ServiceError, message
|
66
|
+
|
67
|
+
else
|
68
|
+
response.return!(request, response, &block)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def message_from(response) #:nodoc:
|
74
|
+
JSON.parse(response)['message']
|
75
|
+
rescue
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
# override to support multiple API hosts
|
80
|
+
|
81
|
+
def api_host #:nodoc:
|
82
|
+
API_URI
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/nic_ar.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'json'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rest_client'
|
6
|
+
|
7
|
+
module NicAr
|
8
|
+
API_URI = 'http://api.nicalert.com.ar'
|
9
|
+
|
10
|
+
# exceptions match API's error codes
|
11
|
+
|
12
|
+
class CaptchaError < StandardError; end # 424: Failed Dependency
|
13
|
+
class DomainError < StandardError; end # 406: Not Acceptable
|
14
|
+
class ExpectationError < StandardError; end # 417: Expectation Failed (available?, pending?)
|
15
|
+
class NoContent < StandardError; end # 204: No Content
|
16
|
+
class NotFound < StandardError; end # 404: Not Found
|
17
|
+
class ParameterError < StandardError; end # 400: Bad Request
|
18
|
+
class PreconditionError < StandardError; end # 412: Precondition Failed
|
19
|
+
class ServiceError < StandardError; end # 500: System Error
|
20
|
+
class TimeoutError < StandardError; end # 408: Request Timeout
|
21
|
+
end
|
22
|
+
|
23
|
+
require "nic_ar/client"
|
24
|
+
require "nic_ar/version"
|
data/nic_ar.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nic_ar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "nic_ar"
|
8
|
+
gem.version = NicAr::VERSION
|
9
|
+
gem.authors = ["Cristian R. Arroyo"]
|
10
|
+
gem.email = ["cristian.arroyo@vivaserver.com"]
|
11
|
+
gem.description = %q{A simple client for the nic!alert API}
|
12
|
+
gem.summary = %q{A simple client for ".ar" (Argentina) domain names lookup using the nic!alert API}
|
13
|
+
gem.homepage = "https://github.com/vivaserver/nic_ar"
|
14
|
+
|
15
|
+
gem.add_runtime_dependency 'rest-client', "~> 1.6"
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nic_ar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Cristian R. Arroyo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-31 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &85718140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *85718140
|
25
|
+
description: A simple client for the nic!alert API
|
26
|
+
email:
|
27
|
+
- cristian.arroyo@vivaserver.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/nic_ar.rb
|
38
|
+
- lib/nic_ar/client.rb
|
39
|
+
- lib/nic_ar/version.rb
|
40
|
+
- nic_ar.gemspec
|
41
|
+
homepage: https://github.com/vivaserver/nic_ar
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.10
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: A simple client for ".ar" (Argentina) domain names lookup using the nic!alert
|
65
|
+
API
|
66
|
+
test_files: []
|