lib/omniauth/strategies/namba.rb in omniauth-namba-0.0.1 vs lib/omniauth/strategies/namba.rb in omniauth-namba-1.0.0
- old
+ new
@@ -6,10 +6,11 @@
module Strategies
class Namba < OmniAuth::Strategies::OAuth
option :name, "namba"
option :client_options, {
+ :locale => "kg",
:site => "http://api.namba.kg",
:request_token_path => "/oauth/request_token.php",
:authorize_url => "http://login.namba.kg/login2.php",
:access_token_path => "/oauth/access_token.php"
}
@@ -34,11 +35,18 @@
{
'raw_info' => raw_info
}
end
+ def initialize app, *args, &block
+ super
+ raise ArgumentError.new("Available locales are only kg or net") if options.locale && !%w(kg net).include?(options.locale)
+ options.client_options.site = "http://api.namba.#{options.locale || 'kg'}"
+ options.client_options.authorize_url = "http://login.namba.#{options.locale || 'kg'}/login2.php"
+ end
+
def raw_info
- @raw_info ||= MultiJson.load(access_token.get('http://api.namba.kg/getUserInfo2.php').body)
+ @raw_info ||= MultiJson.load(access_token.get("http://api.namba.#{options.locale || 'kg'}/getUserInfo2.php").body)
rescue ::Errno::ETIMEDOUT
raise ::Timeout::Error
end
end