dynadot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/dynadot.gemspec +27 -0
- data/lib/dynadot.rb +6 -0
- data/lib/dynadot/api.rb +54 -0
- data/lib/dynadot/version.rb +3 -0
- data/spec/dynadot/api_spec.rb +17 -0
- data/spec/spec_helper.rb +10 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a0cf96b9c8b5b55748c25b0d895d4ff20c695f1
|
4
|
+
data.tar.gz: 179fac8aa8571896f2d621c687f6114a4d782a90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af4d9e326b8828b7118645f7f020cee5cb685b22d6cf3835a966558f99887c241e1b85bc63448cfb3d818fecfadfd85a6cf470abca1f6a1f9726db0e5b684584
|
7
|
+
data.tar.gz: e9c70846e548d4ea49c703f9dc65fb6db64891a18a9269592dd0080ecbb7d8f280dc72670aa96ccc3b8ee1d4c8f23265f97a3af00d3cdb86838d5905e4d9b578
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Eric Yan
|
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,43 @@
|
|
1
|
+
# Dynadot
|
2
|
+
|
3
|
+
A Ruby interface to the [Dynadot's Domain API](https://www.dynadot.com/domain/api2.html).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dynadot'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dynadot
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require 'dynadot'
|
22
|
+
|
23
|
+
dynadot = Dynadot::Api.new('DYNADOT_API_KEY')
|
24
|
+
|
25
|
+
# Execute a command and get raw results
|
26
|
+
dynadot.execute :search, { domain0: "example.com", domain1: "example.net" }
|
27
|
+
# => [["domain0", "example.com", "", "no"], ["domain1", "example.net", "", "no"]]
|
28
|
+
|
29
|
+
# A less messy way to do a domain search
|
30
|
+
dynadot.search("example.com", "example.net")
|
31
|
+
# => {"example.com"=>false, "example.net"=>false }
|
32
|
+
|
33
|
+
# Short-hand for availability check
|
34
|
+
dynadot.availabile?("example.com")
|
35
|
+
# => false
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/dynadot.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dynadot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dynadot"
|
8
|
+
spec.version = Dynadot::VERSION
|
9
|
+
spec.authors = ["Eric Yan"]
|
10
|
+
spec.email = ["long@ericyan.me"]
|
11
|
+
spec.description = "Dropcatch domains and manage your Dynadot account with Ruby."
|
12
|
+
spec.summary = "A Ruby interface to the Dynadot's Domain API"
|
13
|
+
spec.homepage = "https://github.com/ericyan/dynadot"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "httparty", "~> 0.13"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency "webmock", "~> 1.18"
|
26
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
27
|
+
end
|
data/lib/dynadot.rb
ADDED
data/lib/dynadot/api.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Dynadot
|
4
|
+
class Api
|
5
|
+
include HTTParty
|
6
|
+
base_uri 'https://api.dynadot.com/api2.html'
|
7
|
+
|
8
|
+
def initialize(key = nil)
|
9
|
+
raise ArgumentError, 'An API key is required' if key.to_s.empty?
|
10
|
+
self.class.default_params key: key.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(command, parameters = {})
|
14
|
+
response = self.class.get '', query: { command: command.to_s }.merge(parameters)
|
15
|
+
parse(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(*domains)
|
19
|
+
parameters = Hash[domains.map.with_index { |domain, index| ["domain#{index}" , domain] }]
|
20
|
+
results = execute(:search, parameters).map do |result|
|
21
|
+
domain, availability = result[1], result[3]
|
22
|
+
|
23
|
+
case availability
|
24
|
+
when 'yes' then [domain, true]
|
25
|
+
when 'no' then [domain, false]
|
26
|
+
when 'offline' then [domain, nil]
|
27
|
+
when 'system_busy' then [domain, nil]
|
28
|
+
when 'error' then raise "Error processing #{domain}: #{result[4]}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
return Hash[results]
|
33
|
+
end
|
34
|
+
|
35
|
+
def availabile?(domain)
|
36
|
+
search(domain)[domain]
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def parse(response)
|
41
|
+
data = response.parsed_response.split("\n")
|
42
|
+
data.delete_at(1)
|
43
|
+
|
44
|
+
error = data[0, 2] != 'ok' ? data.shift.split(",")[1] : nil
|
45
|
+
results = data.map { |line| line.split(",") }
|
46
|
+
|
47
|
+
if error
|
48
|
+
raise error
|
49
|
+
else
|
50
|
+
return results
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dynadot::Api do
|
4
|
+
it "should include HTTParty methods" do
|
5
|
+
expect(Dynadot::Api).to include(HTTParty)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have the base url set to the Domain API endpoint" do
|
9
|
+
expect(Dynadot::Api.base_uri).to eql 'https://api.dynadot.com/api2.html'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#new" do
|
13
|
+
it "requires a API key" do
|
14
|
+
expect { Dynadot::Api.new }.to raise_error(ArgumentError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynadot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Yan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.18'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.18'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.9'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.9'
|
97
|
+
description: Dropcatch domains and manage your Dynadot account with Ruby.
|
98
|
+
email:
|
99
|
+
- long@ericyan.me
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- dynadot.gemspec
|
110
|
+
- lib/dynadot.rb
|
111
|
+
- lib/dynadot/api.rb
|
112
|
+
- lib/dynadot/version.rb
|
113
|
+
- spec/dynadot/api_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: https://github.com/ericyan/dynadot
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.2.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: A Ruby interface to the Dynadot's Domain API
|
139
|
+
test_files:
|
140
|
+
- spec/dynadot/api_spec.rb
|
141
|
+
- spec/spec_helper.rb
|