Class: RBattlenet::Endpoints::Base
- Inherits:
-
Object
- Object
- RBattlenet::Endpoints::Base
show all
- Defined in:
- lib/rbattlenet/endpoints/base.rb
Direct Known Subclasses
D3::Account, D3::Act, D3::Artisan, D3::CharacterClass, D3::Era, D3::EraLeaderboard, D3::Follower, D3::Hero, D3::Hero::FollowerItems, D3::Hero::Items, D3::Item, D3::ItemType, D3::Recipe, D3::Season, D3::SeasonLeaderboard, D3::Skill, Hearthstone::Card, Hearthstone::Deck, Hearthstone::Metadata, Sc2::Account, Sc2::Leaderboard, Sc2::League, Sc2::Legacy::Achievements, Sc2::Legacy::Ladder, Sc2::Legacy::Profile, Sc2::Legacy::ProfileLadders, Sc2::Legacy::ProfileMatchHistory, Sc2::Legacy::Rewards, Sc2::Profile, Sc2::ProfileLadder, Sc2::ProfileLadderSummary, Sc2::ProfileMetadata, Sc2::Season, Sc2::Static, Wow::Achievement, Wow::AchievementCategory, Wow::AchievementMedia, Wow::AzeriteEssence, Wow::AzeriteEssenceMedia, Wow::Character, Wow::Character::AchievementStatistics, Wow::Character::Achievements, Wow::Character::ActiveQuests, Wow::Character::Appearance, Wow::Character::CompletedDungeons, Wow::Character::CompletedQuests, Wow::Character::CompletedRaids, Wow::Character::Equipment, Wow::Character::HunterPets, Wow::Character::Keystones, Wow::Character::Legacy, Wow::Character::Media, Wow::Character::Mounts, Wow::Character::Pets, Wow::Character::Professions, Wow::Character::PvpBracket2v2, Wow::Character::PvpBracket3v3, Wow::Character::PvpBracketRbg, Wow::Character::PvpSummary, Wow::Character::Reputations, Wow::Character::SeasonKeystones, Wow::Character::Specializations, Wow::Character::Statistics, Wow::Character::Status, Wow::Character::Titles, Wow::Classic::Creature, Wow::Classic::CreatureFamily, Wow::Classic::CreatureFamilyMedia, Wow::Classic::CreatureMedia, Wow::Classic::CreatureType, Wow::Classic::GuildCrestBorderMedia, Wow::Classic::GuildCrestEmblemMedia, Wow::Classic::GuildCrestMedia, Wow::Classic::Item, Wow::Classic::ItemClass, Wow::Classic::ItemMedia, Wow::Classic::ItemSubclass, Wow::Classic::PlayableClass, Wow::Classic::PlayableClassMedia, Wow::Classic::PlayableRace, Wow::Classic::PowerType, Wow::ConnectedRealm, Wow::Creature, Wow::CreatureFamily, Wow::CreatureFamilyMedia, Wow::CreatureMedia, Wow::CreatureType, Wow::Guild, Wow::Guild::Achievements, Wow::Guild::Roster, Wow::GuildCrestBorderMedia, Wow::GuildCrestEmblemMedia, Wow::GuildCrestMedia, Wow::Item, Wow::ItemClass, Wow::ItemMedia, Wow::ItemSubclass, Wow::Mount, Wow::MythicKeystoneAffix, Wow::MythicKeystoneDungeon, Wow::MythicKeystoneLeaderboard, Wow::MythicKeystonePeriod, Wow::MythicKeystoneSeason, Wow::MythicRaidLeaderboard, Wow::Pet, Wow::PlayableClass, Wow::PlayableClass::PvpTalentSlot, Wow::PlayableClassMedia, Wow::PlayableRace, Wow::PlayableSpecialization, Wow::PowerType, Wow::Profile, Wow::Profile::MountsCollection, Wow::Profile::PetsCollection, Wow::Profile::ProtectedSummary, Wow::Profile::User, Wow::PvpLeaderboard, Wow::PvpSeason, Wow::PvpSeason::Rewards, Wow::PvpTier, Wow::PvpTierMedia, Wow::Realm, Wow::Region, Wow::ReputationFaction, Wow::ReputationTiers, Wow::Title, Wow::Token
Constant Summary
collapse
- SUPPORTED_FIELDS =
[:itself]
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
6
7
8
9
10
11
|
# File 'lib/rbattlenet/endpoints/base.rb', line 6
def self.all
raise RBattlenet::Errors::IndexNotSupported.new unless defined?(index_path)
RBattlenet.get [[[[:itself, index_path]], :index]] do |subject, data|
yield(subject, data) if block_given?
end
end
|
.find(subjects, fields: [:itself]) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rbattlenet/endpoints/base.rb', line 13
def self.find(subjects, fields: [:itself])
raise RBattlenet::Errors::FindNotSupported.new unless defined?(path)
if !fields.is_a? Array || (fields.map(&:to_sym) - SUPPORTED_FIELDS).any?
raise RBattlenet::Errors::InvalidFieldsOption.new
end
payload = [subjects].flatten.map do |subject|
subject_fields = [:itself] + fields + (subject[:fields] if subject.is_a?(Hash)).to_a
[subject_fields.uniq.map{ |field| [field, send(field).path(subject)] }, subject]
end
RBattlenet.get payload do |subject, data|
yield(subject, data) if block_given?
end
end
|