opensrs 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +73 -2
- data/VERSION +1 -1
- data/lib/opensrs/response.rb +6 -3
- data/lib/opensrs/server.rb +6 -7
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,8 +1,79 @@
|
|
1
1
|
= OpenSRS
|
2
2
|
|
3
|
-
Provides basic support to connect to, and utilise the OpenSRS API.
|
3
|
+
Provides basic support to connect to, and utilise the OpenSRS API. This library has been well-tested in a high performance production
|
4
|
+
environment. More information on the API can be located here:
|
4
5
|
|
5
|
-
http://opensrs.com/resources/documentation/
|
6
|
+
http://opensrs.com/resources/documentation/opensrs_xmlapi.pdf
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
You can install this gem by doing the following:
|
11
|
+
|
12
|
+
$ gem install opensrs
|
13
|
+
|
14
|
+
You can then include it in a Ruby project, like so:
|
15
|
+
|
16
|
+
require 'opensrs'
|
17
|
+
|
18
|
+
Alternatively, you can include it in a Rails project in the <tt>environment.rb</tt> file, like so:
|
19
|
+
|
20
|
+
config.gem "opensrs"
|
21
|
+
|
22
|
+
== Usage
|
23
|
+
|
24
|
+
This library provides basic functionality for interacting with the OpenSRS XML API.
|
25
|
+
|
26
|
+
* Connection handling
|
27
|
+
* Error reporting
|
28
|
+
* XML encoding
|
29
|
+
* XML decoding
|
30
|
+
|
31
|
+
To connect, instantiate a new OpenSRS::Server object:
|
32
|
+
|
33
|
+
server = OpenSRS::Server.new(
|
34
|
+
:server => "https://rr-n1-tor.opensrs.net:55443/",
|
35
|
+
:username => "testing",
|
36
|
+
:password => "53cr3t",
|
37
|
+
:key => "c633be3170c7fb3fb29e2f99b84be24107b37e206663967f8cdfarandomc17d411fc28b3dbff47d03c51c61279bd6f3c545a3210777ab93b44e6aef5e23d82"
|
38
|
+
)
|
39
|
+
|
40
|
+
Once you have this, you can build from this to create the methods that you need. For instance, let's say we want to grab our balance. The
|
41
|
+
OpenSRS XML API takes a couple of attributes for all commands. You can include those here:
|
42
|
+
|
43
|
+
def get_balance
|
44
|
+
server.call(
|
45
|
+
:action => "GET_BALANCE",
|
46
|
+
:object => "BALANCE"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
Sometimes you might need to include attributes for the command, such as a cookie, or the data attributes themselves. You can do this, too:
|
51
|
+
|
52
|
+
def create_nameserver(nameserver)
|
53
|
+
server.call(
|
54
|
+
:action => "CREATE",
|
55
|
+
:object => "NAMESERVER",
|
56
|
+
:cookie => "366828736:3210384",
|
57
|
+
:attributes => {
|
58
|
+
:name => nameserver.hostname,
|
59
|
+
:ipaddress => "212.112.123.11"
|
60
|
+
}
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
Responses from OpenSRS are returned in an OpenSRS::Response object, which gives you access to a multitude of things.
|
65
|
+
|
66
|
+
* <tt>response.response</tt> - This gives you the response in a Hash form, which is highly accessible to most other actions in your application.
|
67
|
+
* <tt>response.errors</tt> - If there are errors which come back from OpenSRS, they are returned here. If not, it returns nil.
|
68
|
+
* <tt>response.success?</tt> - Returns true if the response was labeled as successful. If not, it returns false.
|
69
|
+
* <tt>response.request_xml</tt> - Returns raw request XML.
|
70
|
+
* <tt>response.response_xml</tt> - Returns raw response XML.
|
71
|
+
|
72
|
+
== Bugs/Feature Requests
|
73
|
+
|
74
|
+
If you have any bugs or feature requests for this gem, feel free to add them in the Issues portion of the GitHub repository here:
|
75
|
+
|
76
|
+
http://github.com/voxxit/opensrs/issues
|
6
77
|
|
7
78
|
== Note on Patches/Pull Requests
|
8
79
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/opensrs/response.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module OpenSRS
|
2
2
|
class Response
|
3
|
+
attr_reader :request_xml, :response_xml
|
3
4
|
attr_accessor :response, :success
|
4
5
|
|
5
|
-
def initialize(
|
6
|
-
@response
|
7
|
-
@
|
6
|
+
def initialize(parsed_response, request_xml, response_xml)
|
7
|
+
@response = parsed_response
|
8
|
+
@request_xml = request_xml
|
9
|
+
@response_xml = response_xml
|
10
|
+
@success = success?
|
8
11
|
end
|
9
12
|
|
10
13
|
# We need to return the error message unless the
|
data/lib/opensrs/server.rb
CHANGED
@@ -15,17 +15,16 @@ module OpenSRS
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(options = {})
|
18
|
-
|
19
|
-
:protocol
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
})
|
18
|
+
attributes = {
|
19
|
+
:protocol => "XCP"
|
20
|
+
}
|
21
|
+
|
22
|
+
xml = OpenSRS::XML.build(attributes.merge!(options))
|
24
23
|
|
25
24
|
response = http.post(server.path, xml, headers(xml))
|
26
25
|
parsed_response = OpenSRS::XML.parse(response.body)
|
27
26
|
|
28
|
-
return OpenSRS::Response.new(parsed_response)
|
27
|
+
return OpenSRS::Response.new(parsed_response, xml, response.body)
|
29
28
|
end
|
30
29
|
|
31
30
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensrs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Delsman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-06 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|