module Slack::Web::Faraday::Request

def delete(path, options = {})

def delete(path, options = {})
  request(:delete, path, options)
end

def get(path, options = {})

def get(path, options = {})
  request(:get, path, options)
end

def post(path, options = {})

def post(path, options = {})
  request(:post, path, options)
end

def put(path, options = {})

def put(path, options = {})
  request(:put, path, options)
end

def request(method, path, options)

def request(method, path, options)
  response = connection.send(method) do |request|
    case method
    when :get, :delete
      request.url(path, options)
    when :post, :put
      request.path = path
      options.compact!
      request.body = options unless options.empty?
    end
    request.headers['Authorization'] = "Bearer #{token}" if token
    request.options.merge!(options.delete(:request)) if options.key?(:request)
  end
  response.body
rescue ::Faraday::ParsingError => e
  raise Slack::Web::Api::Errors::ParsingError, e.response
end