Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Removes duplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Tassinari de Oliveira committed Mar 28, 2013
1 parent a2902ea commit 8b8ec55
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/passaporte_web/http.rb
@@ -1,19 +1,19 @@
# encoding: utf-8
module PassaporteWeb

class Http
class Http # :nodoc:

def self.get(path='/', params={})
RestClient.get(
"#{PassaporteWeb.configuration.url}#{path}",
pw_url(path),
{params: params}.merge(common_params)
)
end

def self.put(path='/', body={}, params={})
encoded_body = (body.is_a?(Hash) ? MultiJson.encode(body) : body)
RestClient.put(
"#{PassaporteWeb.configuration.url}#{path}",
pw_url(path),
encoded_body,
{params: params}.merge(common_params)
)
Expand All @@ -22,21 +22,25 @@ def self.put(path='/', body={}, params={})
def self.post(path='/', body={})
encoded_body = (body.is_a?(Hash) ? MultiJson.encode(body) : body)
RestClient.post(
"#{PassaporteWeb.configuration.url}#{path}",
pw_url(path),
encoded_body,
common_params
)
end

def self.delete(path='/', params={})
RestClient.delete(
"#{PassaporteWeb.configuration.url}#{path}",
pw_url(path),
{params: params}.merge(common_params)
)
end

private

def self.pw_url(path)
"#{PassaporteWeb.configuration.url}#{path}"
end

def self.common_params
{
authorization: PassaporteWeb.configuration.application_credentials,
Expand Down

0 comments on commit 8b8ec55

Please sign in to comment.