transip 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/Gemfile.lock +27 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +39 -0
- data/VERSION.yml +4 -0
- data/init.rb +1 -0
- data/lib/transip.rb +95 -0
- metadata +84 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
remote: http://gemcutter.org/
|
4
|
+
remote: http://gems.github.com/
|
5
|
+
specs:
|
6
|
+
builder (3.0.0)
|
7
|
+
crack (0.1.8)
|
8
|
+
curb (0.7.15)
|
9
|
+
gyoku (0.4.2)
|
10
|
+
builder (>= 2.1.2)
|
11
|
+
httpi (0.9.2)
|
12
|
+
ntlm-http (>= 0.1.1)
|
13
|
+
rack
|
14
|
+
ntlm-http (0.1.1)
|
15
|
+
rack (1.2.2)
|
16
|
+
savon (0.9.1)
|
17
|
+
builder (>= 2.1.2)
|
18
|
+
crack (~> 0.1.8)
|
19
|
+
gyoku (>= 0.4.0)
|
20
|
+
httpi (>= 0.7.8)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
curb
|
27
|
+
savon
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Joost Hietbrink
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= TransIP API
|
2
|
+
|
3
|
+
Ruby gem to use the full TransIP API (v2).
|
4
|
+
|
5
|
+
For more info see:
|
6
|
+
|
7
|
+
* <b>The origin of this code:</b> https://github.com/joost/transip-api
|
8
|
+
* <b>TransIP API Docs:</b> https://www.transip.nl/g/api
|
9
|
+
|
10
|
+
Credits:
|
11
|
+
|
12
|
+
* <b>Savon Gem:</b> See: http://savonrb.com. Wouldn't be so simple without it!
|
13
|
+
|
14
|
+
== Install
|
15
|
+
|
16
|
+
Have to turn into a gem..
|
17
|
+
Download / clone the repository. Bundle install the needed gems and require the lib.
|
18
|
+
|
19
|
+
git clone git://github.com/joost/transip-api.git
|
20
|
+
bundle install
|
21
|
+
irb # and require './transip'
|
22
|
+
|
23
|
+
== Usage
|
24
|
+
|
25
|
+
For the most up-to-date documentation see the source files. Use as follows:
|
26
|
+
|
27
|
+
transip = Transip.new('username', '12.34.12.3')
|
28
|
+
transip.generate_hash('your_api_password')
|
29
|
+
transip.actions # => [:check_availability, .., :set_contacts]
|
30
|
+
transip.request(:get_domain_names)
|
31
|
+
transip.request(:get_info, :domain_name => 'domain.com')
|
32
|
+
|
33
|
+
== TODO
|
34
|
+
|
35
|
+
* Tests
|
36
|
+
|
37
|
+
Please feel free to contribute and send me a pull request via Github!
|
38
|
+
|
39
|
+
Copyright (c) 2011 Joost Hietbrink, released under the MIT license
|
data/VERSION.yml
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'transip-api'
|
data/lib/transip.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
|
4
|
+
require 'savon'
|
5
|
+
require 'curb'
|
6
|
+
require 'digest/md5'
|
7
|
+
#
|
8
|
+
# Implements the www.transip.nl API (v2). For more info see: https://www.transip.nl/g/api/
|
9
|
+
#
|
10
|
+
# Usage:
|
11
|
+
# transip = Transip.new('username', '12.34.12.3') # will use readonly mode
|
12
|
+
# transip = Transip.new('username', '12.34.12.3', :readwrite) # use this in production
|
13
|
+
# transip.generate_hash('your_api_password') # Use this to generate a authentication hash
|
14
|
+
# transip.hash = 'your_hash' # Or use this to directly set the hash (so you don't have to use your password in your code)
|
15
|
+
# transip.actions # => [:check_availability, :get_whois, :get_domain_names, :get_info, :get_auth_code, :get_is_locked, :register, :cancel, :transfer_with_owner_change, :transfer_without_owner_change, :set_nameservers, :set_lock, :unset_lock, :set_dns_entries, :set_owner, :set_contacts]
|
16
|
+
# transip.request(:get_domain_names)
|
17
|
+
# transip.request(:get_info, :domain_name => 'yelloyello.be')
|
18
|
+
#
|
19
|
+
# Credits:
|
20
|
+
# Savon Gem - See: http://savonrb.com/. Wouldn't be so simple without it!
|
21
|
+
class Transip
|
22
|
+
|
23
|
+
WSDL = 'https://api.transip.nl/wsdl/?service=DomainService'
|
24
|
+
|
25
|
+
attr_accessor :login, :ip, :mode, :hash
|
26
|
+
attr_reader :response
|
27
|
+
|
28
|
+
# Example:
|
29
|
+
# transip = Transip.new('username', '12.34.12.3') # will use readonly mode
|
30
|
+
# transip = Transip.new('username', '12.34.12.3', 'readwrite') # use this in production
|
31
|
+
def initialize(login, ip, mode = :readonly)
|
32
|
+
@login = login
|
33
|
+
@ip = ip
|
34
|
+
@mode = mode
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the needed authentication hash.
|
38
|
+
#
|
39
|
+
# NOTE: The password is NOT your general TransIP password
|
40
|
+
# but one specially for the API. Configure it in the Control
|
41
|
+
# Panel.
|
42
|
+
def generate_hash(password)
|
43
|
+
digest_string = "#{login}:#{password}@#{ip}"
|
44
|
+
digest = Digest::MD5.hexdigest(digest_string)
|
45
|
+
@hash = digest
|
46
|
+
end
|
47
|
+
|
48
|
+
# Used as authentication
|
49
|
+
def cookie
|
50
|
+
raise StandardError, "Don't have an authentication hash yet. Please set a hash using generate_hash('your_api_password') or hash= method." if hash.blank?
|
51
|
+
"login=#{login}; hash=#{hash}; mode=#{mode}; "
|
52
|
+
end
|
53
|
+
|
54
|
+
# Same as client method but initializes a brand new fresh client.
|
55
|
+
# You have to use this one when you want to re-set the mode (readwrite, readonly),
|
56
|
+
# or authentication details of your client.
|
57
|
+
def client!
|
58
|
+
@client = Savon::Client.new do
|
59
|
+
wsdl.document = WSDL
|
60
|
+
end
|
61
|
+
@client.http.headers["Cookie"] = cookie
|
62
|
+
return @client
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns a Savon::Client object to be used in the connection.
|
66
|
+
# This object is re-used and cached as @client.
|
67
|
+
def client
|
68
|
+
@client ||= client!
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns Array with all possible SOAP WSDL actions.
|
72
|
+
def actions
|
73
|
+
client.wsdl.soap_actions
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns the response.to_hash (raw Savon::SOAP::Response is also stored in @response).
|
77
|
+
# Examples:
|
78
|
+
# hash_response = transip.request(:get_domain_names)
|
79
|
+
# hash_response[:get_domain_names_response][:return][:item] # => ["your.domain", "names.list"]
|
80
|
+
# For more info see the Transip API docs.
|
81
|
+
# Be sure to rescue all the errors.. since it is hardcore error throwing.
|
82
|
+
def request(action, options = nil)
|
83
|
+
if options.nil?
|
84
|
+
@response = client.request(action)
|
85
|
+
elsif options.is_a?(Hash)
|
86
|
+
@response = client.request(action) do
|
87
|
+
soap.body = options
|
88
|
+
end
|
89
|
+
else
|
90
|
+
raise ArgumentError, "Expected options to be nil or a Hash!"
|
91
|
+
end
|
92
|
+
@response.to_hash
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joost Hietbrink
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-13 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: savon
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.9.1
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: curb
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.7.15
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: Ruby gem to use the full TransIP API (v2).
|
39
|
+
email: joost@joopp.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- MIT-LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- VERSION.yml
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- init.rb
|
54
|
+
- lib/transip.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/joost/transip-api
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.5.0
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Ruby gem to use the full TransIP API (v2).
|
83
|
+
test_files: []
|
84
|
+
|