Class: HordeRPC
- Inherits:
-
Object
- Object
- HordeRPC
- Defined in:
- lib/horde_rpc.rb,
lib/horde_rpc/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Method Summary collapse
-
#first_client_for_company(name) ⇒ Hash?
Find the first client record for a particular company name.
-
#get_client_by_id(id) ⇒ Hash?
Return data for a client by its ID.
-
#initialize(uri, username = nil, password = nil) ⇒ HordeRPC
constructor
Create a new instance of the Horde connection.
-
#record_time(options) ⇒ Object
Record time against a project.
-
#request(method, *options) ⇒ Object
Make an RPC request against the Horde instance.
-
#search_clients(search_params = {}) ⇒ Hash
Search clients by KV-pairs.
Constructor Details
#initialize(uri, username = nil, password = nil) ⇒ HordeRPC
Create a new instance of the Horde connection
12 13 14 15 16 |
# File 'lib/horde_rpc.rb', line 12 def initialize(uri, username = nil, password = nil) @xmlrpc_client = XMLRPC::Client.new2 uri @xmlrpc_client.user = username @xmlrpc_client.password = password end |
Instance Method Details
#first_client_for_company(name) ⇒ Hash?
Find the first client record for a particular company name
84 85 86 87 |
# File 'lib/horde_rpc.rb', line 84 def first_client_for_company(name) results = search_clients :company => name results[name].first end |
#get_client_by_id(id) ⇒ Hash?
Return data for a client by its ID
37 38 39 |
# File 'lib/horde_rpc.rb', line 37 def get_client_by_id(id) request 'clients.getClient', id end |
#record_time(options) ⇒ Object
Record time against a project
100 101 102 103 |
# File 'lib/horde_rpc.rb', line 100 def record_time() raise ArgumentError unless .values_at(:date, :client, :type, :hours, :description, :employee).all? request 'time.recordTime', end |
#request(method, *options) ⇒ Object
Make an RPC request against the Horde instance
26 27 28 |
# File 'lib/horde_rpc.rb', line 26 def request(method, *) @xmlrpc_client.call method, * end |
#search_clients(search_params = {}) ⇒ Hash
Search clients by KV-pairs
70 71 72 73 74 75 |
# File 'lib/horde_rpc.rb', line 70 def search_clients(search_params = {}) # searchClients takes two arrays as params: # * list of search strings # * list of search fields request 'clients.searchClients', search_params.values, search_params.keys.map(&:to_s) end |