Class: Recruitee::HTTP::Client
- Inherits:
-
Object
- Object
- Recruitee::HTTP::Client
- Defined in:
- lib/recruitee/http/client.rb
Constant Summary collapse
- DEFAULT_DOMAIN =
'https://api.recruitee.com'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#recruitee ⇒ Object
readonly
Returns the value of attribute recruitee.
Instance Method Summary collapse
-
#initialize(recruitee, options = {}) ⇒ Client
constructor
A new instance of Client.
- #request(method, path, params: nil, body: nil, headers: {}) ⇒ Object
Constructor Details
#initialize(recruitee, options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/recruitee/http/client.rb', line 10 def initialize(recruitee, = {}) raise ArgumentError if recruitee.nil? @recruitee = recruitee @prefix = [:prefix] || "/c/#{@recruitee.company_id}" @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/recruitee/http/client.rb', line 6 def @options end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/recruitee/http/client.rb', line 6 def prefix @prefix end |
#recruitee ⇒ Object (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 |