action_kit_api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,32 @@ require 'xmlrpc/client'
|
|
5
5
|
# required for ... well every operation ... this is a remote API
|
6
6
|
# gem :)
|
7
7
|
|
8
|
+
# This seems silly and dangerous right? Overwriting something in the ruby
|
9
|
+
# standard libraries? Well ActionKit is doing XMLRPC wrong. This is almost
|
10
|
+
# identical to the Ruby standard library version however it drops the type
|
11
|
+
# check on the faultCode and the faultString. The XMLRPC standard indicates
|
12
|
+
# that yes the faultCode has to be an integer and faultString has to be a
|
13
|
+
# string. ActionKit WILL RETURN A STRING AS THE faultCode.
|
14
|
+
#
|
15
|
+
# References:
|
16
|
+
# XMLRPC Spec:
|
17
|
+
# http://xmlrpc.scripting.com/spec.html
|
18
|
+
# ActionKit (just an example, see second sentence under 'get'
|
19
|
+
# https://roboticdogs.actionkit.com/docs/manual/api/users.html?highlight=faultcode
|
20
|
+
module XMLRPC
|
21
|
+
module Convert
|
22
|
+
def self.fault(hash)
|
23
|
+
if hash.kind_of? Hash and hash.size == 2 and
|
24
|
+
hash.has_key? "faultCode" and hash.has_key? "faultString"
|
25
|
+
|
26
|
+
XMLRPC::FaultException.new(hash["faultCode"], hash["faultString"])
|
27
|
+
else
|
28
|
+
raise "wrong fault-structure: #{hash.inspect}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
8
34
|
module ActionKitApi
|
9
35
|
class NoConnection < Exception
|
10
36
|
# Nothing special, will be raised in the event something
|
@@ -23,7 +23,12 @@ module ActionKitApi
|
|
23
23
|
class_name = self.to_s.split("::").last
|
24
24
|
|
25
25
|
search = parse_attributes(attrs, args)
|
26
|
-
|
26
|
+
|
27
|
+
begin
|
28
|
+
response = ActionKitApi::Connection.call("#{class_name}.get", search)
|
29
|
+
rescue RuntimeError => error
|
30
|
+
response = nil
|
31
|
+
end
|
27
32
|
|
28
33
|
# Build a new object with the response, this might be an empty
|
29
34
|
# object if the search failed or was invalid
|