Module: Pipedrive::APIOperations::Request::ClassMethods
- Defined in:
- lib/pipedrive/api_operations/request.rb
Instance Method Summary collapse
Instance Method Details
#api_client ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pipedrive/api_operations/request.rb', line 29 def api_client @api_client = Faraday.new( url: BASE_URL, headers: { "Content-Type": "application/json" } ) do |faraday| if Pipedrive.debug_http faraday.response :logger, Pipedrive.logger, bodies: Pipedrive.debug_http_body end end end |
#request(method, url, params = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pipedrive/api_operations/request.rb', line 11 def request(method, url, params = {}) check_api_key! raise "Not supported method" \ unless %i[get post put patch delete].include?(method) Util.debug "#{name} #{method.upcase} #{url}" response = api_client.send(method) do |req| req.url url req.params = { api_token: Pipedrive.api_key } if %i[post put patch].include?(method) req.body = params.to_json else req.params.merge!(params) end end Util.serialize_response(response) end |