action_kit_api 0.1.1 → 0.1.2

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.
@@ -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
- response = ActionKitApi::Connection.call("#{class_name}.get", search)
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
@@ -1,3 +1,3 @@
1
1
  module ActionKitApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sam Stelfox