class AkamaiCCU::Client

Constants

GET
JSON_HEADER
POST
SSL

Attributes

host[R]
net_klass[R]

Public Class Methods

new(host:, net_klass: Net::HTTP) click to toggle source
# File lib/akamai_ccu/client.rb, line 13
def initialize(host:, net_klass: Net::HTTP)
  @host = host
  @net_klass = net_klass
end

Public Instance Methods

call(path:, method: POST, initheader: JSON_HEADER) { |request| ... } click to toggle source
# File lib/akamai_ccu/client.rb, line 18
def call(path:, method: POST, initheader: JSON_HEADER)
  request(path, method, initheader)
  yield @request if block_given?
  Thread.new { http.request(@request) }.value
end

Private Instance Methods

base_uri() click to toggle source
# File lib/akamai_ccu/client.rb, line 24
        def base_uri
  @base_uri ||= URI("#{SSL}://#{host}")
end
http() click to toggle source
# File lib/akamai_ccu/client.rb, line 28
        def http
  @http ||= @net_klass.new(base_uri.host, base_uri.port).tap do |http|
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  end
end
request(path, klass = GET, initheader = nil) click to toggle source
# File lib/akamai_ccu/client.rb, line 35
        def request(path, klass = GET, initheader = nil)
  @request ||= @net_klass.const_get(klass).new(base_uri.merge(path).to_s, initheader)
end