Class: MyWoWArmory
Defined Under Namespace
Classes: Profile
Instance Method Summary collapse
-
#get_profile(country, realm, character_name, options = {}) ⇒ Object
def initialize(username,password,options={}) @auth = => username, :password => password end.
Instance Method Details
#get_profile(country, realm, character_name, options = {}) ⇒ Object
def initialize(username,password,options={})
@auth = {:username => username, :password => password}
end
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mywowarmory.rb', line 16 def get_profile(country,realm,character_name,={}) # options.merge!({:basic_auth => @auth}) # detect the input as URL encoded or not by finding "%NN" character name = character_name.match(/%[0-9A-F]{2}/i) ? character_name : URI::encode(character_name) # name = URI::encode(URI::decode(character_name)) # Check the realm realm_response = HTTParty.get("http://#{country}.battle.net/api/wow/realm/status", :query => {:realms => URI.encode(realm)} ).parsed_response realm = realm_response['realms'].select{|r| r['name'] == realm}.first['slug'] rescue realm # if realm not found, may be input is slug query = {:name => name, :server => realm, :country => country} query.merge!(:style => [:style]) if [:style].present? MultiJson.decode(self.class.get("/api/getprofile.php", .merge(:query => query)).parsed_response) end |