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.
42 43 44 45 46 47 |
# File 'lib/limeade/client.rb', line 42 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.
76 77 78 79 80 81 82 |
# File 'lib/limeade/client.rb', line 76 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?
51 52 53 |
# File 'lib/limeade/client.rb', line 51 def connected? @session_key && @json_rpc end |
#disconnect ⇒ Boolean
Release resources for this client locally and at the endpoint.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/limeade/client.rb', line 57 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
84 85 86 |
# File 'lib/limeade/client.rb', line 84 def respond_to_missing?(method_name, include_private = false) API_METHODS.include?(method_name) || super end |