Class: ZeroSSL::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/zerossl/http.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

VERBS =
{
  get:  Net::HTTP::Get,
  post: Net::HTTP::Post
}

Instance Method Summary collapse

Constructor Details

#initializeHTTP

Returns a new instance of HTTP.



15
16
17
18
19
20
# File 'lib/zerossl/http.rb', line 15

def initialize
  @api_uri    = Setup.config.api_uri
  @access_key = Setup.config.access_key
  @logger     = Setup.config.logger
  @user_agent = Setup.config.user_agent
end

Instance Method Details

#default_headers(opts = {}) ⇒ Object



22
23
24
25
26
27
# File 'lib/zerossl/http.rb', line 22

def default_headers(opts = {})
  {
    'User-Agent'   => @user_agent,
    'Content-Type' => 'application/json',
  }.merge!(opts)
end

#default_params(opts = {}) ⇒ Object



29
30
31
32
33
# File 'lib/zerossl/http.rb', line 29

def default_params(opts = {})
  {
    'access_key' => @access_key
  }.merge!(opts)
end

#get(path, options = {}) ⇒ Object



35
36
37
# File 'lib/zerossl/http.rb', line 35

def get(path, options = {})
  execute(path, :get, options)
end

#post(path, options = {}) ⇒ Object



39
40
41
# File 'lib/zerossl/http.rb', line 39

def post(path, options = {})
  execute(path, :post, options)
end