Class: Limeade::Client
- Inherits:
-
Object
- Object
- Limeade::Client
- Defined in:
- lib/limeade/client.rb
Overview
Client for accessing the LimeSurvey RemoteControl API from Ruby.
Instance Method Summary collapse
-
#connected? ⇒ Boolean
Is the client ready to send requests to the endpoint?.
-
#disconnect ⇒ Boolean
Release resources for this client locally and at the endpoint.
-
#initialize(endpoint, username, password, retry_options = {}) ⇒ Client
constructor
Instantiate a client and setup a connection to the LimeSurvey RemoteControl API.
-
#method_missing(method, *arguments) ⇒ Object
Handle LimeSurvey RemoteControl API calls invoked on the client by invoking them on the endpoint.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(endpoint, username, password, retry_options = {}) ⇒ Client
Instantiate a client and setup a connection to the LimeSurvey RemoteControl API. Passes configuration for the Faraday::Request::Retry mechanism.
44 45 46 47 48 49 |
# File 'lib/limeade/client.rb', line 44 def initialize(endpoint, username, password, = {}) @json_rpc = Limeade::JSON_RPC.new(endpoint, ) @username = username @password = password @session_key = get_session_key end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments) ⇒ Object
Handle LimeSurvey RemoteControl API calls invoked on the client by invoking them on the endpoint.
78 79 80 81 82 83 84 |
# File 'lib/limeade/client.rb', line 78 def method_missing(method, *arguments) if API_METHODS.include? method process_request(method, *arguments) else super end end |
Instance Method Details
#connected? ⇒ Boolean
Is the client ready to send requests to the endpoint?
53 54 55 |
# File 'lib/limeade/client.rb', line 53 def connected? @session_key && @json_rpc end |
#disconnect ⇒ Boolean
Release resources for this client locally and at the endpoint.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/limeade/client.rb', line 59 def disconnect if connected? release_session_key @json_rpc = nil @session_key = nil true else false end end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
86 87 88 |
# File 'lib/limeade/client.rb', line 86 def respond_to_missing?(method_name, include_private = false) API_METHODS.include?(method_name) || super end |