Sha256: 1ff12e58594b550685e87ea9afbfd11d558f10cc61a300c8efcc3206a75e2eb6

Contents?: true

Size: 910 Bytes

Versions: 10

Compression:

Stored size: 910 Bytes

Contents

module IEX
  module Cloud
    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)
        path = [endpoint, path].join('/')
        response = connection.send(method) do |request|
          case method
          when :get, :delete
            request.url(path, options)
          when :post, :put
            request.path = path
            request.body = options.to_json unless options.empty?
          end
          request.options.merge!(options.delete(:request)) if options.key?(:request)
        end
        response.body
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
iex-ruby-client-2.1.0 lib/iex/cloud/request.rb
iex-ruby-client-2.0.0 lib/iex/cloud/request.rb
iex-ruby-client-1.6.0 lib/iex/cloud/request.rb
iex-ruby-client-1.5.0 lib/iex/cloud/request.rb
iex-ruby-client-1.4.1 lib/iex/cloud/request.rb
iex-ruby-client-1.4.0 lib/iex/cloud/request.rb
iex-ruby-client-1.3.0 lib/iex/cloud/request.rb
iex-ruby-client-1.2.0 lib/iex/cloud/request.rb
iex-ruby-client-1.1.2 lib/iex/cloud/request.rb
iex-ruby-client-1.1.1 lib/iex/cloud/request.rb