Class: ActionKitApi::Connection
- Inherits:
-
Object
- Object
- ActionKitApi::Connection
- Defined in:
- lib/action_kit_api/connection.rb
Constant Summary collapse
- @@connection =
nil
Class Method Summary collapse
Class Method Details
.call(command, args = {}) ⇒ Object
66 67 68 69 70 |
# File 'lib/action_kit_api/connection.rb', line 66 def self.call(command, args = {}) raise NoConnection if @@connection.nil? @@connection.call(command, args) end |
.connect(user, password, host) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/action_kit_api/connection.rb', line 47 def self.connect(user, password, host) # Build the arguments for the XMLRPC::Client object conn_args = { :user => user, :password => password, :host => host, :use_ssl => true, :path => "/api" } @@connection = XMLRPC::Client.new_from_hash(conn_args) # Unfortunately XMLRPC::Client does not expose it's SSL settings so # we need to dive into it's instance methods to set SSL verification # and add a CA to authenticate against @@connection.instance_variable_get("@http").verify_mode = OpenSSL::SSL::VERIFY_PEER @@connection.instance_variable_get("@http").ca_file = File.join(File.dirname(__FILE__), "actionkit_ca_chain.pem") end |
.version ⇒ Object
72 73 74 |
# File 'lib/action_kit_api/connection.rb', line 72 def self.version self.call("version") end |