23 lines
737 B
Ruby
23 lines
737 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WowCreatureFamiliesWorker < WowSidekiqWorker
|
|
def perform
|
|
RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
|
|
RBattlenet.set_options(locale: 'all')
|
|
result = RBattlenet::Wow::CreatureFamily.all
|
|
|
|
return unless result.status_code == 200
|
|
|
|
result.creature_families.each do |creature_family|
|
|
wow_creature_family = WowCreatureFamily.find_or_initialize_by(creature_family_id: creature_family.id)
|
|
|
|
# Localisation data
|
|
locales.each do |locale|
|
|
Mobility.with_locale(locale[0]) { wow_creature_family.name = creature_family.name[locale[1]] }
|
|
end
|
|
|
|
wow_creature_family.save
|
|
end
|
|
end
|
|
end
|