Class: MetaNexus::Wow::Character

Inherits:
MetaNexus::Wow show all
Defined in:
lib/meta_nexus/wow/character.rb

Constant Summary collapse

FIELDS =
%i(achievements appearance feed guild hunter_pets items mounts pets pet_slots progression pvp quests reputation stats talents titles audit).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from MetaNexus::Wow

client, #url

Methods inherited from Api

call_api, #url

Instance Attribute Details

#achievementsObject

Returns the value of attribute achievements.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def achievements
  @achievements
end

#appearanceObject

Returns the value of attribute appearance.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def appearance
  @appearance
end

#auditObject

Returns the value of attribute audit.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def audit
  @audit
end

#feedObject

Returns the value of attribute feed.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def feed
  @feed
end

#guildObject

Returns the value of attribute guild.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def guild
  @guild
end

#hunter_petsObject

Returns the value of attribute hunter_pets.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def hunter_pets
  @hunter_pets
end

#itemsObject

Returns the value of attribute items.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def items
  @items
end

#mountsObject

Returns the value of attribute mounts.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def mounts
  @mounts
end

#pet_slotsObject

Returns the value of attribute pet_slots.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def pet_slots
  @pet_slots
end

#petsObject

Returns the value of attribute pets.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def pets
  @pets
end

#progressionObject

Returns the value of attribute progression.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def progression
  @progression
end

#pvpObject

Returns the value of attribute pvp.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def pvp
  @pvp
end

#questsObject

Returns the value of attribute quests.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def quests
  @quests
end

#reputationObject

Returns the value of attribute reputation.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def reputation
  @reputation
end

#statsObject

Returns the value of attribute stats.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def stats
  @stats
end

#talentsObject

Returns the value of attribute talents.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def talents
  @talents
end

#titlesObject

Returns the value of attribute titles.



2
3
4
# File 'lib/meta_nexus/wow/character.rb', line 2

def titles
  @titles
end

Class Method Details

.find(args) ⇒ Object

Find Character in Battle.net WoW Api Required arguments: realm - character realm name - character name

Optional arguments:

achievements: true - character achievements info appearance: true - character appearance info feed: true - character feed info guild: true - character guild info hunter_pets: true - character hunter_pets info items: true - character items info mounts: true - character mounts info pets: true - character pets info pet_slots: true - character pet_slots info progression: true - character progression info pvp: true - character pvp info quests: true - character quests info reputation: true - character reputation info stats: true - character stats info talents: true - character talents info titles: true - character titles info audit: true - character audit info

Example:

character = MetaNexus::Wow::Character
character.find('shadowsong', 'Redstone')

Response in Hash:

{"lastModified"=>1435160620000, "name"=>"Redstone", "realm"=>"Shadowsong", "battlegroup"=>"Reckoning / Abrechnung", "class"=>8, "race"=>2, "gender"=>1, "level"=>90, "achievementPoints"=>8390, "thumbnail"=>"internal-record-3666/105/93238889-avatar.jpg", "calcClass"=>"e", "totalHonorableKills"=>4519}

If you want to get character info with any additional fields, such as achievements or character appearance, you should explicitly call it. Example:

character.find('shadowsong', 'Redstone', appearance: true)

This will return character info along with his appearance info.



45
46
47
48
49
50
51
52
53
54
# File 'lib/meta_nexus/wow/character.rb', line 45

def self.find(args)
  call_url = "#{client.url}/character/#{args[:realm]}/#{args[:name]}?"

  fields = FIELDS.map { |field| args[field] ? field : next }.join(',')

  call_url << '&fields=' + fields if fields
  call_url += "locale=#{MetaNexus.config.locale}&apikey=#{MetaNexus.config.api_key}"

  MetaNexus::Api.call_api(call_url)
end