Sha256: 96e8bcb12586c2a811bcbd9bd25ec3701fce332e443a234e0d9da67d13b08aaa

Contents?: true

Size: 984 Bytes

Versions: 10

Compression:

Stored size: 984 Bytes

Contents

module RubyRedtail
  class Query
    # TODO: Refactor (Lots of repetition)
    def self.run (uri, auth_hash, method, request_body = nil)
      base_uri = RubyRedtail.config.api_uri
      if method == "GET"
        @response = HTTParty.get(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}).parsed_response
      elsif method == "POST"
        @response = HTTParty.post(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}, :body => request_body.to_json).parsed_response
      elsif method == "PUT"
        @response = HTTParty.put(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}, :body => request_body.to_json).parsed_response
      elsif method == "DELETE"
        @response = HTTParty.post(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}, :body => "").parsed_response
      end

      return @response
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-redtail-0.3.8 lib/ruby-redtail/query.rb
ruby-redtail-0.3.7 lib/ruby-redtail/query.rb
ruby-redtail-0.3.6 lib/ruby-redtail/query.rb
ruby-redtail-0.3.5 lib/ruby-redtail/query.rb
ruby-redtail-0.3.4 lib/ruby-redtail/query.rb
ruby-redtail-0.3.3 lib/ruby-redtail/query.rb
ruby-redtail-0.3.2 lib/ruby-redtail/query.rb
ruby-redtail-0.3.1 lib/ruby-redtail/query.rb
ruby-redtail-0.3.0 lib/ruby-redtail/query.rb
ruby-redtail-0.2.0 lib/ruby-redtail/query.rb