class SmartRecruiters::Resource
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/smartrecruiters/resource.rb, line 7 def initialize(client) @client = client end
Private Instance Methods
delete_request(url, params: {}, headers: {})
click to toggle source
# File lib/smartrecruiters/resource.rb, line 29 def delete_request(url, params: {}, headers: {}) handle_response client.connection.delete(url, params, headers) end
get_request(url, params: {}, headers: {})
click to toggle source
# File lib/smartrecruiters/resource.rb, line 13 def get_request(url, params: {}, headers: {}) handle_response client.connection.get(url, params, headers) end
handle_response(response)
click to toggle source
# File lib/smartrecruiters/resource.rb, line 33 def handle_response(response) case response.status when 400 raise Error, 'Bad request.' when 401 raise Error, 'Unauthorized' when 403 raise Error, 'Forbidden' when 404 raise Error, 'Not Found' when 429 raise Error, 'Too many requests' when 500 raise Error, 'Internal Server Error' end response end
patch_request(url, body:, headers: {})
click to toggle source
# File lib/smartrecruiters/resource.rb, line 21 def patch_request(url, body:, headers: {}) handle_response client.connection.patch(url, body, headers) end
post_request(url, body:, headers: {})
click to toggle source
# File lib/smartrecruiters/resource.rb, line 17 def post_request(url, body:, headers: {}) handle_response client.connection.post(url, body, headers) end
put_request(url, body:, headers: {})
click to toggle source
# File lib/smartrecruiters/resource.rb, line 25 def put_request(url, body:, headers: {}) handle_response client.connection.put(url, body, headers) end