lib/moip2/client.rb in moip2-1.0.0 vs lib/moip2/client.rb in moip2-1.1.0
- old
+ new
@@ -2,16 +2,16 @@
class Client
include HTTParty
attr_reader :env, :auth, :uri
- def initialize(env = :sandbox, auth = nil, host = get_base_uri(env), opts = {})
+ def initialize(env = :sandbox, auth = nil, opts = {})
@env = env.to_sym
@auth = auth
@opts = opts
- @uri = host
+ @uri = get_base_uri
self.class.base_uri @uri
end
def sandbox?
env == :sandbox
@@ -60,21 +60,21 @@
resp = self.class.get path, opts
create_response resp
end
- private
-
- def get_base_uri(env)
- return ENV["base_uri"] if ENV["base_uri"]
-
- @env = env.to_sym
-
+ def host
if production?
- "https://api.moip.com.br"
+ "api.moip.com.br"
else
- "https://sandbox.moip.com.br"
+ "sandbox.moip.com.br"
end
+ end
+
+ private
+
+ def get_base_uri
+ "https://#{host}"
end
def create_response(resp)
raise NotFoundError, "Resource not found" if resp.code == 404