Class: Morpheus::RestClient

Inherits:
Object
  • Object
show all
Defined in:
lib/morpheus/rest_client.rb

Overview

A wrapper around rest_client so we can more easily deal with passing options (like turning on/off SSL verification)

Class Method Summary collapse

Class Method Details

.enable_ssl_verification=(verify) ⇒ Object



31
32
33
# File 'lib/morpheus/rest_client.rb', line 31

def enable_ssl_verification=(verify)
  @@ssl_verification_enabled = verify
end

.execute(options) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/morpheus/rest_client.rb', line 9

def execute(options)
  opts = options.merge({})

  unless ssl_verification_enabled?
    opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
  end

  ::RestClient::Request.execute opts
end

.post(url, payload) ⇒ Object



19
20
21
# File 'lib/morpheus/rest_client.rb', line 19

def post(url, payload)
  execute url: url, payload: payload, method: :post
end

.ssl_verification_enabled?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/morpheus/rest_client.rb', line 23

def ssl_verification_enabled?
  begin
    @@ssl_verification_enabled.nil? ? true : @@ssl_verification_enabled
  rescue
    @@ssl_verification_enabled = true
  end
end