Sha256: efaca4f9f245f5e32a290c6098074adf5cc494dfa7b0133da222d2b102de8272

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

module Strava
  module Web
    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 unless options.empty?
          end
          request.options.merge!(options.delete(:request)) if options.key?(:request)
        end
        response.body
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strava-ruby-client-0.3.0 lib/strava/web/request.rb
strava-ruby-client-0.2.0 lib/strava/web/request.rb
strava-ruby-client-0.1.0 lib/strava/web/request.rb