Class: PaApi::PBA
- Inherits:
-
Object
- Object
- PaApi::PBA
- Defined in:
- lib/pa_api.rb
Overview
Provides a connection to the default PBA API as configued in ENV
Instance Method Summary collapse
-
#call(method, params = [], server = 'BM') ⇒ Object
Makes a call to the PBA API, with the method param being the full method name, as a string, and an optional params Array.
-
#initialize(host: ENV['PBA_API'], path: '/RPC2', port: 5224) ⇒ PBA
constructor
A new instance of PBA.
Constructor Details
#initialize(host: ENV['PBA_API'], path: '/RPC2', port: 5224) ⇒ PBA
Returns a new instance of PBA.
28 29 30 |
# File 'lib/pa_api.rb', line 28 def initialize(host: ENV['PBA_API'], path: '/RPC2', port: 5224) @conn = XMLRPC::Client.new3(host: host, path: path, port: port) end |
Instance Method Details
#call(method, params = [], server = 'BM') ⇒ Object
Makes a call to the PBA API, with the method param being the full method name, as a string, and an optional params Array. The server param can also be supplied for API calls that do not use ‘BM’. Returns a Hash result.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pa_api.rb', line 36 def call(method, params = [], server = 'BM') begin { status: 0, result: @conn.call( :Execute, Method: method, Server: server, Params: params )['Result'][0] } rescue XMLRPC::FaultException => e { error_message: Base64.decode64(e.faultString).strip, status: -1, method: method, params: params, result: nil } rescue => e { status: -1, result: nil, method: method, params: params, error_message: e } end end |