Module: Chatoperastore::Requests

Included in:
QuotaWdClient
Defined in:
lib/chatoperastore/requests.rb

Instance Method Summary collapse

Instance Method Details

#getRequestBypassSSLChecks(url) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/chatoperastore/requests.rb', line 24

def getRequestBypassSSLChecks(url)
  uri = URI(url)
  req = Net::HTTP::Get.new(uri.path)
  res = Net::HTTP.start(
    uri.host, uri.port,
    :use_ssl => uri.scheme == 'https',
    :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
    https.request(req)
  end
  if res.code == "200"
    return JSON.parse(res.body)
  else
    raise Chatoperastore::InvalidStoreResponseError.new "Invalid resp code " + res.code
  end
end

#postRequestBypassSSLChecks(url, body) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chatoperastore/requests.rb', line 40

def postRequestBypassSSLChecks(url, body)
  uri = URI(url)
  req = Net::HTTP::Post.new(uri.path)
  req.content_type = 'application/json'
  req.body = body.to_json
  res = Net::HTTP.start(
    uri.host, uri.port,
    :use_ssl => uri.scheme == 'https',
    :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
    https.request(req)
  end
  if res.code == "200"
    return JSON.parse(res.body)
  else
    raise Chatoperastore::InvalidStoreResponseError.new "Invalid resp code " + res.code
  end
end