Class: Teamtailor::Request
- Inherits:
-
Object
- Object
- Teamtailor::Request
- Defined in:
- lib/teamtailor/request.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(base_url:, api_token:, api_version:, path:, params: {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(base_url:, api_token:, api_version:, path:, params: {}) ⇒ Request
Returns a new instance of Request.
8 9 10 11 12 13 14 |
# File 'lib/teamtailor/request.rb', line 8 def initialize(base_url:, api_token:, api_version:, path:, params: {}) @base_url = base_url @api_token = api_token @api_version = api_version @path = path @params = params end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/teamtailor/request.rb', line 16 def call request = Typhoeus::Request.new( "#{base_url}#{path}", method: :get, params: params, headers: request_headers ) response = request.run if response.code == 200 Teamtailor::PageResult.new response.body else raise Teamtailor::Error.from_response( body: response.body, status: response.code ) end end |