Class: ProbeDockProbe::Server
- Inherits:
-
Object
- Object
- ProbeDockProbe::Server
- Defined in:
- lib/probe_dock_ruby/server.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project_api_id ⇒ Object
Returns the value of attribute project_api_id.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #upload(payload) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
18 19 20 21 22 23 |
# File 'lib/probe_dock_ruby/server.rb', line 18 def initialize = {} @name = [:name].to_s.strip if [:name] @api_url = [:api_url].to_s if [:api_url] @api_token = [:api_token].to_s if [:api_token] @project_api_id = [:project_api_id].to_s if [:project_api_id] end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
7 8 9 |
# File 'lib/probe_dock_ruby/server.rb', line 7 def api_token @api_token end |
#api_url ⇒ Object
Returns the value of attribute api_url.
7 8 9 |
# File 'lib/probe_dock_ruby/server.rb', line 7 def api_url @api_url end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/probe_dock_ruby/server.rb', line 7 def name @name end |
#project_api_id ⇒ Object
Returns the value of attribute project_api_id.
7 8 9 |
# File 'lib/probe_dock_ruby/server.rb', line 7 def project_api_id @project_api_id end |
Instance Method Details
#clear ⇒ Object
25 26 27 28 29 30 |
# File 'lib/probe_dock_ruby/server.rb', line 25 def clear @name = nil @api_url = nil @api_token = nil @project_api_id = nil end |
#upload(payload) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/probe_dock_ruby/server.rb', line 32 def upload payload validate! body = Oj.dump payload, mode: :strict res = HTTParty.post payload_uri, body: body, headers: payload_headers if res.code != 202 raise Error.new("Expected HTTP 202 Accepted when submitting payload, got #{res.code}", res) end end |