25 lines
759 B
Ruby
25 lines
759 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WowCovenantsWorker < 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::Covenant.all
|
|
|
|
return unless result.status_code == 200
|
|
|
|
result.covenants.each do |covenant|
|
|
wow_covenant = WowCovenant.find_or_initialize_by(covenant_id: covenant.id)
|
|
|
|
# Localisation data
|
|
locales.each do |locale|
|
|
Mobility.with_locale(locale[0]) { wow_covenant.name = covenant.name[locale[1]] }
|
|
end
|
|
|
|
wow_covenant.save
|
|
|
|
WowCovenantDetailWorker.perform_async(wow_covenant.covenant_id) if wow_covenant.persisted?
|
|
end
|
|
end
|
|
end
|