Sha256: 28e17b677368bafbaffd6e80462dc7d8d3e691aa494cb3f00892146809392115

Contents?: true

Size: 1021 Bytes

Versions: 6

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true
module Slack
  module Web
    module Faraday
      module Request
        def get(path, options = {})
          request(:get, path, options)
        end

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

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

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

        private

        def request(method, path, options)
          options = options.merge(token: token)
          response = connection.send(method) do |request|
            case method
            when :get, :delete
              request.url(path, options)
            when :post, :put
              request.path = path
              request.body = options unless options.empty?
            end
            request.options.merge!(options.delete(:request)) if options.key?(:request)
          end
          response.body
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-client-0.17.0 lib/slack/web/faraday/request.rb
slack-ruby-client-0.16.0 lib/slack/web/faraday/request.rb
slack-ruby-client-0.15.1 lib/slack/web/faraday/request.rb
slack-ruby-client-0.15.0 lib/slack/web/faraday/request.rb
slack-ruby-client-0.14.6 lib/slack/web/faraday/request.rb
slack-ruby-client-0.14.5 lib/slack/web/faraday/request.rb