class ThreeScale::Client::HTTPClient::BaseClient

Public Class Methods

available?() click to toggle source
# File lib/3scale/client/http_client.rb, line 31
def self.available?
end
new(host, port) click to toggle source
# File lib/3scale/client/http_client.rb, line 37
def initialize(host, port)
  @host = host
  @port = port
end
prepare() click to toggle source
# File lib/3scale/client/http_client.rb, line 34
def self.prepare
end

Public Instance Methods

get_request(path, headers: nil) click to toggle source
# File lib/3scale/client/http_client.rb, line 42
def get_request(path, headers: nil)
  get = Net::HTTP::Get.new(path)
  get.add_field(*USER_CLIENT_HEADER)
  get.add_field('Host', @host)
  add_request_headers(get, headers) if headers
  get
end
post_request(path, payload, headers: nil) click to toggle source
# File lib/3scale/client/http_client.rb, line 50
def post_request(path, payload, headers: nil)
  post = Net::HTTP::Post.new(path)
  post.add_field(*USER_CLIENT_HEADER)
  post.add_field('Host', @host)
  add_request_headers(post, headers) if headers
  post.set_form_data(payload)
  post
end

Private Instance Methods

add_request_headers(req, headers) click to toggle source
# File lib/3scale/client/http_client.rb, line 61
def add_request_headers(req, headers)
  if headers
    headers.each do |hk, hv|
      req.add_field(hk, hv)
    end
  end
end