Class: LoadRunner::Client
- Inherits:
-
Object
- Object
- LoadRunner::Client
- Includes:
- HTTParty
- Defined in:
- lib/load_runner/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#secret_token ⇒ Object
Returns the value of attribute secret_token.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #send(event = :push, opts = {}) ⇒ Object
- #send_payload(event, payload) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
8 9 10 11 12 |
# File 'lib/load_runner/client.rb', line 8 def initialize(opts={}) @secret_token = opts[:secret_token] @base_url = opts[:base_url] || 'localhost:3000' self.class.base_uri base_url end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/load_runner/client.rb', line 6 def base_url @base_url end |
#payload ⇒ Object
Returns the value of attribute payload.
6 7 8 |
# File 'lib/load_runner/client.rb', line 6 def payload @payload end |
#secret_token ⇒ Object
Returns the value of attribute secret_token.
6 7 8 |
# File 'lib/load_runner/client.rb', line 6 def secret_token @secret_token end |
Instance Method Details
#send(event = :push, opts = {}) ⇒ Object
14 15 16 17 |
# File 'lib/load_runner/client.rb', line 14 def send(event=:push, opts={}) payload = build_payload opts send_payload event, payload end |
#send_payload(event, payload) ⇒ Object
19 20 21 22 23 |
# File 'lib/load_runner/client.rb', line 19 def send_payload(event, payload) @payload = payload.is_a?(String) ? payload : payload.to_json headers = headers event self.class.post "/payload", body: @payload, headers: headers end |