Module: Locked::API::Request

Defined in:
lib/locked/api/request/build.rb,
lib/locked/api/request.rb

Overview

generate api request

Defined Under Namespace

Modules: Build

Class Method Summary collapse

Class Method Details

.call(command, api_key, headers) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/locked/api/request.rb', line 15

def call(command, api_key, headers)
  http.request(
    Locked::API::Request::Build.call(
      command,
      headers.merge(DEFAULT_HEADERS),
      api_key
    )
  )
end

.httpObject



25
26
27
28
29
30
31
32
33
# File 'lib/locked/api/request.rb', line 25

def http
  http = Net::HTTP.new(Locked.config.host, Locked.config.port)
  http.read_timeout = Locked.config.request_timeout / 1000.0
  if Locked.config.port == 443
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  end
  http
end