Class: Recruitee::HTTP::Client

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

Constant Summary collapse

DEFAULT_DOMAIN =
'https://api.recruitee.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recruitee, options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File 'lib/recruitee/http/client.rb', line 10

def initialize(recruitee, options = {})
  raise ArgumentError if recruitee.nil?

  @recruitee = recruitee
  @prefix    = options[:prefix] || "/c/#{@recruitee.company_id}"
  @options   = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/recruitee/http/client.rb', line 6

def options
  @options
end

#prefixObject (readonly)

Returns the value of attribute prefix.



6
7
8
# File 'lib/recruitee/http/client.rb', line 6

def prefix
  @prefix
end

#recruiteeObject (readonly)

Returns the value of attribute recruitee.



6
7
8
# File 'lib/recruitee/http/client.rb', line 6

def recruitee
  @recruitee
end

Instance Method Details

#request(method, path, params: nil, body: nil, headers: {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/recruitee/http/client.rb', line 18

def request(method, path, params: nil, body: nil, headers: {})
  res = connection.send(method.downcase.to_sym, prefixed(path)) do |req|
    req.body = body unless body.nil?
    req.params = params unless params.nil?
    req.headers = default_headers.merge(headers)
  end

  Recruitee::Response.new(res.status, res.body, headers: res.headers)
end