class Setka::Workflow::Request
Public Class Methods
new(http_verb, uri, body, options)
click to toggle source
# File lib/setka/workflow/request.rb, line 7 def initialize(http_verb, uri, body, options) @http_verb = http_verb @uri = uri if body raise WrongParamError.new('Body param must be a hash') unless body.is_a?(Hash) @body = body end @options = options end
Public Instance Methods
execute()
click to toggle source
# File lib/setka/workflow/request.rb, line 21 def execute Response.new(execute_core) end
Private Instance Methods
connection()
click to toggle source
# File lib/setka/workflow/request.rb, line 34 def connection Faraday.new do |conn| conn.request :json conn.response :json, content_type: /\bjson$/ conn.adapter Faraday.default_adapter conn.url_prefix = "#{@uri.scheme}://#{@uri.host}" end end
execute_core()
click to toggle source
# File lib/setka/workflow/request.rb, line 27 def execute_core connection.send @http_verb, @uri.path do |req| req.body = @body if @body && @body.any? req.headers.update @options[:headers] if @options[:headers] end end