Module: Fountain::Api::RequestHelper
- Included in:
- Applicants, AvailableSlots, Funnels, Labels, Notes, Stages
- Defined in:
- lib/fountain/api/request_helper.rb
Overview
Fountain API HTTP request helper
Constant Summary collapse
- DEFAULT_REQUEST_OPTIONS =
{ method: :get, body: nil, headers: nil, ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER, ssl_ca_file: nil }.freeze
Instance Method Summary collapse
Instance Method Details
#request(path, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/fountain/api/request_helper.rb', line 28 def request(path, = {}) = DEFAULT_REQUEST_OPTIONS.merge() raise Fountain::InvalidMethodError unless %i[get post put delete].include? [:method] http = create_http() req = create_request(path, ) http.start { http.request(req) } end |
#request_json(path, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/fountain/api/request_helper.rb', line 21 def request_json(path, = {}) expected_response = .delete :expected_response response = request path, check_response response, expected_response parse_response response.body end |