Class: RoxClient::RSpec::Server
- Inherits:
-
Object
- Object
- RoxClient::RSpec::Server
- Defined in:
- lib/rox-client-rspec/server.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#api_key_id ⇒ Object
readonly
Returns the value of attribute api_key_id.
-
#api_key_secret ⇒ Object
readonly
Returns the value of attribute api_key_secret.
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#project_api_id ⇒ Object
readonly
Returns the value of attribute project_api_id.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #payload_options ⇒ Object
- #upload(payload) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
18 19 20 21 22 23 24 25 |
# File 'lib/rox-client-rspec/server.rb', line 18 def initialize = {} @name = [:name].to_s.strip @api_url = [:api_url].to_s if [:api_url] @api_key_id = [:api_key_id].to_s if [:api_key_id] @api_key_secret = [:api_key_secret].to_s if [:api_key_secret] @api_version = [:api_version] || 1 @project_api_id = [:project_api_id].to_s if [:project_api_id] end |
Instance Attribute Details
#api_key_id ⇒ Object (readonly)
Returns the value of attribute api_key_id.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def api_key_id @api_key_id end |
#api_key_secret ⇒ Object (readonly)
Returns the value of attribute api_key_secret.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def api_key_secret @api_key_secret end |
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def api_url @api_url end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def api_version @api_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def name @name end |
#project_api_id ⇒ Object (readonly)
Returns the value of attribute project_api_id.
7 8 9 |
# File 'lib/rox-client-rspec/server.rb', line 7 def project_api_id @project_api_id end |
Instance Method Details
#payload_options ⇒ Object
27 28 29 |
# File 'lib/rox-client-rspec/server.rb', line 27 def { version: @api_version } end |
#upload(payload) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rox-client-rspec/server.rb', line 31 def upload payload validate! uri = payload_uri body = Oj.dump payload, mode: :strict res = case @api_version when 0 HTTParty.post uri, body: body else HTTParty.post uri, body: body, headers: payload_headers.merge(authentication_headers) end if res.code != 202 raise Error.new("Expected HTTP 202 Accepted when submitting payload, got #{res.code}", res) end end |