Module: MongoHQClient::HTTP

Included in:
Client, Collection, Database
Defined in:
lib/mongohq-client/http.rb

Instance Method Summary collapse

Instance Method Details

#delete(uri) ⇒ Object



20
21
22
23
24
# File 'lib/mongohq-client/http.rb', line 20

def delete(uri)
  HTTParty.delete "#{base_uri}/#{uri}", query: { _apikey: apikey }

  return
end

#get(uri) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/mongohq-client/http.rb', line 5

def get(uri)
  raise "Invalid apikey" unless apikey
  resp = HTTParty.get("#{base_uri}/#{uri}", query: { _apikey: apikey } )

  #TODO error handling

  JSON.parse(resp.body)
end

#post(uri, json) ⇒ Object



14
15
16
17
18
# File 'lib/mongohq-client/http.rb', line 14

def post(uri, json)
  HTTParty.post "#{base_uri}/#{uri}", body: json, query: { _apikey: apikey }

  return
end